1 58 package org.apache.ecs.factory; 59 60 import java.io.StringReader ; 61 import java.io.ByteArrayOutputStream ; 62 import java.io.OutputStream ; 63 64 import org.apache.xerces.parsers.DOMParser; 65 import org.w3c.dom.Document ; 66 67 public class DOMFactory 68 { 69 private ByteArrayOutputStream outStream = new ByteArrayOutputStream (); 70 71 92 public DOMFactory() 93 { 94 } 95 96 99 public OutputStream getOutputStream() 100 { 101 return outStream; 102 } 103 104 107 public Document createDOM() 108 { 109 DOMParser parser = null; 110 Document doc = null; 111 112 try 113 { 114 outStream.close(); StringReader reader = new StringReader (outStream.toString()); 116 parser = new DOMParser(); 117 parser.parse(new org.xml.sax.InputSource (reader)); 118 doc = parser.getDocument(); 119 } 120 catch(java.io.IOException ioe) 121 { 122 System.err.println(ioe.toString()); 123 ioe.printStackTrace(); 124 } 125 catch(org.xml.sax.SAXException sax) 126 { 127 System.err.println(sax.toString()); 128 sax.printStackTrace(); 129 } 130 return doc; 131 } 132 } 133 | Popular Tags |