1 7 8 package org.dom4j.io; 9 10 import java.io.OutputStream ; 11 import java.io.UnsupportedEncodingException ; 12 import java.io.Writer ; 13 14 import javax.xml.transform.sax.SAXResult ; 15 16 import org.xml.sax.ContentHandler ; 17 import org.xml.sax.ext.LexicalHandler ; 18 19 29 public class XMLResult extends SAXResult { 30 private XMLWriter xmlWriter; 31 32 public XMLResult() { 33 this(new XMLWriter()); 34 } 35 36 public XMLResult(Writer writer) { 37 this(new XMLWriter(writer)); 38 } 39 40 public XMLResult(Writer writer, OutputFormat format) { 41 this(new XMLWriter(writer, format)); 42 } 43 44 public XMLResult(OutputStream out) throws UnsupportedEncodingException { 45 this(new XMLWriter(out)); 46 } 47 48 public XMLResult(OutputStream out, OutputFormat format) 49 throws UnsupportedEncodingException { 50 this(new XMLWriter(out, format)); 51 } 52 53 public XMLResult(XMLWriter xmlWriter) { 54 super(xmlWriter); 55 this.xmlWriter = xmlWriter; 56 setLexicalHandler(xmlWriter); 57 } 58 59 public XMLWriter getXMLWriter() { 60 return xmlWriter; 61 } 62 63 public void setXMLWriter(XMLWriter writer) { 64 this.xmlWriter = writer; 65 setHandler(xmlWriter); 66 setLexicalHandler(xmlWriter); 67 } 68 69 public ContentHandler getHandler() { 70 return xmlWriter; 71 } 72 73 public LexicalHandler getLexicalHandler() { 74 return xmlWriter; 75 } 76 } 77 78 114 | Popular Tags |