1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| package org.dom4j.dom; |
11 |
| |
12 |
| import org.dom4j.Element; |
13 |
| import org.dom4j.QName; |
14 |
| import org.dom4j.tree.DefaultAttribute; |
15 |
| import org.w3c.dom.DOMException; |
16 |
| import org.w3c.dom.Document; |
17 |
| import org.w3c.dom.NamedNodeMap; |
18 |
| import org.w3c.dom.NodeList; |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| public class DOMAttribute extends DefaultAttribute implements org.w3c.dom.Attr { |
27 |
| |
28 |
0
| public DOMAttribute(QName qname) {
|
29 |
0
| super(qname);
|
30 |
| } |
31 |
| |
32 |
176
| public DOMAttribute(QName qname, String value) {
|
33 |
176
| super(qname, value);
|
34 |
| } |
35 |
| |
36 |
0
| public DOMAttribute(Element parent, QName qname, String value) {
|
37 |
0
| super(parent, qname, value);
|
38 |
| } |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
0
| public boolean supports(String feature, String version) {
|
44 |
0
| return DOMNodeHelper.supports(this, feature, version);
|
45 |
| } |
46 |
| |
47 |
0
| public String getNamespaceURI() {
|
48 |
0
| return getQName().getNamespaceURI();
|
49 |
| } |
50 |
| |
51 |
0
| public String getPrefix() {
|
52 |
0
| return getQName().getNamespacePrefix();
|
53 |
| } |
54 |
| |
55 |
0
| public void setPrefix(String prefix) throws DOMException {
|
56 |
0
| DOMNodeHelper.setPrefix(this, prefix);
|
57 |
| } |
58 |
| |
59 |
0
| public String getLocalName() {
|
60 |
0
| return getQName().getName();
|
61 |
| } |
62 |
| |
63 |
0
| public String getNodeName() {
|
64 |
0
| return getName();
|
65 |
| } |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
| |
71 |
| |
72 |
| |
73 |
0
| public String getNodeValue() throws DOMException {
|
74 |
0
| return DOMNodeHelper.getNodeValue(this);
|
75 |
| } |
76 |
| |
77 |
0
| public void setNodeValue(String nodeValue) throws DOMException {
|
78 |
0
| DOMNodeHelper.setNodeValue(this, nodeValue);
|
79 |
| } |
80 |
| |
81 |
| |
82 |
0
| public org.w3c.dom.Node getParentNode() {
|
83 |
| |
84 |
| |
85 |
| |
86 |
0
| return null;
|
87 |
| } |
88 |
| |
89 |
0
| public NodeList getChildNodes() {
|
90 |
0
| return DOMNodeHelper.getChildNodes(this);
|
91 |
| } |
92 |
| |
93 |
0
| public org.w3c.dom.Node getFirstChild() {
|
94 |
0
| return DOMNodeHelper.getFirstChild(this);
|
95 |
| } |
96 |
| |
97 |
0
| public org.w3c.dom.Node getLastChild() {
|
98 |
0
| return DOMNodeHelper.getLastChild(this);
|
99 |
| } |
100 |
| |
101 |
0
| public org.w3c.dom.Node getPreviousSibling() {
|
102 |
0
| return DOMNodeHelper.getPreviousSibling(this);
|
103 |
| } |
104 |
| |
105 |
0
| public org.w3c.dom.Node getNextSibling() {
|
106 |
0
| return DOMNodeHelper.getNextSibling(this);
|
107 |
| } |
108 |
| |
109 |
0
| public NamedNodeMap getAttributes() {
|
110 |
0
| return null;
|
111 |
| } |
112 |
| |
113 |
0
| public Document getOwnerDocument() {
|
114 |
0
| return DOMNodeHelper.getOwnerDocument(this);
|
115 |
| } |
116 |
| |
117 |
0
| public org.w3c.dom.Node insertBefore(
|
118 |
| org.w3c.dom.Node newChild, |
119 |
| org.w3c.dom.Node refChild |
120 |
| ) throws DOMException { |
121 |
0
| checkNewChildNode(newChild);
|
122 |
0
| return DOMNodeHelper.insertBefore(this, newChild, refChild);
|
123 |
| } |
124 |
| |
125 |
0
| public org.w3c.dom.Node replaceChild(
|
126 |
| org.w3c.dom.Node newChild, |
127 |
| org.w3c.dom.Node oldChild |
128 |
| ) throws DOMException { |
129 |
0
| checkNewChildNode(newChild);
|
130 |
0
| return DOMNodeHelper.replaceChild(this, newChild, oldChild);
|
131 |
| } |
132 |
| |
133 |
0
| public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws DOMException {
|
134 |
0
| return DOMNodeHelper.removeChild(this, oldChild);
|
135 |
| } |
136 |
| |
137 |
0
| public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException {
|
138 |
0
| checkNewChildNode(newChild);
|
139 |
0
| return DOMNodeHelper.appendChild(this, newChild);
|
140 |
| } |
141 |
| |
142 |
0
| private void checkNewChildNode(org.w3c.dom.Node newChild) throws DOMException {
|
143 |
0
| final int nodeType = newChild.getNodeType();
|
144 |
0
| if (!(nodeType == org.w3c.dom.Node.TEXT_NODE ||
|
145 |
| nodeType == org.w3c.dom.Node.ENTITY_REFERENCE_NODE)) { |
146 |
0
| throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
|
147 |
| "Specified node cannot be a child of attribute"); |
148 |
| } |
149 |
| } |
150 |
| |
151 |
| |
152 |
0
| public boolean hasChildNodes() {
|
153 |
0
| return DOMNodeHelper.hasChildNodes(this);
|
154 |
| } |
155 |
| |
156 |
0
| public org.w3c.dom.Node cloneNode(boolean deep) {
|
157 |
0
| return DOMNodeHelper.cloneNode(this, deep);
|
158 |
| } |
159 |
| |
160 |
0
| public void normalize() {
|
161 |
0
| DOMNodeHelper.normalize(this);
|
162 |
| } |
163 |
| |
164 |
0
| public boolean isSupported(String feature, String version) {
|
165 |
0
| return DOMNodeHelper.isSupported(this, feature, version);
|
166 |
| } |
167 |
| |
168 |
0
| public boolean hasAttributes() {
|
169 |
0
| return DOMNodeHelper.hasAttributes(this);
|
170 |
| } |
171 |
| |
172 |
| |
173 |
| |
174 |
| |
175 |
| |
176 |
| |
177 |
| |
178 |
0
| public boolean getSpecified() {
|
179 |
0
| return true;
|
180 |
| } |
181 |
| |
182 |
| |
183 |
| |
184 |
| |
185 |
| |
186 |
0
| public org.w3c.dom.Element getOwnerElement() {
|
187 |
0
| return DOMNodeHelper.asDOMElement( getParent() );
|
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 |
| |
217 |
| |
218 |
| |
219 |
| |
220 |
| |
221 |
| |
222 |
| |
223 |
| |
224 |
| |
225 |
| |
226 |
| |
227 |
| |
228 |
| |
229 |
| |
230 |
| |
231 |
| |
232 |
| |
233 |
| |
234 |
| |
235 |
| |
236 |
| |
237 |
| |
238 |
| |