Class SymbolMatcher

java.lang.Object
com.ibm.icu.impl.number.parse.SymbolMatcher
All Implemented Interfaces:
NumberParseMatcher
Direct Known Subclasses:
IgnorablesMatcher, InfinityMatcher, MinusSignMatcher, NanMatcher, PaddingMatcher, PercentMatcher, PermilleMatcher, PlusSignMatcher

public abstract class SymbolMatcher extends Object implements NumberParseMatcher
A base class for many matchers that performs a simple match against a UnicodeString and/or UnicodeSet.
  • Field Details

    • string

      protected final String string
    • uniSet

      protected final UnicodeSet uniSet
  • Constructor Details

  • Method Details

    • getSet

      public UnicodeSet getSet()
    • match

      public boolean match(StringSegment segment, ParsedNumber result)
      Description copied from interface: NumberParseMatcher
      Runs this matcher starting at the beginning of the given StringSegment. If this matcher finds something interesting in the StringSegment, it should update the offset of the StringSegment corresponding to how many chars were matched.
      Specified by:
      match in interface NumberParseMatcher
      Parameters:
      segment - The StringSegment to match against. Matches always start at the beginning of the segment. The segment is guaranteed to contain at least one char.
      result - The data structure to store results if the match succeeds.
      Returns:
      Whether this matcher thinks there may be more interesting chars beyond the end of the string segment.
    • smokeTest

      public boolean smokeTest(StringSegment segment)
      Description copied from interface: NumberParseMatcher
      Performs a fast "smoke check" for whether or not this matcher could possibly match against the given string segment. The test should be as fast as possible but also as restrictive as possible. For example, matchers can maintain a UnicodeSet of all code points that count possibly start a match. Matchers should use the StringSegment.startsWith(int) method in order to correctly handle case folding.
      Specified by:
      smokeTest in interface NumberParseMatcher
      Parameters:
      segment - The segment to check against.
      Returns:
      true if the matcher might be able to match against this segment; false if it definitely will not be able to match.
    • postProcess

      public void postProcess(ParsedNumber result)
      Description copied from interface: NumberParseMatcher
      Method called at the end of a parse, after all matchers have failed to consume any more chars. Allows a matcher to make final modifications to the result given the knowledge that no more matches are possible.
      Specified by:
      postProcess in interface NumberParseMatcher
      Parameters:
      result - The data structure to store results.
    • isDisabled

      protected abstract boolean isDisabled(ParsedNumber result)
    • accept

      protected abstract void accept(StringSegment segment, ParsedNumber result)