Class StrMatcher
- java.lang.Object
-
- org.apache.commons.lang3.text.StrMatcher
-
- Direct Known Subclasses:
StrMatcher.CharMatcher,StrMatcher.CharSetMatcher,StrMatcher.NoMatcher,StrMatcher.StringMatcher,StrMatcher.TrimMatcher
@Deprecated public abstract class StrMatcher extends java.lang.ObjectDeprecated.As of 3.6, use Apache Commons Text StringMatcherFactory.A matcher class that can be queried to determine if a character array portion matches.This class comes complete with various factory methods. If these do not suffice, you can subclass and implement your own matcher.
- Since:
- 2.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classStrMatcher.CharMatcherDeprecated.Class used to define a character for matching purposes.(package private) static classStrMatcher.CharSetMatcherDeprecated.Class used to define a set of characters for matching purposes.(package private) static classStrMatcher.NoMatcherDeprecated.Class used to match no characters.(package private) static classStrMatcher.StringMatcherDeprecated.Class used to define a set of characters for matching purposes.(package private) static classStrMatcher.TrimMatcherDeprecated.Class used to match whitespace as per trim().
-
Field Summary
Fields Modifier and Type Field Description private static StrMatcherCOMMA_MATCHERDeprecated.Matches the comma character.private static StrMatcherDOUBLE_QUOTE_MATCHERDeprecated.Matches the double quote character.private static StrMatcherNONE_MATCHERDeprecated.Matches no characters.private static StrMatcherQUOTE_MATCHERDeprecated.Matches the single or double quote character.private static StrMatcherSINGLE_QUOTE_MATCHERDeprecated.Matches the double quote character.private static StrMatcherSPACE_MATCHERDeprecated.Matches the space character.private static StrMatcherSPLIT_MATCHERDeprecated.Matches the same characters as StringTokenizer, namely space, tab, newline, formfeed.private static StrMatcherTAB_MATCHERDeprecated.Matches the tab character.private static StrMatcherTRIM_MATCHERDeprecated.Matches the String trim() whitespace characters.
-
Constructor Summary
Constructors Modifier Constructor Description protectedStrMatcher()Deprecated.Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StrMatchercharMatcher(char ch)Deprecated.Creates a matcher from a character.static StrMatchercharSetMatcher(char... chars)Deprecated.Creates a matcher from a set of characters.static StrMatchercharSetMatcher(java.lang.String chars)Deprecated.Creates a matcher from a string representing a set of characters.static StrMatchercommaMatcher()Deprecated.Gets the matcher for the comma character.static StrMatcherdoubleQuoteMatcher()Deprecated.Gets the matcher for the double quote character.intisMatch(char[] buffer, int pos)Deprecated.Tests whether the number of matching characters, zero for no match.abstract intisMatch(char[] buffer, int pos, int bufferStart, int bufferEnd)Deprecated.Tests whether the number of matching characters, zero for no match.static StrMatchernoneMatcher()Deprecated.Gets the matcher for no characters.static StrMatcherquoteMatcher()Deprecated.Gets the matcher for the single or double quote character.static StrMatchersingleQuoteMatcher()Deprecated.Gets the matcher for the single quote character.static StrMatcherspaceMatcher()Deprecated.Gets the matcher for the space character.static StrMatchersplitMatcher()Deprecated.Gets the matcher for the same characters as StringTokenizer, namely space, tab, newline and form-feed.static StrMatcherstringMatcher(java.lang.String str)Deprecated.Creates a matcher for a string.static StrMatchertabMatcher()Deprecated.Gets the matcher for the tab character.static StrMatchertrimMatcher()Deprecated.Gets the matcher to String trim() whitespace characters.
-
-
-
Field Detail
-
COMMA_MATCHER
private static final StrMatcher COMMA_MATCHER
Deprecated.Matches the comma character.
-
TAB_MATCHER
private static final StrMatcher TAB_MATCHER
Deprecated.Matches the tab character.
-
SPACE_MATCHER
private static final StrMatcher SPACE_MATCHER
Deprecated.Matches the space character.
-
SPLIT_MATCHER
private static final StrMatcher SPLIT_MATCHER
Deprecated.Matches the same characters as StringTokenizer, namely space, tab, newline, formfeed.
-
TRIM_MATCHER
private static final StrMatcher TRIM_MATCHER
Deprecated.Matches the String trim() whitespace characters.
-
SINGLE_QUOTE_MATCHER
private static final StrMatcher SINGLE_QUOTE_MATCHER
Deprecated.Matches the double quote character.
-
DOUBLE_QUOTE_MATCHER
private static final StrMatcher DOUBLE_QUOTE_MATCHER
Deprecated.Matches the double quote character.
-
QUOTE_MATCHER
private static final StrMatcher QUOTE_MATCHER
Deprecated.Matches the single or double quote character.
-
NONE_MATCHER
private static final StrMatcher NONE_MATCHER
Deprecated.Matches no characters.
-
-
Method Detail
-
charMatcher
public static StrMatcher charMatcher(char ch)
Deprecated.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 static StrMatcher charSetMatcher(char... chars)
Deprecated.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 static StrMatcher charSetMatcher(java.lang.String chars)
Deprecated.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 static StrMatcher commaMatcher()
Deprecated.Gets the matcher for the comma character.- Returns:
- the matcher for a comma
-
doubleQuoteMatcher
public static StrMatcher doubleQuoteMatcher()
Deprecated.Gets the matcher for the double quote character.- Returns:
- the matcher for a double quote
-
noneMatcher
public static StrMatcher noneMatcher()
Deprecated.Gets the matcher for no characters.- Returns:
- the matcher that matches nothing
-
quoteMatcher
public static StrMatcher quoteMatcher()
Deprecated.Gets the matcher for the single or double quote character.- Returns:
- the matcher for a single or double quote
-
singleQuoteMatcher
public static StrMatcher singleQuoteMatcher()
Deprecated.Gets the matcher for the single quote character.- Returns:
- the matcher for a single quote
-
spaceMatcher
public static StrMatcher spaceMatcher()
Deprecated.Gets the matcher for the space character.- Returns:
- the matcher for a space
-
splitMatcher
public static StrMatcher splitMatcher()
Deprecated.Gets the matcher for the same characters as StringTokenizer, namely space, tab, newline and form-feed.- Returns:
- the split matcher
-
stringMatcher
public static StrMatcher stringMatcher(java.lang.String str)
Deprecated.Creates a matcher for a string.- Parameters:
str- the string to match, null or empty matches nothing- Returns:
- a new Matcher for the given String
-
tabMatcher
public static StrMatcher tabMatcher()
Deprecated.Gets the matcher for the tab character.- Returns:
- the matcher for a tab
-
trimMatcher
public static StrMatcher trimMatcher()
Deprecated.Gets the matcher to String trim() whitespace characters.- Returns:
- the trim matcher
-
isMatch
public int isMatch(char[] buffer, int pos)Deprecated.Tests whether the number of matching characters, zero for no match.This method is called to check for a match. The parameter
posrepresents the current position to be checked in the stringbuffer(a character array which must not be changed). The API guarantees thatposis a valid index forbuffer.The matching code may check one character or many. It may check characters preceding
posas 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- the text content to match against, do not changepos- the starting position for the match, valid for buffer- Returns:
- the number of matching characters, zero for no match
- Since:
- 2.4
-
isMatch
public abstract int isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd)Deprecated.Tests whether the number of matching characters, zero for no match.This method is called to check for a match. The parameter
posrepresents the current position to be checked in the stringbuffer(a character array which must not be changed). The API guarantees thatposis a valid index forbuffer.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.
The matching code may check one character or many. It may check characters preceding
posas 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 text content to match against, do not changepos- the starting position for the match, valid for bufferbufferStart- the first active index in the buffer, valid for bufferbufferEnd- the end index (exclusive) of the active buffer, valid for buffer- Returns:
- the number of matching characters, zero for no match
-
-