Class PathMap<O>

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

    @Deprecated
    public class PathMap<O>
    extends java.util.HashMap<java.lang.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
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  PathMap.MappedEntry<O>
      Deprecated.
       
      static class  PathMap.PathSet
      Deprecated.
       
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      PathMap()
      Deprecated.
       
      PathMap​(boolean noDefault)
      Deprecated.
       
      PathMap​(int capacity)
      Deprecated.
       
      PathMap​(java.util.Map<java.lang.String,​? extends O> dictMap)
      Deprecated.
      Construct from dictionary PathMap.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void clear()
      Deprecated.
       
      boolean containsMatch​(java.lang.String path)
      Deprecated.
      Return whether the path matches any entries in the PathMap, excluding the default entry
      PathMap.MappedEntry<O> getMatch​(java.lang.String path)
      Deprecated.
      Get the entry mapped by the best specification.
      java.util.List<? extends java.util.Map.Entry<java.lang.String,​O>> getMatches​(java.lang.String path)
      Deprecated.
      Get all entries matched by the path.
      O match​(java.lang.String path)
      Deprecated.
      Get object matched by the path.
      static boolean match​(java.lang.String pathSpec, java.lang.String path)
      Deprecated.
       
      static boolean match​(java.lang.String pathSpec, java.lang.String path, boolean noDefault)
      Deprecated.
       
      static java.lang.String pathInfo​(java.lang.String pathSpec, java.lang.String path)
      Deprecated.
      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)
      Deprecated.
      Return the portion of a path that matches a path spec.
      O put​(java.lang.String pathSpec, O object)
      Deprecated.
      Add a single path match to the PathMap.
      static java.lang.String relativePath​(java.lang.String base, java.lang.String pathSpec, java.lang.String path)
      Deprecated.
      Relative path.
      O remove​(java.lang.Object pathSpec)
      Deprecated.
       
      static void setPathSpecSeparators​(java.lang.String s)
      Deprecated.
      Set the path spec separator.
      • Methods inherited from class java.util.HashMap

        clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, 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()
        Deprecated.
      • PathMap

        public PathMap​(boolean noDefault)
        Deprecated.
      • PathMap

        public PathMap​(int capacity)
        Deprecated.
      • PathMap

        public PathMap​(java.util.Map<java.lang.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​(java.lang.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​(java.lang.String pathSpec,
                     O object)
        Deprecated.
        Add a single path match to the PathMap.
        Specified by:
        put in interface java.util.Map<java.lang.String,​O>
        Overrides:
        put in class java.util.HashMap<java.lang.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​(java.lang.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​(java.lang.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 java.util.List<? extends java.util.Map.Entry<java.lang.String,​O>> getMatches​(java.lang.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​(java.lang.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
      • remove

        public O remove​(java.lang.Object pathSpec)
        Deprecated.
        Specified by:
        remove in interface java.util.Map<java.lang.String,​O>
        Overrides:
        remove in class java.util.HashMap<java.lang.String,​O>
      • clear

        public void clear()
        Deprecated.
        Specified by:
        clear in interface java.util.Map<java.lang.String,​O>
        Overrides:
        clear in class java.util.HashMap<java.lang.String,​O>
      • match

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

        public static boolean match​(java.lang.String pathSpec,
                                    java.lang.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 java.lang.String pathMatch​(java.lang.String pathSpec,
                                                 java.lang.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 java.lang.String pathInfo​(java.lang.String pathSpec,
                                                java.lang.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 java.lang.String relativePath​(java.lang.String base,
                                                    java.lang.String pathSpec,
                                                    java.lang.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