1   
2   
3   
4   
5   
6   
7   
8   package org.dom4j;
9   
10  import java.util.Map;
11  
12  import org.xml.sax.EntityResolver;
13  
14  /***
15   * <p>
16   * <code>Document</code> defines an XML Document.
17   * </p>
18   * 
19   * @author <a href="mailto:jstrachan@apache.org">James Strachan </a>
20   * @version $Revision: 1.14 $
21   */
22  public interface Document extends Branch {
23      /***
24       * Returns the root {@link Element}for this document.
25       * 
26       * @return the root element for this document
27       */
28      Element getRootElement();
29  
30      /***
31       * Sets the root element for this document
32       * 
33       * @param rootElement
34       *            the new root element for this document
35       */
36      void setRootElement(Element rootElement);
37  
38      /***
39       * Adds a new <code>Comment</code> node with the given text to this
40       * branch.
41       * 
42       * @param comment
43       *            is the text for the <code>Comment</code> node.
44       * 
45       * @return this <code>Document</code> instance.
46       */
47      Document addComment(String comment);
48  
49      /***
50       * Adds a processing instruction for the given target
51       * 
52       * @param target
53       *            is the target of the processing instruction
54       * @param text
55       *            is the textual data (key/value pairs) of the processing
56       *            instruction
57       * 
58       * @return this <code>Document</code> instance.
59       */
60      Document addProcessingInstruction(String target, String text);
61  
62      /***
63       * Adds a processing instruction for the given target
64       * 
65       * @param target
66       *            is the target of the processing instruction
67       * @param data
68       *            is a Map of the key / value pairs of the processing
69       *            instruction
70       * 
71       * @return this <code>Document</code> instance.
72       */
73      Document addProcessingInstruction(String target, Map data);
74  
75      /***
76       * Adds a DOCTYPE declaration to this document
77       * 
78       * @param name
79       *            is the name of the root element
80       * @param publicId
81       *            is the PUBLIC URI
82       * @param systemId
83       *            is the SYSTEM URI
84       * 
85       * @return this <code>Document</code> instance.
86       */
87      Document addDocType(String name, String publicId, String systemId);
88  
89      /***
90       * DOCUMENT ME!
91       * 
92       * @return the DocumentType property
93       */
94      DocumentType getDocType();
95  
96      /***
97       * Sets the DocumentType property
98       * 
99       * @param docType
100      *            DOCUMENT ME!
101      */
102     void setDocType(DocumentType docType);
103 
104     /***
105      * DOCUMENT ME!
106      * 
107      * @return the EntityResolver used to find resolve URIs such as for DTDs, or
108      *         XML Schema documents
109      */
110     EntityResolver getEntityResolver();
111 
112     /***
113      * Sets the EntityResolver used to find resolve URIs such as for DTDs, or
114      * XML Schema documents
115      * 
116      * @param entityResolver
117      *            DOCUMENT ME!
118      */
119     void setEntityResolver(EntityResolver entityResolver);
120 
121     /***
122      * Return the encoding of this document, as part of the XML declaration This
123      * is <code>null</code> when unspecified or when it is not known (such as
124      * when the Document was created in memory) or when the implementation does
125      * not support this operation.
126      * 
127      * <p>
128      * The way this encoding is retrieved also depends on the way the XML source
129      * is parsed. For instance, if the SAXReader is used and if the underlying
130      * XMLReader implementation support the
131      * <code>org.xml.sax.ext.Locator2</code> interface, the result returned by
132      * this method is specified by the <code>getEncoding()</code> method of
133      * that interface.
134      * </p>
135      * 
136      * @return The encoding of this document, as stated in the XML declaration,
137      *         or <code>null</code> if unknown.
138      * 
139      * @since 1.5
140      */
141     String getXMLEncoding();
142 
143     /***
144      * Sets the encoding of this document as it will appear in the XML
145      * declaration part of the document.
146      * 
147      * @param encoding the encoding of the document
148      * 
149      * @since 1.6
150      */
151     void setXMLEncoding(String encoding);
152 }
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189