org.objectweb.jonas_web.deployment.api
Class Pattern

java.lang.Object
  extended by org.objectweb.jonas_web.deployment.api.Pattern
All Implemented Interfaces:
java.lang.Comparable

public class Pattern
extends java.lang.Object
implements java.lang.Comparable

Defines a Pattern object for JACC Allow to check if this pattern is a path prefix pattern, and can return the type of the pattern Implements Comparable interface to sort items

Author:
Florent Benoit
See Also:
3.1.3.1 and 3.1.3.3 for more details

Constructor Summary
Pattern(java.lang.String pattern)
          Constructor
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object o)
          Tests if this object is equal to another object
 java.lang.String getValue()
          Gets the string representation of this object
 int hashCode()
          Gets the hashcode of this object
 boolean isDefaultPattern()
          Test if this pattern is the default pattern (equals to "/")
 boolean isExactPattern()
          Test if this pattern is an exact pattern (not in the other case)
 boolean isExtensionPattern()
          Test if this pattern is an extension pattern (Starts with ".*")
 boolean isMatching(Pattern otherPattern)
          Test if this pattern matches another pattern This URL pattern matches another pattern if they are related, by case sensitive comparison, as follows: - their pattern values are String equivalent, or - this pattern is the path-prefix pattern "/*", or - this pattern is a path-prefix pattern (that is, it starts with "/" and ends with "/*") and the other pattern starts with the substring of this pattern, minus its last 2 characters, and the next character of the other pattern, if there is one, is "/", or - this pattern is an extension pattern (that is, it starts with "*.") and the other pattern ends with this pattern, or this pattern is the special default pattern, "/", which matches all other patterns.
 boolean isPathPrefix()
          Test if this pattern is a path-prefix pattern or not (Starts with "/" and ends with "/*"
 boolean isSubstringPattern(java.lang.String substring)
          Test if the pattern starts with the given pattern It's the inverse of this definition : The other pattern starts with the substring of this pattern, minus its last 2 characters, and the next character of the other pattern, if there is one, is "/"
 java.lang.String toString()
          String representation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pattern

public Pattern(java.lang.String pattern)
Constructor

Parameters:
pattern - string representation of the pattern
Method Detail

isPathPrefix

public boolean isPathPrefix()
Test if this pattern is a path-prefix pattern or not (Starts with "/" and ends with "/*"

Returns:
true if this pattern is a path-prefix

isExtensionPattern

public boolean isExtensionPattern()
Test if this pattern is an extension pattern (Starts with ".*")

Returns:
true if this pattern is an extension pattern

isDefaultPattern

public boolean isDefaultPattern()
Test if this pattern is the default pattern (equals to "/")

Returns:
true if this pattern is the default pattern

isExactPattern

public boolean isExactPattern()
Test if this pattern is an exact pattern (not in the other case)

Returns:
true if this pattern is an exact pattern

isSubstringPattern

public boolean isSubstringPattern(java.lang.String substring)
Test if the pattern starts with the given pattern It's the inverse of this definition : The other pattern starts with the substring of this pattern, minus its last 2 characters, and the next character of the other pattern, if there is one, is "/"

Parameters:
substring - string to test
Returns:
true if the pattern starts with the given pattern

isMatching

public boolean isMatching(Pattern otherPattern)
Test if this pattern matches another pattern This URL pattern matches another pattern if they are related, by case sensitive comparison, as follows: - their pattern values are String equivalent, or - this pattern is the path-prefix pattern "/*", or - this pattern is a path-prefix pattern (that is, it starts with "/" and ends with "/*") and the other pattern starts with the substring of this pattern, minus its last 2 characters, and the next character of the other pattern, if there is one, is "/", or - this pattern is an extension pattern (that is, it starts with "*.") and the other pattern ends with this pattern, or this pattern is the special default pattern, "/", which matches all other patterns.

Parameters:
otherPattern - pattern to check for matching
Returns:
true if the patterns match
See Also:
3.1.3.3 for the definition of these rules

getValue

public java.lang.String getValue()
Gets the string representation of this object

Returns:
the string representation of this pattern

toString

public java.lang.String toString()
String representation

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this pattern

equals

public boolean equals(java.lang.Object o)
Tests if this object is equal to another object

Overrides:
equals in class java.lang.Object
Parameters:
o - given object to test
Returns:
true if the other object is a pattern object with the same value

hashCode

public int hashCode()
Gets the hashcode of this object

Overrides:
hashCode in class java.lang.Object
Returns:
hashcode of this object

compareTo

public int compareTo(java.lang.Object o)
Compares this object with the specified object for order.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - object to compare
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.