• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 // © 2017 and later: Unicode, Inc. and others.
3 // License & terms of use: http://www.unicode.org/copyright.html#License
4 package ohos.global.icu.impl.number.parse;
5 
6 import static ohos.global.icu.impl.number.parse.ParsingUtils.safeContains;
7 
8 import ohos.global.icu.impl.StaticUnicodeSets;
9 import ohos.global.icu.impl.StringSegment;
10 import ohos.global.icu.text.DecimalFormatSymbols;
11 
12 /**
13  * @author sffc
14  * @hide exposed on OHOS
15  *
16  */
17 public class PlusSignMatcher extends SymbolMatcher {
18 
19     private static final PlusSignMatcher DEFAULT = new PlusSignMatcher(false);
20     private static final PlusSignMatcher DEFAULT_ALLOW_TRAILING = new PlusSignMatcher(true);
21 
getInstance(DecimalFormatSymbols symbols, boolean allowTrailing)22     public static PlusSignMatcher getInstance(DecimalFormatSymbols symbols, boolean allowTrailing) {
23         String symbolString = symbols.getPlusSignString();
24         if (safeContains(DEFAULT.uniSet, symbolString)) {
25             return allowTrailing ? DEFAULT_ALLOW_TRAILING : DEFAULT;
26         } else {
27             return new PlusSignMatcher(symbolString, allowTrailing);
28         }
29     }
30 
31     private final boolean allowTrailing;
32 
PlusSignMatcher(String symbolString, boolean allowTrailing)33     private PlusSignMatcher(String symbolString, boolean allowTrailing) {
34         super(symbolString, DEFAULT.uniSet);
35         this.allowTrailing = allowTrailing;
36     }
37 
PlusSignMatcher(boolean allowTrailing)38     private PlusSignMatcher(boolean allowTrailing) {
39         super(StaticUnicodeSets.Key.PLUS_SIGN);
40         this.allowTrailing = allowTrailing;
41     }
42 
43     @Override
isDisabled(ParsedNumber result)44     protected boolean isDisabled(ParsedNumber result) {
45         return !allowTrailing && result.seenNumber();
46     }
47 
48     @Override
accept(StringSegment segment, ParsedNumber result)49     protected void accept(StringSegment segment, ParsedNumber result) {
50         result.setCharsConsumed(segment);
51     }
52 
53     @Override
toString()54     public String toString() {
55         return "<PlusSignMatcher>";
56     }
57 
58 }
59