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