1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.xml;
16  
17  import com.liferay.portal.kernel.xml.Document;
18  import com.liferay.portal.kernel.xml.Element;
19  import com.liferay.util.xml.XMLFormatter;
20  
21  import java.io.IOException;
22  
23  /**
24   * <a href="DocumentImpl.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class DocumentImpl extends BranchImpl implements Document {
29  
30      public DocumentImpl(org.dom4j.Document document) {
31          super(document);
32  
33          _document = document;
34      }
35  
36      public Document addComment(String comment) {
37          _document.addComment(comment);
38  
39          return this;
40      }
41  
42      public Document addDocType(String name, String publicId, String systemId) {
43          _document.addDocType(name, publicId, systemId);
44  
45          return this;
46      }
47  
48      public boolean equals(Object obj) {
49          org.dom4j.Document document = ((DocumentImpl)obj).getWrappedDocument();
50  
51          return _document.equals(document);
52      }
53  
54      public String formattedString() throws IOException {
55          return XMLFormatter.toString(_document);
56      }
57  
58      public String formattedString(String indent) throws IOException {
59          return XMLFormatter.toString(_document, indent);
60      }
61  
62      public String formattedString(String indent, boolean expandEmptyElements)
63          throws IOException {
64  
65          return XMLFormatter.toString(_document, indent, expandEmptyElements);
66      }
67  
68      public Element getRootElement() {
69          return new ElementImpl(_document.getRootElement());
70      }
71  
72      public org.dom4j.Document getWrappedDocument() {
73          return _document;
74      }
75  
76      public String getXMLEncoding() {
77          return _document.getXMLEncoding();
78      }
79  
80      public int hashCode() {
81          return _document.hashCode();
82      }
83  
84      public void setRootElement(Element rootElement) {
85          ElementImpl rootElementImpl = (ElementImpl)rootElement;
86  
87          _document.setRootElement(rootElementImpl.getWrappedElement());
88      }
89  
90      public void setXMLEncoding(String encoding) {
91          _document.setXMLEncoding(encoding);
92      }
93  
94      public String toString() {
95          return _document.toString();
96      }
97  
98      private org.dom4j.Document _document;
99  
100 }