MCPcopy Create free account
hub / github.com/antlr/codebuff / CharMatcher

Class CharMatcher

output/java_guava/1.4.13/CharMatcher.java:53–1970  ·  view source on GitHub ↗

Determines a true or false value for any Java char value, just as Predicate does for any Object. Also offers basic text processing methods based on this function. Implementations are strongly encouraged to be side-effect-free and immutable. Throughout the documentation of

Source from the content-addressed store, hash-verified

51
52
53@Beta // Possibly change from chars to code points; decide constants vs. methods
54@GwtCompatible(emulated = true)
55public abstract class CharMatcher implements Predicate<Character> {
56
57 // Constant matcher factory methods
58
59 /**
60 * Matches any character.
61 *
62 * @since 19.0 (since 1.0 as constant {@code ANY})
63 */
64
65 public static CharMatcher any() {
66return Any.INSTANCE;
67 }
68
69 /**
70 * Matches no characters.
71 *
72 * @since 19.0 (since 1.0 as constant {@code NONE})
73 */
74
75
76 public static CharMatcher none() {
77 return None.INSTANCE;
78 }
79
80 /**
81 * Determines whether a character is whitespace according to the latest Unicode standard, as
82 * illustrated
83 * <a href="http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5Cp%7Bwhitespace%7D">here</a>.
84 * This is not the same definition used by other Java APIs. (See a
85 * <a href="http://spreadsheets.google.com/pub?key=pd8dAQyHbdewRsnE5x5GzKQ">comparison of several
86 * definitions of "whitespace"</a>.)
87 *
88 * <p><b>Note:</b> as the Unicode definition evolves, we will modify this matcher to keep it up to
89 * date.
90 *
91 * @since 19.0 (since 1.0 as constant {@code WHITESPACE})
92 */
93
94
95 public static CharMatcher whitespace() {
96 return Whitespace.INSTANCE;
97 }
98
99 /**
100 * Determines whether a character is a breaking whitespace (that is, a whitespace which can be
101 * interpreted as a break between words for formatting purposes). See {@link #whitespace()} for a
102 * discussion of that term.
103 *
104 * @since 19.0 (since 2.0 as constant {@code BREAKING_WHITESPACE})
105 */
106
107
108 public static CharMatcher breakingWhitespace() {
109 return BreakingWhitespace.INSTANCE;
110 }

Callers

nothing calls this directly

Calls 14

whitespaceMethod · 0.95
breakingWhitespaceMethod · 0.95
asciiMethod · 0.95
digitMethod · 0.95
javaDigitMethod · 0.95
javaLetterMethod · 0.95
javaLetterOrDigitMethod · 0.95
javaUpperCaseMethod · 0.95
javaLowerCaseMethod · 0.95
javaIsoControlMethod · 0.95
invisibleMethod · 0.95
singleWidthMethod · 0.95

Tested by

no test coverage detected