Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(571)

Unified Diff: icu4j/main/classes/core/src/com/ibm/icu/impl/number/parse/NanMatcher.java

Issue 335150043: Refreshing Number Parsing: ICU4J Base URL: svn+icussh://source.icu-project.org/repos/icu/trunk/
Patch Set: Replying to Andy feedback round one. See commit message. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b