OLD | NEW |
1 // © 2017 and later: Unicode, Inc. and others. | 1 // © 2017 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html#License | 2 // License & terms of use: http://www.unicode.org/copyright.html#License |
3 package com.ibm.icu.impl.number.parse; | 3 package com.ibm.icu.impl.number.parse; |
4 | 4 |
5 import com.ibm.icu.impl.StringSegment; | 5 import com.ibm.icu.impl.StringSegment; |
| 6 import com.ibm.icu.impl.StaticUnicodeSets; |
6 import com.ibm.icu.text.DecimalFormatSymbols; | 7 import com.ibm.icu.text.DecimalFormatSymbols; |
7 | 8 |
8 /** | 9 /** |
9 * @author sffc | 10 * @author sffc |
10 * | 11 * |
11 */ | 12 */ |
12 public class PlusSignMatcher extends SymbolMatcher { | 13 public class PlusSignMatcher extends SymbolMatcher { |
13 | 14 |
14 private static final PlusSignMatcher DEFAULT = new PlusSignMatcher(false); | 15 private static final PlusSignMatcher DEFAULT = new PlusSignMatcher(false); |
15 private static final PlusSignMatcher DEFAULT_ALLOW_TRAILING = new PlusSignMa
tcher(true); | 16 private static final PlusSignMatcher DEFAULT_ALLOW_TRAILING = new PlusSignMa
tcher(true); |
16 | 17 |
17 public static PlusSignMatcher getInstance(DecimalFormatSymbols symbols, bool
ean allowTrailing) { | 18 public static PlusSignMatcher getInstance(DecimalFormatSymbols symbols, bool
ean allowTrailing) { |
18 String symbolString = symbols.getPlusSignString(); | 19 String symbolString = symbols.getPlusSignString(); |
19 if (DEFAULT.uniSet.contains(symbolString)) { | 20 if (DEFAULT.uniSet.contains(symbolString)) { |
20 return allowTrailing ? DEFAULT_ALLOW_TRAILING : DEFAULT; | 21 return allowTrailing ? DEFAULT_ALLOW_TRAILING : DEFAULT; |
21 } else { | 22 } else { |
22 return new PlusSignMatcher(symbolString, allowTrailing); | 23 return new PlusSignMatcher(symbolString, allowTrailing); |
23 } | 24 } |
24 } | 25 } |
25 | 26 |
26 private final boolean allowTrailing; | 27 private final boolean allowTrailing; |
27 | 28 |
28 private PlusSignMatcher(String symbolString, boolean allowTrailing) { | 29 private PlusSignMatcher(String symbolString, boolean allowTrailing) { |
29 super(symbolString, DEFAULT.uniSet); | 30 super(symbolString, DEFAULT.uniSet); |
30 this.allowTrailing = allowTrailing; | 31 this.allowTrailing = allowTrailing; |
31 } | 32 } |
32 | 33 |
33 private PlusSignMatcher(boolean allowTrailing) { | 34 private PlusSignMatcher(boolean allowTrailing) { |
34 super(UnicodeSetStaticCache.Key.PLUS_SIGN); | 35 super(StaticUnicodeSets.Key.PLUS_SIGN); |
35 this.allowTrailing = allowTrailing; | 36 this.allowTrailing = allowTrailing; |
36 } | 37 } |
37 | 38 |
38 @Override | 39 @Override |
39 protected boolean isDisabled(ParsedNumber result) { | 40 protected boolean isDisabled(ParsedNumber result) { |
40 return !allowTrailing && result.seenNumber(); | 41 return !allowTrailing && result.seenNumber(); |
41 } | 42 } |
42 | 43 |
43 @Override | 44 @Override |
44 protected void accept(StringSegment segment, ParsedNumber result) { | 45 protected void accept(StringSegment segment, ParsedNumber result) { |
45 result.setCharsConsumed(segment); | 46 result.setCharsConsumed(segment); |
46 } | 47 } |
47 | 48 |
48 @Override | 49 @Override |
49 public String toString() { | 50 public String toString() { |
50 return "<PlusSignMatcher>"; | 51 return "<PlusSignMatcher>"; |
51 } | 52 } |
52 | 53 |
53 } | 54 } |
OLD | NEW |