|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.generic.util.PatternMatcher
Class PatternMatcher implements a very simple regular expression
mechanism. It can be used to do plain pattern matching similar to the one you
can find in DOS filename placeholders.
See the comments in the constructor of this class for further details on the supported pattern matching modes.
Because a PatternMatcher does not precompile a given pattern,
instantiation is extremely fast.
| Field Summary | |
static int |
STYLE_FILENAME
This mode is similar to dos-filename expansion. '?' |
static int |
STYLE_REGULAR
A simple regular expression style where '.' is the placeholder for any character, 'C*' matches character C (which can be any character) zero or more times, '^' matches the beginning of the string and '$' matches the end of the string. |
| Constructor Summary | |
PatternMatcher(int mode)
Constructs a new PatterMatcher with the given mode.
|
|
| Method Summary | |
boolean |
check(java.lang.String pattern,
java.lang.String text)
Checks whether the given text is matched by the
given 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 STYLE_REGULAR
public static final int STYLE_FILENAME
| Constructor Detail |
public PatternMatcher(int mode)
PatterMatcher with the given mode.
The modes are:
STYLE_REGULAR
A simple regular expression style where '.' is the placeholder for any character, 'C*' matches character C (which can be any character) zero or more times, '^' matches the beginning of the string and '$' matches the end of the string.
STYLE_FILENAME
This mode is similar to dos-filename expansion. '?' serves as a placeholder for a single character. '*' is the wildcard that matches arbitrarily long substrings. For example the pattern '?*house*?' would match all strings that have the substring 'house' inside of them, but would both start and end with two arbitrary additional characters. The pattern '*house*' would match all strings with the substring house anywhere in it.
The patternmatcher does not precompile the patterns. It's instantiation is fairly cheap.
mode - the mode to be used.
InvalidArgumentException - if an invalid mode is given.| Method Detail |
public final boolean check(java.lang.String pattern,
java.lang.String text)
text is matched by the
given pattern. The pattern is interpreted according
to the selected mode of this PatternMatcher instance.
pattern - the pattern to match, pattern is interpreted according to
the mode of this PatternMatcher.text - the text to match against the pattern.
true, if text was matched; false if not.
InvalidArgumentException - if one of the arguments is
null.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||