1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.xml;
21  
22  import com.liferay.portal.kernel.xml.Document;
23  import com.liferay.portal.kernel.xml.Element;
24  import com.liferay.util.xml.XMLFormatter;
25  
26  import java.io.IOException;
27  
28  /**
29   * <a href="DocumentImpl.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   *
33   */
34  public class DocumentImpl extends BranchImpl implements Document {
35  
36      public DocumentImpl(org.dom4j.Document document) {
37          super(document);
38  
39          _document = document;
40      }
41  
42      public Document addComment(String comment) {
43          _document.addComment(comment);
44  
45          return this;
46      }
47  
48      public Document addDocType(String name, String publicId, String systemId) {
49          _document.addDocType(name, publicId, systemId);
50  
51          return this;
52      }
53  
54      public boolean equals(Object obj) {
55          org.dom4j.Document document = ((DocumentImpl)obj).getWrappedDocument();
56  
57          return _document.equals(document);
58      }
59  
60      public String formattedString() throws IOException {
61          return XMLFormatter.toString(_document);
62      }
63  
64      public String formattedString(String indent) throws IOException {
65          return XMLFormatter.toString(_document, indent);
66      }
67  
68      public String formattedString(String indent, boolean expandEmptyElements)
69          throws IOException {
70  
71          return XMLFormatter.toString(_document, indent, expandEmptyElements);
72      }
73  
74      public Element getRootElement() {
75          return new ElementImpl(_document.getRootElement());
76      }
77  
78      public org.dom4j.Document getWrappedDocument() {
79          return _document;
80      }
81  
82      public String getXMLEncoding() {
83          return _document.getXMLEncoding();
84      }
85  
86      public int hashCode() {
87          return _document.hashCode();
88      }
89  
90      public void setRootElement(Element rootElement) {
91          ElementImpl rootElementImpl = (ElementImpl)rootElement;
92  
93          _document.setRootElement(rootElementImpl.getWrappedElement());
94      }
95  
96      public void setXMLEncoding(String encoding) {
97          _document.setXMLEncoding(encoding);
98      }
99  
100     private org.dom4j.Document _document;
101 
102 }