Class Pattern
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.name.Pattern
-
public abstract class Pattern extends Object
Pattern to match normalizedPath
s. 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 theMatcher
class 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 Pattern
all()
A pattern which matches all input.protected abstract org.apache.jackrabbit.spi.commons.name.Pattern.Context
match(org.apache.jackrabbit.spi.commons.name.Pattern.Context input)
MatchResult
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 namestatic Pattern
nothing()
A pattern which matches nothing.static Pattern
path(Path path)
Construct a new pattern which matches an exact pathstatic Pattern
repeat(Pattern pattern)
A pattern which matchespattern
as many times as possiblestatic Pattern
repeat(Pattern pattern, int min, int max)
A pattern which matchespattern
as many times as possible but at leastmin
times and at mostmax
times.static Pattern
selection(Pattern pattern1, Pattern pattern2)
A pattern which matchespattern1
followed bypattern2
and returns the longer of the two matches.static Pattern
sequence(Pattern pattern1, Pattern pattern2)
A pattern which matchespattern1
followed 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
pattern
againstinput
- Throws:
IllegalArgumentException
- ifinput
is 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
path
and nothing else - Throws:
IllegalArgumentException
- ifpath
isnull
-
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
- ifname
isnull
-
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 eithernamespaceUri
orlocalName
isnull
- 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 matchespattern1
followed bypattern2
and 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 matchespattern1
followed bypattern2
.- Parameters:
pattern1
-pattern2
-- Returns:
-
repeat
public static Pattern repeat(Pattern pattern)
A pattern which matchespattern
as many times as possible- Parameters:
pattern
-- Returns:
-
-