Top Description Methods
org.apache.commons.text.matcher

public Interface StringMatcher

Known Direct Implementers
org.apache.commons.text.matcher.AbstractStringMatcher
Imports
org.apache.commons.lang3.CharSequenceUtils

Determines if a character array portion matches.
Since
1.3

Method Summary

Modifier and TypeMethod and Description
public default StringMatcher

Returns:

a matcher that matches this matcher followed by the given matcher.
andThen
(final StringMatcher
the next matcher.
stringMatcher
)

Returns a matcher that matches this matcher followed by the given matcher.

public default int

Returns:

The number of matching characters, zero for no match.
isMatch
(final char[]
the text content to match against, do not change.
buffer
,
final int
the starting position for the match, valid for buffer.
pos
)

Returns the number of matching characters, zero for no match.

public int

Returns:

The number of matching characters, zero if there is no match.
isMatch
(char[]
the source text to search, do not change.
buffer
,
int
the starting position for the match, valid in buffer.
start
,
int
the first active index in the buffer, valid in buffer.
bufferStart
,
int
the end index (exclusive) of the active buffer, valid in buffer.
bufferEnd
)

Returns the number of matching characters, 0 if there is no match.

public default int

Returns:

The number of matching characters, zero for no match.
isMatch
(final CharSequence
the text content to match against, do not change.
buffer
,
final int
the starting position for the match, valid for buffer.
pos
)

Returns the number of matching characters, zero for no match.

public default int

Returns:

The number of matching characters, zero if there is no match.
isMatch
(final CharSequence
the source text to search, do not change.
buffer
,
final int
the starting position for the match, valid in buffer.
start
,
final int
the first active index in the buffer, valid in buffer.
bufferStart
,
final int
the end index (exclusive) of the active buffer, valid in buffer.
bufferEnd
)

Returns the number of matching characters, 0 if there is no match.

public default int

Returns:

the size of the matching string.
size
()

Returns the size of the matching string.

Method Detail

andThenback to summary
public default StringMatcher andThen(final StringMatcher stringMatcher)

Returns a matcher that matches this matcher followed by the given matcher.

Parameters
stringMatcher:StringMatcher

the next matcher.

Returns:StringMatcher

a matcher that matches this matcher followed by the given matcher.

Since
1.9
isMatchback to summary
public default int isMatch(final char[] buffer, final 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 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 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:char[]

the text content to match against, do not change.

pos:int

the starting position for the match, valid for buffer.

Returns:int

The number of matching characters, zero for no match.

Since
1.9
isMatchback to summary
public 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 parameter start represents the start position to be checked in the buffer (a character array which MUST not be changed). The implementation SHOULD guarantees that start is a valid index in buffer.

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:char[]

the source text to search, do not change.

start:int

the starting position for the match, valid in buffer.

bufferStart:int

the first active index in the buffer, valid in buffer.

bufferEnd:int

the end index (exclusive) of the active buffer, valid in buffer.

Returns:int

The number of matching characters, zero if there is no match.

isMatchback to summary
public default int isMatch(final CharSequence buffer, final 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 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 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:CharSequence

the text content to match against, do not change.

pos:int

the starting position for the match, valid for buffer.

Returns:int

The number of matching characters, zero for no match.

Since
1.9
isMatchback to summary
public default int isMatch(final CharSequence buffer, final int start, final int bufferStart, final 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 parameter start represents the start position to be checked in the buffer (a character array which MUST not be changed). The implementation SHOULD guarantees that start is a valid index in buffer.

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:CharSequence

the source text to search, do not change.

start:int

the starting position for the match, valid in buffer.

bufferStart:int

the first active index in the buffer, valid in buffer.

bufferEnd:int

the end index (exclusive) of the active buffer, valid in buffer.

Returns:int

The number of matching characters, zero if there is no match.

Since
1.9
sizeback to summary
public default int size()

Returns the size of the matching string. Defaults to 0.

Returns:int

the size of the matching string.

Since
1.9