java.lang.Object
org.apache.jackrabbit.spi.commons.name.Pattern

public abstract class Pattern extends Object
Pattern to match normalized Paths. A pattern matches either a constant path, a name of a path element, a selection of either of two patterns or a sequence of two patterns. The matching process is greedy. That is, whenever a match is not unique only the longest match is considered. Matching consumes as many elements from the beginning of an input path as possible and returns what's left as an instance of MatchResult. Use the Matcher class for matching a whole path or finding matches inside a path.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Pattern
    all()
    A pattern which matches all input.
    match(Path input)
    Matches this pattern against the input.
    static Pattern
    name(String namespaceUri, String localName)
    Constructs a pattern which matches a path elements against regular expressions.
    static Pattern
    name(Name name)
    Construct a new pattern which matches a path element of a given name
    static Pattern
    A pattern which matches nothing.
    static Pattern
    path(Path path)
    Construct a new pattern which matches an exact path
    static Pattern
    repeat(Pattern pattern)
    A pattern which matches pattern as many times as possible
    static Pattern
    repeat(Pattern pattern, int min, int max)
    A pattern which matches pattern as many times as possible but at least min times and at most max times.
    static Pattern
    selection(Pattern pattern1, Pattern pattern2)
    A pattern which matches pattern1 followed by pattern2 and returns the longer of the two matches.
    static Pattern
    sequence(Pattern pattern1, Pattern pattern2)
    A pattern which matches pattern1 followed by pattern2.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Pattern

      public Pattern()
  • Method Details

    • match

      public MatchResult match(Path input)
      Matches this pattern against the input.
      Parameters:
      input - path to match with this pattern
      Returns:
      result from the matching pattern against input
      Throws:
      IllegalArgumentException - if input is not normalized
    • path

      public static Pattern path(Path path)
      Construct a new pattern which matches an exact path
      Parameters:
      path -
      Returns:
      A pattern which matches path and nothing else
      Throws:
      IllegalArgumentException - if path is null
    • name

      public static Pattern name(Name name)
      Construct a new pattern which matches a path element of a given name
      Parameters:
      name -
      Returns:
      A pattern which matches a path element with name name
      Throws:
      IllegalArgumentException - if name is null
    • name

      public static Pattern name(String namespaceUri, String localName)
      Constructs a pattern which matches a path elements against regular expressions.
      Parameters:
      namespaceUri - A regular expression used for matching the name space URI of a path element.
      localName - A regular expression used for matching the local name of a path element
      Returns:
      A pattern which matches a path element if namespaceUri matches the name space URI of the path element and localName matches the local name of the path element.
      Throws:
      IllegalArgumentException - if either namespaceUri or localName is null
      See Also:
    • all

      public static Pattern all()
      A pattern which matches all input.
      Returns:
    • nothing

      public static Pattern nothing()
      A pattern which matches nothing.
      Returns:
    • selection

      public static Pattern selection(Pattern pattern1, Pattern pattern2)
      A pattern which matches pattern1 followed by pattern2 and returns the longer of the two matches.
      Parameters:
      pattern1 -
      pattern2 -
      Returns:
      Throws:
      IllegalArgumentException - if either argument is null
    • sequence

      public static Pattern sequence(Pattern pattern1, Pattern pattern2)
      A pattern which matches pattern1 followed by pattern2.
      Parameters:
      pattern1 -
      pattern2 -
      Returns:
    • repeat

      public static Pattern repeat(Pattern pattern)
      A pattern which matches pattern as many times as possible
      Parameters:
      pattern -
      Returns:
    • repeat

      public static Pattern repeat(Pattern pattern, int min, int max)
      A pattern which matches pattern as many times as possible but at least min times and at most max times.
      Parameters:
      pattern -
      min -
      max -
      Returns: