org.echarts.servlet.sip.appRouter.DFCRouterImpl
Class AddressPattern

java.lang.Object
  extended by org.echarts.servlet.sip.appRouter.DFCRouterImpl.AddressPattern
All Implemented Interfaces:
java.io.Serializable

public class AddressPattern
extends java.lang.Object
implements java.io.Serializable

The AddressPattern class encapsulates a regular expression that establishes a pattern against which addresses are evaluated for a match. Address patterns occur in subscription rules, each of which maps an address pattern to a list of subscribing applications.

Author:
khp
See Also:
Serialized Form

Field Summary
static boolean ENCODE
           
static java.lang.String metaChars
           
 
Constructor Summary
AddressPattern(java.lang.String regExp)
          Build AddressPattern from string representation of regular expression
AddressPattern(java.lang.String regExp, boolean encode)
          Encapsulate a regular expresssion as an AddressPattern, optionally encoding literal strings that contain regular expression meta-characters.
 
Method Summary
static java.lang.String decode(java.lang.String literal)
          Unescape regular expression meta-characters in literal string.
static java.lang.String encode(java.lang.String literal)
          Escape regular expression meta-characters using the backslash character, '\'.
 boolean equals(java.lang.Object o)
          Check if two address patterns are equal.
 java.lang.String getRegExp()
          Get a String represenation of the underlying regular expression.
 boolean matches(Address address)
          Indicates whether the given address matches the address pattern.
 java.lang.String toString()
          Get String representation of the regular expression
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

metaChars

public static final java.lang.String metaChars
See Also:
Constant Field Values

ENCODE

public static final boolean ENCODE
See Also:
Constant Field Values
Constructor Detail

AddressPattern

public AddressPattern(java.lang.String regExp)
               throws java.util.regex.PatternSyntaxException
Build AddressPattern from string representation of regular expression

Parameters:
regExp - String representation of Java regular expression
Throws:
java.util.regex.PatternSyntaxException - if regular expression is not well formed

AddressPattern

public AddressPattern(java.lang.String regExp,
                      boolean encode)
               throws java.util.regex.PatternSyntaxException
Encapsulate a regular expresssion as an AddressPattern, optionally encoding literal strings that contain regular expression meta-characters. TODO: Do we still need any of this encoding/decoding stuff?

Parameters:
regExp - - the String representing the regular expresssion
encode - - Does the regExp string have literal characters in it that need to be escaped to avoid being interpreted as regular expression meta-characters
Throws:
java.util.regex.PatternSyntaxException
Method Detail

encode

public static java.lang.String encode(java.lang.String literal)
Escape regular expression meta-characters using the backslash character, '\'. Probably not needed anymore.


decode

public static java.lang.String decode(java.lang.String literal)
Unescape regular expression meta-characters in literal string. Probably not needed anymore.


equals

public boolean equals(java.lang.Object o)
Check if two address patterns are equal. For now, equals() means that the regExp strings are lexicographically equal. What would be best here would be if equals() meant that the sets of matching addresses were the same. That is, consider the two regExps:

They define the same set of matching strings but are lexicographically unequal.

Overrides:
equals in class java.lang.Object

getRegExp

public java.lang.String getRegExp()
Get a String represenation of the underlying regular expression.


toString

public java.lang.String toString()
Get String representation of the regular expression

Overrides:
toString in class java.lang.Object
Returns:
regular expression string

matches

public boolean matches(Address address)
Indicates whether the given address matches the address pattern. This method is the crux of the AddressPattern class.

Parameters:
address - The address to be checked for a match. Since SIP URIs are case insensitive, matches are performed in a case-insensitive manner.
Returns:
true if the address matches the pattern, else false