| java.lang.Object com.sshtools.daemon.util.StringPattern
StringPattern | public class StringPattern implements Serializable(Code) | | This class provides services for checking strings against string-patterns.
Currently it supports the wildcards
'' for any number of any character and
'?' for any one character. The API is very simple:
There are only the two class methods match() and
matchIgnoreCase().
Example:
StringPattern.match( 'Hello World", "H W" ) ; --> evaluates to true
StringPattern.matchIgnoreCase( 'StringPattern", "str???pat" ) ; -->
evaluates to true
author: Manfred Duchrow version: 1.7 |
Constructor Summary | |
public | StringPattern(String pattern, boolean ignoreCase) Initializes the new instance with the string pattern and the selecteion,
if case should be ignored when comparing characters. | public | StringPattern(String pattern) Initializes the new instance with the string pattern. | public | StringPattern(String pattern, char digitWildcard) Initializes the new instance with the string pattern and a digit
wildcard character. | public | StringPattern(String pattern, boolean ignoreCase, char digitWildcard) Initializes the new instance with the string pattern and the selecteion,
if case should be ignored when comparing characters plus a wildcard
character for digits. |
MULTICHAR_WILDCARD | final protected static char MULTICHAR_WILDCARD(Code) | | |
MULTI_WILDCARD | final protected static String MULTI_WILDCARD(Code) | | |
SINGLECHAR_WILDCARD | final protected static char SINGLECHAR_WILDCARD(Code) | | |
StringPattern | public StringPattern(String pattern, boolean ignoreCase)(Code) | | Initializes the new instance with the string pattern and the selecteion,
if case should be ignored when comparing characters.
Parameters: pattern - The pattern to check against ( May contain '' and '?'wildcards ) Parameters: ignoreCase - Definition, if case sensitive character comparison ornot. |
StringPattern | public StringPattern(String pattern)(Code) | | Initializes the new instance with the string pattern. The default is
case sensitive checking.
Parameters: pattern - The pattern to check against ( May contain '' and '?'wildcards ) |
StringPattern | public StringPattern(String pattern, char digitWildcard)(Code) | | Initializes the new instance with the string pattern and a digit
wildcard character. The default is case sensitive checking.
Parameters: pattern - The pattern to check against ( May contain '', '?'wildcards and the digit wildcard ) Parameters: digitWildcard - A wildcard character that stands as placeholder fordigits |
StringPattern | public StringPattern(String pattern, boolean ignoreCase, char digitWildcard)(Code) | | Initializes the new instance with the string pattern and the selecteion,
if case should be ignored when comparing characters plus a wildcard
character for digits.
Parameters: pattern - The pattern to check against ( May contain '' and '?'wildcards ) Parameters: ignoreCase - Definition, if case sensitive character comparison ornot. Parameters: digitWildcard - A wildcard character that stands as placeholder fordigits |
charsAreEqual | protected boolean charsAreEqual(char probeChar, char patternChar)(Code) | | |
digitWildcard | protected void digitWildcard(Character newValue)(Code) | | Parameters: newValue - |
digitWildcardChar | protected char digitWildcardChar()(Code) | | |
endNotReached | protected boolean endNotReached(char character)(Code) | | |
endReached | protected boolean endReached(char character)(Code) | | |
getIgnoreCase | public boolean getIgnoreCase()(Code) | | Returns whether or not the pattern matching ignores upper and lower case
|
getPattern | public String getPattern()(Code) | | Returns the pattern as string.
|
hasDigitWildcard | protected boolean hasDigitWildcard()(Code) | | |
hasWildcard | public boolean hasWildcard()(Code) | | Returns true if the pattern contains any '' or '?' wildcard character.
|
match | public static boolean match(String probe, String pattern)(Code) | | Returns true, if the given probe string matches the given pattern.
The character comparison is done case sensitive.
Parameters: probe - The string to check against the pattern. Parameters: pattern - The patter, that probably contains wildcards ( '' or '?') |
matchIgnoreCase | public static boolean matchIgnoreCase(String probe, String pattern)(Code) | | Returns true, if the given probe string matches the given pattern.
The character comparison is done ignoring upper/lower-case.
Parameters: probe - The string to check against the pattern. Parameters: pattern - The patter, that probably contains wildcards ( '' or '?') |
matches | public boolean matches(String probe)(Code) | | Tests if a specified string matches the pattern.
Parameters: probe - The string to compare to the pattern true if and only if the probe matches the pattern, falseotherwise. |
setDigitWildcardChar | public void setDigitWildcardChar(char digitWildcard)(Code) | | Sets the given character as a wildcard character in this pattern to
match only digits ('0'-'9').
Parameters: digitWildcard - The placeholder character for digits |
setIgnoreCase | public void setIgnoreCase(boolean newValue)(Code) | | Sets whether the pattern matching should ignore case or not
Parameters: newValue - |
setPattern | public void setPattern(String newValue)(Code) | | Sets the pattern to a new value
Parameters: newValue - |
skipAfter | protected boolean skipAfter(StringExaminer examiner, String matchString)(Code) | | Increments the given iterator up to the last character that matched the
character sequence in the given matchString. Returns true, if the
matchString was found, otherwise false.
Parameters: examiner - Parameters: matchString - The string to be found (must not contain ) |
skipWildcards | protected char skipWildcards(StringExaminer iterator)(Code) | | Moves the iterator position to the next character that is no wildcard.
Doesn't skip digit wildcards !
Parameters: iterator - |
|
|