Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.securityfilter.filter
Class URLPattern  view URLPattern download URLPattern.java

java.lang.Object
  extended byorg.securityfilter.filter.URLPattern
All Implemented Interfaces:
java.lang.Comparable

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

URLPattern - Contains matchable URL pattern and the associated SecurityConstraint and WebResourceCollection objects for the pattern. Also supports sorting according to the Servlet Spec v2.3.

Version:
$Revision: 1.5 $ $Date: 2003/01/06 05:01:57 $

Field Summary
protected  org.apache.oro.text.regex.Pattern compiledPattern
           
protected  org.securityfilter.config.SecurityConstraint constraint
           
protected  java.lang.String convertedPattern
           
static int DEFAULT_TYPE
          Pattern type for EXTENSION_TYPE mappings.
static int EXACT_TYPE
          Pattern type for patterns that do not meet the specifications for the other pattern types.
static int EXTENSION_TYPE
          Pattern type for EXTENSION_TYPE mappings.
protected  int order
           
static int PATH_TYPE
          Pattern type for PATH_TYPE mappings.
protected  int pathLength
           
protected  java.lang.String pattern
           
protected  int patternType
           
protected  org.securityfilter.config.WebResourceCollection resourceCollection
           
 
Constructor Summary
URLPattern(java.lang.String pattern, org.securityfilter.config.SecurityConstraint constraint, org.securityfilter.config.WebResourceCollection resourceCollection, int order, org.apache.oro.text.regex.PatternCompiler compiler)
          Construct a new URLPattern object.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares this URLPattern to obj to support sorting.
 boolean equals(java.lang.Object obj)
          Test if this pattern is equivalent to another pattern.
 org.apache.oro.text.regex.Pattern getCompiledPattern()
          Get the compiled version of this pattern.
 int getOrder()
          Get the order value for this pattern (the order in which it appeared in the config file).
 int getPathLength()
          Get the path length of the pattern.
 java.lang.String getPattern()
          Get the url pattern to match.
 int getPatternType()
          Get the pattern type.
 org.securityfilter.config.SecurityConstraint getSecurityConstraint()
          Get the SecurityConstraint object associated with this pattern.
 org.securityfilter.config.WebResourceCollection getWebResourceCollection()
          Get the WebResourceCollection associated with this pattern.
protected  void initCompiledPattern(org.apache.oro.text.regex.PatternCompiler compiler)
          Initialize the compiledPattern protected member.
protected  void initConvertedPattern()
          Initialize the convertedPattern protected member.
protected  void initPathLength()
          Initialize the pathLength protected member.
protected  void initPatternType()
          Initialize the patternType protected member.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXACT_TYPE

public static final int EXACT_TYPE
Pattern type for patterns that do not meet the specifications for the other pattern types.

See Also:
Constant Field Values

PATH_TYPE

public static final int PATH_TYPE
Pattern type for PATH_TYPE mappings. Starts with '/' and ends with '/*'.

See Also:
Constant Field Values

EXTENSION_TYPE

public static final int EXTENSION_TYPE
Pattern type for EXTENSION_TYPE mappings. Starts with '*.'

See Also:
Constant Field Values

DEFAULT_TYPE

public static final int DEFAULT_TYPE
Pattern type for EXTENSION_TYPE mappings. Starts with '*.'

See Also:
Constant Field Values

pattern

protected java.lang.String pattern

convertedPattern

protected java.lang.String convertedPattern

compiledPattern

protected org.apache.oro.text.regex.Pattern compiledPattern

constraint

protected org.securityfilter.config.SecurityConstraint constraint

resourceCollection

protected org.securityfilter.config.WebResourceCollection resourceCollection

order

protected int order

patternType

protected int patternType

pathLength

protected int pathLength
Constructor Detail

URLPattern

public URLPattern(java.lang.String pattern,
                  org.securityfilter.config.SecurityConstraint constraint,
                  org.securityfilter.config.WebResourceCollection resourceCollection,
                  int order,
                  org.apache.oro.text.regex.PatternCompiler compiler)
           throws java.lang.Exception
Construct a new URLPattern object.

Method Detail

getPattern

public java.lang.String getPattern()
Get the url pattern to match.


getCompiledPattern

public org.apache.oro.text.regex.Pattern getCompiledPattern()
Get the compiled version of this pattern.


getPatternType

public int getPatternType()
Get the pattern type. The pattern type will be determined on the first call to this method.


getPathLength

public int getPathLength()
Get the path length of the pattern. This is only valid when getPatternType() = PATH.

Examples:

  • /* = 0
  • /path/* = 1
  • /really/long/path/* = 3


getSecurityConstraint

public org.securityfilter.config.SecurityConstraint getSecurityConstraint()
Get the SecurityConstraint object associated with this pattern.


getOrder

public int getOrder()
Get the order value for this pattern (the order in which it appeared in the config file).


getWebResourceCollection

public org.securityfilter.config.WebResourceCollection getWebResourceCollection()
Get the WebResourceCollection associated with this pattern.


initPatternType

protected void initPatternType()
Initialize the patternType protected member.


initPathLength

protected void initPathLength()
Initialize the pathLength protected member.


initConvertedPattern

protected void initConvertedPattern()
Initialize the convertedPattern protected member.


initCompiledPattern

protected void initCompiledPattern(org.apache.oro.text.regex.PatternCompiler compiler)
                            throws java.lang.Exception
Initialize the compiledPattern protected member.


equals

public boolean equals(java.lang.Object obj)
Test if this pattern is equivalent to another pattern. This is implemented so that consistency with the compareTo method results can be maintained.


compareTo

public int compareTo(java.lang.Object obj)
              throws java.lang.ClassCastException
Compares this URLPattern to obj to support sorting.

The sort order is dictated by the servlet spec. The ordering by type is: EXACT_TYPE PATH_TYPE EXTENTION_TYPE DEFAULT_TYPE Ordering among PATH_TYPE patterns is determined by path length, with the longer path coming first. If the path lengths are the same, or both patterns are of the same type other than PATH_TYPE, ordering is determined by the order in which the pattern appeared in the config file. Thanks to Chris Nokleberg for contributing code for this method.

Specified by:
compareTo in interface java.lang.Comparable