Interface StringMatcher
public interface StringMatcher
- Since:
- 1.3
-
Method Summary
Modifier and Type Method Description default StringMatcher
andThen(StringMatcher stringMatcher)
Returns a matcher that matches this matcher followed by the given matcher.default int
isMatch(char[] buffer, int pos)
Returns the number of matching characters, zero for no match.int
isMatch(char[] buffer, int start, int bufferStart, int bufferEnd)
Returns the number of matching characters,0
if there is no match.default int
isMatch(CharSequence buffer, int pos)
Returns the number of matching characters, zero for no match.default int
isMatch(CharSequence buffer, int start, int bufferStart, int bufferEnd)
Returns the number of matching characters,0
if there is no match.default int
size()
Returns the size of the matching string.
-
Method Details
-
andThen
Returns a matcher that matches this matcher followed by the given matcher.- Parameters:
stringMatcher
- the next matcher.- Returns:
- a matcher that matches this matcher followed by the given matcher.
- Since:
- 1.9
-
isMatch
default int isMatch(char[] buffer, int pos)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 stringbuffer
(a character array which must not be changed). The API guarantees thatpos
is a valid index forbuffer
.The matching code may check one character or many. It may check characters preceding
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 changepos
- the starting position for the match, valid for buffer- Returns:
- The number of matching characters, zero for no match
- Since:
- 1.9
-
isMatch
int isMatch(char[] buffer, int start, int bufferStart, int bufferEnd)Returns the number of matching characters,0
if there is no match.This method is called to check for a match against a source
buffer
. The parameterstart
represents the start position to be checked in thebuffer
(a character array which MUST not be changed). The implementation SHOULD guarantees thatstart
is a valid index inbuffer
.The character array may be larger than the active area to be matched. Only values in the buffer between the specified indices may be accessed, in other words:
bufferStart <= start < bufferEnd
.The matching code may check one character or many. It may check characters preceding
start
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 source text to search, do not change.start
- the starting position for the match, valid inbuffer
.bufferStart
- the first active index in the buffer, valid inbuffer
.bufferEnd
- the end index (exclusive) of the active buffer, valid inbuffer
.- Returns:
- The number of matching characters, zero if there is no match.
-
isMatch
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 stringbuffer
(a character array which must not be changed). The API guarantees thatpos
is a valid index forbuffer
.The matching code may check one character or many. It may check characters preceding
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 changepos
- the starting position for the match, valid for buffer- Returns:
- The number of matching characters, zero for no match
- Since:
- 1.9
-
isMatch
Returns the number of matching characters,0
if there is no match.This method is called to check for a match against a source
buffer
. The parameterstart
represents the start position to be checked in thebuffer
(a character array which MUST not be changed). The implementation SHOULD guarantees thatstart
is a valid index inbuffer
.The character array may be larger than the active area to be matched. Only values in the buffer between the specified indices may be accessed, in other words:
bufferStart <= start < bufferEnd
.The matching code may check one character or many. It may check characters preceding
start
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 source text to search, do not change.start
- the starting position for the match, valid inbuffer
.bufferStart
- the first active index in the buffer, valid inbuffer
.bufferEnd
- the end index (exclusive) of the active buffer, valid inbuffer
.- Returns:
- The number of matching characters, zero if there is no match.
- Since:
- 1.9
-
size
default int size()Returns the size of the matching string. Defaults to 0.- Returns:
- the size of the matching string.
- Since:
- 1.9
-