Class NumberParserImpl

java.lang.Object
com.ibm.icu.impl.number.parse.NumberParserImpl

public class NumberParserImpl extends Object
Primary number parsing implementation class.
  • Field Details

    • parseFlags

      private final int parseFlags
    • matchers

      private final List<NumberParseMatcher> matchers
    • frozen

      private boolean frozen
  • Constructor Details

    • NumberParserImpl

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

    • createSimpleParser

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

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

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

      public static NumberParserImpl createDefaultParserForLocale(ULocale loc)
    • 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.
    • addMatcher

      public void addMatcher(NumberParseMatcher matcher)
    • addMatchers

      public void addMatchers(Collection<? extends NumberParseMatcher> matchers)
    • freeze

      public void freeze()
    • getParseFlags

      public int getParseFlags()
    • parse

      public void parse(String input, boolean greedy, ParsedNumber result)
    • parse

      public void parse(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.
    • parseGreedy

      private void parseGreedy(StringSegment segment, ParsedNumber result)
    • parseLongestRecursive

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

      public String toString()
      Overrides:
      toString in class Object