Package au.com.acegi.xmlformat
Class FormatUtil
- java.lang.Object
-
- au.com.acegi.xmlformat.FormatUtil
-
final class FormatUtil extends java.lang.ObjectUtility methods private to the package.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringTMP_FILE_PREFIX
-
Constructor Summary
Constructors Modifier Constructor Description privateFormatUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static voidformat(java.io.InputStream in, java.io.OutputStream out, XmlOutputFormat fmt)Ingest an input stream, writing formatted XML to the output stream.(package private) static booleanformatInPlace(java.io.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(java.io.OutputStream out, XmlOutputFormat fmt)(package private) static booleanneedsFormatting(java.io.File file, XmlOutputFormat fmt)Only checks if the input file would be modified by the formatter, without overwriting it.
-
-
-
Method Detail
-
format
static void format(java.io.InputStream in, java.io.OutputStream out, XmlOutputFormat fmt) throws org.dom4j.DocumentException, java.io.IOExceptionIngest 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 parsedjava.io.IOException- if output XML stream could not be written
-
getXmlWriter
private static org.dom4j.io.XMLWriter getXmlWriter(java.io.OutputStream out, XmlOutputFormat fmt) throws java.io.UnsupportedEncodingException- Throws:
java.io.UnsupportedEncodingException
-
formatInPlace
static boolean formatInPlace(java.io.File file, XmlOutputFormat fmt) throws org.dom4j.DocumentException, java.io.IOExceptionFormats 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 parsedjava.io.IOException- if output XML stream could not be written
-
needsFormatting
static boolean needsFormatting(java.io.File file, XmlOutputFormat fmt) throws org.dom4j.DocumentException, java.io.IOExceptionOnly 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 parsedjava.io.IOException- if output XML stream could not be written
-
-