Index: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/NanMatcher.java |
=================================================================== |
--- icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/NanMatcher.java (revision 0) |
+++ icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/NanMatcher.java (revision 40784) |
@@ -0,0 +1,61 @@ |
+// © 2017 and later: Unicode, Inc. and others. |
+// License & terms of use: http://www.unicode.org/copyright.html#License |
+package com.ibm.icu.impl.number.parse; |
+ |
+import com.ibm.icu.lang.UCharacter; |
+import com.ibm.icu.text.DecimalFormatSymbols; |
+import com.ibm.icu.text.UnicodeSet; |
+ |
+/** |
+ * @author sffc |
+ * |
+ */ |
+public class NanMatcher extends SymbolMatcher { |
+ |
+ private static final NanMatcher DEFAULT = new NanMatcher("NaN"); |
+ private static final NanMatcher DEFAULT_FOLDED = new NanMatcher(UCharacter.foldCase("NaN", true)); |
+ |
+ public static NanMatcher getInstance(DecimalFormatSymbols symbols, int parseFlags) { |
+ String symbolString = ParsingUtils.maybeFold(symbols.getNaN(), parseFlags); |
+ if (DEFAULT.string.equals(symbolString)) { |
+ return DEFAULT; |
+ } else if (DEFAULT_FOLDED.string.equals(symbolString)) { |
+ return DEFAULT_FOLDED; |
+ } else { |
+ return new NanMatcher(symbolString); |
+ } |
+ } |
+ |
+ private NanMatcher(String symbolString) { |
+ super(symbolString, UnicodeSet.EMPTY); |
+ } |
+ |
+ @Override |
+ public UnicodeSet getLeadCodePoints() { |
+ // Overriding this here to allow use of statically allocated sets |
+ if (this == DEFAULT) { |
+ return UnicodeSetStaticCache.get(UnicodeSetStaticCache.Key.CAPITAL_N); |
+ } else if (this == DEFAULT_FOLDED) { |
+ return UnicodeSetStaticCache.get(UnicodeSetStaticCache.Key.FOLDED_N); |
+ } else { |
+ return super.getLeadCodePoints(); |
+ } |
+ } |
+ |
+ @Override |
+ protected boolean isDisabled(ParsedNumber result) { |
+ return result.seenNumber(); |
+ } |
+ |
+ @Override |
+ protected void accept(StringSegment segment, ParsedNumber result) { |
+ result.flags |= ParsedNumber.FLAG_NAN; |
+ result.setCharsConsumed(segment); |
+ } |
+ |
+ @Override |
+ public String toString() { |
+ return "<NanMatcher>"; |
+ } |
+ |
+} |
Property changes on: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/NanMatcher.java |
___________________________________________________________________ |
Added: svn:mime-type |
## -0,0 +1 ## |
+text/plain;charset=utf-8 |
\ No newline at end of property |
Added: svn:eol-style |
## -0,0 +1 ## |
+native |
\ No newline at end of property |