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

pack-priv abstract Class AbstractStringMatcher

extends Object
implements StringMatcher
Class Inheritance
All Implemented Interfaces
org.apache.commons.text.matcher.StringMatcher
Known Direct Subclasses
org.apache.commons.text.matcher.AbstractStringMatcher.AndStringMatcher, org.apache.commons.text.matcher.AbstractStringMatcher.CharArrayMatcher, org.apache.commons.text.matcher.AbstractStringMatcher.CharMatcher, org.apache.commons.text.matcher.AbstractStringMatcher.CharSetMatcher, org.apache.commons.text.matcher.AbstractStringMatcher.NoneMatcher, org.apache.commons.text.matcher.AbstractStringMatcher.TrimMatcher
Imports
java.util.Arrays

A matcher that determines if a character array portion matches.

Thread=safe.

Since
1.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
AbstractStringMatcher.AndStringMatcher

Matches all of the given matchers in order.

pack-priv static class
AbstractStringMatcher.CharArrayMatcher

Matches out of a set of characters.

pack-priv static class
pack-priv static class
AbstractStringMatcher.CharSetMatcher

Matches a set of characters.

pack-priv static class
pack-priv static class
AbstractStringMatcher.TrimMatcher

Matches whitespace as per trim().

Constructor Summary

AccessConstructor and Description
protected
AbstractStringMatcher()

Constructs a new instance.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AbstractStringMatcherback to summary
protected AbstractStringMatcher()

Constructs a new instance.

org.apache.commons.text.matcher back to summary

pack-priv final Class AbstractStringMatcher.AndStringMatcher

extends AbstractStringMatcher
Class Inheritance

Matches all of the given matchers in order.
Since
1.9

Field Summary

Modifier and TypeField and Description
private final StringMatcher[]
stringMatchers

Matchers in order.

Constructor Summary

AccessConstructor and Description
pack-priv
AndStringMatcher(final StringMatcher...
Matchers in order. Never null since the StringMatcherFactory uses the NoneMatcher instead.
stringMatchers
)

Constructs a new initialized instance.

Method Summary

Modifier and TypeMethod and Description
public int
isMatch(final char[] buffer, final int start, final int bufferStart, final int bufferEnd)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

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

public int
isMatch(final CharSequence buffer, final int start, final int bufferStart, final int bufferEnd)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

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

public int
size()

Overrides default org.apache.commons.text.matcher.StringMatcher.size.

Returns the size of the matching string.

Field Detail

stringMatchersback to summary
private final StringMatcher[] stringMatchers

Matchers in order.

Constructor Detail

AndStringMatcherback to summary
pack-priv AndStringMatcher(final StringMatcher... stringMatchers)

Constructs a new initialized instance.

Parameters
stringMatchers:StringMatcher[]

Matchers in order. Never null since the StringMatcherFactory uses the NoneMatcher instead.

Method Detail

isMatchback to summary
public int isMatch(final char[] buffer, final int start, final int bufferStart, final int bufferEnd)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

Doc from org.apache.commons.text.matcher.StringMatcher.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 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.

Annotations
@Override
isMatchback to summary
public int isMatch(final CharSequence buffer, final int start, final int bufferStart, final int bufferEnd)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

Doc from org.apache.commons.text.matcher.StringMatcher.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 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.

Annotations
@Override
sizeback to summary
public int size()

Overrides default org.apache.commons.text.matcher.StringMatcher.size.

Doc from org.apache.commons.text.matcher.StringMatcher.size.

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

Annotations
@Override
org.apache.commons.text.matcher back to summary

pack-priv final Class AbstractStringMatcher.CharArrayMatcher

extends AbstractStringMatcher
Class Inheritance

Matches out of a set of characters.

Thread=safe.

Field Summary

Modifier and TypeField and Description
private final char[]
chars

The string to match, as a character array, implementation treats as immutable.

private final String
string

The string to match.

Constructor Summary

AccessConstructor and Description
pack-priv
CharArrayMatcher(final char...
the string to match, must not be null
chars
)

Constructs a matcher from a String.

Method Summary

Modifier and TypeMethod and Description
public 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.
start
,
final int
unused.
bufferStart
,
final int
the end index of the active buffer, valid for buffer.
bufferEnd
)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

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

