Class PathMapper


  • public final class PathMapper
    extends java.lang.Object
    The PathMapper is used to map file patterns to keys, and find an approriate key for a given file path. The pattern rules are consistent with those defined in the Servlet 2.3 API on the whole. Wildcard patterns are also supported, using any combination of * and ?.

    Example

    PathMapper pm = new PathMapper();

    pm.put("one","/");
    pm.put("two","/mydir/*");
    pm.put("three","*.xml");
    pm.put("four","/myexactfile.html");
    pm.put("five","/*\/admin/*.??ml");

    String result1 = pm.get("/mydir/myfile.xml"); // returns "two";
    String result2 = pm.get("/mydir/otherdir/admin/myfile.html"); // returns "five";
    Version:
    $Revision: 1.2 $
    Author:
    Joe Walnes, Mike Cannon-Brookes, Hani Suleiman
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map mappings  
    • Constructor Summary

      Constructors 
      Constructor Description
      PathMapper()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String findComplexKey​(java.lang.String path, java.util.Map mappings)  
      private static java.lang.String findDefaultKey​(java.util.Map mappings)
      Look for root pattern ( / ).
      private static java.lang.String findExactKey​(java.lang.String path, java.util.Map mappings)
      Check if path matches exact pattern ( /blah/blah.jsp ).
      private static java.lang.String findKey​(java.lang.String path, java.util.Map mappings)
      Find exact key in mappings.
      java.lang.String get​(java.lang.String path)
      Retrieve appropriate key by matching patterns with supplied path.
      private static boolean match​(java.lang.String pattern, java.lang.String str, boolean isCaseSensitive)  
      void put​(java.lang.String key, java.lang.String pattern)
      Add a key and appropriate matching pattern.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • mappings

        private java.util.Map mappings
    • Constructor Detail

      • PathMapper

        public PathMapper()
    • Method Detail

      • put

        public void put​(java.lang.String key,
                        java.lang.String pattern)
        Add a key and appropriate matching pattern.
      • get

        public java.lang.String get​(java.lang.String path)
        Retrieve appropriate key by matching patterns with supplied path.
      • findKey

        private static java.lang.String findKey​(java.lang.String path,
                                                java.util.Map mappings)
        Find exact key in mappings.
      • findExactKey

        private static java.lang.String findExactKey​(java.lang.String path,
                                                     java.util.Map mappings)
        Check if path matches exact pattern ( /blah/blah.jsp ).
      • findComplexKey

        private static java.lang.String findComplexKey​(java.lang.String path,
                                                       java.util.Map mappings)
      • findDefaultKey

        private static java.lang.String findDefaultKey​(java.util.Map mappings)
        Look for root pattern ( / ).
      • match

        private static boolean match​(java.lang.String pattern,
                                     java.lang.String str,
                                     boolean isCaseSensitive)