Package com.ibm.icu.number
Class NumberSkeletonImpl
java.lang.Object
com.ibm.icu.number.NumberSkeletonImpl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classUtility class for methods for processing stems and options that cannot be interpreted literally.(package private) static final classUtility class for methods that convert from enums to stem strings.(package private) static final classUtility class for methods for generating a token corresponding to each macro-prop.(package private) static enumWhile parsing a skeleton, this enum records what type of option we expect to find next.(package private) static enumAll possible stem literals have an entry in the StemEnum.(package private) static final classUtility class for methods that convert from StemEnum to corresponding objects or enums. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final charAlternative wildcard char, accept on input but not printed in outputprivate static final CacheBase<String, UnlocalizedNumberFormatter, Void> Cache for parsed skeleton strings.(package private) static final StringA data structure for mapping from stem strings to the stem enum.(package private) static final NumberSkeletonImpl.StemEnum[]For mapping from ordinal back to StemEnum in Java.(package private) static final charDefault wildcard char, accepted on input and printed in output -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidappendMultiple(StringBuilder sb, int cp, int count) (package private) static Stringprivate static voidcheckNull(Object value, CharSequence content) static UnlocalizedNumberFormatterCreates a NumberFormatter corresponding to the given skeleton string.static Stringgenerate(MacroProps macros) Create a skeleton string corresponding to the given NumberFormatter.private static voidgenerateSkeleton(MacroProps macros, StringBuilder sb) Main skeleton generator function.static UnlocalizedNumberFormattergetOrCreate(String skeletonString) Gets the number formatter for the given number skeleton string from the cache, creating it if it does not exist in the cache.(package private) static booleanisWildcardChar(char c) Checks whether the char is a wildcard on inputprivate static NumberSkeletonImpl.ParseStateparseOption(NumberSkeletonImpl.ParseState stem, StringSegment segment, MacroProps macros) Given that the current segment represents an option, parse it and save the result.private static MacroPropsparseSkeleton(String skeletonString) Converts from a skeleton string to a MacroProps.private static NumberSkeletonImpl.ParseStateparseStem(StringSegment segment, CharsTrie stemTrie, MacroProps macros) Given that the current segment represents a stem, parse it and save the result.
-
Field Details
-
WILDCARD_CHAR
static final char WILDCARD_CHARDefault wildcard char, accepted on input and printed in output- See Also:
-
ALT_WILDCARD_CHAR
static final char ALT_WILDCARD_CHARAlternative wildcard char, accept on input but not printed in output- See Also:
-
STEM_ENUM_VALUES
For mapping from ordinal back to StemEnum in Java. -
SERIALIZED_STEM_TRIE
A data structure for mapping from stem strings to the stem enum. Built at startup. -
cache
Cache for parsed skeleton strings.
-
-
Constructor Details
-
NumberSkeletonImpl
NumberSkeletonImpl()
-
-
Method Details
-
isWildcardChar
static boolean isWildcardChar(char c) Checks whether the char is a wildcard on input -
buildStemTrie
-
getOrCreate
Gets the number formatter for the given number skeleton string from the cache, creating it if it does not exist in the cache.- Parameters:
skeletonString- A number skeleton string, possibly not in its shortest form.- Returns:
- An UnlocalizedNumberFormatter with behavior defined by the given skeleton string.
-
create
Creates a NumberFormatter corresponding to the given skeleton string.- Parameters:
skeletonString- A number skeleton string, possibly not in its shortest form.- Returns:
- An UnlocalizedNumberFormatter with behavior defined by the given skeleton string.
-
generate
Create a skeleton string corresponding to the given NumberFormatter.- Parameters:
macros- The NumberFormatter options object.- Returns:
- A skeleton string in normalized form.
-
parseSkeleton
Converts from a skeleton string to a MacroProps. This method contains the primary parse loop. -
parseStem
private static NumberSkeletonImpl.ParseState parseStem(StringSegment segment, CharsTrie stemTrie, MacroProps macros) Given that the current segment represents a stem, parse it and save the result.- Returns:
- The next state after parsing this stem, corresponding to what subset of options to expect.
-
parseOption
private static NumberSkeletonImpl.ParseState parseOption(NumberSkeletonImpl.ParseState stem, StringSegment segment, MacroProps macros) Given that the current segment represents an option, parse it and save the result.- Returns:
- The next state after parsing this option, corresponding to what subset of options to expect next.
-
generateSkeleton
Main skeleton generator function. Appends the normalized skeleton for the MacroProps to the given StringBuilder. -
checkNull
-
appendMultiple
-