public 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.
start
,
final int
unused.
bufferStart
,
final int
the end index of the active buffer, valid for buffer.
bufferEnd
)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

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

public int
size()

Overrides default org.apache.commons.text.matcher.StringMatcher.size.

Returns the size of the string to match given in the constructor.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Field Detail

charsback to summary
private final char[] chars

The string to match, as a character array, implementation treats as immutable.

stringback to summary
private final String string

The string to match.

Constructor Detail

CharArrayMatcherback to summary
pack-priv CharArrayMatcher(final char... chars)

Constructs a matcher from a String.

Parameters
chars:char[]

the string to match, must not be null

Method Detail

isMatchback to summary
public int isMatch(final char[] buffer, final int start, final int bufferStart, final int bufferEnd)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

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

Parameters
buffer:char[]

the text content to match against, do not change.

start:int

the starting position for the match, valid for buffer.

bufferStart:int

unused.

bufferEnd:int

the end index of the active buffer, valid for buffer.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
isMatchback to summary
public int isMatch(final CharSequence buffer, final int start, final int bufferStart, final int bufferEnd)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

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

Parameters
buffer:CharSequence

the text content to match against, do not change.

start:int

the starting position for the match, valid for buffer.

bufferStart:int

unused.

bufferEnd:int

the end index of the active buffer, valid for buffer.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
sizeback to summary
public int size()

Overrides default org.apache.commons.text.matcher.StringMatcher.size.

Returns the size of the string to match given in the constructor.

Annotations
@Override
Since
1.9
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
org.apache.commons.text.matcher back to summary

pack-priv final Class AbstractStringMatcher.CharMatcher

extends AbstractStringMatcher
Class Inheritance

Matches a character.

Thread=safe.

Field Summary

Modifier and TypeField and Description
private final char
ch

The character to match.

Constructor Summary

AccessConstructor and Description
pack-priv
CharMatcher(final char
the character to match
ch
)

Constructs a matcher for a single character.

Method Summary

Modifier and TypeMethod and Description
public 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.
start
,
final int
unused.
bufferStart
,
final int
unused.
bufferEnd
)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

public 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.
start
,
final int
unused.
bufferStart
,
final int
unused.
bufferEnd
)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

public int
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Field Detail

chback to summary
private final char ch

The character to match.

Constructor Detail

CharMatcherback to summary
pack-priv CharMatcher(final char ch)

Constructs a matcher for a single character.

Parameters
ch:char

the character to match

Method Detail

isMatchback to summary
public int isMatch(final char[] buffer, final int start, final int bufferStart, final int bufferEnd)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

Parameters
buffer:char[]

the text content to match against, do not change.

start:int

the starting position for the match, valid for buffer.

bufferStart:int

unused.

bufferEnd:int

unused.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
isMatchback to summary
public int isMatch(final CharSequence buffer, final int start, final int bufferStart, final int bufferEnd)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

Parameters
buffer:CharSequence

the text content to match against, do not change.

start:int

the starting position for the match, valid for buffer.

bufferStart:int

unused.

bufferEnd:int

unused.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
sizeback to summary
public int size()

Overrides default org.apache.commons.text.matcher.StringMatcher.size.

Returns 1.

Annotations
@Override
Since
1.9
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
org.apache.commons.text.matcher back to summary

pack-priv final Class AbstractStringMatcher.CharSetMatcher

extends AbstractStringMatcher
Class Inheritance

Matches a set of characters.

Thread=safe.

Field Summary

Modifier and TypeField and Description
private final char[]
chars

The set of characters to match.

Constructor Summary

AccessConstructor and Description
pack-priv
CharSetMatcher(final char[]
the characters to match, must not be null.
chars
)

Constructs a matcher from a character array.

Method Summary

Modifier and TypeMethod and Description
public 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.
start
,
final int
unused.
bufferStart
,
final int
unused.
bufferEnd
)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

public 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.
start
,
final int
unused.
bufferStart
,
final int
unused.
bufferEnd
)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

public int
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Field Detail

charsback to summary
private final char[] chars

The set of characters to match.

Constructor Detail

CharSetMatcherback to summary
pack-priv CharSetMatcher(final char[] chars)

Constructs a matcher from a character array.

Parameters
chars:char[]

the characters to match, must not be null.

Method Detail

isMatchback to summary
public int isMatch(final char[] buffer, final int start, final int bufferStart, final int bufferEnd)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

