Class PathMap<O>

  • Type Parameters:
    O - the Map.Entry value type
    All Implemented Interfaces:
    Serializable, Cloneable, Map<String,​O>

    @Deprecated
    public class PathMap<O>
    extends HashMap<String,​O>
    Deprecated.
    replaced with PathMappings (this class will be removed in Jetty 10)
    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.
     ""                 - the / path specification
     
    Matching is performed in the following order
    1. Exact match.
    2. Longest prefix match.
    3. Longest suffix match.
    4. default.

    Multiple path specifications can be mapped by providing a list of specifications. By default this class uses characters ":," as path separators, unless configured differently by calling the static method @see PathMap#setPathSpecSeparators(String)

    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. If concurrent modifications are possible then it should be synchronized at a higher level.

    See Also:
    Serialized Form
    • Constructor Detail

      • PathMap

        public PathMap()
        Deprecated.
      • PathMap

        public PathMap​(boolean noDefault)
        Deprecated.
      • PathMap

        public PathMap​(int capacity)
        Deprecated.
      • PathMap

        public PathMap​(Map<String,​? extends O> dictMap)
        Deprecated.
        Construct from dictionary PathMap.
        Parameters:
        dictMap - the map representing the dictionary to build this PathMap from
    • Method Detail

      • setPathSpecSeparators

        public static void setPathSpecSeparators​(String s)
        Deprecated.
        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. By default this class uses ":," characters as path separators.
        Parameters:
        s - separators
      • put

        public O put​(String pathSpec,
                     O object)
        Deprecated.
        Add a single path match to the PathMap.
        Specified by:
        put in interface Map<String,​O>
        Overrides:
        put in class HashMap<String,​O>
        Parameters:
        pathSpec - The path specification, or comma separated list of path specifications.
        object - The object the path maps to
      • match

        public O match​(String path)
        Deprecated.
        Get object matched by the path.
        Parameters:
        path - the path.
        Returns:
        Best matched object or null.
      • getMatch

        public PathMap.MappedEntry<O> getMatch​(String path)
        Deprecated.
        Get the entry mapped by the best specification.
        Parameters:
        path - the path.
        Returns:
        Map.Entry of the best matched or null.
      • getMatches

        public List<? extends Map.Entry<String,​O>> getMatches​(String path)
        Deprecated.
        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​(String path)
        Deprecated.
        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
      • match

        public static boolean match​(String pathSpec,
                                    String path)
        Deprecated.
        Parameters:
        pathSpec - the path spec
        path - the path
        Returns:
        true if match.
      • match

        public static boolean match​(String pathSpec,
                                    String path,
                                    boolean noDefault)
        Deprecated.
        Parameters:
        pathSpec - the path spec
        path - the path
        noDefault - true to not handle the default path "/" special, false to allow matcher rules to run
        Returns:
        true if match.
      • pathMatch

        public static String pathMatch​(String pathSpec,
                                       String path)
        Deprecated.
        Return the portion of a path that matches a path spec.
        Parameters:
        pathSpec - the path spec
        path - the path
        Returns:
        null if no match at all.
      • pathInfo

        public static String pathInfo​(String pathSpec,
                                      String path)
        Deprecated.
        Return the portion of a path that is after a path spec.
        Parameters:
        pathSpec - the path spec
        path - the path
        Returns:
        The path info string
      • relativePath

        public static String relativePath​(String base,
                                          String pathSpec,
                                          String path)
        Deprecated.
        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