public XmlOutput createWriter( Writer w, String encoding ) { // XMLWriter doesn't do buffering, so do it here if it looks like a good idea if(!(w instanceof BufferedWriter)) w = new BufferedWriter(w); assert toBeFlushed==null; toBeFlushed = w; CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(!isFragment()); xw.setHeader(header); return new SAXOutput(xw); // TODO: don't we need a better writer? }
public XmlOutput createWriter( Writer w, String encoding ) { // XMLWriter doesn't do buffering, so do it here if it looks like a good idea if(!(w instanceof BufferedWriter)) w = new BufferedWriter(w); assert toBeFlushed==null; toBeFlushed = w; CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(!isFragment()); xw.setHeader(header); return new SAXOutput(xw); // TODO: don't we need a better writer? }
DataWriter dataWriter = new DataWriter() { @Override void onWritingDone() { //do data read here } };
Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); DataWriter dataWriter = new DataWriter(printWriter, "UTF-8", new CharacterEscapeHandler() { @Override public void escape(char[] buf, int start, int len, boolean b, Writer out) throws IOException { out.write(buf, start, len); } }); marshaller.marshal(data, dataWriter); System.out.println(stringWriter.toString());
public class DataCreate { public void readData() { new DataReader().readData(); } public void writeData() { new DataWriter().writeData(); } }
/** * Dumps the contents of the forest to the specified stream. * * This is a debug method. As such, error handling is sloppy. */ public void dump( OutputStream out ) throws IOException { try { // create identity transformer Transformer it = TransformerFactory.newInstance().newTransformer(); for (Map.Entry<String, Document> e : core.entrySet()) { out.write( ("---<< "+e.getKey()+'\n').getBytes() ); DataWriter dw = new DataWriter(new OutputStreamWriter(out),null); dw.setIndentStep(" "); it.transform( new DOMSource(e.getValue()), new SAXResult(dw)); out.write( "\n\n\n".getBytes() ); } } catch( TransformerException e ) { e.printStackTrace(); } } }
/** * Dumps the contents of the forest to the specified stream. * * This is a debug method. As such, error handling is sloppy. */ public void dump( OutputStream out ) throws IOException { try { // create identity transformer Transformer it = TransformerFactory.newInstance().newTransformer(); for (Map.Entry<String, Document> e : core.entrySet()) { out.write( ("---<< "+e.getKey()+'\n').getBytes() ); DataWriter dw = new DataWriter(new OutputStreamWriter(out),null); dw.setIndentStep(" "); it.transform( new DOMSource(e.getValue()), new SAXResult(dw)); out.write( "\n\n\n".getBytes() ); } } catch( TransformerException e ) { e.printStackTrace(); } } }
/** * Dumps the contents of the forest to the specified stream. * <p/> * This is a debug method. As such, error handling is sloppy. */ public void dump(OutputStream out) throws IOException { try { // create identity transformer // secure xml processing can be switched off if input requires it boolean secureProcessingEnabled = options == null || !options.disableXmlSecurity; TransformerFactory tf = XmlUtil.newTransformerFactory(secureProcessingEnabled); Transformer it = tf.newTransformer(); for (Map.Entry<String, Document> e : core.entrySet()) { out.write(("---<< " + e.getKey() + '\n').getBytes()); DataWriter dw = new DataWriter(new OutputStreamWriter(out), null); dw.setIndentStep(" "); it.transform(new DOMSource(e.getValue()), new SAXResult(dw)); out.write("\n\n\n".getBytes()); } } catch (TransformerException e) { e.printStackTrace(); } }
/** * Dumps the contents of the forest to the specified stream. * <p/> * This is a debug method. As such, error handling is sloppy. */ public void dump(OutputStream out) throws IOException { try { // create identity transformer // secure xml processing can be switched off if input requires it boolean secureProcessingEnabled = options == null || !options.disableXmlSecurity; TransformerFactory tf = XmlUtil.newTransformerFactory(secureProcessingEnabled); Transformer it = tf.newTransformer(); for (Map.Entry<String, Document> e : core.entrySet()) { out.write(("---<< " + e.getKey() + '\n').getBytes()); DataWriter dw = new DataWriter(new OutputStreamWriter(out), null); dw.setIndentStep(" "); it.transform(new DOMSource(e.getValue()), new SAXResult(dw)); out.write("\n\n\n".getBytes()); } } catch (TransformerException e) { e.printStackTrace(); } }
/** * Dumps the contents of the forest to the specified stream. * <p/> * This is a debug method. As such, error handling is sloppy. */ public void dump(OutputStream out) throws IOException { try { // create identity transformer // secure xml processing can be switched off if input requires it boolean secureProcessingEnabled = options == null || !options.disableXmlSecurity; TransformerFactory tf = XmlUtil.newTransformerFactory(secureProcessingEnabled); Transformer it = tf.newTransformer(); for (Map.Entry<String, Document> e : core.entrySet()) { out.write(("---<< " + e.getKey() + '\n').getBytes()); DataWriter dw = new DataWriter(new OutputStreamWriter(out), null); dw.setIndentStep(" "); it.transform(new DOMSource(e.getValue()), new SAXResult(dw)); out.write("\n\n\n".getBytes()); } } catch (TransformerException e) { e.printStackTrace(); } }
/** * Dumps the contents of the forest to the specified stream. * <p/> * This is a debug method. As such, error handling is sloppy. */ public void dump(OutputStream out) throws IOException { try { // create identity transformer // secure xml processing can be switched off if input requires it boolean secureProcessingEnabled = options == null || !options.disableXmlSecurity; TransformerFactory tf = XmlUtil.newTransformerFactory(secureProcessingEnabled); Transformer it = tf.newTransformer(); for (Map.Entry<String, Document> e : core.entrySet()) { out.write(("---<< " + e.getKey() + '\n').getBytes()); DataWriter dw = new DataWriter(new OutputStreamWriter(out), null); dw.setIndentStep(" "); it.transform(new DOMSource(e.getValue()), new SAXResult(dw)); out.write("\n\n\n".getBytes()); } } catch (TransformerException e) { e.printStackTrace(); } }
out.write( ("---<< "+e.getKey()+'\n').getBytes() ); DataWriter dw = new DataWriter(new OutputStreamWriter(out),null); dw.setIndentStep(" "); it.transform( new DOMSource(e.getValue()),
out.write( ("---<< "+e.getKey()+'\n').getBytes() ); DataWriter dw = new DataWriter(new OutputStreamWriter(out),null); dw.setIndentStep(" "); it.transform( new DOMSource(e.getValue()),
public XMLWriter createWriter( Writer w, String encoding ) throws JAXBException { CharacterEscapeHandler ceh = createEscapeHandler(encoding); if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); return d; } else return new XMLWriter(w,encoding,ceh); }
public XMLWriter createWriter( Writer w, String encoding ) throws JAXBException { // buffering improves the performance w = new BufferedWriter(w); CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(printXmlDeclaration); xw.setHeader(header); return xw; }
public XMLWriter createWriter( Writer w, String encoding ) throws JAXBException { // buffering improves the performance w = new BufferedWriter(w); CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(printXmlDeclaration); xw.setHeader(header); return xw; }
public XMLWriter createWriter( Writer w, String encoding ) throws JAXBException { // buffering improves the performance w = new BufferedWriter(w); CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(printXmlDeclaration); xw.setHeader(header); return xw; }
public XMLWriter createWriter( Writer w, String encoding ) throws JAXBException { // buffering improves the performance w = new BufferedWriter(w); CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(printXmlDeclaration); xw.setHeader(header); return xw; }
public XmlOutput createWriter( Writer w, String encoding ) { // XMLWriter doesn't do buffering, so do it here if it looks like a good idea if(!(w instanceof BufferedWriter)) w = new BufferedWriter(w); assert toBeFlushed==null; toBeFlushed = w; CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(!isFragment()); xw.setHeader(header); return new SAXOutput(xw); // TODO: don't we need a better writer? }
public XmlOutput createWriter( Writer w, String encoding ) { // XMLWriter doesn't do buffering, so do it here if it looks like a good idea if(!(w instanceof BufferedWriter)) w = new BufferedWriter(w); assert toBeFlushed==null; toBeFlushed = w; CharacterEscapeHandler ceh = createEscapeHandler(encoding); XMLWriter xw; if(isFormattedOutput()) { DataWriter d = new DataWriter(w,encoding,ceh); d.setIndentStep(indent); xw=d; } else xw = new XMLWriter(w,encoding,ceh); xw.setXmlDecl(!isFragment()); xw.setHeader(header); return new SAXOutput(xw); // TODO: don't we need a better writer? }