|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.jparsec.pattern.Pattern
public abstract class Pattern
Encapsulates algorithm to recognize certain string pattern. When fed with a character range,
a Pattern
object either fails to match, or matches with the match length returned.
There is no error reported on where and what exactly failed.
Field Summary | |
---|---|
static int |
MISMATCH
Returned by match(CharSequence, int, int) method when match fails. |
Constructor Summary | |
---|---|
Pattern()
|
Method Summary | |
---|---|
Pattern |
atLeast(int min)
Returns Pattern object that matches this pattern for at least min times. |
Pattern |
atMost(int max)
Returns Pattern object that matches this pattern for up to max times. |
Pattern |
ifelse(Pattern consequence,
Pattern alternative)
Returns Pattern object that, if this pattern matches,
matches the remaining input against consequence pattern, or otherwise matches against
alternative pattern. |
Pattern |
many()
Returns a Pattern object that matches this pattern for 0 or more times. |
Pattern |
many(int min)
Deprecated. Use atLeast(int) instead. |
Pattern |
many1()
Returns a Pattern object that matches this pattern for 1 or more times. |
abstract int |
match(CharSequence src,
int begin,
int end)
Matches character range against the pattern. |
Pattern |
next(Pattern next)
Returns a Pattern object that sequentially matches the character range against
this and then next . |
Pattern |
not()
Returns a Pattern object that only matches if this pattern mismatches, 0 is returned
otherwise. |
Pattern |
optional()
Returns a Pattern object that matches with 0 length even if this mismatches. |
Pattern |
or(Pattern p2)
Returns Pattern object that matches if either this or p2 matches. |
Pattern |
peek()
Returns Pattern object that matches with match length 0 if this Pattern object matches. |
Pattern |
repeat(int n)
Deprecated. Use times(int) instead. |
Pattern |
some(int max)
Deprecated. Use atMost(int) instead. |
Pattern |
some(int min,
int max)
Deprecated. Use times(int, int) instead. |
Pattern |
times(int n)
Returns Pattern object that matches the input against this pattern for n times. |
Pattern |
times(int min,
int max)
Returns Pattern object that matches this pattern for at least min times
and up to max times. |
Parser<Void> |
toScanner(String name)
Returns a scanner parser using this pattern. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MISMATCH
match(CharSequence, int, int)
method when match fails.
Constructor Detail |
---|
public Pattern()
Method Detail |
---|
public abstract int match(CharSequence src, int begin, int end)
end - begin
.
src
- the source string.begin
- the beginning index in the sequence.end
- the end index of the source string (exclusive).
NOTE: the range is [begin, end)
.
public final Pattern next(Pattern next)
Pattern
object that sequentially matches the character range against
this
and then next
. If both succeeds, the entire match length is returned.
next
- the next pattern to match.
public final Pattern optional()
Pattern
object that matches with 0 length even if this
mismatches.
public final Pattern many()
Pattern
object that matches this pattern for 0 or more times.
The total match length is returned.
@Deprecated public final Pattern many(int min)
atLeast(int)
instead.
Pattern
object that matches this pattern for at least min
times.
The total match length is returned.
min
- the minimal number of times to match.
public final Pattern atLeast(int min)
Pattern
object that matches this pattern for at least min
times.
The total match length is returned.
min
- the minimal number of times to match.
public final Pattern many1()
Pattern
object that matches this pattern for 1 or more times.
The total match length is returned.
@Deprecated public final Pattern some(int max)
atMost(int)
instead.
Pattern
object that matches this pattern for up to max
times.
The total match length is returned.
max
- the maximal number of times to match.
public final Pattern atMost(int max)
Pattern
object that matches this pattern for up to max
times.
The total match length is returned.
max
- the maximal number of times to match.
@Deprecated public final Pattern some(int min, int max)
times(int, int)
instead.
Pattern
object that matches this pattern for at least min
times
and up to max
times. The total match length is returned.
min
- the minimal number of times to match.max
- the maximal number of times to match.
public final Pattern times(int min, int max)
Pattern
object that matches this pattern for at least min
times
and up to max
times. The total match length is returned.
min
- the minimal number of times to match.max
- the maximal number of times to match.
public final Pattern not()
Pattern
object that only matches if this pattern mismatches, 0 is returned
otherwise.
public final Pattern peek()
Pattern
object that matches with match length 0 if this Pattern object matches.
public final Pattern ifelse(Pattern consequence, Pattern alternative)
Pattern
object that, if this pattern matches,
matches the remaining input against consequence
pattern, or otherwise matches against
alternative
pattern.
@Deprecated public final Pattern repeat(int n)
times(int)
instead.
Pattern
object that matches the input against this pattern for n
times.
public final Pattern times(int n)
Pattern
object that matches the input against this pattern for n
times.
public final Pattern or(Pattern p2)
Pattern
object that matches if either this
or p2
matches.
public final Parser<Void> toScanner(String name)
this
pattern.
Convenient short-hand for Scanners.pattern(org.codehaus.jparsec.pattern.Pattern, java.lang.String)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |