1
2
3
4
5
6
7
8
9
10 package org.dom4j.dom;
11
12 import org.dom4j.Element;
13 import org.dom4j.tree.DefaultEntity;
14 import org.w3c.dom.DOMException;
15 import org.w3c.dom.Document;
16 import org.w3c.dom.NamedNodeMap;
17 import org.w3c.dom.NodeList;
18
19 /*** <p><code>DOMEntity</code> implements a Entity node which
20 * supports the W3C DOM API.</p>
21 *
22 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
23 * @version $Revision: 1.10 $
24 */
25 public class DOMEntityReference extends DefaultEntity implements org.w3c.dom.EntityReference {
26
27 public DOMEntityReference(String name) {
28 super( name );
29 }
30
31 public DOMEntityReference(String name, String text) {
32 super( name, text );
33 }
34
35 public DOMEntityReference(Element parent, String name, String text) {
36 super( parent, name, text );
37 }
38
39
40
41
42 public boolean supports(String feature, String version) {
43 return DOMNodeHelper.supports(this, feature, version);
44 }
45
46 public String getNamespaceURI() {
47 return DOMNodeHelper.getNamespaceURI(this);
48 }
49
50 public String getPrefix() {
51 return DOMNodeHelper.getPrefix(this);
52 }
53
54 public void setPrefix(String prefix) throws DOMException {
55 DOMNodeHelper.setPrefix(this, prefix);
56 }
57
58 public String getLocalName() {
59 return DOMNodeHelper.getLocalName(this);
60 }
61
62 public String getNodeName() {
63 return getName();
64 }
65
66
67
68
69
70
71
72 public String getNodeValue() throws DOMException {
73 return null;
74 }
75
76 public void setNodeValue(String nodeValue) throws DOMException {
77 }
78
79
80 public org.w3c.dom.Node getParentNode() {
81 return DOMNodeHelper.getParentNode(this);
82 }
83
84 public NodeList getChildNodes() {
85 return DOMNodeHelper.getChildNodes(this);
86 }
87
88 public org.w3c.dom.Node getFirstChild() {
89 return DOMNodeHelper.getFirstChild(this);
90 }
91
92 public org.w3c.dom.Node getLastChild() {
93 return DOMNodeHelper.getLastChild(this);
94 }
95
96 public org.w3c.dom.Node getPreviousSibling() {
97 return DOMNodeHelper.getPreviousSibling(this);
98 }
99
100 public org.w3c.dom.Node getNextSibling() {
101 return DOMNodeHelper.getNextSibling(this);
102 }
103
104 public NamedNodeMap getAttributes() {
105 return null;
106 }
107
108 public Document getOwnerDocument() {
109 return DOMNodeHelper.getOwnerDocument(this);
110 }
111
112 public org.w3c.dom.Node insertBefore(
113 org.w3c.dom.Node newChild,
114 org.w3c.dom.Node refChild
115 ) throws DOMException {
116 checkNewChildNode(newChild);
117 return DOMNodeHelper.insertBefore(this, newChild, refChild);
118 }
119
120 public org.w3c.dom.Node replaceChild(
121 org.w3c.dom.Node newChild,
122 org.w3c.dom.Node oldChild
123 ) throws DOMException {
124 checkNewChildNode(newChild);
125 return DOMNodeHelper.replaceChild(this, newChild, oldChild);
126 }
127
128 public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws DOMException {
129 return DOMNodeHelper.removeChild(this, oldChild);
130 }
131
132 public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException {
133 checkNewChildNode(newChild);
134 return DOMNodeHelper.appendChild(this, newChild);
135 }
136
137 private void checkNewChildNode(org.w3c.dom.Node newChild) throws DOMException {
138 final int nodeType = newChild.getNodeType();
139 if (!(nodeType == org.w3c.dom.Node.ELEMENT_NODE ||
140 nodeType == org.w3c.dom.Node.TEXT_NODE ||
141 nodeType == org.w3c.dom.Node.COMMENT_NODE ||
142 nodeType == org.w3c.dom.Node.PROCESSING_INSTRUCTION_NODE ||
143 nodeType == org.w3c.dom.Node.CDATA_SECTION_NODE ||
144 nodeType == org.w3c.dom.Node.ENTITY_REFERENCE_NODE)) {
145 throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
146 "Specified node cannot be a child of an entity reference");
147 }
148 }
149
150
151 public boolean hasChildNodes() {
152 return DOMNodeHelper.hasChildNodes(this);
153 }
154
155 public org.w3c.dom.Node cloneNode(boolean deep) {
156 return DOMNodeHelper.cloneNode(this, deep);
157 }
158
159 public void normalize() {
160 DOMNodeHelper.normalize(this);
161 }
162
163 public boolean isSupported(String feature, String version) {
164 return DOMNodeHelper.isSupported(this, feature, version);
165 }
166
167 public boolean hasAttributes() {
168 return DOMNodeHelper.hasAttributes(this);
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
217
218