Top Description Inners Fields Constructors Methods
org.mortbay.jetty.servlet

public Class PathMap

extends HashMap
implements Externalizable
Class Inheritance
All Implemented Interfaces
java.io.Externalizable, java.io.Serializable
Imports
java.io.Externalizable, java.util.HashMap, .List, .Map, .Set, .StringTokenizer, org.mortbay.util.LazyList, .SingletonList, .StringMap, .URIUtil

URI path map to Object. This mapping implements the path specification recommended in the 2.2 Servlet API. Path specifications can be of the following forms:
/foo/bar           - an exact path specification.
/foo/*             - a prefix path specification (must end '/*').
*.ext              - a suffix path specification.
/                  - the default path specification.       
Matching is performed in the following order
  • Exact match.
  • Longest prefix match.
  • Longest suffix match.
  • default. Multiple path specifications can be mapped by providing a list of specifications. The list is separated by the characters specified in the "org.mortbay.http.PathMap.separators" System property, which defaults to :

    Special characters within paths such as '?� and ';' are not treated specially as it is assumed they would have been either encoded in the original URL or stripped from the path.

    This class is not synchronized for get's. If concurrent modifications are possible then it should be synchronized at a higher level.

  • Author
    Greg Wilkins (gregw)

    Nested and Inner Type Summary

    Modifier and TypeClass and Description
    public static class

    Field Summary

    Modifier and TypeField and Description
    private static String
    pack-priv PathMap.Entry
    pack-priv List<E>
    pack-priv Set<E>
    pack-priv StringMap
    pack-priv boolean
    pack-priv PathMap.Entry
    pack-priv StringMap
    pack-priv StringMap

    Constructor Summary

    AccessConstructor and Description
    public
    PathMap()

    Construct empty PathMap.

    public
    PathMap(boolean nodefault)

    Construct empty PathMap.

    public
    PathMap(int capacity)

    Construct empty PathMap.

    public
    PathMap(Map<K, V> m)

    Construct from dictionary PathMap.

    Method Summary

    Modifier and TypeMethod and Description
    public void
    clear()

    Overrides java.util.HashMap.clear.

    Implements java.util.Map.clear.

    Removes all of the mappings from this map.
    public Object

    Returns:

    LazyList of Map.Entry instances key=pathSpec
    getLazyMatches
    (String
    Path to match
    path
    )

    Get all entries matched by the path.

    public PathMap.Entry

    Returns:

    Map.Entry of the best matched or null.
    getMatch
    (String
    the path.
    path
    )

    Get the entry mapped by the best specification.

    public List<E>

    Returns:

    List of Map.Entry instances key=pathSpec
    getMatches
    (String
    Path to match
    path
    )

    Get all entries matched by the path.

    private static boolean
    public Object

    Returns:

    Best matched object or null.
    match
    (String
    the path.
    path
    )

    Get object matched by the path.

    public static boolean

    Returns:

    true if match.
    match
    (String pathSpec, String path)

    public static boolean

    Returns:

    true if match.
    match
    (String pathSpec, String path, boolean noDefault)

    public static String

    Returns:

    The path info string
    pathInfo
    (String pathSpec, String path)

    Return the portion of a path that is after a path spec.

    public static String

    Returns:

    null if no match at all.
    pathMatch
    (String pathSpec, String path)

    Return the portion of a path that matches a path spec.

    public synchronized Object
    put(Object
    The path specification, or comma separated list of path specifications.
    pathSpec
    ,
    Object
    The object the path maps to
    object
    )

    Overrides java.util.HashMap.put.

    Implements java.util.Map.put.

    Add a single path match to the PathMap.
    public void
    readExternal(ObjectInput
    the stream to read data from in order to restore the object
    in
    )

    Implements java.io.Externalizable.readExternal.

    The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.
    public static String

    Returns:

    base plus path with pathspec removed
    relativePath
    (String
    The base the path is relative to.
    base
    ,
    String
    The spec of the path segment to ignore.
    pathSpec
    ,
    String
    the additional path
    path
    )

    Relative path.

    public synchronized Object
    remove(Object
    key whose mapping is to be removed from the map
    pathSpec
    )

    Overrides java.util.HashMap.remove.

    Implements java.util.Map.remove.

    Removes the mapping for the specified key from this map if present.
    public static void
    setPathSpecSeparators(String
    separators
    s
    )

    Set the path spec separator.

    public void
    writeExternal(ObjectOutput
    the stream to write the object to
    out
    )

    Implements java.io.Externalizable.writeExternal.

    The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
    Inherited from java.util.HashMap:
    clonecomputecomputeIfAbsentcomputeIfPresentcontainsKeycontainsValueentrySetforEachgetgetOrDefaultisEmptykeySetmergenewHashMapputAllputIfAbsentremovereplacereplacereplaceAllsizevalues

    Field Detail

    __pathSpecSeparatorsback to summary
    private static String __pathSpecSeparators
    _defaultback to summary
    pack-priv PathMap.Entry _default
    _defaultSingletonListback to summary
    pack-priv List<E> _defaultSingletonList
    _entrySetback to summary
    pack-priv Set<E> _entrySet
    _exactMapback to summary
    pack-priv StringMap _exactMap
    _nodefaultback to summary
    pack-priv boolean _nodefault
    _prefixDefaultback to summary
    pack-priv PathMap.Entry _prefixDefault
    _prefixMapback to summary
    pack-priv StringMap _prefixMap
    _suffixMapback to summary
    pack-priv StringMap _suffixMap

    Constructor Detail

    PathMapback to summary
    public PathMap()

    Construct empty PathMap.

    PathMapback to summary
    public PathMap(boolean nodefault)

    Construct empty PathMap.

    PathMapback to summary
    public PathMap(int capacity)

    Construct empty PathMap.

    PathMapback to summary
    public PathMap(Map<K, V> m)

    Construct from dictionary PathMap.

    Method Detail

    clearback to summary
    public void clear()

    Overrides java.util.HashMap.clear.

    Implements java.util.Map.clear.

    Doc from java.util.HashMap.clear.

    Removes all of the mappings from this map. The map will be empty after this call returns.

    getLazyMatchesback to summary
    public Object getLazyMatches(String path)

    Get all entries matched by the path. Best match first.

    Parameters
    path:String

    Path to match

    Returns:Object

    LazyList of Map.Entry instances key=pathSpec

    getMatchback to summary
    public PathMap.Entry getMatch(String path)

    Get the entry mapped by the best specification.

    Parameters
    path:String

    the path.

    Returns:PathMap.Entry

    Map.Entry of the best matched or null.

    getMatchesback to summary
    public List<E> getMatches(String path)

    Get all entries matched by the path. Best match first.

    Parameters
    path:String

    Path to match

    Returns:List<E>

    List of Map.Entry instances key=pathSpec

    isPathWildcardMatchback to summary
    private static boolean isPathWildcardMatch(String pathSpec, String path)
    matchback to summary
    public Object match(String path)

    Get object matched by the path.

    Parameters
    path:String

    the path.

    Returns:Object

    Best matched object or null.

    matchback to summary
    public static boolean match(String pathSpec, String path) throws IllegalArgumentException
    Returns:boolean

    true if match.

    matchback to summary
    public static boolean match(String pathSpec, String path, boolean noDefault) throws IllegalArgumentException
    Returns:boolean

    true if match.

    pathInfoback to summary
    public static String pathInfo(String pathSpec, String path)

    Return the portion of a path that is after a path spec.

    Returns:String

    The path info string

    pathMatchback to summary
    public static String pathMatch(String pathSpec, String path)

    Return the portion of a path that matches a path spec.

    Returns:String

    null if no match at all.

    putback to summary
    public synchronized Object put(Object pathSpec, Object object)

    Overrides java.util.HashMap.put.

    Implements java.util.Map.put.

    Add a single path match to the PathMap.

    Parameters
    pathSpec:Object

    The path specification, or comma separated list of path specifications.

    object:Object

    The object the path maps to

    Returns:Object

    Doc from java.util.HashMap.put.

    the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)

    readExternalback to summary
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

    Implements java.io.Externalizable.readExternal.

    Doc from java.io.Externalizable.readExternal.

    The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

    Parameters
    in:ObjectInput

    the stream to read data from in order to restore the object

    Exceptions
    IOException:
    if I/O errors occur
    ClassNotFoundException:
    If the class for an object being restored cannot be found.
    relativePathback to summary
    public static String relativePath(String base, String pathSpec, String path)

    Relative path.

    Parameters
    base:String

    The base the path is relative to.

    pathSpec:String

    The spec of the path segment to ignore.

    path:String

    the additional path

    Returns:String

    base plus path with pathspec removed

    removeback to summary
    public synchronized Object remove(Object pathSpec)

    Overrides java.util.HashMap.remove.

    Implements java.util.Map.remove.

    Doc from java.util.HashMap.remove.

    Removes the mapping for the specified key from this map if present.

    Parameters
    pathSpec:Object

    key whose mapping is to be removed from the map

    Returns:Object

    the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)

    setPathSpecSeparatorsback to summary
    public static void setPathSpecSeparators(String s)

    Set the path spec separator. Multiple path specification may be included in a single string if they are separated by the characters set in this string. The default value is ":," or whatever has been set by the system property org.mortbay.http.PathMap.separators

    Parameters
    s:String

    separators

    writeExternalback to summary
    public void writeExternal(ObjectOutput out) throws IOException

    Implements java.io.Externalizable.writeExternal.

    Doc from java.io.Externalizable.writeExternal.

    The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

    Parameters
    out:ObjectOutput

    the stream to write the object to

    Exceptions
    IOException:
    Includes any I/O exceptions that may occur
    org.mortbay.jetty.servlet back to summary

    public Class PathMap.Entry

    extends Object
    implements Entry
    Class Inheritance
    All Implemented Interfaces
    java.util.Map.Entry

    Field Summary

    Modifier and TypeField and Description
    private Object
    private String
    private transient String
    private Object

    Constructor Summary

    AccessConstructor and Description
    pack-priv
    Entry(Object key, Object value)

    Method Summary

    Modifier and TypeMethod and Description
    public Object
    getKey()

    Implements java.util.Map.Entry.getKey.

    Returns the key corresponding to this entry.
    public String
    public Object
    getValue()

    Implements java.util.Map.Entry.getValue.

    Returns the value corresponding to this entry.
    pack-priv void
    setMapped(String mapped)

    public Object
    setValue(Object
    new value to be stored in this entry
    o
    )

    Implements java.util.Map.Entry.setValue.

    Replaces the value corresponding to this entry with the specified value (optional operation).
    public String
    toString()

    Overrides java.lang.Object.toString.

    Returns a string representation of the object.
    Inherited from java.lang.Object:
    cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

    Field Detail

    keyback to summary
    private Object key
    mappedback to summary
    private String mapped
    stringback to summary
    private transient String string
    valueback to summary
    private Object value

    Constructor Detail

    Entryback to summary
    pack-priv Entry(Object key, Object value)

    Method Detail

    getKeyback to summary
    public Object getKey()

    Implements java.util.Map.Entry.getKey.

    Doc from java.util.Map.Entry.getKey.

    Returns the key corresponding to this entry.

    Returns:Object

    the key corresponding to this entry

    getMappedback to summary
    public String getMapped()
    getValueback to summary
    public Object getValue()

    Implements java.util.Map.Entry.getValue.

    Doc from java.util.Map.Entry.getValue.

    Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove operation), the results of this call are undefined.

    Returns:Object

    the value corresponding to this entry

    setMappedback to summary
    pack-priv void setMapped(String mapped)
    setValueback to summary
    public Object setValue(Object o)

    Implements java.util.Map.Entry.setValue.

    Doc from java.util.Map.Entry.setValue.

    Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).

    Parameters
    o:Object

    new value to be stored in this entry

    Returns:Object

    old value corresponding to the entry

    toStringback to summary
    public String toString()

    Overrides java.lang.Object.toString.

    Doc from java.lang.Object.toString.

    Returns a string representation of the object.

    Returns:String

    a string representation of the object