org.apache.commons.lang.text
public abstract class StrMatcher extends Object
This class comes complete with various factory methods. If these do not suffice, you can subclass and implement your own matcher.
Since: 2.2
Version: $Id: StrMatcher.java 618884 2008-02-06 04:37:17Z bayard $
Constructor Summary | |
---|---|
protected | StrMatcher()
Constructor. |
Method Summary | |
---|---|
static StrMatcher | charMatcher(char ch)
Constructor that creates a matcher from a character.
|
static StrMatcher | charSetMatcher(char[] chars)
Constructor that creates a matcher from a set of characters.
|
static StrMatcher | charSetMatcher(String chars)
Constructor that creates a matcher from a string representing a set of characters.
|
static StrMatcher | commaMatcher()
Returns a matcher which matches the comma character.
|
static StrMatcher | doubleQuoteMatcher()
Returns a matcher which matches the double quote character.
|
abstract int | isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd)
Returns the number of matching characters, zero for no match.
|
int | isMatch(char[] buffer, int pos)
Returns the number of matching characters, zero for no match.
|
static StrMatcher | noneMatcher()
Matches no characters.
|
static StrMatcher | quoteMatcher()
Returns a matcher which matches the single or double quote character.
|
static StrMatcher | singleQuoteMatcher()
Returns a matcher which matches the single quote character.
|
static StrMatcher | spaceMatcher()
Returns a matcher which matches the space character.
|
static StrMatcher | splitMatcher()
Matches the same characters as StringTokenizer,
namely space, tab, newline and formfeed.
|
static StrMatcher | stringMatcher(String str)
Constructor that creates a matcher from a string.
|
static StrMatcher | tabMatcher()
Returns a matcher which matches the tab character.
|
static StrMatcher | trimMatcher()
Matches the String trim() whitespace characters.
|
Parameters: ch the character to match, must not be null
Returns: a new Matcher for the given char
Parameters: chars the characters to match, null or empty matches nothing
Returns: a new matcher for the given char[]
Parameters: chars the characters to match, null or empty matches nothing
Returns: a new Matcher for the given characters
Returns: a matcher for a comma
Returns: a matcher for a double quote
This method is called to check for a match.
The parameter pos
represents the current position to be
checked in the string buffer
(a character array which must
not be changed).
The API guarantees that pos
is a valid index for buffer
.
The character array may be larger than the active area to be matched. Only values in the buffer between the specifed indices may be accessed.
The matching code may check one character or many.
It may check characters preceeding pos
as well as those
after, so long as no checks exceed the bounds specified.
It must return zero for no match, or a positive number if a match was found. The number indicates the number of characters that matched.
Parameters: buffer the text content to match against, do not change pos the starting position for the match, valid for buffer bufferStart the first active index in the buffer, valid for buffer bufferEnd the end index (exclusive) of the active buffer, valid for buffer
Returns: the number of matching characters, zero for no match
This method is called to check for a match.
The parameter pos
represents the current position to be
checked in the string buffer
(a character array which must
not be changed).
The API guarantees that pos
is a valid index for buffer
.
The matching code may check one character or many.
It may check characters preceeding pos
as well as those after.
It must return zero for no match, or a positive number if a match was found. The number indicates the number of characters that matched.
Parameters: buffer the text content to match against, do not change pos the starting position for the match, valid for buffer
Returns: the number of matching characters, zero for no match
Since: 2.4
Returns: a matcher that matches nothing
Returns: a matcher for a single or double quote
Returns: a matcher for a single quote
Returns: a matcher for a space
Returns: the split matcher
Parameters: str the string to match, null or empty matches nothing
Returns: a new Matcher for the given String
Returns: a matcher for a tab
Returns: the trim matcher