Class FormatUtil
java.lang.Object
au.com.acegi.xmlformat.FormatUtil
Utility methods private to the package.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidformat(InputStream in, OutputStream out, XmlOutputFormat fmt) Ingest an input stream, writing formatted XML to the output stream.(package private) static booleanformatInPlace(File file, XmlOutputFormat fmt) Formats the input file, overwriting the input file with the new content if the formatted content differs.private static org.dom4j.io.XMLWritergetXmlWriter(OutputStream out, XmlOutputFormat fmt) (package private) static booleanneedsFormatting(File file, XmlOutputFormat fmt) Only checks if the input file would be modified by the formatter, without overwriting it.
-
Field Details
-
TMP_FILE_PREFIX
-
-
Constructor Details
-
FormatUtil
private FormatUtil()
-
-
Method Details
-
format
static void format(InputStream in, OutputStream out, XmlOutputFormat fmt) throws org.dom4j.DocumentException, IOException Ingest an input stream, writing formatted XML to the output stream. The caller is responsible for closing the input and output streams. Any errors in the input stream will cause an exception and the output stream should not be relied upon.- Parameters:
in- input XML streamout- output XML streamfmt- format configuration to apply- Throws:
org.dom4j.DocumentException- if input XML could not be parsedIOException- if output XML stream could not be written
-
getXmlWriter
private static org.dom4j.io.XMLWriter getXmlWriter(OutputStream out, XmlOutputFormat fmt) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
formatInPlace
static boolean formatInPlace(File file, XmlOutputFormat fmt) throws org.dom4j.DocumentException, IOException Formats the input file, overwriting the input file with the new content if the formatted content differs.- Parameters:
file- to read and then potentially overwritefmt- format configuration to apply- Returns:
- true if the file was overwritten
- Throws:
org.dom4j.DocumentException- if input XML could not be parsedIOException- if output XML stream could not be written
-
needsFormatting
static boolean needsFormatting(File file, XmlOutputFormat fmt) throws org.dom4j.DocumentException, IOException Only checks if the input file would be modified by the formatter, without overwriting it.- Parameters:
file- to readfmt- format configuration to apply- Returns:
- true if the file would be modified by the formatter
- Throws:
org.dom4j.DocumentException- if input XML could not be parsedIOException- if output XML stream could not be written
-