Parameters
buffer:char[]

the text content to match against, do not change.

start:int

the starting position for the match, valid for buffer.

bufferStart:int

unused.

bufferEnd:int

unused.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
isMatchback to summary
public int isMatch(final CharSequence buffer, final int start, final int bufferStart, final int bufferEnd)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

Parameters
buffer:CharSequence

the text content to match against, do not change.

start:int

the starting position for the match, valid for buffer.

bufferStart:int

unused.

bufferEnd:int

unused.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
sizeback to summary
public int size()

Overrides default org.apache.commons.text.matcher.StringMatcher.size.

Returns 1.

Annotations
@Override
Since
1.9
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
org.apache.commons.text.matcher back to summary

pack-priv final Class AbstractStringMatcher.NoneMatcher

extends AbstractStringMatcher
Class Inheritance

Matches nothing.

Thread=safe.

Constructor Summary

AccessConstructor and Description
pack-priv
NoneMatcher()

Constructs a new instance of NoMatcher.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The number of matching characters, zero for no match.
isMatch
(final char[]
unused.
buffer
,
final int
unused.
start
,
final int
unused.
bufferStart
,
final int
unused.
bufferEnd
)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

Always returns 0.

public int

Returns:

The number of matching characters, zero for no match.
isMatch
(final CharSequence
unused.
buffer
,
final int
unused.
start
,
final int
unused.
bufferStart
,
final int
unused.
bufferEnd
)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

Always returns 0.

public int

Constructor Detail

NoneMatcherback to summary
pack-priv NoneMatcher()

Constructs a new instance of NoMatcher.

Method Detail

isMatchback to summary
public int isMatch(final char[] buffer, final int start, final int bufferStart, final int bufferEnd)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

Always returns 0.

Parameters
buffer:char[]

unused.

start:int

unused.

bufferStart:int

unused.

bufferEnd:int

unused.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
isMatchback to summary
public int isMatch(final CharSequence buffer, final int start, final int bufferStart, final int bufferEnd)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

Always returns 0.

Parameters
buffer:CharSequence

unused.

start:int

unused.

bufferStart:int

unused.

bufferEnd:int

unused.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
sizeback to summary
public int size()

Overrides default org.apache.commons.text.matcher.StringMatcher.size.

Returns 0.

Annotations
@Override
Since
1.9
org.apache.commons.text.matcher back to summary

pack-priv final Class AbstractStringMatcher.TrimMatcher

extends AbstractStringMatcher
Class Inheritance

Matches whitespace as per trim().

Thread=safe.

Field Summary

Modifier and TypeField and Description
private static final int
SPACE_INT

The space character.

Constructor Summary

AccessConstructor and Description
pack-priv
TrimMatcher()

Constructs a new instance of TrimMatcher.

Method Summary

Modifier and TypeMethod and Description
public 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.
start
,
final int
unused.
bufferStart
,
final int
unused.
bufferEnd
)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

public 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.
start
,
final int
unused.
bufferStart
,
final int
unused.
bufferEnd
)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

public int

Field Detail

SPACE_INTback to summary
private static final int SPACE_INT

The space character.

Constructor Detail

TrimMatcherback to summary
pack-priv TrimMatcher()

Constructs a new instance of TrimMatcher.

Method Detail

isMatchback to summary
public int isMatch(final char[] buffer, final int start, final int bufferStart, final int bufferEnd)

Implements org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

Parameters
buffer:char[]

the text content to match against, do not change.

start:int

the starting position for the match, valid for buffer.

bufferStart:int

unused.

bufferEnd:int

unused.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
isMatchback to summary
public int isMatch(final CharSequence buffer, final int start, final int bufferStart, final int bufferEnd)

Overrides default org.apache.commons.text.matcher.StringMatcher.isMatch.

Returns 1 if there is a match, or 0 if there is no match.

Parameters
buffer:CharSequence

the text content to match against, do not change.

start:int

the starting position for the match, valid for buffer.

bufferStart:int

unused.

bufferEnd:int

unused.

Returns:int

The number of matching characters, zero for no match.

Annotations
@Override
sizeback to summary
public int size()

Overrides default org.apache.commons.text.matcher.StringMatcher.size.

Returns 1.

Annotations
@Override
Since
1.9