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 17 public class DomHTMLDocument implements HTMLDocument { 18 private UrlBean uBean; 19 private List framesList; 20 21 private org.w3c.dom.Document w3cOriginalDocument; 23 private org.w3c.dom.Document transformedDocument; 24 private org.w3c.dom.Document chewDocument; 25 private org.w3c.dom.Document documentWithLabel; 26 private org.w3c.dom.Document userDocument; 27 28 private DomHTMLTransformer transformer; 30 private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(DomHTMLDocument.class); 31 32 33 40 public DomHTMLDocument(UrlBean uBean, org.w3c.dom.Document document, String htmlDocumentAsString) { 41 setW3cOriginalDocument(document); 42 setUrlBean(uBean); 43 } 44 45 46 47 52 public void setTransformer(DomHTMLTransformer transformer) { 53 this.transformer = transformer; 54 55 } 56 57 58 59 64 public void setTransformedDocument(Document transformedDocument) { 65 this.transformedDocument = transformedDocument; 66 } 67 68 69 74 public void setChewDocument(Document chewDocument) { 75 this.chewDocument = chewDocument; 76 } 77 78 79 84 public void setDocumentWithLabel(Document documentWithLabel) { 85 this.documentWithLabel = documentWithLabel; 86 } 87 88 89 94 public void setUrlBean(UrlBean urlBean) { 95 this.uBean = urlBean; 96 97 } 98 99 100 105 public void setUserDocument(Document userDocument) { 106 this.userDocument = userDocument; 107 } 108 109 110 115 public void setFramesList(List framesList) { 116 this.framesList = framesList; 117 } 118 119 120 121 126 public java.util.List getTransformationErrors() { 127 return getTransformer().getLastParsingErrors(); 128 } 129 130 131 136 public HTMLTransformer getTransformer() { 137 return transformer; 138 } 139 140 141 147 public String getOriginalDocumentAsString() { 148 return DomUtilities.getDocumentAsString(getW3cOriginalDocument()); 149 } 150 151 152 158 public String getTransformedDocumentAsString() { 159 return DomUtilities.getDocumentAsString(getTransformedDocument()); 160 } 161 162 163 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 184 public Document getChewDocument(String tagName) { 185 logger.debug("[ Get chew document ]"); 186 getTransformer().buildChewDocument(tagName); 187 return chewDocument; 188 } 189 190 191 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 213 public String getChewDocumentAsString(String tagName) { 214 return DomUtilities.getDocumentAsString(getChewDocument(tagName)); 215 } 216 217 218 224 public String getDocumentWhithParamLabelAsString() { 225 return DomUtilities.getDocumentAsString(getDocumentWithLabel()); 226 } 227 228 229 235 public String getSelectPartFromHash(String hash) { 236 return null; 237 } 238 239 240 245 public String getUserDocumentAsString() { 246 return DomUtilities.getDocumentAsString(this.getUserDocument()); 247 } 248 249 250 255 public UrlBean getUrlBean() { 256 return this.uBean; 257 } 258 259 260 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 279 public List getFramesList() { 280 return framesList; 281 } 282 283 284 289 protected Document getW3cOriginalDocument() { 290 return w3cOriginalDocument; 291 } 292 293 294 299 private void setW3cOriginalDocument(Document originalDocument) { 300 this.w3cOriginalDocument = originalDocument; 301 } 302 303 } 304 | Popular Tags |