Save This Page
Home » j2ssh-0.2.9-src » com.sshtools.daemon.util » [javadoc | source]
com.sshtools.daemon.util
public class: StringPattern [javadoc | source]
java.lang.Object
   com.sshtools.daemon.util.StringPattern

All Implemented Interfaces:
    Serializable

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
Field Summary
protected static final  String MULTI_WILDCARD     
protected static final  char MULTICHAR_WILDCARD     
protected static final  char SINGLECHAR_WILDCARD     
Constructor:
 public StringPattern(String pattern) 
    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 )
 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.
    Parameters:
    pattern - The pattern to check against ( May contain '' and '?' wildcards )
    ignoreCase - Definition, if case sensitive character comparison or not.
 public StringPattern(String pattern,
    char digitWildcard) 
    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 )
    digitWildcard - A wildcard character that stands as placeholder for digits
 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.
    Parameters:
    pattern - The pattern to check against ( May contain '' and '?' wildcards )
    ignoreCase - Definition, if case sensitive character comparison or not.
    digitWildcard - A wildcard character that stands as placeholder for digits
Method from com.sshtools.daemon.util.StringPattern Summary:
charsAreEqual,   digitWildcard,   digitWildcard,   digitWildcardChar,   endNotReached,   endReached,   getIgnoreCase,   getPattern,   getPatternChar,   hasDigitWildcard,   hasWildcard,   match,   matchIgnoreCase,   matchReverse,   matches,   newExaminer,   setDigitWildcardChar,   setIgnoreCase,   setPattern,   skipAfter,   skipWildcards,   strUtil,   toString,   upToEnd
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sshtools.daemon.util.StringPattern Detail:
 protected boolean charsAreEqual(char probeChar,
    char patternChar) 
 protected Character digitWildcard() 
 protected  void digitWildcard(Character newValue) 
 protected char digitWildcardChar() 
 protected boolean endNotReached(char character) 
 protected boolean endReached(char character) 
 public boolean getIgnoreCase() 
    Returns whether or not the pattern matching ignores upper and lower case
 public String getPattern() 
    Returns the pattern as string.
 protected char getPatternChar(StringExaminer patternIterator,
    char probeCh) 
 protected boolean hasDigitWildcard() 
 public boolean hasWildcard() 
    Returns true if the pattern contains any '' or '?' wildcard character.
 public static boolean match(String probe,
    String pattern) 
    Returns true, if the given probe string matches the given pattern.
    The character comparison is done case sensitive.
 public static boolean matchIgnoreCase(String probe,
    String pattern) 
    Returns true, if the given probe string matches the given pattern.
    The character comparison is done ignoring upper/lower-case.
 protected boolean matchReverse(String pattern,
    StringExaminer probeIterator) 
 public boolean matches(String probe) 
    Tests if a specified string matches the pattern.
 protected StringExaminer newExaminer(String str) 
 public  void setDigitWildcardChar(char digitWildcard) 
    Sets the given character as a wildcard character in this pattern to match only digits ('0'-'9').
 public  void setIgnoreCase(boolean newValue) 
    Sets whether the pattern matching should ignore case or not
 public  void setPattern(String newValue) 
    Sets the pattern to a new value
 protected boolean skipAfter(StringExaminer examiner,
    String matchString) 
    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.
 protected char skipWildcards(StringExaminer iterator) 
    Moves the iterator position to the next character that is no wildcard. Doesn't skip digit wildcards !
 protected StringUtil strUtil() 
 public String toString() 
    Returns the pattern string.
 protected String upToEnd(StringExaminer iterator)