AFEVarAttr.java
4.83 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
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.text;
import com.adobe.xfa.text.AFEAttrMap;
import com.adobe.xfa.text.AFEAttrSet;
import com.adobe.xfa.ut.Storage;
import java.util.List;
class AFEVarAttr
extends AFEAttrSet {
private static final int INITIAL_ATTR_SIZE = 8;
private Storage<Object> mAttrs;
AFEVarAttr(AFEAttrMap afeAttrMap) {
super(afeAttrMap);
}
AFEVarAttr(AFEVarAttr source) {
super(source.getAFEAttrMap());
if (source.mAttrs != null) {
this.mAttrs = new Storage<Object>(source.mAttrs);
}
}
@Override
public int compareTo(AFEAttrSet compare) {
if (this == compare) {
return 0;
}
if (compare == null) {
throw new NullPointerException();
}
if (!(compare instanceof AFEVarAttr)) {
return -1;
}
AFEVarAttr attrSet = (AFEVarAttr)compare;
int attrCount = this.getAFEAttrMap().getAFEIndexCount();
block5 : for (int i = 0; i < attrCount; ++i) {
Object value1 = this.getAttr(i);
Object value2 = attrSet.getAttr(i);
switch (AFEVarAttr.nullCompare(value1, value2)) {
case 1: {
return -1;
}
case 2: {
return 1;
}
case 3: {
int h1 = value1.hashCode();
int h2 = value2.hashCode();
if (h1 < h2) {
return -1;
}
if (h1 > h2) {
return 1;
}
int cmp = value1.toString().compareTo(value2.toString());
if (cmp == 0) continue block5;
return cmp;
}
}
}
return 0;
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!super.equals(object)) {
return false;
}
AFEVarAttr other = (AFEVarAttr)object;
int attrCount = this.getAFEAttrMap().getAFEIndexCount();
block4 : for (int i = 0; i < attrCount; ++i) {
Object value1 = this.getAttr(i);
Object value2 = other.getAttr(i);
switch (AFEVarAttr.nullCompare(value1, value2)) {
case 1:
case 2: {
return false;
}
case 3: {
int h1 = value1.hashCode();
int h2 = value2.hashCode();
if (h1 != h2) {
return false;
}
if (value1.toString().equals(value2.toString())) continue block4;
return false;
}
}
}
return true;
}
public int hashCode() {
int hash = 13;
int attrCount = this.getAFEAttrMap().getAFEIndexCount();
hash = hash * 31 ^ attrCount;
for (int i = 0; i < attrCount; ++i) {
Object value = this.getAttr(i);
hash = hash * 31 ^ (value == null ? 0 : value.hashCode());
}
return hash;
}
@Override
Object getAttr(Object key) {
return this.getAttr(this.getAFEAttrMap().mapAFEIndex(key));
}
Object getAttr(int index) {
return this.mAttrs != null && index < this.mAttrs.size() ? this.mAttrs.get(index) : null;
}
@Override
boolean matchAttr(AFEAttrSet compare, Object attribute) {
Object o2;
assert (compare instanceof AFEVarAttr);
AFEVarAttr other = (AFEVarAttr)compare;
int index = this.getAFEAttrMap().mapAFEIndex(attribute);
Object o1 = this.getAttr(index);
return AFEVarAttr.nullCompare(o1, o2 = other.getAttr(index)) == 0;
}
void setAttr(Object key, Object value) {
this.setAttr(this.getAFEAttrMap().mapAFEIndex(key), value);
}
void setAttr(int index, Object value) {
if (this.mAttrs == null) {
this.mAttrs = new Storage(8);
}
if (index >= this.mAttrs.size()) {
this.mAttrs.setSize(index + 1);
}
this.mAttrs.set(index, value);
}
public String toString() {
StringBuilder result = new StringBuilder();
Object[] afeKeys = this.getAFEAttrMap().getAFEKeys();
int attrCount = this.mAttrs.size();
assert (attrCount <= afeKeys.length);
for (int i = 0; i < attrCount; ++i) {
Object value = this.mAttrs.get(i);
if (value == null) continue;
if (result.length() > 0) {
result.append(", ");
}
result.append(afeKeys[i].toString());
result.append(": ");
result.append(value.toString());
}
return result.toString();
}
}