1 18 package org.enhydra.util.jivan; 19 20 import java.io.ByteArrayOutputStream ; 21 import java.io.IOException ; 22 23 import org.enhydra.util.dom.SimpleXMLObjectImpl; 24 import org.jivan.html.document.DocumentManager; 25 import org.jivan.html.dom.HTMLDocumentCEImpl; 26 import org.w3c.dom.Document ; 27 28 29 44 public class JivanSimpleXMLObjectImpl 45 extends SimpleXMLObjectImpl { 46 47 public JivanSimpleXMLObjectImpl() { 48 super(); 49 } 50 51 61 public void setDocument(Document document, String mimeType, String encoding) { 62 if (document != null && document instanceof org.jivan.html.dom.HTMLDocumentCEImpl) { 63 super.setDocument(document, mimeType, encoding); 64 } 65 else 66 throw new java.lang.ClassCastException ( 67 "Document must be the org.jivan.html.dom.HTMLDocumentCEImpl implementation!"); 68 } 69 70 80 public void setDocument(Document document, String encoding) { 81 this.setDocument(document, "text/html", encoding); 82 } 83 84 93 public void setDocument(Document document) { 94 this.setDocument(document, "text/html", "UTF-8"); 95 } 96 97 105 public void setDocument(DocumentManager docMan, String mimeType, String encoding) { 106 Document temp = docMan.getDocument(); 107 this.setDocument(temp, mimeType, encoding); 108 } 109 110 118 public void setDocument(DocumentManager docMan, String encoding) { 119 Document temp = docMan.getDocument(); 120 this.setDocument(temp, "text/html", encoding); 121 } 122 123 131 public void setDocument(DocumentManager docMan) { 132 Document temp = docMan.getDocument(); 133 this.setDocument(temp, "text/html", "UTF-8"); 134 } 135 136 142 public byte[] toByteDocument() throws IOException { 143 HTMLDocumentCEImpl doc = (HTMLDocumentCEImpl)super.getDocument(); 144 DocumentManager dm = doc.getDocman(); 145 146 ByteArrayOutputStream bos = new ByteArrayOutputStream (); 147 dm.serialize(bos); 148 bos.flush(); 149 byte[] retArray = bos.toByteArray(); 150 bos.close(); 151 152 return retArray; 153 } 154 155 } | Popular Tags |