net.rim.device.api.util
Class StringMatch

java.lang.Object
  |
  +--net.rim.device.api.util.StringMatch
All Implemented Interfaces:
Persistable, Persistable

public final class StringMatch
extends Object
implements Persistable

Checks for matching of substring patterns in strings.

Behaviour
You can concatenate a number of substring patterns together, attempting to match against each substring pattern in the conglomerate; separate your patterns with spaces only.

A string matches if it contains all of the patterns. The match is the first instance of any pattern found in the string.

Note that you can search against a substring pattern that is the empty string.


Constructor Summary
StringMatch(String pattern)
          Constructs a new, case-sensitive StringMatch instance.
StringMatch(String[] patterns, boolean caseSensitivity, boolean allMatch)
          Constructs a new StringMatch instance.
StringMatch(String patternToMatch, boolean caseSensitivity)
          Constructs a new StringMatch instance.
StringMatch(String patternToMatch, boolean caseSensitivity, boolean spaceDelimitsNewPattern)
          Constructs a new StringMatch instance.
StringMatch(String patternToMatch, boolean caseSensitivity, boolean spaceDelimitsNewPattern, boolean allMatch)
          Constructs a new StringMatch instance.
 
Method Summary
 int getLastMatchedPattern()
          Retrieves position of the last matched pattern.
 int indexOf(String text)
          Retrieves position of first match in target string.
 int indexOf(StringBuffer text, int offset)
          Retrieves position of first match in section of target StringBuffer.
 int indexOf(String text, int offset)
          Retrieves position of first match in section of target string.
 int numStringsInPattern()
          Retrieves number of substring patterns used in matching.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringMatch

public StringMatch(String pattern)
Constructs a new, case-sensitive StringMatch instance.

This builds a string match object, digesting the provided substring pattern for optimized future use. This object observes case when matching.

Parameters:
pattern - Substring pattern to use in match checking.

StringMatch

public StringMatch(String[] patterns,
                   boolean caseSensitivity,
                   boolean allMatch)
Constructs a new StringMatch instance.

This builds a string match object, digesting the provided substring pattern for optimized future use.

Parameters:
pattern - Substring pattern to use in match checking.
caseSensitivity - If true, matching observes case; if false, disregard case in substring pattern and target string.
allMatch - If true, all patterns must match for pattern to match.
Since:
JDE 4.0.0

StringMatch

public StringMatch(String patternToMatch,
                   boolean caseSensitivity)
Constructs a new StringMatch instance.

This builds a string match object, digesting the provided substring pattern for optimized future use.

Parameters:
pattern - Substring pattern to use in match checking.
caseSensitiviy - If true, matching observes case; if false, disregard case in substring pattern and target string.

StringMatch

public StringMatch(String patternToMatch,
                   boolean caseSensitivity,
                   boolean spaceDelimitsNewPattern)
Constructs a new StringMatch instance.

This builds a string match object, digesting the provided substring pattern for optimized future use.

Parameters:
pattern - Substring pattern to use in match checking.
caseSensitivity - If true, matching observes case; if false, disregard case in substring pattern and target string.
spaceDelimitsNewPattern - If true, patternToMatch is broken into subpatters using space as a delimiter. If false, whole patternToMatch string is used as the pattern, including spaces.
Since:
JDE 3.6.0

StringMatch

public StringMatch(String patternToMatch,
                   boolean caseSensitivity,
                   boolean spaceDelimitsNewPattern,
                   boolean allMatch)
Constructs a new StringMatch instance.

This builds a string match object, digesting the provided substring pattern for optimized future use.

Parameters:
pattern - Substring pattern to use in match checking.
caseSensitivity - If true, matching observes case; if false, disregard case in substring pattern and target string.
spaceDelimitsNewPattern - If true, patternToMatch is broken into subpatters using space as a delimiter. If false, whole patternToMatch string is used as the pattern, including spaces.
Since:
JDE 4.0.0
Method Detail

getLastMatchedPattern

public int getLastMatchedPattern()
Retrieves position of the last matched pattern.

Returns:
The position of the last matched pattern.
Since:
JDE 4.0.0

indexOf

public int indexOf(String text)
Retrieves position of first match in target string.

Parameters:
text - Target string.
Returns:
Position of first match of substring pattern(s) in target string, or -1 to indicate no match.

indexOf

public int indexOf(StringBuffer text,
                   int offset)
            throws IllegalArgumentException
Retrieves position of first match in section of target StringBuffer.

Parameters:
text - Text containing the section to match against.
offset - Position of first character in section to match against.
Returns:
Position of first match of substring pattern(s) in target string, or -1 to indicate no match.
Throws:
IllegalArgumentException - If offset parameter is not contained in the target string.
Since:
JDE 3.7.0

indexOf

public int indexOf(String text,
                   int offset)
            throws IllegalArgumentException
Retrieves position of first match in section of target string.

Parameters:
text - Text containing the section to match against.
offset - Position of first character in section to match against.
Returns:
Position of first match of substring pattern(s) in target string, or -1 to indicate no match.
Throws:
IllegalArgumentException - If offset parameter is not contained in the target string.

numStringsInPattern

public int numStringsInPattern()
Retrieves number of substring patterns used in matching.

Returns:
Number of substring patterns used to match.



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.