ArrayNodeList.java
4.63 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.NodeList;
import com.adobe.xfa.Obj;
import com.adobe.xfa.ut.ExFull;
import com.adobe.xfa.ut.ResId;
import java.util.ArrayList;
import java.util.List;
public final class ArrayNodeList
extends NodeList {
private final List<Node> mArray;
public ArrayNodeList() {
this.mArray = new ArrayList<Node>();
}
public ArrayNodeList(List<? extends Node> list) {
this.mArray = new ArrayList<Node>(list);
}
public ArrayNodeList(Element e) {
this.mArray = new ArrayList<Node>();
for (Node child = e.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
this.mArray.add(child);
}
}
@Override
public void append(Obj newNode) {
if (this.isReadOnly() || newNode == null) {
return;
}
if (!(newNode instanceof Node)) {
throw new ExFull(ResId.ArgumentMismatchException);
}
this.mArray.add((Node)newNode);
}
@Override
public Object clone() {
return new ArrayNodeList(this.mArray);
}
@Override
public String getClassAtom() {
return "nodeList";
}
@Override
public String getClassName() {
return "nodeList";
}
@Override
public Node getNamedItem(String name) {
if (name == null) {
return null;
}
String aName = name.intern();
int n = this.mArray.size();
for (int i = 0; i < n; ++i) {
Node child = this.mArray.get(i);
if (aName != child.getName()) continue;
return child;
}
return null;
}
@Override
public Node getNamedItem(String aName, String aClassName, int nTargetOccurrence) {
if (aName == null && aClassName == null) {
return null;
}
int nLength = this.length();
int nOccurrence = 0;
if (nTargetOccurrence > nLength) {
return null;
}
for (int i = 0; i < nLength; ++i) {
boolean bMatched = false;
Node tmp = (Node)this.item(i);
if (aName != null && aClassName != null) {
if (aClassName == tmp.getClassAtom() && aName == tmp.getName()) {
bMatched = true;
}
} else if (aClassName != null && aClassName == tmp.getClassAtom()) {
bMatched = true;
} else if (aName != null && aName == tmp.getName()) {
bMatched = true;
}
if (!bMatched) continue;
if (nOccurrence == nTargetOccurrence) {
return tmp;
}
++nOccurrence;
}
return null;
}
@Override
Integer getOccurrence(Node oNode) {
int nLength = this.length();
int nOccurrence = 0;
String aName = oNode.getName();
String aClassName = oNode.getClassAtom();
for (int i = 0; i < nLength; ++i) {
Node oTemp = this.mArray.get(i);
if (aClassName != oTemp.getClassAtom() || aName != oTemp.getName()) continue;
if (oNode == oTemp) {
return nOccurrence;
}
++nOccurrence;
}
return null;
}
@Override
public void insert(Obj newNode, Obj refNode) {
if (this.isReadOnly() || newNode == null) {
return;
}
if (refNode == null) {
throw new ExFull(ResId.InsertFailedException);
}
if (!(newNode instanceof Node)) {
throw new ExFull(ResId.ArgumentMismatchException);
}
if (!(refNode instanceof Node)) {
throw new ExFull(ResId.ArgumentMismatchException);
}
for (int i = 0; i < this.mArray.size(); ++i) {
if (this.mArray.get(i) != refNode) continue;
this.mArray.add(i, (Node)newNode);
}
}
@Override
public Obj item(int index) {
return this.mArray.get(index);
}
@Override
public int length() {
return this.mArray.size();
}
@Override
public void remove(Obj removeNode) {
if (this.isReadOnly() || removeNode == null) {
return;
}
if (!(removeNode instanceof Node)) {
throw new ExFull(ResId.ArgumentMismatchException);
}
this.mArray.remove(removeNode);
}
@Override
boolean appendPermsCheck() {
return true;
}
@Override
boolean removePermsCheck(Obj obj) {
return true;
}
@Override
boolean insertPermsCheck() {
return true;
}
}