NamedNodeMapImpl.java
2.84 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.dom;
import com.adobe.xfa.dom.NodeImpl;
import com.adobe.xfa.dom.NodeListImpl;
import com.adobe.xfa.ut.StringUtils;
import java.util.HashMap;
import java.util.Map;
import org.w3c.dom.DOMException;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
class NamedNodeMapImpl
extends NodeListImpl
implements NamedNodeMap {
private final Map<NodeKey, NodeImpl> mNameMap = new HashMap<NodeKey, NodeImpl>();
private final Map<NodeKey, NodeImpl> mNSMap = new HashMap<NodeKey, NodeImpl>();
NamedNodeMapImpl(int initialCapacity) {
super(initialCapacity);
}
@Override
public Node getNamedItem(String name) {
return this.mNameMap.get(new NodeKey(name));
}
@Override
public Node getNamedItemNS(String namespaceURI, String localName) throws DOMException {
return this.mNSMap.get(new NodeKey(namespaceURI, localName));
}
@Override
public Node removeNamedItem(String name) throws DOMException {
throw new DOMException(7, "");
}
@Override
public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
throw new DOMException(7, "");
}
@Override
public Node setNamedItem(Node arg) throws DOMException {
throw new DOMException(7, "");
}
@Override
public Node setNamedItemNS(Node arg) throws DOMException {
throw new DOMException(7, "");
}
@Override
void addNode(NodeImpl node) {
String ns;
super.addNode(node);
String name = node.getNodeName();
if (name != null) {
this.mNameMap.put(new NodeKey(name), node);
}
if ((ns = node.getNamespaceURI()) != null) {
this.mNSMap.put(new NodeKey(ns, node.getLocalName()), node);
}
}
private static final class NodeKey {
final String mFirst;
final String mSecond;
NodeKey(String first, String second) {
this.mFirst = first;
this.mSecond = second;
}
NodeKey(String first) {
this.mFirst = first;
this.mSecond = null;
}
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (other == null) {
return false;
}
if (other.getClass() != NodeKey.class) {
return false;
}
NodeKey otherKey = (NodeKey)other;
return StringUtils.equalsWithNull(this.mFirst, otherKey.mFirst) && StringUtils.equalsWithNull(this.mSecond, otherKey.mSecond);
}
public int hashCode() {
int result = this.mFirst.hashCode();
if (this.mSecond != null) {
result ^= this.mSecond.hashCode();
}
return result;
}
}
}