Class NumberParserImpl


  • public class NumberParserImpl
    extends java.lang.Object
    Primary number parsing implementation class.
    • Field Detail

      • parseFlags

        private final int parseFlags
      • frozen

        private boolean frozen
    • Constructor Detail

      • NumberParserImpl

        public NumberParserImpl​(int parseFlags)
        Creates a new, empty parser.
        Parameters:
        parseFlags - The parser settings defined in the PARSE_FLAG_* fields.
    • Method Detail

      • createSimpleParser

        public static NumberParserImpl createSimpleParser​(ULocale locale,
                                                          java.lang.String pattern,
                                                          int parseFlags)
        Creates a parser with most default options. Used for testing, not production.
      • parseStatic

        public static java.lang.Number parseStatic​(java.lang.String input,
                                                   java.text.ParsePosition ppos,
                                                   DecimalFormatProperties properties,
                                                   DecimalFormatSymbols symbols)
        Parses the string without returning a NumberParserImpl. Used for testing, not production.
      • parseStaticCurrency

        public static CurrencyAmount parseStaticCurrency​(java.lang.String input,
                                                         java.text.ParsePosition ppos,
                                                         DecimalFormatProperties properties,
                                                         DecimalFormatSymbols symbols)
        Parses the string without returning a NumberParserImpl. Used for testing, not production.
      • createParserFromProperties

        public static NumberParserImpl createParserFromProperties​(DecimalFormatProperties properties,
                                                                  DecimalFormatSymbols symbols,
                                                                  boolean parseCurrency)
        Creates a parser from the given DecimalFormatProperties. This is the endpoint used by DecimalFormat in production code.
        Parameters:
        properties - The property bag.
        symbols - The locale's symbols.
        parseCurrency - True to force a currency match and use monetary separators; false otherwise.
        Returns:
        An immutable parser object.
      • addMatchers

        public void addMatchers​(java.util.Collection<? extends NumberParseMatcher> matchers)
      • freeze

        public void freeze()
      • getParseFlags

        public int getParseFlags()
      • parse

        public void parse​(java.lang.String input,
                          boolean greedy,
                          ParsedNumber result)
      • parse

        public void parse​(java.lang.String input,
                          int start,
                          boolean greedy,
                          ParsedNumber result)
        Primary entrypoint to parsing code path.
        Parameters:
        input - The string to parse. This is a String, not CharSequence, to enforce assumptions about immutability (CharSequences are not guaranteed to be immutable).
        start - The index into the string at which to start parsing.
        greedy - Whether to use the faster but potentially less accurate greedy code path.
        result - Output variable to store results.
      • parseLongestRecursive

        private void parseLongestRecursive​(StringSegment segment,
                                           ParsedNumber result,
                                           int recursionLevels)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object