com.caucho.server.dispatch
Class UrlMap<E>

java.lang.Object
  extended by com.caucho.server.dispatch.UrlMap<E>

public class UrlMap<E>
extends java.lang.Object

Maps uris to objects, using the syntax in the servlet2.2 deployment descriptors: /foo/bar -- exact match /foo/bar/* -- matches anything with the /foo/bar prefix *.jsp -- matches anything with the .jsp suffix


Nested Class Summary
static interface UrlMap.Filter<X>
           
 
Constructor Summary
UrlMap()
          Create a new map
UrlMap(boolean bestShort)
          Create a new map preferring a short match.
 
Method Summary
 void addMap(java.lang.String pattern, E value)
           
 void addMap(java.lang.String pattern, E value, boolean isIgnore)
           
 void addMap(java.lang.String pattern, E value, boolean isIgnore, boolean ifAbsent)
           
 void addMap(java.lang.String pattern, java.lang.String flags, E value, boolean isIgnore, boolean ifAbsent)
          Adds a new url-pattern and its corresponding value to the map
 void addRegexp(int prefixLength, java.lang.String regexp, java.lang.String flags, E value, boolean isShort, boolean isIgnore, boolean ifAbsent)
          Adds a regular expression to the map.
 void addRegexp(int prefixLength, java.lang.String pattern, java.lang.String regexp, java.lang.String flags, E value, boolean isShort, boolean isIgnore, boolean ifAbsent, boolean isSimple)
          Adds a regular expression to the map.
 void addRegexp(java.lang.String regexp, E value)
           
 void addRegexp(java.lang.String regexp, java.lang.String flags, E value)
           
 void addRegexpIfAbsent(java.lang.String regexp, E value)
           
 void addStrictMap(java.lang.String pattern, java.lang.String flags, E value)
          Adds a new url-pattern and its corresponding value to the map
 java.util.ArrayList<java.lang.String> getURLPatterns()
          Return the matching url patterns.
 E map(java.lang.String uri)
          Finds the best match for the uri.
 E map(java.lang.String uri, java.util.ArrayList<java.lang.String> vars)
           
 E map(java.lang.String uri, java.util.ArrayList<java.lang.String> vars, boolean isWelcome)
          Finds the best match for the uri.
static java.lang.String urlPatternToRegexpPattern(java.lang.String pattern)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlMap

public UrlMap()
Create a new map


UrlMap

public UrlMap(boolean bestShort)
Create a new map preferring a short match.

Parameters:
bestShort - if true, use the shortest match
Method Detail

addMap

public void addMap(java.lang.String pattern,
                   E value,
                   boolean isIgnore)
            throws java.util.regex.PatternSyntaxException
Throws:
java.util.regex.PatternSyntaxException

addMap

public void addMap(java.lang.String pattern,
                   E value)
            throws java.util.regex.PatternSyntaxException
Throws:
java.util.regex.PatternSyntaxException

addMap

public void addMap(java.lang.String pattern,
                   E value,
                   boolean isIgnore,
                   boolean ifAbsent)
            throws java.util.regex.PatternSyntaxException
Throws:
java.util.regex.PatternSyntaxException

addMap

public void addMap(java.lang.String pattern,
                   java.lang.String flags,
                   E value,
                   boolean isIgnore,
                   boolean ifAbsent)
            throws java.util.regex.PatternSyntaxException
Adds a new url-pattern and its corresponding value to the map

Parameters:
pattern - servlet2.2 url-pattern
value - object stored as the value
Throws:
java.util.regex.PatternSyntaxException

urlPatternToRegexpPattern

public static java.lang.String urlPatternToRegexpPattern(java.lang.String pattern)

addStrictMap

public void addStrictMap(java.lang.String pattern,
                         java.lang.String flags,
                         E value)
                  throws java.util.regex.PatternSyntaxException,
                         ServletException
Adds a new url-pattern and its corresponding value to the map

Parameters:
pattern - servlet2.2 url-pattern
value - object stored as the value
Throws:
java.util.regex.PatternSyntaxException
ServletException

addRegexp

public void addRegexp(java.lang.String regexp,
                      java.lang.String flags,
                      E value)
               throws java.util.regex.PatternSyntaxException
Throws:
java.util.regex.PatternSyntaxException

addRegexp

public void addRegexp(java.lang.String regexp,
                      E value)
               throws java.util.regex.PatternSyntaxException
Throws:
java.util.regex.PatternSyntaxException

addRegexpIfAbsent

public void addRegexpIfAbsent(java.lang.String regexp,
                              E value)
                       throws java.util.regex.PatternSyntaxException
Throws:
java.util.regex.PatternSyntaxException

addRegexp

public void addRegexp(int prefixLength,
                      java.lang.String regexp,
                      java.lang.String flags,
                      E value,
                      boolean isShort,
                      boolean isIgnore,
                      boolean ifAbsent)
               throws java.util.regex.PatternSyntaxException
Adds a regular expression to the map.

Parameters:
prefixLength - the length of the pattern's mandatory prefix
regexp - the regexp pattern to add
flags - regexp flags, like "i" for case insensitive
value - the value for matching the pattern
isShort - if true, this regexp expects to be shorter than others
Throws:
java.util.regex.PatternSyntaxException

addRegexp

public void addRegexp(int prefixLength,
                      java.lang.String pattern,
                      java.lang.String regexp,
                      java.lang.String flags,
                      E value,
                      boolean isShort,
                      boolean isIgnore,
                      boolean ifAbsent,
                      boolean isSimple)
               throws java.util.regex.PatternSyntaxException
Adds a regular expression to the map.

Parameters:
prefixLength - the length of the pattern's mandatory prefix
pattern - the regexp pattern to add
regexp - the regexp pattern to add
flags - regexp flags, like "i" for case insensitive
value - the value for matching the pattern
isShort - if true, this regexp expects to be shorter than others
Throws:
java.util.regex.PatternSyntaxException

map

public E map(java.lang.String uri)
Finds the best match for the uri. In the case of a servlet dispatch, match is servletPath and replacement is pathInfo.

Parameters:
uri - uri to match
Returns:
matching object

map

public E map(java.lang.String uri,
             java.util.ArrayList<java.lang.String> vars)

map

public E map(java.lang.String uri,
             java.util.ArrayList<java.lang.String> vars,
             boolean isWelcome)
Finds the best match for the uri. In the case of a servlet dispatch, match is servletPath and replacement is pathInfo.

Parameters:
uri - uri to match
vars - a list of the regexp variables.
Returns:
matching object

getURLPatterns

public java.util.ArrayList<java.lang.String> getURLPatterns()
Return the matching url patterns.