Class CharMatcher.None
- Enclosing class:
CharMatcher
CharMatcher.none().-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.base.CharMatcher
CharMatcher.FastMatcher, CharMatcher.NamedFastMatcher, CharMatcher.Whitespace -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionand(CharMatcher other) Returns a matcher that matches any character matched by both this matcher andother.collapseFrom(CharSequence sequence, char replacement) Returns a string copy of the input character sequence, with each group of consecutive matching BMP characters replaced by a single replacement character.intcountIn(CharSequence sequence) Returns the number of matchingchars found in a character sequence.intindexIn(CharSequence sequence) Returns the index of the first matching BMP character in a character sequence, or-1if no matching character is present.intindexIn(CharSequence sequence, int start) Returns the index of the first matching BMP character in a character sequence, starting from a given position, or-1if no character matches after that position.intlastIndexIn(CharSequence sequence) Returns the index of the last matching BMP character in a character sequence, or-1if no matching character is present.booleanmatches(char c) Determines a true or false value for the given character.booleanmatchesAllOf(CharSequence sequence) Returnstrueif a character sequence contains only matching BMP characters.booleanmatchesNoneOf(CharSequence sequence) Returnstrueif a character sequence contains no matching BMP characters.negate()Returns a matcher that matches any character not matched by this matcher.or(CharMatcher other) Returns a matcher that matches any character matched by either this matcher orother.removeFrom(CharSequence sequence) Returns a string containing all non-matching characters of a character sequence, in order.replaceFrom(CharSequence sequence, char replacement) Returns a string copy of the input character sequence, with each matching BMP character replaced by a given replacement character.replaceFrom(CharSequence sequence, CharSequence replacement) Returns a string copy of the input character sequence, with each matching BMP character replaced by a given replacement sequence.trimFrom(CharSequence sequence) Returns a substring of the input character sequence that omits all matching BMP characters from the beginning and from the end of the string.trimLeadingFrom(CharSequence sequence) Returns a substring of the input character sequence that omits all matching BMP characters from the beginning of the string.trimTrailingFrom(CharSequence sequence) Returns a substring of the input character sequence that omits all matching BMP characters from the end of the string.Methods inherited from class com.google.common.base.CharMatcher.NamedFastMatcher
toStringMethods inherited from class com.google.common.base.CharMatcher.FastMatcher
precomputedMethods inherited from class com.google.common.base.CharMatcher
any, anyOf, apply, ascii, breakingWhitespace, digit, forPredicate, inRange, invisible, is, isNot, javaDigit, javaIsoControl, javaLetter, javaLetterOrDigit, javaLowerCase, javaUpperCase, matchesAnyOf, none, noneOf, precomputedInternal, retainFrom, setBits, singleWidth, trimAndCollapseFrom, whitespace
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
None
private None()
-
-
Method Details
-
matches
public boolean matches(char c) Description copied from class:CharMatcherDetermines a true or false value for the given character.- Specified by:
matchesin classCharMatcher
-
indexIn
Description copied from class:CharMatcherReturns the index of the first matching BMP character in a character sequence, or-1if no matching character is present.The default implementation iterates over the sequence in forward order calling
CharMatcher.matches(char)for each character.- Overrides:
indexInin classCharMatcher- Parameters:
sequence- the character sequence to examine from the beginning- Returns:
- an index, or
-1if no character matches
-
indexIn
Description copied from class:CharMatcherReturns the index of the first matching BMP character in a character sequence, starting from a given position, or-1if no character matches after that position.The default implementation iterates over the sequence in forward order, beginning at
start, callingCharMatcher.matches(char)for each character.- Overrides:
indexInin classCharMatcher- Parameters:
sequence- the character sequence to examinestart- the first index to examine; must be nonnegative and no greater thansequence.length()- Returns:
- the index of the first matching character, guaranteed to be no less than
start, or-1if no character matches
-
lastIndexIn
Description copied from class:CharMatcherReturns the index of the last matching BMP character in a character sequence, or-1if no matching character is present.The default implementation iterates over the sequence in reverse order calling
CharMatcher.matches(char)for each character.- Overrides:
lastIndexInin classCharMatcher- Parameters:
sequence- the character sequence to examine from the end- Returns:
- an index, or
-1if no character matches
-
matchesAllOf
Description copied from class:CharMatcherReturnstrueif a character sequence contains only matching BMP characters.The default implementation iterates over the sequence, invoking
CharMatcher.matches(char)for each character, until this returnsfalseor the end is reached.- Overrides:
matchesAllOfin classCharMatcher- Parameters:
sequence- the character sequence to examine, possibly empty- Returns:
trueif this matcher matches every character in the sequence, including when the sequence is empty
-
matchesNoneOf
Description copied from class:CharMatcherReturnstrueif a character sequence contains no matching BMP characters. Equivalent to!matchesAnyOf(sequence).The default implementation iterates over the sequence, invoking
CharMatcher.matches(char)for each character, until this returnstrueor the end is reached.- Overrides:
matchesNoneOfin classCharMatcher- Parameters:
sequence- the character sequence to examine, possibly empty- Returns:
trueif this matcher matches no characters in the sequence, including when the sequence is empty
-
removeFrom
Description copied from class:CharMatcherReturns a string containing all non-matching characters of a character sequence, in order. For example:
... returnsCharMatcher.is('a').removeFrom("bazaar")"bzr".- Overrides:
removeFromin classCharMatcher
-
replaceFrom
Description copied from class:CharMatcherReturns a string copy of the input character sequence, with each matching BMP character replaced by a given replacement character. For example:
... returnsCharMatcher.is('a').replaceFrom("radar", 'o')"rodor".The default implementation uses
CharMatcher.indexIn(CharSequence)to find the first matching character, then iterates the remainder of the sequence callingCharMatcher.matches(char)for each character.- Overrides:
replaceFromin classCharMatcher- Parameters:
sequence- the character sequence to replace matching characters inreplacement- the character to append to the result string in place of each matching character insequence- Returns:
- the new string
-
replaceFrom
Description copied from class:CharMatcherReturns a string copy of the input character sequence, with each matching BMP character replaced by a given replacement sequence. For example:
... returnsCharMatcher.is('a').replaceFrom("yaha", "oo")"yoohoo".Note: If the replacement is a fixed string with only one character, you are better off calling
CharMatcher.replaceFrom(CharSequence, char)directly.- Overrides:
replaceFromin classCharMatcher- Parameters:
sequence- the character sequence to replace matching characters inreplacement- the characters to append to the result string in place of each matching character insequence- Returns:
- the new string
-
collapseFrom
Description copied from class:CharMatcherReturns a string copy of the input character sequence, with each group of consecutive matching BMP characters replaced by a single replacement character. For example:
... returnsCharMatcher.anyOf("eko").collapseFrom("bookkeeper", '-')"b-p-r".The default implementation uses
CharMatcher.indexIn(CharSequence)to find the first matching character, then iterates the remainder of the sequence callingCharMatcher.matches(char)for each character.- Overrides:
collapseFromin classCharMatcher- Parameters:
sequence- the character sequence to replace matching groups of characters inreplacement- the character to append to the result string in place of each group of matching characters insequence- Returns:
- the new string
-
trimFrom
Description copied from class:CharMatcherReturns a substring of the input character sequence that omits all matching BMP characters from the beginning and from the end of the string. For example:
... returnsCharMatcher.anyOf("ab").trimFrom("abacatbab")"cat".Note that:
... is equivalent toCharMatcher.inRange('\0', ' ').trimFrom(str)String.trim().- Overrides:
trimFromin classCharMatcher
-
trimLeadingFrom
Description copied from class:CharMatcherReturns a substring of the input character sequence that omits all matching BMP characters from the beginning of the string. For example:
... returnsCharMatcher.anyOf("ab").trimLeadingFrom("abacatbab")"catbab".- Overrides:
trimLeadingFromin classCharMatcher
-
trimTrailingFrom
Description copied from class:CharMatcherReturns a substring of the input character sequence that omits all matching BMP characters from the end of the string. For example:
... returnsCharMatcher.anyOf("ab").trimTrailingFrom("abacatbab")"abacat".- Overrides:
trimTrailingFromin classCharMatcher
-
countIn
Description copied from class:CharMatcherReturns the number of matchingchars found in a character sequence.Counts 2 per supplementary character, such as for
CharMatcher.whitespace()().CharMatcher.negate()().- Overrides:
countInin classCharMatcher
-
and
Description copied from class:CharMatcherReturns a matcher that matches any character matched by both this matcher andother.- Overrides:
andin classCharMatcher
-
or
Description copied from class:CharMatcherReturns a matcher that matches any character matched by either this matcher orother.- Overrides:
orin classCharMatcher
-
negate
Description copied from class:CharMatcherReturns a matcher that matches any character not matched by this matcher.- Specified by:
negatein interfacePredicate<Character>- Overrides:
negatein classCharMatcher.FastMatcher
-