public static void writeXml(Document document, OutputStream outputStream) throws IOException { xmlOutputer().output(document, outputStream); }
public static void writeXml(Element element, OutputStream outputStream) throws IOException { xmlOutputer().output(element, outputStream); }
public void modifyOutputStream( JarOutputStream jos ) throws IOException { jos.putNextEntry( new JarEntry( resource ) ); new XMLOutputter( Format.getPrettyFormat() ).output( doc, jos ); doc = null; } }
/** * Return a string representing a {@link CDATA} node. * <p> * <b>Warning</b>: a String is Unicode, which may not match the outputter's * specified encoding. * * @param cdata * <code>CDATA</code> to format. * @return the input content formatted as an XML String. * @throws NullPointerException * if the specified content is null. */ public final String outputString(CDATA cdata) { StringWriter out = new StringWriter(); try { output(cdata, out); // output() flushes } catch (IOException e) { // swallow - will never happen. } return out.toString(); }
/** * Return a string representing an {@link Element}. * <p> * <b>Warning</b>: a String is Unicode, which may not match the outputter's * specified encoding. * * @param element * <code>Element</code> to format. * @return the input content formatted as an XML String. * @throws NullPointerException * if the specified content is null. */ public final String outputString(Element element) { StringWriter out = new StringWriter(); try { output(element, out); // output() flushes } catch (IOException e) { // swallow - will never happen. } return out.toString(); }
/** * Return a string representing a {@link Comment}. * <p> * <b>Warning</b>: a String is Unicode, which may not match the outputter's * specified encoding. * * @param comment * <code>Comment</code> to format. * @return the input content formatted as an XML String. * @throws NullPointerException * if the specified content is null. */ public final String outputString(Comment comment) { StringWriter out = new StringWriter(); try { output(comment, out); // output() flushes } catch (IOException e) { // swallow - will never happen. } return out.toString(); }
/** * Return a string representing a {@link ProcessingInstruction}. * <p> * <b>Warning</b>: a String is Unicode, which may not match the outputter's * specified encoding. * * @param pi * <code>ProcessingInstruction</code> to format. * @return the input content formatted as an XML String. * @throws NullPointerException * if the specified content is null. */ public final String outputString(ProcessingInstruction pi) { StringWriter out = new StringWriter(); try { output(pi, out); // output() flushes } catch (IOException e) { // swallow - will never happen. } return out.toString(); }
/** * Return a string representing a {@link Document}. Uses an internal * StringWriter. * <p> * <b>Warning</b>: a String is Unicode, which may not match the outputter's * specified encoding. * * @param doc * <code>Document</code> to format. * @return the input content formatted as an XML String. * @throws NullPointerException * if the specified content is null. */ public final String outputString(Document doc) { StringWriter out = new StringWriter(); try { output(doc, out); // output() flushes } catch (IOException e) { // swallow - will never happen. } return out.toString(); }
/** * Return a string representing an {@link EntityRef}. * <p> * <b>Warning</b>: a String is Unicode, which may not match the outputter's * specified encoding. * * @param entity * <code>EntityRef</code> to format. * @return the input content formatted as an XML String. * @throws NullPointerException * if the specified content is null. */ public final String outputString(EntityRef entity) { StringWriter out = new StringWriter(); try { output(entity, out); // output() flushes } catch (IOException e) { // swallow - will never happen. } return out.toString(); }
/** * Return a string representing a {@link DocType}. * <p> * <b>Warning</b>: a String is Unicode, which may not match the outputter's * specified encoding. * * @param doctype * <code>DocType</code> to format. * @return the input content formatted as an XML String. * @throws NullPointerException * if the specified content is null. */ public final String outputString(DocType doctype) { StringWriter out = new StringWriter(); try { output(doctype, out); // output() flushes } catch (IOException e) { // swallow - will never happen. } return out.toString(); }
/** * Return a string representing a {@link Text} node. * <p> * <b>Warning</b>: a String is Unicode, which may not match the outputter's * specified encoding. * * @param text * <code>Text</code> to format. * @return the input content formatted as an XML String. * @throws NullPointerException * if the specified content is null. */ public final String outputString(Text text) { StringWriter out = new StringWriter(); try { output(text, out); // output() flushes } catch (IOException e) { // swallow - will never happen. } return out.toString(); }
/** * Print out a <code>{@link Comment}</code>. * * @param comment * <code>Comment</code> to output. * @param out * <code>OutputStream</code> to use. * @throws IOException * if there's any problem writing. * @throws NullPointerException * if the specified content is null. */ public final void output(Comment comment, OutputStream out) throws IOException { output(comment, makeWriter(out, myFormat)); // output() flushes }
/** * Print out an <code>{@link Element}</code>, including its * <code>{@link Attribute}</code>s, and all contained (child) elements, etc. * * @param element * <code>Element</code> to output. * @param out * <code>OutputStream</code> to use. * @throws IOException * if there's any problem writing. * @throws NullPointerException * if the specified content is null. */ public final void output(Element element, OutputStream out) throws IOException { output(element, makeWriter(out, myFormat)); }
/** * Print out a <code>{@link CDATA}</code> node. * * @param cdata * <code>CDATA</code> to output. * @param out * <code>OutputStream</code> to use. * @throws IOException * if there's any problem writing. * @throws NullPointerException * if the specified content is null. */ public final void output(CDATA cdata, OutputStream out) throws IOException { output(cdata, makeWriter(out, myFormat)); // output() flushes }
/** * Print out a <code>{@link EntityRef}</code>. * * @param entity * <code>EntityRef</code> to output. * @param out * <code>OutputStream</code> to use. * @throws IOException * if there's any problem writing. * @throws NullPointerException * if the specified content is null. */ public void output(EntityRef entity, OutputStream out) throws IOException { output(entity, makeWriter(out, myFormat)); // output() flushes }
/** * This will print the <code>{@link DocType}</code> to the given * OutputStream. * * @param doctype * <code>DocType</code> to output. * @param out * <code>OutputStream</code> to use. * @throws IOException * if there's any problem writing. * @throws NullPointerException * if the specified content is null. */ public final void output(DocType doctype, OutputStream out) throws IOException { output(doctype, makeWriter(out, myFormat)); }
/** * Print out a <code>{@link ProcessingInstruction}</code>. * * @param pi * <code>ProcessingInstruction</code> to output. * @param out * <code>OutputStream</code> to use. * @throws IOException * if there's any problem writing. * @throws NullPointerException * if the specified content is null. */ public final void output(ProcessingInstruction pi, OutputStream out) throws IOException { output(pi, makeWriter(out, myFormat)); // output() flushes }
/** * Print out a <code>{@link Text}</code> node. Perfoms the necessary entity * escaping and whitespace stripping. * * @param text * <code>Text</code> to output. * @param out * <code>OutputStream</code> to use. * @throws IOException * if there's any problem writing. * @throws NullPointerException * if the specified content is null. */ public final void output(Text text, OutputStream out) throws IOException { output(text, makeWriter(out, myFormat)); // output() flushes }
/** * This will print the <code>{@link Document}</code> to the given * OutputStream. The characters are printed using the encoding specified in * the constructor, or a default of UTF-8. * * @param doc * <code>Document</code> to format. * @param out * <code>OutputStream</code> to use. * @throws IOException * if there's any problem writing. * @throws NullPointerException * if the specified content is null. */ public final void output(Document doc, OutputStream out) throws IOException { output(doc, makeWriter(out, myFormat)); }
/** * This will handle printing out a list of nodes. This can be useful for * printing the content of an element that contains HTML, like * "<description>JDOM is <b>fun>!</description>". * <p> * The list is assumed to contain legal JDOM nodes. If other content is * coerced on to the list it will cause ClassCastExceptions, and null Lists * or null list members will cause NullPointerException. * * @param list * <code>List</code> of nodes. * @param out * <code>OutputStream</code> to use. * @throws IOException * if there's any problem writing. * @throws ClassCastException * if non-{@link Content} is forced in to the list * @throws NullPointerException * if the List is null or contains null members. */ public final void output(List<? extends Content> list, OutputStream out) throws IOException { output(list, makeWriter(out, myFormat)); // output() flushes }