TextImpl.java
2.03 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.dom;
import com.adobe.xfa.Chars;
import com.adobe.xfa.Node;
import com.adobe.xfa.dom.*;
import org.w3c.dom.DOMException;
import org.w3c.dom.Text;
class TextImpl
extends CharacterDataImpl
implements Text {
TextImpl(ParentNode parent, Chars newTextNode) {
super(parent, newTextNode, newTextNode.getData());
}
@Override
public String getWholeText() {
XFANodeHolder prevNode;
XFANodeHolder currentNode = this;
while ((prevNode = currentNode.forcePrev()) != null && TextImpl.isBenignNode(prevNode)) {
currentNode = prevNode;
}
StringBuilder textBuilder = new StringBuilder();
while (currentNode != null && TextImpl.isBenignNode(currentNode)) {
if (currentNode instanceof TextImpl) {
XFANodeHolder textNode = currentNode;
textBuilder.append(textNode.getCharacterData());
}
currentNode = currentNode.forceNext();
}
return textBuilder.toString();
}
@Override
public boolean isElementContentWhitespace() {
return false;
}
@Override
public boolean isEqualNode(org.w3c.dom.Node other) {
if (this == other) {
return true;
}
if (!super.isEqualNode(other)) {
return false;
}
if (!(other instanceof TextImpl)) {
return false;
}
return true;
}
@Override
public Text replaceWholeText(String content) throws DOMException {
throw new DOMException(7, "");
}
@Override
public Text splitText(int offset) throws DOMException {
throw new DOMException(7, "");
}
@Override
public String getNodeName() {
return "#text";
}
@Override
public short getNodeType() {
return 3;
}
private static boolean isBenignNode(NodeImpl node) {
return node instanceof TextImpl || node instanceof CommentImpl || node instanceof ProcessingInstructionImpl;
}
}