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 class
Utility class for methods for processing stems and options that cannot be interpreted literally.(package private) static final class
Utility class for methods that convert from enums to stem strings.(package private) static final class
Utility class for methods for generating a token corresponding to each macro-prop.(package private) static enum
While parsing a skeleton, this enum records what type of option we expect to find next.(package private) static enum
All possible stem literals have an entry in the StemEnum.(package private) static final class
Utility class for methods that convert from StemEnum to corresponding objects or enums. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final char
Alternative 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 String
A 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 char
Default wildcard char, accepted on input and printed in output -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
appendMultiple
(StringBuilder sb, int cp, int count) (package private) static String
private static void
checkNull
(Object value, CharSequence content) static UnlocalizedNumberFormatter
Creates a NumberFormatter corresponding to the given skeleton string.static String
generate
(MacroProps macros) Create a skeleton string corresponding to the given NumberFormatter.private static void
generateSkeleton
(MacroProps macros, StringBuilder sb) Main skeleton generator function.static UnlocalizedNumberFormatter
getOrCreate
(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 boolean
isWildcardChar
(char c) Checks whether the char is a wildcard on inputprivate 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.private static MacroProps
parseSkeleton
(String skeletonString) Converts from a skeleton string to a MacroProps.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.
-
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
-