public abstract class Pattern extends Object
Path
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 of MatchResult
.
Use the Matcher
class for matching a whole path or finding matches inside a path.Constructor and Description |
---|
Pattern() |
Modifier and Type | Method and Description |
---|---|
static Pattern |
all()
A pattern which matches all input.
|
MatchResult |
match(Path input)
Matches this pattern against the input.
|
protected abstract org.apache.jackrabbit.spi.commons.name.Pattern.Context |
match(org.apache.jackrabbit.spi.commons.name.Pattern.Context input) |
static Pattern |
name(Name name)
Construct a new pattern which matches a path element of a given name
|
static Pattern |
name(String namespaceUri,
String localName)
Constructs a pattern which matches a path elements against regular expressions.
|
static Pattern |
nothing()
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 . |
public MatchResult match(Path input)
input
- path to match with this patternpattern
against input
IllegalArgumentException
- if input
is not normalizedprotected abstract org.apache.jackrabbit.spi.commons.name.Pattern.Context match(org.apache.jackrabbit.spi.commons.name.Pattern.Context input) throws RepositoryException
RepositoryException
public static Pattern path(Path path)
path
- path
and nothing elseIllegalArgumentException
- if path
is null
public static Pattern name(Name name)
name
- name
IllegalArgumentException
- if name
is null
public static Pattern name(String namespaceUri, String localName)
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
elementIllegalArgumentException
- if either namespaceUri
or
localName
is null
Pattern
public static Pattern all()
public static Pattern nothing()
public static Pattern selection(Pattern pattern1, Pattern pattern2)
pattern1
followed by pattern2
and
returns the longer of the two matches.pattern1
- pattern2
- IllegalArgumentException
- if either argument is null
public static Pattern sequence(Pattern pattern1, Pattern pattern2)
pattern1
followed by pattern2
.pattern1
- pattern2
- public static Pattern repeat(Pattern pattern)
pattern
as many times as possiblepattern
- Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.