jrun.jms.core.client
Class JmsTopic

jrun.jms.core.client.JmsTopic
All Implemented Interfaces:
java.io.Externalizable, javax.naming.Referenceable, java.io.Serializable

public class JmsTopic
implements java.io.Externalizable, javax.naming.Referenceable

A topic is a destination specific for the puiblish-subscribe messaging model. OpenJMS also supports topic hierarchy and wild carding.

Version:
$Revision: 1.8 $ $Date: 2001/06/21 20:53:05 $
Author:
Jim Alateras, Jim Mourikis
See Also:
org.exolab.jms.client.JmsDestination, Serialized Form

Field Summary
static java.lang.String ALL_WILDCARD
           
static java.lang.String SEPARATOR
           
static java.lang.String WILDCARD
           
 
Constructor Summary
JmsTopic()
          Need a default constructor for the serialization
JmsTopic(java.lang.String name)
          Instantiate an instance of this object with the specified string
 
Method Summary
 boolean equals(java.lang.Object object)
           
 javax.naming.Reference getReference()
           
 java.lang.String getTopicName()
          Return the name of the topic
 int hashCode()
           
 boolean isWildCard()
          Check whether this topic represents a wildcard expression.
 boolean match(JmsTopic destination)
          If it is a wildcard check to see that it matches the specified topic.
 void readExternal(java.io.ObjectInput stream)
           
 void writeExternal(java.io.ObjectOutput stream)
           
 

Field Detail

WILDCARD

public static final java.lang.String WILDCARD

ALL_WILDCARD

public static final java.lang.String ALL_WILDCARD

SEPARATOR

public static final java.lang.String SEPARATOR
Constructor Detail

JmsTopic

public JmsTopic()
Need a default constructor for the serialization

JmsTopic

public JmsTopic(java.lang.String name)
Instantiate an instance of this object with the specified string
Parameters:
name - name of the queue
Method Detail

getTopicName

public java.lang.String getTopicName()
                              throws javax.jms.JMSException
Return the name of the topic
Returns:
name name of the topic
Throws:
JMSException -  

equals

public boolean equals(java.lang.Object object)

writeExternal

public void writeExternal(java.io.ObjectOutput stream)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable

readExternal

public void readExternal(java.io.ObjectInput stream)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable

hashCode

public int hashCode()

isWildCard

public boolean isWildCard()
                   throws javax.jms.JMSException
Check whether this topic represents a wildcard expression.
Returns:
boolean true if the topic contains wildcards
Throws:
JMSException - error in retrieving dest

match

public boolean match(JmsTopic destination)
If it is a wildcard check to see that it matches the specified topic. if wildcard is **, its a an imediate match for every topic. else tokenize both the wildcard and the topic. if the wildcard has less or equal no of tokens than the topic and ends in "**" check tokens if both wildcard and topic contain the same no of tokens check tokens Otherwise topic and wildcard do not match so return false.

Note we treat "a.b.c.*.*" and "a.b.c" as not a match at this stage, since the wildcard is attempting to match more levels than exist in the topic. if this proves to be unpopular with the masses, its a very trivial change below to fix this problem.

Tokens are compared and must either be identical or the wildcard token must be a "*" to match at this level. Once a mismatch is detected the comparison is stopped and a false returned.

NOTE: This check assumes both the topic and wildcard topic have both already been validated. if the topics are inavlid this test can return arbitrary results.

Parameters:
destination - The specific topic to match to
Returns:
True if the wildcard matches.

getReference

public javax.naming.Reference getReference()
Specified by:
getReference in interface javax.naming.Referenceable


Copyright � 2002 Macromedia Corporation. All Rights Reserved.