private static XMLOutputter xmlOutputer() { Format format = Format.getPrettyFormat().setEncoding("utf-8").setLineSeparator("\n"); return new XMLOutputter(format); }
public String elementOutput(Element e) { return "\n\t" + new XMLOutputter().outputString(e); }
public void modifyOutputStream( JarOutputStream jos ) throws IOException { jos.putNextEntry( new JarEntry( resource ) ); new XMLOutputter( Format.getPrettyFormat() ).output( doc, jos ); doc = null; } }
/** * 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 }
public static void writeXml(Document document, OutputStream outputStream) throws IOException { xmlOutputer().output(document, outputStream); }
/** * Set a new Format instance for this DOMOutputter * * @param format * the new Format instance to use (null implies the default) * @since JDOM2 */ public void setFormat(Format format) { this.format = format == null ? Format.getRawFormat() : format; }
/** * Creates a new Format instance with default (raw) behavior. */ private Format() { setEncoding(STANDARD_ENCODING); }
/** * Returns a new Format object that performs whitespace normalization, uses * the UTF-8 encoding, doesn't expand empty elements, includes the * declaration and encoding, and uses the default entity escape strategy. * Tweaks can be made to the returned Format instance without affecting * other instances. * * @return a Format with whitespace normalization */ public static Format getCompactFormat() { Format f = new Format(); f.setTextMode(TextMode.NORMALIZE); return f; }
/** * A helper method to implement backward-compatibility with JDOM1 * * @see XMLOutputter#escapeElementEntities(String) * @param str * The String to output. * @param format * The format details to use. * @return The input String escaped as an element text value. */ public final String escapeElementEntities(final String str, final Format format) { return Format.escapeText(format.getEscapeStrategy(), format.getLineSeparator(), str); }
/** * Sets the new format logic for the XMLOutputter. Note the Format object is * cloned internally before use. * * @see #getFormat() * @param newFormat * the format to use for subsequent output */ public void setFormat(Format newFormat) { this.myFormat = newFormat.clone(); }
/** * Escape any characters in the input string in such a way that the returned * value is valid as output in an XML Attribute value. * * @param str * the input String to escape * @return the escaped version of the input String */ public String escapeAttributeEntities(String str) { return DEFAULTPROCESSOR.escapeAttributeEntities(str, myFormat); }
/** * Returns a new Format object that performs no whitespace changes, uses * the UTF-8 encoding, doesn't expand empty elements, includes the * declaration and encoding, and uses the default entity escape strategy. * Tweaks can be made to the returned Format instance without affecting * other instances. * @return a Format with no whitespace changes */ public static Format getRawFormat() { return new Format(); }
/** * Escape any characters in the input string in such a way that the returned * value is valid as output in an XML Element text. * * @param str * the input String to escape * @return the escaped version of the input String */ public String escapeElementEntities(String str) { return DEFAULTPROCESSOR.escapeElementEntities(str, myFormat); }
/** * Sets the output encoding. The name should be an accepted XML * encoding. * * @param encoding the encoding format. Use XML-style names like * "UTF-8" or "ISO-8859-1" or "US-ASCII" * @return a pointer to this Format for chaining */ public Format setEncoding(String encoding) { this.encoding = encoding; escapeStrategy = chooseStrategy(encoding); return this; }
public String xmlRepresentation() { if (cachedXmlRepresentation == null) { cachedXmlRepresentation = new XMLOutputter().outputString(ccTrayXmlElement(SITE_URL_PREFIX)); } return cachedXmlRepresentation; }
/** * 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 }
public static void writeXml(Element element, OutputStream outputStream) throws IOException { xmlOutputer().output(element, outputStream); }
/** * Set the current {@link Format} to be used for output. * * @param format * the new Format */ public void setFormat(Format format) { this.format = format == null ? Format.getRawFormat() : format; }
/** * Sets the new format logic for the StAXStreamOutputter. Note the Format object is * cloned internally before use. * * @see #getFormat() * @param newFormat * the format to use for subsequent output */ public void setFormat(Format newFormat) { this.myFormat = newFormat.clone(); }
/** * Sets the new format logic for the StAXStreamOutputter. Note the Format object is * cloned internally before use. * * @see #getFormat() * @param newFormat * the format to use for subsequent output */ public void setFormat(Format newFormat) { this.myFormat = newFormat.clone(); }