Package com.ibm.icu.impl.number.parse
Class CombinedCurrencyMatcher
- java.lang.Object
-
- com.ibm.icu.impl.number.parse.CombinedCurrencyMatcher
-
- All Implemented Interfaces:
NumberParseMatcher
public class CombinedCurrencyMatcher extends java.lang.Object implements NumberParseMatcher
Matches a currency, either a custom currency or one from the data bundle. The class is called "combined" to emphasize that the currency string may come from one of multiple sources. Will match currency spacing either before or after the number depending on whether we are currently in the prefix or suffix. The implementation of this class is slightly different between J and C. See #13584 for a follow-up.
-
-
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 private java.lang.String
afterPrefixInsert
private java.lang.String
beforeSuffixInsert
private java.lang.String
currency1
private java.lang.String
currency2
private java.lang.String
isoCode
private java.lang.String[]
localLongNames
private TextTrieMap<Currency.CurrencyStringInfo>
longNameTrie
private TextTrieMap<Currency.CurrencyStringInfo>
symbolTrie
-
Constructor Summary
Constructors Modifier Constructor Description private
CombinedCurrencyMatcher(Currency currency, DecimalFormatSymbols dfs, int parseFlags)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CombinedCurrencyMatcher
getInstance(Currency currency, DecimalFormatSymbols dfs, int parseFlags)
boolean
match(StringSegment segment, ParsedNumber result)
Runs this matcher starting at the beginning of the given StringSegment.private boolean
matchCurrency(StringSegment segment, ParsedNumber result)
Matches the currency string without concern for currency spacing.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
-
isoCode
private final java.lang.String isoCode
-
currency1
private final java.lang.String currency1
-
currency2
private final java.lang.String currency2
-
localLongNames
private final java.lang.String[] localLongNames
-
afterPrefixInsert
private final java.lang.String afterPrefixInsert
-
beforeSuffixInsert
private final java.lang.String beforeSuffixInsert
-
longNameTrie
private final TextTrieMap<Currency.CurrencyStringInfo> longNameTrie
-
symbolTrie
private final TextTrieMap<Currency.CurrencyStringInfo> symbolTrie
-
-
Constructor Detail
-
CombinedCurrencyMatcher
private CombinedCurrencyMatcher(Currency currency, DecimalFormatSymbols dfs, int parseFlags)
-
-
Method Detail
-
getInstance
public static CombinedCurrencyMatcher getInstance(Currency currency, DecimalFormatSymbols dfs, int parseFlags)
-
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.
-
matchCurrency
private boolean matchCurrency(StringSegment segment, ParsedNumber result)
Matches the currency string without concern for currency spacing.
-
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.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-