Package org.apache.commons.text.matcher
Class StringMatcherFactory
- java.lang.Object
-
- org.apache.commons.text.matcher.StringMatcherFactory
-
public final class StringMatcherFactory extends java.lang.Object
Provides access to matchers defined in this package.- Since:
- 1.3
-
-
Field Summary
Fields Modifier and Type Field Description private static AbstractStringMatcher.CharMatcher
COMMA_MATCHER
Matches the comma character.private static AbstractStringMatcher.CharMatcher
DOUBLE_QUOTE_MATCHER
Matches the double quote character.static StringMatcherFactory
INSTANCE
Defines the singleton for this class.private static AbstractStringMatcher.NoneMatcher
NONE_MATCHER
Matches no characters.private static AbstractStringMatcher.CharSetMatcher
QUOTE_MATCHER
Matches the single or double quote character.private static AbstractStringMatcher.CharMatcher
SINGLE_QUOTE_MATCHER
Matches the double quote character.private static AbstractStringMatcher.CharMatcher
SPACE_MATCHER
Matches the space character.private static AbstractStringMatcher.CharSetMatcher
SPLIT_MATCHER
Matches the same characters as StringTokenizer, namely space, tab, newline, form feed.private static AbstractStringMatcher.CharMatcher
TAB_MATCHER
Matches the tab character.private static AbstractStringMatcher.TrimMatcher
TRIM_MATCHER
Matches the String trim() whitespace characters.
-
Constructor Summary
Constructors Modifier Constructor Description private
StringMatcherFactory()
No need to build instances for now.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringMatcher
andMatcher(StringMatcher... stringMatchers)
Creates a matcher that matches all of the given matchers in order.StringMatcher
charMatcher(char ch)
Constructor that creates a matcher from a character.StringMatcher
charSetMatcher(char... chars)
Constructor that creates a matcher from a set of characters.StringMatcher
charSetMatcher(java.lang.String chars)
Creates a matcher from a string representing a set of characters.StringMatcher
commaMatcher()
Returns a matcher which matches the comma character.StringMatcher
doubleQuoteMatcher()
Returns a matcher which matches the double quote character.StringMatcher
noneMatcher()
Matches no characters.StringMatcher
quoteMatcher()
Returns a matcher which matches the single or double quote character.StringMatcher
singleQuoteMatcher()
Returns a matcher which matches the single quote character.StringMatcher
spaceMatcher()
Returns a matcher which matches the space character.StringMatcher
splitMatcher()
Matches the same characters as StringTokenizer, namely space, tab, newline and form feed.StringMatcher
stringMatcher(char... chars)
Creates a matcher from a string.StringMatcher
stringMatcher(java.lang.String str)
Creates a matcher from a string.StringMatcher
tabMatcher()
Returns a matcher which matches the tab character.StringMatcher
trimMatcher()
Matches the String trim() whitespace characters.
-
-
-
Field Detail
-
COMMA_MATCHER
private static final AbstractStringMatcher.CharMatcher COMMA_MATCHER
Matches the comma character.
-
DOUBLE_QUOTE_MATCHER
private static final AbstractStringMatcher.CharMatcher DOUBLE_QUOTE_MATCHER
Matches the double quote character.
-
INSTANCE
public static final StringMatcherFactory INSTANCE
Defines the singleton for this class.
-
NONE_MATCHER
private static final AbstractStringMatcher.NoneMatcher NONE_MATCHER
Matches no characters.
-
QUOTE_MATCHER
private static final AbstractStringMatcher.CharSetMatcher QUOTE_MATCHER
Matches the single or double quote character.
-
SINGLE_QUOTE_MATCHER
private static final AbstractStringMatcher.CharMatcher SINGLE_QUOTE_MATCHER
Matches the double quote character.
-
SPACE_MATCHER
private static final AbstractStringMatcher.CharMatcher SPACE_MATCHER
Matches the space character.
-
SPLIT_MATCHER
private static final AbstractStringMatcher.CharSetMatcher SPLIT_MATCHER
Matches the same characters as StringTokenizer, namely space, tab, newline, form feed.
-
TAB_MATCHER
private static final AbstractStringMatcher.CharMatcher TAB_MATCHER
Matches the tab character.
-
TRIM_MATCHER
private static final AbstractStringMatcher.TrimMatcher TRIM_MATCHER
Matches the String trim() whitespace characters.
-
-
Method Detail
-
andMatcher
public StringMatcher andMatcher(StringMatcher... stringMatchers)
Creates a matcher that matches all of the given matchers in order.- Parameters:
stringMatchers
- the matcher- Returns:
- a matcher that matches all of the given matchers in order.
- Since:
- 1.9
-
charMatcher
public StringMatcher charMatcher(char ch)
Constructor that creates a matcher from a character.- Parameters:
ch
- the character to match, must not be null- Returns:
- a new Matcher for the given char
-
charSetMatcher
public StringMatcher charSetMatcher(char... chars)
Constructor that creates a matcher from a set of characters.- Parameters:
chars
- the characters to match, null or empty matches nothing- Returns:
- a new matcher for the given char[]
-
charSetMatcher
public StringMatcher charSetMatcher(java.lang.String chars)
Creates a matcher from a string representing a set of characters.- Parameters:
chars
- the characters to match, null or empty matches nothing- Returns:
- a new Matcher for the given characters
-
commaMatcher
public StringMatcher commaMatcher()
Returns a matcher which matches the comma character.- Returns:
- a matcher for a comma
-
doubleQuoteMatcher
public StringMatcher doubleQuoteMatcher()
Returns a matcher which matches the double quote character.- Returns:
- a matcher for a double quote
-
noneMatcher
public StringMatcher noneMatcher()
Matches no characters.- Returns:
- a matcher that matches nothing
-
quoteMatcher
public StringMatcher quoteMatcher()
Returns a matcher which matches the single or double quote character.- Returns:
- a matcher for a single or double quote
-
singleQuoteMatcher
public StringMatcher singleQuoteMatcher()
Returns a matcher which matches the single quote character.- Returns:
- a matcher for a single quote
-
spaceMatcher
public StringMatcher spaceMatcher()
Returns a matcher which matches the space character.- Returns:
- a matcher for a space
-
splitMatcher
public StringMatcher splitMatcher()
Matches the same characters as StringTokenizer, namely space, tab, newline and form feed.- Returns:
- The split matcher
-
stringMatcher
public StringMatcher stringMatcher(char... chars)
Creates a matcher from a string.- Parameters:
chars
- the string to match, null or empty matches nothing- Returns:
- a new Matcher for the given String
- Since:
- 1.9
-
stringMatcher
public StringMatcher stringMatcher(java.lang.String str)
Creates a matcher from a string.- Parameters:
str
- the string to match, null or empty matches nothing- Returns:
- a new Matcher for the given String
-
tabMatcher
public StringMatcher tabMatcher()
Returns a matcher which matches the tab character.- Returns:
- a matcher for a tab
-
trimMatcher
public StringMatcher trimMatcher()
Matches the String trim() whitespace characters.- Returns:
- The trim matcher
-
-