Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.jetty.servlet
Class PathMap

    java.lang.Object
      java.util.AbstractMap<K,V>
          java.util.HashMap
              org.mortbay.jetty.servlet.PathMap

All Implemented Interfaces:
  java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.util.Map

    public class PathMap

extends java.util.HashMap
implements java.io.Externalizable

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)
See Also:
  Serialized Form

Nested Class Summary
`static class` | `PathMap.Entry`

Nested classes/interfaces inherited from class java.util.AbstractMap
`java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>`

Constructor Summary
`PathMap()` Construct empty PathMap.
`PathMap(boolean nodefault)` Construct empty PathMap.
`PathMap(int capacity)` Construct empty PathMap.
`PathMap(java.util.Map m)` Construct from dictionary PathMap.

Method Summary
`void` | `clear()`
`boolean` | `containsMatch(java.lang.String path)` Return whether the path matches any entries in the PathMap, excluding the default entry
`java.lang.Object` | `getLazyMatches(java.lang.String path)` Get all entries matched by the path.
`PathMap.Entry` | `getMatch(java.lang.String path)` Get the entry mapped by the best specification.
`java.util.List` | `getMatches(java.lang.String path)` Get all entries matched by the path.
`java.lang.Object` | `match(java.lang.String path)` Get object matched by the path.
`static boolean` | `match(java.lang.String pathSpec, java.lang.String path)`
`static boolean` | `match(java.lang.String pathSpec, java.lang.String path, boolean noDefault)`
`static java.lang.String` | `pathInfo(java.lang.String pathSpec, java.lang.String path)` Return the portion of a path that is after a path spec.
`static java.lang.String` | `pathMatch(java.lang.String pathSpec, java.lang.String path)` Return the portion of a path that matches a path spec.
`java.lang.Object` | `put(java.lang.Object pathSpec, java.lang.Object object)` Add a single path match to the PathMap.
`void` | `readExternal(java.io.ObjectInput in)`
`static java.lang.String` | `relativePath(java.lang.String base, java.lang.String pathSpec, java.lang.String path)` Relative path.
`java.lang.Object` | `remove(java.lang.Object pathSpec)`
`static void` | `setPathSpecSeparators(java.lang.String s)` Set the path spec separator.
`void` | `writeExternal(java.io.ObjectOutput out)`

Methods inherited from class java.util.HashMap
`clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, size, values`

Methods inherited from class java.util.AbstractMap
`equals, hashCode, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Map
`equals, hashCode`

Constructor Detail

### PathMap

    public PathMap()

  Construct empty PathMap.

### PathMap

    public PathMap(boolean nodefault)

  Construct empty PathMap.

### PathMap

    public PathMap(int capacity)

  Construct empty PathMap.

### PathMap

    public PathMap(java.util.Map m)

  Construct from dictionary PathMap.

Method Detail

### setPathSpecSeparators

    public static void setPathSpecSeparators(java.lang.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` - separators

### writeExternal

    public void writeExternal(java.io.ObjectOutput out)
                       throws java.io.IOException

  Specified by:
    `writeExternal` in interface `java.io.Externalizable`
  Throws:
    `java.io.IOException`

### readExternal

    public void readExternal(java.io.ObjectInput in)
                      throws java.io.IOException,
                             java.lang.ClassNotFoundException

  Specified by:
    `readExternal` in interface `java.io.Externalizable`
  Throws:
    `java.io.IOException`
    `java.lang.ClassNotFoundException`

### put

    public java.lang.Object put(java.lang.Object pathSpec,
                                java.lang.Object object)

  Add a single path match to the PathMap.

  Specified by:
    `put` in interface `java.util.Map`
  Overrides:
    `put` in class `java.util.HashMap`
  Parameters:
    `pathSpec` - The path specification, or comma separated list of path specifications.
    `object` - The object the path maps to

### match

    public java.lang.Object match(java.lang.String path)

  Get object matched by the path.

  Parameters:
    `path` - the path.
  Returns:
    Best matched object or null.

### getMatch

    public PathMap.Entry getMatch(java.lang.String path)

  Get the entry mapped by the best specification.

  Parameters:
    `path` - the path.
  Returns:
    Map.Entry of the best matched or null.

### getLazyMatches

    public java.lang.Object getLazyMatches(java.lang.String path)

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

  Parameters:
    `path` - Path to match
  Returns:
    LazyList of Map.Entry instances key=pathSpec

### getMatches

    public java.util.List getMatches(java.lang.String path)

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

  Parameters:
    `path` - Path to match
  Returns:
    List of Map.Entry instances key=pathSpec

### containsMatch

    public boolean containsMatch(java.lang.String path)

  Return whether the path matches any entries in the PathMap, excluding the default entry

  Parameters:
    `path` - Path to match
  Returns:
    Whether the PathMap contains any entries that match this

### remove

    public java.lang.Object remove(java.lang.Object pathSpec)

  Specified by:
    `remove` in interface `java.util.Map`
  Overrides:
    `remove` in class `java.util.HashMap`

### clear

    public void clear()

  Specified by:
    `clear` in interface `java.util.Map`
  Overrides:
    `clear` in class `java.util.HashMap`

### match

    public static boolean match(java.lang.String pathSpec,
                                java.lang.String path)
                         throws java.lang.IllegalArgumentException

  Returns:
    true if match.
  Throws:
    `java.lang.IllegalArgumentException`

### match

    public static boolean match(java.lang.String pathSpec,
                                java.lang.String path,
                                boolean noDefault)
                         throws java.lang.IllegalArgumentException

  Returns:
    true if match.
  Throws:
    `java.lang.IllegalArgumentException`

### pathMatch

    public static java.lang.String pathMatch(java.lang.String pathSpec,
                                             java.lang.String path)

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

  Returns:
    null if no match at all.

### pathInfo

    public static java.lang.String pathInfo(java.lang.String pathSpec,
                                            java.lang.String path)

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

  Returns:
    The path info string

### relativePath

    public static java.lang.String relativePath(java.lang.String base,
                                                java.lang.String pathSpec,
                                                java.lang.String path)

  Relative path.

  Parameters:
    `base` - The base the path is relative to.
    `pathSpec` - The spec of the path segment to ignore.
    `path` - the additional path
  Returns:
    base plus path with pathspec removed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.