CharTrie.java
4.7 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.agl.impl;
import com.adobe.agl.impl.Trie;
import com.adobe.agl.impl.UCharacterProperty;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
public class CharTrie
extends Trie {
private char m_initialValue_;
private char[] m_data_;
private FriendAgent m_friendAgent_;
public CharTrie(InputStream inputStream, Trie.DataManipulate dataManipulate) throws IOException {
super(inputStream, dataManipulate);
if (!this.isCharTrie()) {
throw new IllegalArgumentException("Data given does not belong to a char trie.");
}
this.m_friendAgent_ = new FriendAgent();
}
public CharTrie(int initialValue, int leadUnitValue, Trie.DataManipulate dataManipulate) {
int i;
super(new char[2080], 512, dataManipulate);
int latin1Length = 256;
int dataLength = 256;
if (leadUnitValue != initialValue) {
dataLength += 32;
}
this.m_data_ = new char[dataLength];
this.m_dataLength_ = dataLength;
this.m_initialValue_ = (char)initialValue;
for (i = 0; i < latin1Length; ++i) {
this.m_data_[i] = (char)initialValue;
}
if (leadUnitValue != initialValue) {
char block = (char)(latin1Length >> 2);
int limit = 1760;
for (i = 1728; i < limit; ++i) {
this.m_index_[i] = block;
}
limit = latin1Length + 32;
for (i = latin1Length; i < limit; ++i) {
this.m_data_[i] = (char)leadUnitValue;
}
}
this.m_friendAgent_ = new FriendAgent();
}
public void putIndexData(UCharacterProperty friend) {
friend.setIndexData(this.m_friendAgent_);
}
public final char getCodePointValue(int ch) {
if (0 <= ch && ch < 55296) {
int offset = (this.m_index_[ch >> 5] << 2) + (ch & 31);
return this.m_data_[offset];
}
int offset = this.getCodePointOffset(ch);
return offset >= 0 ? this.m_data_[offset] : this.m_initialValue_;
}
public final char getLeadValue(char ch) {
return this.m_data_[this.getLeadOffset(ch)];
}
public final char getBMPValue(char ch) {
return this.m_data_[this.getBMPOffset(ch)];
}
public final char getSurrogateValue(char lead, char trail) {
int offset = this.getSurrogateOffset(lead, trail);
if (offset > 0) {
return this.m_data_[offset];
}
return this.m_initialValue_;
}
public final char getTrailValue(int leadvalue, char trail) {
if (this.m_dataManipulate_ == null) {
throw new NullPointerException("The field DataManipulate in this Trie is null");
}
int offset = this.m_dataManipulate_.getFoldingOffset(leadvalue);
if (offset > 0) {
return this.m_data_[this.getRawOffset(offset, (char)(trail & 1023))];
}
return this.m_initialValue_;
}
public boolean equals(Object other) {
boolean result = super.equals(other);
if (result && other instanceof CharTrie) {
CharTrie othertrie = (CharTrie)other;
return this.m_initialValue_ == othertrie.m_initialValue_;
}
return false;
}
protected final void unserialize(InputStream inputStream) throws IOException {
DataInputStream input = new DataInputStream(inputStream);
int indexDataLength = this.m_dataOffset_ + this.m_dataLength_;
this.m_index_ = new char[indexDataLength];
for (int i = 0; i < indexDataLength; ++i) {
this.m_index_[i] = input.readChar();
}
this.m_data_ = this.m_index_;
this.m_initialValue_ = this.m_data_[this.m_dataOffset_];
}
protected final int getSurrogateOffset(char lead, char trail) {
if (this.m_dataManipulate_ == null) {
throw new NullPointerException("The field DataManipulate in this Trie is null");
}
int offset = this.m_dataManipulate_.getFoldingOffset(this.getLeadValue(lead));
if (offset > 0) {
return this.getRawOffset(offset, (char)(trail & 1023));
}
return -1;
}
protected final int getValue(int index) {
return this.m_data_[index];
}
protected final int getInitialValue() {
return this.m_initialValue_;
}
public class FriendAgent {
public char[] getPrivateIndex() {
return CharTrie.this.m_index_;
}
public char[] getPrivateData() {
return CharTrie.this.m_data_;
}
public int getPrivateInitialValue() {
return CharTrie.this.m_initialValue_;
}
}
}