| Affix Pattern | Example Unescaped (Formatted) String |
|---|---|
| abc | abc |
| ab- | ab− |
| ab'-' | ab- |
| ab'' | ab' |
long tag = 0L;
while (AffixPatternUtils.hasNext(tag, patternString)) {
tag = AffixPatternUtils.nextToken(tag, patternString);
int typeOrCp = AffixPatternUtils.getTypeOrCp(tag);
switch (typeOrCp) {
case AffixPatternUtils.TYPE_MINUS_SIGN:
// Current token is a minus sign.
break;
case AffixPatternUtils.TYPE_PLUS_SIGN:
// Current token is a plus sign.
break;
case AffixPatternUtils.TYPE_PERCENT:
// Current token is a percent sign.
break;
// ... other types ...
default:
// Current token is an arbitrary code point.
// The variable typeOrCp is the code point.
break;
}
}
| Modifier and Type | Class and Description |
|---|---|
| public static interface | |
| public static interface |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| public static final int | |
| private static final int | TYPE_CODEPOINT
Represents a literal character; the value is stored in the code point field. |
| public static final int | TYPE_CURRENCY_DOUBLE
Represents a double currency symbol '¤¤'. |
| public static final int | TYPE_CURRENCY_OVERFLOW
Represents a sequence of six or more currency symbols. |
| public static final int | TYPE_CURRENCY_QUAD
Represents a quadruple currency symbol '¤¤¤¤'. |
| public static final int | TYPE_CURRENCY_QUINT
Represents a quintuple currency symbol '¤¤¤¤¤'. |
| public static final int | TYPE_CURRENCY_SINGLE
Represents a single currency symbol '¤'. |
| public static final int | TYPE_CURRENCY_TRIPLE
Represents a triple currency symbol '¤¤¤'. |
| public static final int | TYPE_MINUS_SIGN
Represents a minus sign symbol '-'. |
| public static final int | TYPE_PERCENT
Represents a percent sign symbol '%'. |
| public static final int | TYPE_PERMILLE
Represents a permille sign symbol '‰'. |
| public static final int | TYPE_PLUS_SIGN
Represents a plus sign symbol '+'. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static boolean | containsOnlySymbolsAndIgnorables(CharSequence affixPattern, UnicodeSet ignorables)
Returns whether the given affix pattern contains only symbols and ignorables as defined by the given ignorables set. |
| public static boolean | Returns: true if the affix pattern contains the given token type; false otherwise.The affix pattern to check. affixPattern, int The token type. type)Checks whether the given affix pattern contains at least one token of the given type, which is one
of the constants "TYPE_" in |
| public static int | Returns: The number of chars (UTF-16 code units) appended to the output.The string to be escaped. input, StringBuilder The string builder to which to append the escaped string. output)Takes a string and escapes (quotes) characters that have special meaning in the affix pattern syntax. |
| public static String | |
| public static int | Returns: The length of the unescaped string.The original string whose width will be estimated. patternString)Estimates the number of code points present in an unescaped version of the affix pattern string
(one that would be returned by |
| private static int | |
| public static final NumberFormat. | |
| private static int | |
| private static int | |
| private static int | |
| private static int | Returns: If less than zero, a symbol type corresponding to one of theTYPE_ constants,
such as TYPE_MINUS_SIGN. If greater than or equal to zero, a literal code point.The bitmask tag of the current token, as returned by tag)nextToken.This function helps determine the identity of the token consumed by |
| public static boolean | Returns: true if the literal has at least one unquoted currency symbol; false otherwise.The string to check for currency symbols. affixPattern)Checks whether the specified affix pattern has any unquoted currency symbols ("¤"). |
| private static boolean | Returns: true if there are more tokens to consume; false otherwise.The bitmask tag of the previous token, as returned by tag, CharSequence nextToken.The affix pattern. string)Returns whether the affix pattern string has any more tokens to be retrieved from a call to
|
| public static void | iterateWithConsumer(CharSequence affixPattern, AffixUtils.
Iterates over the affix pattern, calling the TokenConsumer for each token. |
| private static long | |
| private static long | Returns: The bitmask tag to pass to the next call of this method to retrieve the following token (never negative), or -1 if there were no more tokens in the affix pattern.A bitmask used for keeping track of state from token to token. The initial value should
be 0L. tag, CharSequence The affix pattern. patternString)Returns the next token from the affix pattern. |
| public static String | Returns: A string containing the new affix pattern.The source affix pattern (does not get modified). affixPattern, int The token type. type, char The char to substitute in place of chars of the given token type. replacementChar)Replaces all occurrences of tokens with the given type with the given replacement char. |
| public static int | Returns: The length of the string added to affixPattern.The original string to be unescaped. affixPattern, FormattedStringBuilder The FormattedStringBuilder to mutate with the result. output, int The index into the FormattedStringBuilder to insert the the string. position, AffixUtils.An object to generate locale symbols. provider,Executes the unescape state machine. |
| public static int | Returns: The number of code points in the unescaped string.The original string to be unescaped. affixPattern, boolean true to count length (UTF-16 code units); false to count code points lengthOrCount, AffixUtils.An object to generate locale symbols. providerSames as |
| STATE_AFTER_QUOTE | back to summary |
|---|---|
| private static final int STATE_AFTER_QUOTE | |
| STATE_BASE | back to summary |
|---|---|
| private static final int STATE_BASE | |
| STATE_FIFTH_CURR | back to summary |
|---|---|
| private static final int STATE_FIFTH_CURR | |
| STATE_FIRST_CURR | back to summary |
|---|---|
| private static final int STATE_FIRST_CURR | |
| STATE_FIRST_QUOTE | back to summary |
|---|---|
| private static final int STATE_FIRST_QUOTE | |
| STATE_FOURTH_CURR | back to summary |
|---|---|
| private static final int STATE_FOURTH_CURR | |
| STATE_INSIDE_QUOTE | back to summary |
|---|---|
| private static final int STATE_INSIDE_QUOTE | |
| STATE_OVERFLOW_CURR | back to summary |
|---|---|
| private static final int STATE_OVERFLOW_CURR | |
| STATE_SECOND_CURR | back to summary |
|---|---|
| private static final int STATE_SECOND_CURR | |
| STATE_THIRD_CURR | back to summary |
|---|---|
| private static final int STATE_THIRD_CURR | |
| TYPE_APPROXIMATELY_SIGN | back to summary |
|---|---|
| public static final int TYPE_APPROXIMATELY_SIGN | |
| TYPE_CODEPOINT | back to summary |
|---|---|
| private static final int TYPE_CODEPOINT Represents a literal character; the value is stored in the code point field. | |
| TYPE_CURRENCY_DOUBLE | back to summary |
|---|---|
| public static final int TYPE_CURRENCY_DOUBLE Represents a double currency symbol '¤¤'. | |
| TYPE_CURRENCY_OVERFLOW | back to summary |
|---|---|
| public static final int TYPE_CURRENCY_OVERFLOW Represents a sequence of six or more currency symbols. | |
| TYPE_CURRENCY_QUAD | back to summary |
|---|---|
| public static final int TYPE_CURRENCY_QUAD Represents a quadruple currency symbol '¤¤¤¤'. | |
| TYPE_CURRENCY_QUINT | back to summary |
|---|---|
| public static final int TYPE_CURRENCY_QUINT Represents a quintuple currency symbol '¤¤¤¤¤'. | |
| TYPE_CURRENCY_SINGLE | back to summary |
|---|---|
| public static final int TYPE_CURRENCY_SINGLE Represents a single currency symbol '¤'. | |
| TYPE_CURRENCY_TRIPLE | back to summary |
|---|---|
| public static final int TYPE_CURRENCY_TRIPLE Represents a triple currency symbol '¤¤¤'. | |
| TYPE_MINUS_SIGN | back to summary |
|---|---|
| public static final int TYPE_MINUS_SIGN Represents a minus sign symbol '-'. | |
| TYPE_PERCENT | back to summary |
|---|---|
| public static final int TYPE_PERCENT Represents a percent sign symbol '%'. | |
| TYPE_PERMILLE | back to summary |
|---|---|
| public static final int TYPE_PERMILLE Represents a permille sign symbol '‰'. | |
| TYPE_PLUS_SIGN | back to summary |
|---|---|
| public static final int TYPE_PLUS_SIGN Represents a plus sign symbol '+'. | |
| AffixUtils | back to summary |
|---|---|
| public AffixUtils() | |
| containsOnlySymbolsAndIgnorables | back to summary |
|---|---|
| public static boolean containsOnlySymbolsAndIgnorables(CharSequence affixPattern, UnicodeSet ignorables) Returns whether the given affix pattern contains only symbols and ignorables as defined by the given ignorables set. | |
| containsType | back to summary |
|---|---|
| public static boolean containsType(CharSequence affixPattern, int type) Checks whether the given affix pattern contains at least one token of the given type, which is one
of the constants "TYPE_" in
| |
| escape | back to summary |
|---|---|
| public static int escape(CharSequence input, StringBuilder output) Takes a string and escapes (quotes) characters that have special meaning in the affix pattern syntax. This function does not reverse-lookup symbols. Example input: "-$x"; example output: "'-'$x"
| |
| escape | back to summary |
|---|---|
| public static String escape(CharSequence input) Version of | |
| estimateLength | back to summary |
|---|---|
| public static int estimateLength(CharSequence patternString) Estimates the number of code points present in an unescaped version of the affix pattern string
(one that would be returned by
| |
| getCodePoint | back to summary |
|---|---|
| private static int getCodePoint(long tag) | |
| getFieldForType | back to summary |
|---|---|
| public static final NumberFormat. | |
| getOffset | back to summary |
|---|---|
| private static int getOffset(long tag) | |
| getState | back to summary |
|---|---|
| private static int getState(long tag) | |
| getType | back to summary |
|---|---|
| private static int getType(long tag) | |
| getTypeOrCp | back to summary |
|---|---|
| private static int getTypeOrCp(long tag) This function helps determine the identity of the token consumed by
| |
| hasCurrencySymbols | back to summary |
|---|---|
| public static boolean hasCurrencySymbols(CharSequence affixPattern) Checks whether the specified affix pattern has any unquoted currency symbols ("¤").
| |
| hasNext | back to summary |
|---|---|
| private static boolean hasNext(long tag, CharSequence string) Returns whether the affix pattern string has any more tokens to be retrieved from a call to
| |
| iterateWithConsumer | back to summary |
|---|---|
| public static void iterateWithConsumer(CharSequence affixPattern, AffixUtils. Iterates over the affix pattern, calling the TokenConsumer for each token. | |
| makeTag | back to summary |
|---|---|
| private static long makeTag(int offset, int type, int state, int cp) Encodes the given values into a 64-bit tag.
| |
| nextToken | back to summary |
|---|---|
| private static long nextToken(long tag, CharSequence patternString) Returns the next token from the affix pattern.
| |
| replaceType | back to summary |
|---|---|
| public static String replaceType(CharSequence affixPattern, int type, char replacementChar) Replaces all occurrences of tokens with the given type with the given replacement char.
| |
| unescape | back to summary |
|---|---|
| public static int unescape(CharSequence affixPattern, FormattedStringBuilder output, int position, AffixUtils. Executes the unescape state machine. Replaces the unquoted characters "-", "+", "%", "‰", and "¤"
with the corresponding symbols provided by the Example input: "'-'¤x"; example output: "-$x"
| |
| unescapedCount | back to summary |
|---|---|
| public static int unescapedCount(CharSequence affixPattern, boolean lengthOrCount, AffixUtils. Sames as
| |
| Modifier and Type | Method and Description |
|---|---|
| public CharSequence |
| getSymbol | back to summary |
|---|---|
| public CharSequence getSymbol(int type) | |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| consumeToken | back to summary |
|---|---|
| public void consumeToken(int typeOrCp) | |