1
22
23 package com.liferay.portal.xml;
24
25 import com.liferay.portal.kernel.xml.Document;
26 import com.liferay.portal.kernel.xml.Element;
27 import com.liferay.util.xml.XMLFormatter;
28
29 import java.io.IOException;
30
31
37 public class DocumentImpl extends BranchImpl implements Document {
38
39 public DocumentImpl(org.dom4j.Document document) {
40 super(document);
41
42 _document = document;
43 }
44
45 public Document addComment(String comment) {
46 _document.addComment(comment);
47
48 return this;
49 }
50
51 public Document addDocType(String name, String publicId, String systemId) {
52 _document.addDocType(name, publicId, systemId);
53
54 return this;
55 }
56
57 public boolean equals(Object obj) {
58 org.dom4j.Document document = ((DocumentImpl)obj).getWrappedDocument();
59
60 return _document.equals(document);
61 }
62
63 public String formattedString() throws IOException {
64 return XMLFormatter.toString(_document);
65 }
66
67 public String formattedString(String indent) throws IOException {
68 return XMLFormatter.toString(_document, indent);
69 }
70
71 public String formattedString(String indent, boolean expandEmptyElements)
72 throws IOException {
73
74 return XMLFormatter.toString(_document, indent, expandEmptyElements);
75 }
76
77 public Element getRootElement() {
78 return new ElementImpl(_document.getRootElement());
79 }
80
81 public org.dom4j.Document getWrappedDocument() {
82 return _document;
83 }
84
85 public String getXMLEncoding() {
86 return _document.getXMLEncoding();
87 }
88
89 public int hashCode() {
90 return _document.hashCode();
91 }
92
93 public void setRootElement(Element rootElement) {
94 ElementImpl rootElementImpl = (ElementImpl)rootElement;
95
96 _document.setRootElement(rootElementImpl.getWrappedElement());
97 }
98
99 public void setXMLEncoding(String encoding) {
100 _document.setXMLEncoding(encoding);
101 }
102
103 private org.dom4j.Document _document;
104
105 }