Package com.ibm.icu.number
Class NumberSkeletonImpl
- java.lang.Object
-
- com.ibm.icu.number.NumberSkeletonImpl
-
class NumberSkeletonImpl extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
NumberSkeletonImpl.BlueprintHelpers
Utility class for methods for processing stems and options that cannot be interpreted literally.(package private) static class
NumberSkeletonImpl.EnumToStemString
Utility class for methods that convert from enums to stem strings.(package private) static class
NumberSkeletonImpl.GeneratorHelpers
Utility class for methods for generating a token corresponding to each macro-prop.(package private) static class
NumberSkeletonImpl.ParseState
While parsing a skeleton, this enum records what type of option we expect to find next.(package private) static class
NumberSkeletonImpl.StemEnum
All possible stem literals have an entry in the StemEnum.(package private) static class
NumberSkeletonImpl.StemToObject
Utility class for methods that convert from StemEnum to corresponding objects or enums.
-
Field Summary
Fields Modifier and Type Field Description (package private) static char
ALT_WILDCARD_CHAR
Alternative wildcard char, accept on input but not printed in outputprivate static CacheBase<java.lang.String,UnlocalizedNumberFormatter,java.lang.Void>
cache
Cache for parsed skeleton strings.(package private) static java.lang.String
SERIALIZED_STEM_TRIE
A data structure for mapping from stem strings to the stem enum.(package private) static NumberSkeletonImpl.StemEnum[]
STEM_ENUM_VALUES
For mapping from ordinal back to StemEnum in Java.(package private) static char
WILDCARD_CHAR
Default wildcard char, accepted on input and printed in output
-
Constructor Summary
Constructors Constructor Description NumberSkeletonImpl()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
appendMultiple(java.lang.StringBuilder sb, int cp, int count)
(package private) static java.lang.String
buildStemTrie()
private static void
checkNull(java.lang.Object value, java.lang.CharSequence content)
static UnlocalizedNumberFormatter
create(java.lang.String skeletonString)
Creates a NumberFormatter corresponding to the given skeleton string.static java.lang.String
generate(MacroProps macros)
Create a skeleton string corresponding to the given NumberFormatter.private static void
generateSkeleton(MacroProps macros, java.lang.StringBuilder sb)
Main skeleton generator function.static UnlocalizedNumberFormatter
getOrCreate(java.lang.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(java.lang.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 Detail
-
WILDCARD_CHAR
static final char WILDCARD_CHAR
Default wildcard char, accepted on input and printed in output- See Also:
- Constant Field Values
-
ALT_WILDCARD_CHAR
static final char ALT_WILDCARD_CHAR
Alternative wildcard char, accept on input but not printed in output- See Also:
- Constant Field Values
-
STEM_ENUM_VALUES
static final NumberSkeletonImpl.StemEnum[] STEM_ENUM_VALUES
For mapping from ordinal back to StemEnum in Java.
-
SERIALIZED_STEM_TRIE
static final java.lang.String SERIALIZED_STEM_TRIE
A data structure for mapping from stem strings to the stem enum. Built at startup.
-
cache
private static final CacheBase<java.lang.String,UnlocalizedNumberFormatter,java.lang.Void> cache
Cache for parsed skeleton strings.
-
-
Method Detail
-
isWildcardChar
static boolean isWildcardChar(char c)
Checks whether the char is a wildcard on input
-
buildStemTrie
static java.lang.String buildStemTrie()
-
getOrCreate
public static UnlocalizedNumberFormatter getOrCreate(java.lang.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.- Parameters:
skeletonString
- A number skeleton string, possibly not in its shortest form.- Returns:
- An UnlocalizedNumberFormatter with behavior defined by the given skeleton string.
-
create
public static UnlocalizedNumberFormatter create(java.lang.String skeletonString)
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
public static java.lang.String generate(MacroProps macros)
Create a skeleton string corresponding to the given NumberFormatter.- Parameters:
macros
- The NumberFormatter options object.- Returns:
- A skeleton string in normalized form.
-
parseSkeleton
private static MacroProps parseSkeleton(java.lang.String skeletonString)
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
private static void generateSkeleton(MacroProps macros, java.lang.StringBuilder sb)
Main skeleton generator function. Appends the normalized skeleton for the MacroProps to the given StringBuilder.
-
checkNull
private static void checkNull(java.lang.Object value, java.lang.CharSequence content)
-
appendMultiple
private static void appendMultiple(java.lang.StringBuilder sb, int cp, int count)
-
-