Class NumberSkeletonImpl


  • class NumberSkeletonImpl
    extends java.lang.Object
    • 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
      • 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.
    • Constructor Detail

      • NumberSkeletonImpl

        NumberSkeletonImpl()
    • 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.
      • 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)