Class NumberSkeletonImpl

java.lang.Object
com.ibm.icu.number.NumberSkeletonImpl

class NumberSkeletonImpl extends Object
  • Field Details

    • WILDCARD_CHAR

      static final char WILDCARD_CHAR
      Default wildcard char, accepted on input and printed in output
      See Also:
    • ALT_WILDCARD_CHAR

      static final char ALT_WILDCARD_CHAR
      Alternative wildcard char, accept on input but not printed in output
      See Also:
    • STEM_ENUM_VALUES

      static final NumberSkeletonImpl.StemEnum[] STEM_ENUM_VALUES
      For mapping from ordinal back to StemEnum in Java.
    • SERIALIZED_STEM_TRIE

      static final String SERIALIZED_STEM_TRIE
      A data structure for mapping from stem strings to the stem enum. Built at startup.
    • cache

      private static final CacheBase<String,UnlocalizedNumberFormatter,Void> 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

      static String buildStemTrie()
    • getOrCreate

      public 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.
      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(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 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(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, StringBuilder sb)
      Main skeleton generator function. Appends the normalized skeleton for the MacroProps to the given StringBuilder.
    • checkNull

      private static void checkNull(Object value, CharSequence content)
    • appendMultiple

      private static void appendMultiple(StringBuilder sb, int cp, int count)