• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 // © 2018 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 ohos.global.icu.impl.StringSegment;
7 
8 /**
9  * Matches a single code point, performing no other logic.
10  *
11  * @author sffc
12  * @hide exposed on OHOS
13  */
14 public class CodePointMatcher implements NumberParseMatcher {
15 
16     private final int cp;
17 
getInstance(int cp)18     public static CodePointMatcher getInstance(int cp) {
19         // TODO: Cache certain popular instances?
20         return new CodePointMatcher(cp);
21     }
22 
CodePointMatcher(int cp)23     private CodePointMatcher(int cp) {
24         this.cp = cp;
25     }
26 
27     @Override
match(StringSegment segment, ParsedNumber result)28     public boolean match(StringSegment segment, ParsedNumber result) {
29         if (segment.startsWith(cp)) {
30             segment.adjustOffsetByCodePoint();
31             result.setCharsConsumed(segment);
32         }
33         return false;
34     }
35 
36     @Override
smokeTest(StringSegment segment)37     public boolean smokeTest(StringSegment segment) {
38         return segment.startsWith(cp);
39     }
40 
41     @Override
postProcess(ParsedNumber result)42     public void postProcess(ParsedNumber result) {
43         // No-op
44     }
45 
46     @Override
toString()47     public String toString() {
48         return "<CodePointMatcher U+" + Integer.toHexString(cp) + ">";
49     }
50 
51 }
52