public abstract class Pattern
extends java.lang.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.
|
static Pattern |
name(Name name)
Construct a new pattern which matches a path element of a given name
|
static Pattern |
name(java.lang.String namespaceUri,
java.lang.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
java.lang.IllegalArgumentException
- if input
is not normalizedpublic static Pattern path(Path path)
path
- path
and nothing elsejava.lang.IllegalArgumentException
- if path
is null
public static Pattern name(Name name)
name
- name
java.lang.IllegalArgumentException
- if name
is null
public static Pattern name(java.lang.String namespaceUri, java.lang.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
elementjava.lang.IllegalArgumentException
- 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
- java.lang.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 © 2010 - 2020 Adobe. All Rights Reserved