public class StringPattern
extends java.lang.Object
Additionally, the concept of the "combined pattern" is supported (see
matches(StringPattern[], String).
| Modifier and Type | Field and Description |
|---|---|
static int |
EXCLUDE |
static int |
INCLUDE |
private int |
mode |
private java.lang.String |
pattern |
static StringPattern[] |
PATTERNS_ALL
A
StringPattern that matches any subject. |
static StringPattern[] |
PATTERNS_NONE
A
StringPattern that matches no subject whatsoever. |
| Constructor and Description |
|---|
StringPattern(int mode,
java.lang.String pattern) |
StringPattern(java.lang.String pattern) |
| Modifier and Type | Method and Description |
|---|---|
int |
getMode() |
boolean |
matches(java.lang.String text)
Match the given
text against the pattern represented by the current instance,
as follows:
A * in the pattern matches any sequence of zero or more characters in the
text
A ? in the pattern matches exactly one character in the text
Any other character in the pattern must appear exactly as it is in the text
Notice: The mode flag of the current instance does not take any effect here. |
static boolean |
matches(StringPattern[] patterns,
java.lang.String text)
Match a given
text against an array of StringPatterns (which was
typically created by parseCombinedPattern(String). |
static StringPattern[] |
parseCombinedPattern(java.lang.String combinedPattern)
Parse a "combined pattern" into an array of
StringPatterns. |
java.lang.String |
toString() |
private static boolean |
wildmatch(java.lang.String pattern,
java.lang.String text) |
public static final int INCLUDE
public static final int EXCLUDE
private final int mode
private final java.lang.String pattern
public static final StringPattern[] PATTERNS_ALL
StringPattern that matches any subject.public static final StringPattern[] PATTERNS_NONE
StringPattern that matches no subject whatsoever.public StringPattern(int mode,
java.lang.String pattern)
public StringPattern(java.lang.String pattern)
public int getMode()
StringPattern represents inclusion (INCLUDE) or exclusion
exclusion (EXCLUDE) of subjectspublic boolean matches(java.lang.String text)
text against the pattern represented by the current instance,
as follows:
* in the pattern matches any sequence of zero or more characters in the
text
? in the pattern matches exactly one character in the text
text
mode flag of the current instance does not take any effect here.public static StringPattern[] parseCombinedPattern(java.lang.String combinedPattern)
StringPatterns. A combined pattern
string is structured as follows:
combined-pattern :=
[ '+' | '-' ] pattern
{ ( '+' | '-' ) pattern }
If a pattern is preceeded with a '-', then the StringPattern is created with mode
EXCLUDE, otherwise with mode INCLUDE.public static boolean matches(StringPattern[] patterns, java.lang.String text)
text against an array of StringPatterns (which was
typically created by parseCombinedPattern(String).
The last matching pattern takes effect; if its mode is INCLUDE, then
true is returned, if its mode is EXCLUDE, then false is
returned.
If patterns is PATTERNS_NONE, or empty, or none of its patterns
matches, then false is returned.
If patterns is PATTERNS_ALL, then true is
returned.
For backwards compatibility, null patterns are treated like
PATTERNS_NONE.
public java.lang.String toString()
toString in class java.lang.Objectprivate static boolean wildmatch(java.lang.String pattern,
java.lang.String text)