Package com.ibm.icu.impl.number.parse
Class AffixMatcher
- java.lang.Object
-
- com.ibm.icu.impl.number.parse.AffixMatcher
-
- All Implemented Interfaces:
NumberParseMatcher
public class AffixMatcher extends java.lang.Object implements NumberParseMatcher
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.ibm.icu.impl.number.parse.NumberParseMatcher
NumberParseMatcher.Flexible
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<AffixMatcher>
COMPARATOR
Comparator for two AffixMatcher instances which prioritizes longer prefixes followed by longer suffixes, ensuring that the longest prefix/suffix pair is always chosen.private int
flags
private AffixPatternMatcher
prefix
private AffixPatternMatcher
suffix
-
Constructor Summary
Constructors Modifier Constructor Description private
AffixMatcher(AffixPatternMatcher prefix, AffixPatternMatcher suffix, int flags)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
createMatchers(AffixPatternProvider patternInfo, NumberParserImpl output, AffixTokenMatcherFactory factory, IgnorablesMatcher ignorables, int parseFlags)
boolean
equals(java.lang.Object _other)
private static AffixMatcher
getInstance(AffixPatternMatcher prefix, AffixPatternMatcher suffix, int flags)
int
hashCode()
private static boolean
isInteresting(AffixPatternProvider patternInfo, IgnorablesMatcher ignorables, int parseFlags)
private static int
length(AffixPatternMatcher matcher)
Helper method to return the length of the given AffixPatternMatcher.boolean
match(StringSegment segment, ParsedNumber result)
Runs this matcher starting at the beginning of the given StringSegment.(package private) static boolean
matched(AffixPatternMatcher affix, java.lang.String patternString)
Helper method to return whether the given AffixPatternMatcher equals the given pattern string.void
postProcess(ParsedNumber result)
Method called at the end of a parse, after all matchers have failed to consume any more chars.boolean
smokeTest(StringSegment segment)
Performs a fast "smoke check" for whether or not this matcher could possibly match against the given string segment.java.lang.String
toString()
-
-
-
Field Detail
-
prefix
private final AffixPatternMatcher prefix
-
suffix
private final AffixPatternMatcher suffix
-
flags
private final int flags
-
COMPARATOR
public static final java.util.Comparator<AffixMatcher> COMPARATOR
Comparator for two AffixMatcher instances which prioritizes longer prefixes followed by longer suffixes, ensuring that the longest prefix/suffix pair is always chosen.
-
-
Constructor Detail
-
AffixMatcher
private AffixMatcher(AffixPatternMatcher prefix, AffixPatternMatcher suffix, int flags)
-
-
Method Detail
-
isInteresting
private static boolean isInteresting(AffixPatternProvider patternInfo, IgnorablesMatcher ignorables, int parseFlags)
-
createMatchers
public static void createMatchers(AffixPatternProvider patternInfo, NumberParserImpl output, AffixTokenMatcherFactory factory, IgnorablesMatcher ignorables, int parseFlags)
-
getInstance
private static final AffixMatcher getInstance(AffixPatternMatcher prefix, AffixPatternMatcher suffix, int flags)
-
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 interfaceNumberParseMatcher
- 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 theStringSegment.startsWith(int)
method in order to correctly handle case folding.- Specified by:
smokeTest
in interfaceNumberParseMatcher
- 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 interfaceNumberParseMatcher
- Parameters:
result
- The data structure to store results.
-
matched
static boolean matched(AffixPatternMatcher affix, java.lang.String patternString)
Helper method to return whether the given AffixPatternMatcher equals the given pattern string. Either both arguments must be null or the pattern string inside the AffixPatternMatcher must equal the given pattern string.
-
length
private static int length(AffixPatternMatcher matcher)
Helper method to return the length of the given AffixPatternMatcher. Returns 0 for null.
-
equals
public boolean equals(java.lang.Object _other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-