Class Pattern
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.name.Pattern
-
public abstract class Pattern extends Object
Pattern to match normalizedPaths. 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 ofMatchResult. Use theMatcherclass for matching a whole path or finding matches inside a path.
-
-
Constructor Summary
Constructors Constructor Description Pattern()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Patternall()A pattern which matches all input.protected abstract org.apache.jackrabbit.spi.commons.name.Pattern.Contextmatch(org.apache.jackrabbit.spi.commons.name.Pattern.Context input)MatchResultmatch(Path input)Matches this pattern against the input.static Patternname(String namespaceUri, String localName)Constructs a pattern which matches a path elements against regular expressions.static Patternname(Name name)Construct a new pattern which matches a path element of a given namestatic Patternnothing()A pattern which matches nothing.static Patternpath(Path path)Construct a new pattern which matches an exact pathstatic Patternrepeat(Pattern pattern)A pattern which matchespatternas many times as possiblestatic Patternrepeat(Pattern pattern, int min, int max)A pattern which matchespatternas many times as possible but at leastmintimes and at mostmaxtimes.static Patternselection(Pattern pattern1, Pattern pattern2)A pattern which matchespattern1followed bypattern2and returns the longer of the two matches.static Patternsequence(Pattern pattern1, Pattern pattern2)A pattern which matchespattern1followed bypattern2.
-
-
-
Method Detail
-
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
patternagainstinput - Throws:
IllegalArgumentException- ifinputis not normalized
-
match
protected abstract org.apache.jackrabbit.spi.commons.name.Pattern.Context match(org.apache.jackrabbit.spi.commons.name.Pattern.Context input) throws RepositoryException- Throws:
RepositoryException
-
path
public static Pattern path(Path path)
Construct a new pattern which matches an exact path- Parameters:
path-- Returns:
- A pattern which matches
pathand nothing else - Throws:
IllegalArgumentException- ifpathisnull
-
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- ifnameisnull
-
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 eithernamespaceUriorlocalNameisnull- See Also:
Pattern
-
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 matchespattern1followed bypattern2and returns the longer of the two matches.- Parameters:
pattern1-pattern2-- Returns:
- Throws:
IllegalArgumentException- if either argument isnull
-
sequence
public static Pattern sequence(Pattern pattern1, Pattern pattern2)
A pattern which matchespattern1followed bypattern2.- Parameters:
pattern1-pattern2-- Returns:
-
repeat
public static Pattern repeat(Pattern pattern)
A pattern which matchespatternas many times as possible- Parameters:
pattern-- Returns:
-
-