org.jlab.coda.cMsg
Class cMsgMessageMatcher

java.lang.Object
  extended by org.jlab.coda.cMsg.cMsgMessageMatcher

public class cMsgMessageMatcher
extends java.lang.Object

This class contains the methods used to determine whether a message's subject and type match a subscription's subject and type. It also contains a method to check the format of a server's name.


Constructor Summary
cMsgMessageMatcher()
           
 
Method Summary
static java.lang.String constructServerName(java.lang.String s)
          This method tests its input argument to see if it is in the proper format for a server; namely, "host:port".
static java.lang.String escape(java.lang.String s)
          This method takes a string and escapes most special, regular expression characters.
static boolean matches(java.lang.String regexp, java.lang.String s, boolean escapeRegexp)
          This method implements a simple wildcard matching scheme where "*" means any or no characters and "?" means exactly 1 character.
static boolean matches(java.lang.String subject, java.lang.String type, cMsgGetHelper helper)
          This method checks to see if there is a match between a subject & type pair and a subscribeAndGet helper object.
static boolean matches(java.lang.String subject, java.lang.String type, cMsgSubscription sub)
          This method checks to see if there is a match between a subject & type pair and a subscription.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

cMsgMessageMatcher

public cMsgMessageMatcher()
Method Detail

matches

public static boolean matches(java.lang.String regexp,
                              java.lang.String s,
                              boolean escapeRegexp)
This method implements a simple wildcard matching scheme where "*" means any or no characters and "?" means exactly 1 character.

Parameters:
regexp - subscription string that can contain wildcards (* and ?)
s - message string to be matched (can be blank which only matches *)
escapeRegexp - if true, the regexp argument is escaped, else not
Returns:
true if there is a match, false if there is not

matches

public static boolean matches(java.lang.String subject,
                              java.lang.String type,
                              cMsgGetHelper helper)
This method checks to see if there is a match between a subject & type pair and a subscribeAndGet helper object. The subscription's subject and type may include wildcards where "*" means any or no characters and "?" means exactly 1 character. There is a match only if both subject and type strings match their conterparts in the subscription.

Parameters:
subject - subject
type - type
helper - subscription
Returns:
true if there is a match of both subject and type, false if there is not

matches

public static boolean matches(java.lang.String subject,
                              java.lang.String type,
                              cMsgSubscription sub)
This method checks to see if there is a match between a subject & type pair and a subscription. The subscription's subject and type may include wildcards where "*" means any or no characters and "?" means exactly 1 character. There is a match only if both subject and type strings match their conterparts in the subscription.

Parameters:
subject - subject
type - type
sub - subscription
Returns:
true if there is a match of both subject and type, false if there is not

escape

public static java.lang.String escape(java.lang.String s)
This method takes a string and escapes most special, regular expression characters. The return string can allows only * and ? to be passed through in a way meaningful to regular expressions (as .* and .{1} respectively).

Parameters:
s - string to be escaped
Returns:
escaped string

constructServerName

public static java.lang.String constructServerName(java.lang.String s)
                                            throws cMsgException
This method tests its input argument to see if it is in the proper format for a server; namely, "host:port". If it is, it makes sure the host is in its canonical form.

Parameters:
s - input string of a possible server name
Returns:
an acceptable server name with the canonical form of the host name
Throws:
cMsgException - if input string is not in the proper form (host:port) or the host is unknown