类 PatternMatcher<S>


  • public class PatternMatcher<S>
    extends java.lang.Object
    作者:
    Dave Syer, Dan Garrette
    • 构造器概要

      构造器 
      构造器说明
      PatternMatcher​(java.util.Map<java.lang.String,​S> map)
      Initialize a new PatternMatcher with a map of patterns to values
    • 方法概要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型方法说明
      Smatch​(java.lang.String line)
      This method takes a String key and a map from Strings to values of any type.
      static booleanmatch​(java.lang.String pattern, java.lang.String str)
      Lifted from AntPathMatcher in Spring Core.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • PatternMatcher

        public PatternMatcher​(java.util.Map<java.lang.String,​S> map)
        Initialize a new PatternMatcher with a map of patterns to values
        参数:
        map - a map from String patterns to values
    • 方法详细资料

      • match

        public static boolean match​(java.lang.String pattern,
                                    java.lang.String str)
        Lifted from AntPathMatcher in Spring Core. Tests whether or not a string matches against a pattern. The pattern may contain two special characters:
        '*' means zero or more characters
        '?' means one and only one character
        参数:
        pattern - pattern to match against. Must not be null.
        str - string which must be matched against the pattern. Must not be null.
        返回:
        true if the string matches against the pattern, or false otherwise.
      • match

        public S match​(java.lang.String line)

        This method takes a String key and a map from Strings to values of any type. During processing, the method will identify the most specific key in the map that matches the line. Once the correct is identified, its value is returned. Note that if the map contains the wildcard string "*" as a key, then it will serve as the "default" case, matching every line that does not match anything else.

        If no matching prefix is found, a IllegalStateException will be thrown.

        Null keys are not allowed in the map.

        参数:
        line - An input string
        返回:
        the value whose prefix matches the given line