|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.borland.primetime.util.RegularExpression
Currently implements a simple regular expression matching engine that interprets only "*", "?" and "\" as special characters. An asterisk matches any sequence of characters, including none. A question mark matches any single character, and a backslash indicates that the character that follows should be interpreted as a literal character, allowing any of the three special characters to be matched directly.
Inner Class Summary | |
static class |
RegularExpression.MatchResult
|
Field Summary | |
static char |
CHAR_ANY
The '?' expression. |
static char |
CHAR_ESCAPE
The '\\' expression. |
static char |
CHAR_WILDCARD
The '*' expression. |
static RegularExpression.MatchResult |
NO_MATCH
The non-match result which has both the start index and length as -1. |
Constructor Summary | |
RegularExpression(java.lang.String pattern)
Creates a new case-sensitive RegularExpression instance for the specified pattern. |
|
RegularExpression(java.lang.String pattern,
boolean caseSensitive)
Creates a new RegularExpression instance for the specified pattern and case sensitivity. |
Method Summary | |
boolean |
exactMatch(char[] test)
Tests the specified array of characters to see if the pattern matches the entire sequence. |
boolean |
exactMatch(char[] test,
int startIndex,
int endIndex)
Tests a subset of the specified array of characters to see if the pattern matches the entire subset. |
boolean |
exactMatch(java.lang.String test)
Tests the specified string to see if the pattern matches the entire string. |
RegularExpression.MatchResult |
findSubstringMatch(char[] test,
int startIndex,
int endIndex)
Tests a subset of the the specified array of characters to see if the pattern matches any portion of the subset. |
RegularExpression.MatchResult |
findSubstringMatch(java.lang.String test)
Tests the specified string to see if the pattern matches any portion of the string. |
boolean |
isBreakOnNewline()
Describes whether or not the pattern will match wildcards to sequences of characters that contain a newline. |
boolean |
isCaseSensitive()
Describes whether or not the pattern is case-sensitive. |
boolean |
isPatternMatch()
Describes whether or not wildcard characters and escape sequences are evaluated specially. |
static boolean |
isSpecialChar(char character)
Describes whether a given character will be treated as a literal or is treated specially and needs to be escaped to be used as a literal. |
boolean |
prefixMatch(char[] test)
Tests the specified array of characters to see if the pattern matches some portion of the sequence starting with the first character. |
boolean |
prefixMatch(char[] test,
int startIndex,
int endIndex)
Tests a subset of the specified array of characters to see if the pattern matches some portion of the subset starting with the first character of the subset. |
boolean |
prefixMatch(java.lang.String test)
Tests the specified string to see if the pattern matches some portion of the string starting with the first character. |
void |
setBreakOnNewline(boolean breakOnNewline)
Changes whether or not the pattern will match wildcards to sequences of characters that contain a newline. |
void |
setPatternMatch(boolean patternMatch)
Changes whether or not wildcard characters and escape sequences are evaluated specially. |
int |
substringMatch(char[] test)
Tests the specified array of characters to see if the pattern matches any portion of the sequence. |
int |
substringMatch(char[] test,
int startIndex,
int endIndex)
Tests a subset of the specified array of characters to see if the pattern matches any portion of the subset. |
int |
substringMatch(java.lang.String test)
Tests the specified string to see if the pattern matches any portion of the string. |
java.lang.String |
toString()
Returns a description useful for diagnostic purposes but not much else. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final char CHAR_ANY
public static final char CHAR_WILDCARD
public static final char CHAR_ESCAPE
public static final RegularExpression.MatchResult NO_MATCH
Constructor Detail |
public RegularExpression(java.lang.String pattern)
pattern
- A non-null string of literal and wildcard characters.public RegularExpression(java.lang.String pattern, boolean caseSensitive)
pattern
- A non-null string of literal and wildcard characters.caseSensitive
- True if the pattern should be case sensitive, false
otherwise.Method Detail |
public static boolean isSpecialChar(char character)
character
- The character to be tested.public boolean isCaseSensitive()
public void setBreakOnNewline(boolean breakOnNewline)
breakOnNewline
- True if newline is a valid character in a wildcard
match, false otherwise.public boolean isBreakOnNewline()
public void setPatternMatch(boolean patternMatch)
patternMatch
- True if the wildcard characters and escape sequences
should be evaluated specially, false if all characters in the pattern
should be treated as literals.public boolean isPatternMatch()
public boolean prefixMatch(java.lang.String test)
test
- The string to be tested.public boolean exactMatch(java.lang.String test)
test
- The string to be tested.public int substringMatch(java.lang.String test)
test
- The string to be tested.public RegularExpression.MatchResult findSubstringMatch(java.lang.String test)
RegularExpression.NO_MATCH
if no match is found.public boolean prefixMatch(char[] test)
test
- The array of characters to be tested.public boolean exactMatch(char[] test)
test
- The array of characters to be tested.public int substringMatch(char[] test)
test
- The array of characters to be tested.public boolean prefixMatch(char[] test, int startIndex, int endIndex)
test
- The array of characters to be tested.startIndex
- The offset of the first character in the subset to be
tested.startIndex
- One greater than the offset of the last character in the
subset to be tested.public boolean exactMatch(char[] test, int startIndex, int endIndex)
test
- The array of characters to be tested.startIndex
- The offset of the first character in the subset to be
tested.startIndex
- One greater than the offset of the last character in the
subset to be tested.public int substringMatch(char[] test, int startIndex, int endIndex)
test
- The array of characters to be tested.startIndex
- The offset of the first character in the subset to be
tested.startIndex
- One greater than the offset of the last character in the
subset to be tested.public RegularExpression.MatchResult findSubstringMatch(char[] test, int startIndex, int endIndex)
test
- The array of characters to be tested.startIndex
- The offset of the first character in the subset to be
tested.startIndex
- One greater than the offset of the last character in the
subset to be tested.RegularExpression.NO_MATCH
if no match is found.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |