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

public final Class StringMatcherFactory

extends Object
Class Inheritance
Imports
org.apache.commons.lang3.ArrayUtils, .StringUtils

Provides access to matchers defined in this package.
Since
1.3

Field Summary

Modifier and TypeField and Description
private static final AbstractStringMatcher.CharMatcher
COMMA_MATCHER

Matches the comma character.

private static final AbstractStringMatcher.CharMatcher
DOUBLE_QUOTE_MATCHER

Matches the double quote character.

public static final StringMatcherFactory
INSTANCE

Defines the singleton for this class.

private static final AbstractStringMatcher.NoneMatcher
NONE_MATCHER

Matches no characters.

private static final AbstractStringMatcher.CharSetMatcher
QUOTE_MATCHER

Matches the single or double quote character.

private static final AbstractStringMatcher.CharMatcher
SINGLE_QUOTE_MATCHER

Matches the double quote character.

private static final AbstractStringMatcher.CharMatcher
SPACE_MATCHER

Matches the space character.

private static final AbstractStringMatcher.CharSetMatcher
SPLIT_MATCHER

Matches the same characters as StringTokenizer, namely space, tab, newline, form feed.

private static final AbstractStringMatcher.CharMatcher
TAB_MATCHER

Matches the tab character.

private static final AbstractStringMatcher.TrimMatcher
TRIM_MATCHER

Matches the String trim() whitespace characters.

Constructor Summary

AccessConstructor and Description
private
StringMatcherFactory()

No need to build instances for now.

Method Summary

Modifier and TypeMethod and Description
public StringMatcher

Returns:

a matcher that matches all of the given matchers in order.
andMatcher
(final StringMatcher...
the matcher.
stringMatchers
)

Creates a matcher that matches all of the given matchers in order.

public StringMatcher

Returns:

a new Matcher for the given char.
charMatcher
(final char
the character to match, must not be null.
ch
)

Constructor that creates a matcher from a character.

public StringMatcher

Returns:

a new matcher for the given char[].
charSetMatcher
(final char...
the characters to match, null or empty matches nothing.
chars
)

Constructor that creates a matcher from a set of characters.

public StringMatcher

Returns:

a new Matcher for the given characters.
charSetMatcher
(final String
the characters to match, null or empty matches nothing.
chars
)

Creates a matcher from a string representing a set of characters.

public StringMatcher

Returns:

a matcher for a comma.
commaMatcher
()

Returns a matcher which matches the comma character.

public StringMatcher

Returns:

a matcher for a double quote.
doubleQuoteMatcher
()

Returns a matcher which matches the double quote character.

public StringMatcher

Returns:

a matcher that matches nothing.
noneMatcher
()

Matches no characters.

public StringMatcher

Returns:

a matcher for a single or double quote.
quoteMatcher
()

Returns a matcher which matches the single or double quote character.

public StringMatcher

Returns:

a matcher for a single quote.
singleQuoteMatcher
()

Returns a matcher which matches the single quote character.

public StringMatcher

Returns:

a matcher for a space.
spaceMatcher
()

Returns a matcher which matches the space character.

public StringMatcher

Returns:

The split matcher.
splitMatcher
()

Matches the same characters as StringTokenizer, namely space, tab, newline and form feed.

public StringMatcher

Returns:

a new Matcher for the given String.
stringMatcher
(final char...
the string to match, null or empty matches nothing.
chars
)

Creates a matcher from a string.

public StringMatcher

Returns:

a new Matcher for the given String.
stringMatcher
(final String
the string to match, null or empty matches nothing.
str
)

Creates a matcher from a string.

public StringMatcher

Returns:

a matcher for a tab.
tabMatcher
()

Returns a matcher which matches the tab character.

public StringMatcher

Returns:

The trim matcher.
trimMatcher
()

Matches the String trim() whitespace characters.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COMMA_MATCHERback to summary
private static final AbstractStringMatcher.CharMatcher COMMA_MATCHER

Matches the comma character.

DOUBLE_QUOTE_MATCHERback to summary
private static final AbstractStringMatcher.CharMatcher DOUBLE_QUOTE_MATCHER

Matches the double quote character.

INSTANCEback to summary
public static final StringMatcherFactory INSTANCE

Defines the singleton for this class.

