1
22
23 package com.liferay.portal.xml;
24
25 import com.liferay.portal.kernel.xml.Attribute;
26 import com.liferay.portal.kernel.xml.CDATA;
27 import com.liferay.portal.kernel.xml.Element;
28 import com.liferay.portal.kernel.xml.Entity;
29 import com.liferay.portal.kernel.xml.Namespace;
30 import com.liferay.portal.kernel.xml.Node;
31 import com.liferay.portal.kernel.xml.QName;
32 import com.liferay.portal.kernel.xml.Text;
33
34 import java.util.Iterator;
35 import java.util.List;
36 import java.util.Map;
37
38
44 public class ElementImpl extends BranchImpl implements Element {
45
46 public ElementImpl(org.dom4j.Element element) {
47 super(element);
48
49 _element = element;
50 }
51
52 public void add(Attribute attribute) {
53 AttributeImpl attributeImpl = (AttributeImpl)attribute;
54
55 _element.add(attributeImpl.getWrappedAttribute());
56 }
57
58 public void add(CDATA cdata) {
59 CDATAImpl cdataImpl = (CDATAImpl)cdata;
60
61 _element.add(cdataImpl.getWrappedCDATA());
62 }
63
64 public void add(Entity entity) {
65 EntityImpl entityImpl = (EntityImpl)entity;
66
67 _element.add(entityImpl.getWrappedEntity());
68 }
69
70 public void add(Namespace namespace) {
71 NamespaceImpl namespaceImpl = (NamespaceImpl)namespace;
72
73 _element.add(namespaceImpl.getWrappedNamespace());
74 }
75
76 public void add(Text text) {
77 TextImpl textImpl = (TextImpl)text;
78
79 _element.add(textImpl.getWrappedText());
80 }
81
82 public Element addAttribute(QName qName, String value) {
83 QNameImpl qNameImpl = (QNameImpl)qName;
84
85 return new ElementImpl(
86 _element.addAttribute(qNameImpl.getWrappedQName(), value));
87 }
88
89 public Element addAttribute(String name, String value) {
90 return new ElementImpl(_element.addAttribute(name, value));
91 }
92
93 public Element addCDATA(String cdata) {
94 return new ElementImpl(_element.addCDATA(cdata));
95 }
96
97 public Element addComment(String comment) {
98 return new ElementImpl(_element.addComment(comment));
99 }
100
101 public Element addEntity(String name, String text) {
102 return new ElementImpl(_element.addEntity(name, text));
103 }
104
105 public Element addNamespace(String prefix, String uri) {
106 return new ElementImpl(_element.addNamespace(prefix, uri));
107 }
108
109 public Element addProcessingInstruction(
110 String target, Map<String, String> data) {
111
112 return new ElementImpl(_element.addProcessingInstruction(target, data));
113 }
114
115 public Element addProcessingInstruction(String target, String data) {
116 return new ElementImpl(_element.addProcessingInstruction(target, data));
117 }
118
119 public Element addText(String text) {
120 return new ElementImpl(_element.addText(text));
121 }
122
123 public List<Namespace> additionalNamespaces() {
124 return SAXReaderImpl.toNewNamespaces(_element.additionalNamespaces());
125 }
126
127 public void appendAttributes(Element element) {
128 ElementImpl elementImpl = (ElementImpl)element;
129
130 _element.appendAttributes(elementImpl.getWrappedElement());
131 }
132
133 public Attribute attribute(int index) {
134 org.dom4j.Attribute attribute = _element.attribute(index);
135
136 if (attribute == null) {
137 return null;
138 }
139 else {
140 return new AttributeImpl(attribute);
141 }
142 }
143
144 public Attribute attribute(QName qName) {
145 QNameImpl qNameImpl = (QNameImpl)qName;
146
147 org.dom4j.Attribute attribute = _element.attribute(
148 qNameImpl.getWrappedQName());
149
150 if (attribute == null) {
151 return null;
152 }
153 else {
154 return new AttributeImpl(attribute);
155 }
156 }
157
158 public Attribute attribute(String name) {
159 org.dom4j.Attribute attribute = _element.attribute(name);
160
161 if (attribute == null) {
162 return null;
163 }
164 else {
165 return new AttributeImpl(attribute);
166 }
167 }
168
169 public int attributeCount() {
170 return _element.attributeCount();
171 }
172
173 public Iterator<Attribute> attributeIterator() {
174 return attributes().iterator();
175 }
176
177 public String attributeValue(QName qName) {
178 QNameImpl qNameImpl = (QNameImpl)qName;
179
180 return _element.attributeValue(qNameImpl.getWrappedQName());
181 }
182
183 public String attributeValue(QName qName, String defaultValue) {
184 QNameImpl qNameImpl = (QNameImpl)qName;
185
186 return _element.attributeValue(
187 qNameImpl.getWrappedQName(), defaultValue);
188 }
189
190 public String attributeValue(String name) {
191 return _element.attributeValue(name);
192 }
193
194 public String attributeValue(String name, String defaultValue) {
195 return _element.attributeValue(name, defaultValue);
196 }
197
198 public List<Attribute> attributes() {
199 return SAXReaderImpl.toNewAttributes(_element.attributes());
200 }
201
202 public Element createCopy() {
203 return new ElementImpl(_element.createCopy());
204 }
205
206 public Element createCopy(QName qName) {
207 QNameImpl qNameImpl = (QNameImpl)qName;
208
209 return new ElementImpl(
210 _element.createCopy(qNameImpl.getWrappedQName()));
211 }
212
213 public Element createCopy(String name) {
214 return new ElementImpl(_element.createCopy(name));
215 }
216
217 public List<Namespace> declaredNamespaces() {
218 return SAXReaderImpl.toNewNamespaces(_element.declaredNamespaces());
219 }
220
221 public Element element(QName qName) {
222 QNameImpl qNameImpl = (QNameImpl)qName;
223
224 org.dom4j.Element element = _element.element(
225 qNameImpl.getWrappedQName());
226
227 if (element == null) {
228 return null;
229 }
230 else {
231 return new ElementImpl(element);
232 }
233 }
234
235 public Element element(String name) {
236 org.dom4j.Element element = _element.element(name);
237
238 if (element == null) {
239 return null;
240 }
241 else {
242 return new ElementImpl(element);
243 }
244 }
245
246 public Iterator<Element> elementIterator() {
247 return elements().iterator();
248 }
249
250 public Iterator<Element> elementIterator(QName qName) {
251 return elements(qName).iterator();
252 }
253
254 public Iterator<Element> elementIterator(String name) {
255 return elements(name).iterator();
256 }
257
258 public String elementText(QName qName) {
259 QNameImpl qNameImpl = (QNameImpl)qName;
260
261 return _element.elementText(qNameImpl.getWrappedQName());
262 }
263
264 public String elementText(String name) {
265 return _element.elementText(name);
266 }
267
268 public String elementTextTrim(QName qName) {
269 QNameImpl qNameImpl = (QNameImpl)qName;
270
271 return _element.elementTextTrim(qNameImpl.getWrappedQName());
272 }
273
274 public String elementTextTrim(String name) {
275 return _element.elementTextTrim(name);
276 }
277
278 public List<Element> elements() {
279 return SAXReaderImpl.toNewElements(_element.elements());
280 }
281
282 public List<Element> elements(QName qName) {
283 QNameImpl qNameImpl = (QNameImpl)qName;
284
285 return SAXReaderImpl.toNewElements(
286 _element.elements(qNameImpl.getWrappedQName()));
287 }
288
289 public List<Element> elements(String name) {
290 return SAXReaderImpl.toNewElements(_element.elements(name));
291 }
292
293 public boolean equals(Object obj) {
294 org.dom4j.Element element = ((ElementImpl)obj).getWrappedElement();
295
296 return _element.equals(element);
297 }
298
299 public Object getData() {
300 return _element.getData();
301 }
302
303 public Namespace getNamespace() {
304 org.dom4j.Namespace namespace = _element.getNamespace();
305
306 if (namespace == null) {
307 return null;
308 }
309 else {
310 return new NamespaceImpl(namespace);
311 }
312 }
313
314 public Namespace getNamespaceForPrefix(String prefix) {
315 org.dom4j.Namespace namespace = _element.getNamespaceForPrefix(prefix);
316
317 if (namespace == null) {
318 return null;
319 }
320 else {
321 return new NamespaceImpl(namespace);
322 }
323 }
324
325 public Namespace getNamespaceForURI(String uri) {
326 org.dom4j.Namespace namespace = _element.getNamespaceForURI(uri);
327
328 if (namespace == null) {
329 return null;
330 }
331 else {
332 return new NamespaceImpl(namespace);
333 }
334 }
335
336 public String getNamespacePrefix() {
337 return _element.getNamespacePrefix();
338 }
339
340 public String getNamespaceURI() {
341 return _element.getNamespaceURI();
342 }
343
344 public List<Namespace> getNamespacesForURI(String uri) {
345 return SAXReaderImpl.toNewNamespaces(_element.getNamespacesForURI(uri));
346 }
347
348 public QName getQName() {
349 org.dom4j.QName qName = _element.getQName();
350
351 if (qName == null) {
352 return null;
353 }
354 else {
355 return new QNameImpl(qName);
356 }
357 }
358
359 public QName getQName(String qualifiedName) {
360 org.dom4j.QName qName = _element.getQName(qualifiedName);
361
362 if (qName == null) {
363 return null;
364 }
365 else {
366 return new QNameImpl(qName);
367 }
368 }
369
370 public String getQualifiedName() {
371 return _element.getQualifiedName();
372 }
373
374 public String getTextTrim() {
375 return _element.getTextTrim();
376 }
377
378 public org.dom4j.Element getWrappedElement() {
379 return _element;
380 }
381
382 public Node getXPathResult(int index) {
383 org.dom4j.Node node = _element.getXPathResult(index);
384
385 if (node == null) {
386 return null;
387 }
388 else {
389 return new NodeImpl(node);
390 }
391 }
392
393 public int hashCode() {
394 return _element.hashCode();
395 }
396
397 public boolean hasMixedContent() {
398 return _element.hasMixedContent();
399 }
400
401 public boolean isRootElement() {
402 return _element.isRootElement();
403 }
404
405 public boolean isTextOnly() {
406 return _element.isTextOnly();
407 }
408
409 public boolean remove(Attribute attribute) {
410 AttributeImpl attributeImpl = (AttributeImpl)attribute;
411
412 return _element.remove(attributeImpl.getWrappedAttribute());
413 }
414
415 public boolean remove(CDATA cdata) {
416 CDATAImpl cdataImpl = (CDATAImpl)cdata;
417
418 return _element.remove(cdataImpl.getWrappedCDATA());
419 }
420
421 public boolean remove(Entity entity) {
422 EntityImpl entityImpl = (EntityImpl)entity;
423
424 return _element.remove(entityImpl.getWrappedEntity());
425 }
426
427 public boolean remove(Namespace namespace) {
428 NamespaceImpl namespaceImpl = (NamespaceImpl)namespace;
429
430 return _element.remove(namespaceImpl.getWrappedNamespace());
431 }
432
433 public boolean remove(Text text) {
434 TextImpl textImpl = (TextImpl)text;
435
436 return _element.remove(textImpl.getWrappedText());
437 }
438
439 public void setAttributes(List<Attribute> attributes) {
440 _element.setAttributes(SAXReaderImpl.toOldAttributes(attributes));
441 }
442
443 public void setData(Object data) {
444 _element.setData(data);
445 }
446
447 public void setQName(QName qName) {
448 QNameImpl qNameImpl = (QNameImpl)qName;
449
450 _element.setQName(qNameImpl.getWrappedQName());
451 }
452
453 private org.dom4j.Element _element;
454
455 }