KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > clipbuilder > html > web > html > Impl > Dom > DomHTMLDocument


1 package org.jahia.clipbuilder.html.web.html.Impl.Dom;
2
3 import java.util.*;
4
5 import org.jahia.clipbuilder.html.bean.*;
6 import org.jahia.clipbuilder.html.util.*;
7 import org.jahia.clipbuilder.html.web.*;
8 import org.jahia.clipbuilder.html.web.html.*;
9 import org.w3c.dom.*;
10 import org.jahia.clipbuilder.html.web.Constant.WebConstants;
11
12 /**
13  * Implementation of HTMLDocument whith xerces
14  *
15  *@author Tlili Khaled
16  */

17 public class DomHTMLDocument implements HTMLDocument {
18     private UrlBean uBean;
19     private List framesList;
20
21     // Documents
22
private org.w3c.dom.Document JavaDoc w3cOriginalDocument;
23     private org.w3c.dom.Document JavaDoc transformedDocument;
24     private org.w3c.dom.Document JavaDoc chewDocument;
25     private org.w3c.dom.Document JavaDoc documentWithLabel;
26     private org.w3c.dom.Document JavaDoc userDocument;
27
28     //transformer
29
private DomHTMLTransformer transformer;
30     private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(DomHTMLDocument.class);
31
32
33     /**
34      * Constructor for the NekoHTMLDocument object
35      *
36      *@param uBean Description of Parameter
37      *@param document Description of Parameter
38      *@param htmlDocumentAsString Description of Parameter
39      */

40     public DomHTMLDocument(UrlBean uBean, org.w3c.dom.Document JavaDoc document, String JavaDoc htmlDocumentAsString) {
41         setW3cOriginalDocument(document);
42         setUrlBean(uBean);
43     }
44
45
46
47     /**
48      * Sets the Transformer attribute of the XercesHTMLDocument object
49      *
50      *@param transformer The new Transformer value
51      */

52     public void setTransformer(DomHTMLTransformer transformer) {
53         this.transformer = transformer;
54
55     }
56
57
58
59     /**
60      * Sets the TransformedDocument attribute of the XercesHTMLDocument object
61      *
62      *@param transformedDocument The new TransformedDocument value
63      */

64     public void setTransformedDocument(Document transformedDocument) {
65         this.transformedDocument = transformedDocument;
66     }
67
68
69     /**
70      * Sets the ChewDocument attribute of the XercesHTMLDocument object
71      *
72      *@param chewDocument The new ChewDocument value
73      */

74     public void setChewDocument(Document chewDocument) {
75         this.chewDocument = chewDocument;
76     }
77
78
79     /**
80      * Sets the DocumentWithLabel attribute of the XercesHTMLDocument object
81      *
82      *@param documentWithLabel The new DocumentWithLabel value
83      */

84     public void setDocumentWithLabel(Document documentWithLabel) {
85         this.documentWithLabel = documentWithLabel;
86     }
87
88
89     /**
90      * Sets the UrlBean attribute of the HTMLDocument object
91      *
92      *@param urlBean The new UrlBean value
93      */

94     public void setUrlBean(UrlBean urlBean) {
95         this.uBean = urlBean;
96
97     }
98
99
100     /**
101      * Sets the HiddenUserDocument attribute of the DomHTMLDocument object
102      *
103      *@param userDocument The new UserDocument value
104      */

105     public void setUserDocument(Document userDocument) {
106         this.userDocument = userDocument;
107     }
108
109
110     /**
111      * Sets the FramesList attribute of the DomHTMLDocument object
112      *
113      *@param framesList The new FramesList value
114      */

115     public void setFramesList(List framesList) {
116         this.framesList = framesList;
117     }
118
119
120
121     /**
122      * Gets the ParsingErrors attribute of the DomHTMLDocument object
123      *
124      *@return The ParsingErrors value
125      */

126     public java.util.List JavaDoc getTransformationErrors() {
127         return getTransformer().getLastParsingErrors();
128     }
129
130
131     /**
132      * Gets the Transformer attribute of the XercesHTMLDocument object
133      *
134      *@return The Transformer value
135      */

136     public HTMLTransformer getTransformer() {
137         return transformer;
138     }
139
140
141     /**
142      * Gets the OriginalHTMLSocumentAsString attribute of the XercesHTMLDocument
143      * object
144      *
145      *@return The OriginalHTMLSocumentAsString value
146      */

147     public String JavaDoc getOriginalDocumentAsString() {
148         return DomUtilities.getDocumentAsString(getW3cOriginalDocument());
149     }
150
151
152     /**
153      * Gets the TransformedDocumentAsString attribute of the DomHTMLDocument
154      * object
155      *
156      *@return The TransformedDocumentAsString value
157      */

158     public String JavaDoc getTransformedDocumentAsString() {
159         return DomUtilities.getDocumentAsString(getTransformedDocument());
160     }
161
162
163     /**
164      * Gets the TransformedDocument attribute of the XercesHTMLDocument object
165      *
166      *@return The TransformedDocument value
167      */

168     public Document getTransformedDocument() {
169         logger.debug("[ Get transformed document ]");
170         if (transformedDocument == null) {
171             logger.debug("Transformed document is null, build it");
172             getTransformer().buildTransformedDocument();
173         }
174         return transformedDocument;
175     }
176
177
178     /**
179      * Gets the ChewDocument attribute of the XercesHTMLDocument object
180      *
181      *@param tagName Description of Parameter
182      *@return The ChewDocument value
183      */

184     public Document getChewDocument(String JavaDoc tagName) {
185         logger.debug("[ Get chew document ]");
186         getTransformer().buildChewDocument(tagName);
187         return chewDocument;
188     }
189
190
191     /**
192      * Gets the DocumentWithLabel attribute of the XercesHTMLDocument object
193      *
194      *@return The DocumentWithLabel value
195      */

196     public Document getDocumentWithLabel() {
197         logger.debug("[ Get document whith label ]");
198         if (documentWithLabel == null) {
199             getTransformer().buildDocumentWhithLabel();
200         }
201
202         return documentWithLabel;
203     }
204
205
206
207     /**
208      * Gets the ChewDocumentAsString attribute of the HTMLDocument object
209      *
210      *@param tagName Description of Parameter
211      *@return The ChewDocumentAsString value
212      */

213     public String JavaDoc getChewDocumentAsString(String JavaDoc tagName) {
214         return DomUtilities.getDocumentAsString(getChewDocument(tagName));
215     }
216
217
218     /**
219      * Gets the DocumentWhithParamLabelAsString attribute of the HTMLDocument
220      * object
221      *
222      *@return The DocumentWhithParamLabelAsString value
223      */

224     public String JavaDoc getDocumentWhithParamLabelAsString() {
225         return DomUtilities.getDocumentAsString(getDocumentWithLabel());
226     }
227
228
229     /**
230      * Gets the SelectPartFromHash attribute of the HTMLDocument object
231      *
232      *@param hash Description of Parameter
233      *@return The SelectPartFromHash value
234      */

235     public String JavaDoc getSelectPartFromHash(String JavaDoc hash) {
236         return null;
237     }
238
239
240     /**
241      * Gets the TransformedDocumentAsString attribute of the HTMLDocument object
242      *
243      *@return The TransformedDocumentAsString value
244      */

245     public String JavaDoc getUserDocumentAsString() {
246         return DomUtilities.getDocumentAsString(this.getUserDocument());
247     }
248
249
250     /**
251      * Gets the UrlBean attribute of the HTMLDocument object
252      *
253      *@return The UrlBean value
254      */

255     public UrlBean getUrlBean() {
256         return this.uBean;
257     }
258
259
260     /**
261      * Gets the HiddenUserDocument attribute of the DomHTMLDocument object
262      *
263      *@return The HiddenUserDocument value
264      */

265     public Document getUserDocument() {
266         logger.debug(" Get User document");
267         if (userDocument == null) {
268             logger.debug("Hidden user document is null, build it");
269             getTransformer().buildUserDocument();
270         }
271         return userDocument;
272     }
273
274     /**
275      * Gets the FramesList attribute of the DomHTMLDocument object
276      *
277      *@return The FramesList value
278      */

279     public List getFramesList() {
280         return framesList;
281     }
282
283
284     /**
285      * Gets the OriginalDocument attribute of the XercesHTMLDocument object
286      *
287      *@return The OriginalDocument value
288      */

289     protected Document getW3cOriginalDocument() {
290         return w3cOriginalDocument;
291     }
292
293
294     /**
295      * Sets the OriginalDocument attribute of the XercesHTMLDocument object
296      *
297      *@param originalDocument The new OriginalDocument value
298      */

299     private void setW3cOriginalDocument(Document originalDocument) {
300         this.w3cOriginalDocument = originalDocument;
301     }
302
303 }
304
Popular Tags