Class AbstractStringMatcher.AndStringMatcher
- All Implemented Interfaces:
StringMatcher
- Enclosing class:
AbstractStringMatcher
- Since:
- 1.9
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.text.matcher.AbstractStringMatcher
AbstractStringMatcher.AndStringMatcher, AbstractStringMatcher.CharArrayMatcher, AbstractStringMatcher.CharMatcher, AbstractStringMatcher.CharSetMatcher, AbstractStringMatcher.NoneMatcher, AbstractStringMatcher.TrimMatcher
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAndStringMatcher
(StringMatcher... stringMatchers) Constructs a new initialized instance. -
Method Summary
Modifier and TypeMethodDescriptionint
isMatch
(char[] buffer, int start, int bufferStart, int bufferEnd) Returns the number of matching characters,0
if there is no match.int
isMatch
(CharSequence buffer, int start, int bufferStart, int bufferEnd) Returns the number of matching characters,0
if there is no match.int
size()
Returns the size of the matching string.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.commons.text.matcher.StringMatcher
andThen, isMatch, isMatch
-
Field Details
-
stringMatchers
Matchers in order.
-
-
Constructor Details
-
AndStringMatcher
AndStringMatcher(StringMatcher... stringMatchers) Constructs a new initialized instance.- Parameters:
stringMatchers
- Matchers in order. Never null since theStringMatcherFactory
uses theAbstractStringMatcher.NoneMatcher
instead.
-
-
Method Details
-
isMatch
public int isMatch(char[] buffer, int start, int bufferStart, int bufferEnd) Description copied from interface:StringMatcher
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
Description copied from interface:StringMatcher
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.
-
size
public int size()Description copied from interface:StringMatcher
Returns the size of the matching string. Defaults to 0.- Returns:
- the size of the matching string.
-