Package org.apache.ws.notification.topics.impl

Source Code of org.apache.ws.notification.topics.impl.TopicSpaceSetImpl

/*=============================================================================*
*  Copyright 2004 The Apache Software Foundation
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*=============================================================================*/
package org.apache.ws.notification.topics.impl;

import org.apache.ws.notification.topics.Topic;
import org.apache.ws.notification.topics.TopicSpace;
import org.apache.ws.notification.topics.TopicSpaceSet;
import org.apache.ws.notification.topics.expression.TopicExpression;
import org.apache.ws.notification.topics.expression.TopicExpressionEngine;
import org.apache.ws.notification.topics.expression.TopicExpressionException;
import org.apache.ws.notification.topics.expression.impl.TopicExpressionEngineImpl;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;

/**
* @author Sal Campana
*/
public class TopicSpaceSetImpl
   implements TopicSpaceSet
{
   private static final TopicExpressionEngine TOPIC_EXPR_ENGINE = TopicExpressionEngineImpl.getInstance(  );
   private Map                                m_topicSpaces = new Hashtable(  );
   private boolean                            m_fixed;

   /**
    * Creates a new {@link TopicSpaceSetImpl} object.
    *
    * @param fixed DOCUMENT_ME
    */
   public TopicSpaceSetImpl( boolean fixed )
   {
      m_fixed = fixed;
   }

   /**
    * DOCUMENT_ME
    *
    * @param fixed DOCUMENT_ME
    */
   public void setFixed( boolean fixed )
   {
      m_fixed = fixed;
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public boolean isFixed(  )
   {
      return m_fixed;
   }

   /**
    * DOCUMENT_ME
    *
    * @param namespaceURI DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public TopicSpace getTopicSpace( String namespaceURI )
   {
      return (TopicSpace) m_topicSpaces.get( namespaceURI );
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public TopicSpace[] getTopicSpaces(  )
   {
      return (TopicSpace[]) m_topicSpaces.values(  ).toArray( new TopicSpace[0] );
   }

   /**
    * Adds the TopicSpace to the TopicSpaceSet.
    *
    * Note. If the TopiSpace already exists, this method will add all the known Topics
    * to the passed-in TopicSpace and set it as the current TopicSpace in the TopicSpaceSet.
    * This will ensure there is only 1 TopicSpace in the set and it is complete...
    *
    * @param topicSpace
    */
   public TopicSpace addTopicSpace( TopicSpace topicSpace )
   {
      String namespaceURI = topicSpace.getTargetNamespace(  );

      //if topicSpace exists, simply add all topics to topicspace
      if ( m_topicSpaces.containsKey( namespaceURI ) )
      {
         TopicSpace topicSpc = (TopicSpace) m_topicSpaces.get( namespaceURI );
         Iterator   iterator = topicSpc.topicIterator(  );
         while ( iterator.hasNext(  ) )
         {
            Topic topic = (Topic) iterator.next(  );
            topicSpace.addTopic( topic );
         }
      }

      m_topicSpaces.put( namespaceURI, topicSpace );
      return topicSpace;
   }

   /**
    * DOCUMENT_ME
    *
    * @param topicExpr DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    *
    * @throws TopicExpressionException DOCUMENT_ME
    */
   public Topic[] evaluateTopicExpression( TopicExpression topicExpr )
   throws TopicExpressionException
   {
      return TOPIC_EXPR_ENGINE.evaluateTopicExpression( this, topicExpr );
   }

   /**
    * DOCUMENT_ME
    *
    * @param namespaceURI DOCUMENT_ME
    */
   public void removeTopicSpace( String namespaceURI )
   {
      m_topicSpaces.remove( namespaceURI );
   }
}
TOP

Related Classes of org.apache.ws.notification.topics.impl.TopicSpaceSetImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.