NONE_MATCHERback to summary
private static final AbstractStringMatcher.NoneMatcher NONE_MATCHER

Matches no characters.

QUOTE_MATCHERback to summary
private static final AbstractStringMatcher.CharSetMatcher QUOTE_MATCHER

Matches the single or double quote character.

SINGLE_QUOTE_MATCHERback to summary
private static final AbstractStringMatcher.CharMatcher SINGLE_QUOTE_MATCHER

Matches the double quote character.

SPACE_MATCHERback to summary
private static final AbstractStringMatcher.CharMatcher SPACE_MATCHER

Matches the space character.

SPLIT_MATCHERback to summary
private static final AbstractStringMatcher.CharSetMatcher SPLIT_MATCHER

Matches the same characters as StringTokenizer, namely space, tab, newline, form feed.

TAB_MATCHERback to summary
private static final AbstractStringMatcher.CharMatcher TAB_MATCHER

Matches the tab character.

TRIM_MATCHERback to summary
private static final AbstractStringMatcher.TrimMatcher TRIM_MATCHER

Matches the String trim() whitespace characters.

Constructor Detail

StringMatcherFactoryback to summary
private StringMatcherFactory()

No need to build instances for now.

Method Detail

andMatcherback to summary
public StringMatcher andMatcher(final StringMatcher... stringMatchers)

Creates a matcher that matches all of the given matchers in order.

Parameters
stringMatchers:StringMatcher[]

the matcher.

Returns:StringMatcher

a matcher that matches all of the given matchers in order.

Since
1.9
charMatcherback to summary
public StringMatcher charMatcher(final char ch)

Constructor that creates a matcher from a character.

Parameters
ch:char

the character to match, must not be null.

Returns:StringMatcher

a new Matcher for the given char.

charSetMatcherback to summary
public StringMatcher charSetMatcher(final char... chars)

Constructor that creates a matcher from a set of characters.

Parameters
chars:char[]

the characters to match, null or empty matches nothing.

Returns:StringMatcher

a new matcher for the given char[].

charSetMatcherback to summary
public StringMatcher charSetMatcher(final String chars)

Creates a matcher from a string representing a set of characters.

Parameters
chars:String

the characters to match, null or empty matches nothing.

Returns:StringMatcher

a new Matcher for the given characters.

commaMatcherback to summary
public StringMatcher commaMatcher()

Returns a matcher which matches the comma character.

Returns:StringMatcher

a matcher for a comma.

doubleQuoteMatcherback to summary
public StringMatcher doubleQuoteMatcher()

Returns a matcher which matches the double quote character.

Returns:StringMatcher

a matcher for a double quote.

noneMatcherback to summary
public StringMatcher noneMatcher()

Matches no characters.

Returns:StringMatcher

a matcher that matches nothing.

quoteMatcherback to summary
public StringMatcher quoteMatcher()

Returns a matcher which matches the single or double quote character.

Returns:StringMatcher

a matcher for a single or double quote.

singleQuoteMatcherback to summary
public StringMatcher singleQuoteMatcher()

Returns a matcher which matches the single quote character.

Returns:StringMatcher

a matcher for a single quote.

spaceMatcherback to summary
public StringMatcher spaceMatcher()

Returns a matcher which matches the space character.

Returns:StringMatcher

a matcher for a space.

splitMatcherback to summary
public StringMatcher splitMatcher()

Matches the same characters as StringTokenizer, namely space, tab, newline and form feed.

Returns:StringMatcher

The split matcher.

stringMatcherback to summary
public StringMatcher stringMatcher(final char... chars)

Creates a matcher from a string.

Parameters
chars:char[]

the string to match, null or empty matches nothing.

Returns:StringMatcher

a new Matcher for the given String.

Since
1.9
stringMatcherback to summary
public StringMatcher stringMatcher(final String str)

Creates a matcher from a string.

Parameters
str:String

the string to match, null or empty matches nothing.

Returns:StringMatcher

a new Matcher for the given String.

tabMatcherback to summary
public StringMatcher tabMatcher()

Returns a matcher which matches the tab character.

Returns:StringMatcher

a matcher for a tab.

trimMatcherback to summary
public StringMatcher trimMatcher()

Matches the String trim() whitespace characters.

Returns:StringMatcher

The trim matcher.