ParentNode.java
6.44 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.dom;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.dom.NodeImpl;
import com.adobe.xfa.dom.NodeListImpl;
import com.adobe.xfa.dom.XFANodeHolder;
import org.w3c.dom.DOMException;
import org.w3c.dom.NodeList;
abstract class ParentNode
extends XFANodeHolder {
private XFANodeHolder mFirstChild;
private XFANodeHolder mLastChild;
private final Element mXFAElement;
ParentNode(ParentNode parent, Element newElement) {
super(parent, newElement);
this.mXFAElement = newElement;
}
@Override
public NodeList getChildNodes() {
this.fillAllChildren();
NodeListImpl nodeList = new NodeListImpl(this.getXFAElement().getNumAttrs());
nodeList.addNodes(this.getFirstChildImpl());
return nodeList;
}
@Override
public org.w3c.dom.Node getFirstChild() {
this.fillChildrenFromStart();
return this.mFirstChild;
}
@Override
public org.w3c.dom.Node getLastChild() {
this.fillChildrenToEnd();
return this.mLastChild;
}
@Override
public boolean hasChildNodes() {
return this.mXFAElement.getFirstXMLChild() != null;
}
@Override
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException {
throw new DOMException(7, "");
}
@Override
public boolean isEqualNode(org.w3c.dom.Node other) {
if (other == null) {
return false;
}
if (!(other instanceof ParentNode)) {
return false;
}
ParentNode otherParent = (ParentNode)other;
this.fillAllChildren();
otherParent.fillAllChildren();
NodeImpl thisChild = this.getFirstChildImpl();
NodeImpl otherChild = otherParent.getFirstChildImpl();
do {
if (thisChild == null) {
if (otherChild == null) break;
return false;
}
if (otherChild == null) {
return false;
}
if (!thisChild.isEqualNode(otherChild)) {
return false;
}
thisChild = thisChild.getNext();
otherChild = otherChild.getNext();
} while (true);
return true;
}
@Override
public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldCcild) throws DOMException {
throw new DOMException(7, "");
}
@Override
public org.w3c.dom.Node replaceChild(org.w3c.dom.Node oldChild, org.w3c.dom.Node newChild) throws DOMException {
throw new DOMException(7, "");
}
final XFANodeHolder createNode(Node source) {
return ParentNode.createNode(this, source);
}
abstract boolean testDefaultNamespace(String var1);
final void fillAllChildren() {
this.fillChildrenFromStart();
this.fillChildrenToEnd();
}
XFANodeHolder forcePrev(NodeImpl child) {
assert (child == this.mFirstChild);
this.fillChildrenFromStart();
NodeImpl prevNode = child.getPrev();
assert (prevNode == null || prevNode instanceof XFANodeHolder);
return (XFANodeHolder)prevNode;
}
XFANodeHolder forceNext(NodeImpl child) {
assert (child == this.mLastChild);
Node xfaChild = this.mLastChild.getXFANode();
Node xfaNext = xfaChild.getNextXMLSibling();
if (xfaNext == null) {
return null;
}
XFANodeHolder newChild = this.createNode(xfaNext);
newChild.setPrev(this.mLastChild);
this.mLastChild.setNext(newChild);
this.mLastChild = newChild;
return this.mLastChild;
}
final XFANodeHolder getFirstChildImpl() {
return this.mFirstChild;
}
final XFANodeHolder getLastChildImpl() {
return this.mLastChild;
}
final Element getXFAElement() {
return this.mXFAElement;
}
XFANodeHolder lookupXFAChild(Node xfaChild) {
this.fillAllChildren();
for (NodeImpl child = this.mFirstChild; child != null; child = child.getNext()) {
assert (child instanceof XFANodeHolder);
XFANodeHolder xfaNodeHolder = child;
if (xfaNodeHolder.getXFANode() != xfaChild) continue;
return xfaNodeHolder;
}
return null;
}
void setOnlyChild(XFANodeHolder child) {
assert (this.mFirstChild == null);
assert (this.mLastChild == null);
this.mFirstChild = child;
this.mLastChild = child;
}
private void fillChildrenFromStart() {
Node firstXFAChild = this.mXFAElement.getFirstXMLChild();
Node currentFirstXFAChild = null;
if (this.mFirstChild != null) {
currentFirstXFAChild = this.mFirstChild.getXFANode();
}
if (currentFirstXFAChild == firstXFAChild) {
return;
}
assert (firstXFAChild != null);
NodeImpl lastAdded = null;
XFANodeHolder firstAdded = null;
for (Node xfaNodeToAdd = firstXFAChild; xfaNodeToAdd != currentFirstXFAChild; xfaNodeToAdd = xfaNodeToAdd.getNextXMLSibling()) {
XFANodeHolder newNode = this.createNode(xfaNodeToAdd);
if (firstAdded == null) {
firstAdded = newNode;
} else {
assert (lastAdded != null);
lastAdded.setNext(newNode);
}
newNode.setPrev(lastAdded);
lastAdded = newNode;
if (this.mFirstChild == null) break;
assert (xfaNodeToAdd != null);
}
if (this.mFirstChild == null) {
this.mLastChild = lastAdded;
} else {
lastAdded.setNext(this.mFirstChild);
this.mFirstChild.setPrev(lastAdded);
}
this.mFirstChild = firstAdded;
}
private void fillChildrenToEnd() {
if (this.mLastChild == null) {
this.fillChildrenFromStart();
if (this.mLastChild == null) {
return;
}
}
while (this.forceNextChild() != null) {
}
}
private NodeImpl forceNextChild() {
Node xfaChild = this.mLastChild.getXFANode();
Node xfaNext = xfaChild.getNextXMLSibling();
if (xfaNext == null) {
return null;
}
XFANodeHolder newChild = this.createNode(xfaNext);
newChild.setPrev(this.mLastChild);
this.mLastChild.setNext(newChild);
this.mLastChild = newChild;
return this.mLastChild;
}
}