001
014
015 package com.liferay.portal.xml;
016
017 import com.liferay.portal.kernel.xml.Document;
018 import com.liferay.portal.kernel.xml.Element;
019 import com.liferay.util.xml.XMLFormatter;
020
021 import java.io.IOException;
022
023
026 public class DocumentImpl extends BranchImpl implements Document {
027
028 public DocumentImpl(org.dom4j.Document document) {
029 super(document);
030
031 _document = document;
032 }
033
034 public Document addComment(String comment) {
035 _document.addComment(comment);
036
037 return this;
038 }
039
040 public Document addDocType(String name, String publicId, String systemId) {
041 _document.addDocType(name, publicId, systemId);
042
043 return this;
044 }
045
046 public boolean equals(Object obj) {
047 org.dom4j.Document document = ((DocumentImpl)obj).getWrappedDocument();
048
049 return _document.equals(document);
050 }
051
052 public String formattedString() throws IOException {
053 return XMLFormatter.toString(_document);
054 }
055
056 public String formattedString(String indent) throws IOException {
057 return XMLFormatter.toString(_document, indent);
058 }
059
060 public String formattedString(String indent, boolean expandEmptyElements)
061 throws IOException {
062
063 return XMLFormatter.toString(_document, indent, expandEmptyElements);
064 }
065
066 public Element getRootElement() {
067 return new ElementImpl(_document.getRootElement());
068 }
069
070 public org.dom4j.Document getWrappedDocument() {
071 return _document;
072 }
073
074 public String getXMLEncoding() {
075 return _document.getXMLEncoding();
076 }
077
078 public int hashCode() {
079 return _document.hashCode();
080 }
081
082 public void setRootElement(Element rootElement) {
083 ElementImpl rootElementImpl = (ElementImpl)rootElement;
084
085 _document.setRootElement(rootElementImpl.getWrappedElement());
086 }
087
088 public void setXMLEncoding(String encoding) {
089 _document.setXMLEncoding(encoding);
090 }
091
092 public String toString() {
093 return _document.toString();
094 }
095
096 private org.dom4j.Document _document;
097
098 }