UniCharIterator.java
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.ut;
public class UniCharIterator {
private CharSequence mCharSequence;
private int mLength;
private int mIndex;
public UniCharIterator() {
}
public UniCharIterator(CharSequence charSequence) {
this.attach(charSequence);
}
public UniCharIterator(CharSequence charSequence, int index) {
this.attach(charSequence, index);
}
public static void append(StringBuilder s, int c) {
assert (c >= 0 && c <= 1114111);
if (c < 65536) {
s.append((char)c);
} else {
s.append((char)((c -= 65536) >> 10 | 55296));
s.append((char)(c & 1023 | 56320));
}
}
public void attach(CharSequence charSequence) {
this.attach(charSequence, 0);
}
public void attach(CharSequence charSequence, int index) {
this.mCharSequence = charSequence;
this.mLength = charSequence.length();
this.mIndex = index;
if (this.mIndex > this.mLength) {
this.mIndex = this.mLength;
}
}
public int getIndex() {
return this.mIndex;
}
public boolean isAtEnd() {
return this.mIndex >= this.mLength;
}
public boolean isAtStart() {
return this.mIndex == 0;
}
public int next() {
assert (this.mCharSequence != null);
if (this.mIndex >= this.mLength) {
return 0;
}
assert (this.mCharSequence != null);
int result = this.mCharSequence.charAt(this.mIndex++);
assert (result < 56320 || result > 57343);
if (result >= 55296 && result <= 56319) {
assert (this.mIndex < this.mLength);
char low = this.mCharSequence.charAt(this.mIndex++);
assert (low >= '\udc00' || low <= '\udfff');
result = result << 10 | low & 1023;
}
return result;
}
public int prev() {
if (this.mIndex <= 0) {
return 0;
}
assert (this.mCharSequence != null);
int result = this.mCharSequence.charAt(--this.mIndex);
assert (result < 55296 || result > 56319);
if (result >= 56320 && result <= 57343) {
assert (this.mIndex > 0);
char high = this.mCharSequence.charAt(--this.mIndex);
assert (high >= '\ud800' || high <= '\udbff');
result = high << 10 | result & 1023;
}
return result;
}
public void setIndex(int index) {
assert (index >= 0 && index <= this.mCharSequence.length());
this.mIndex = index;
}
public static String toString(int c) {
StringBuilder s = new StringBuilder();
UniCharIterator.append(s, c);
return s.toString();
}
}