Package cdc.util.data.xml
Class XmlDataWriter
- java.lang.Object
-
- cdc.util.data.xml.XmlDataWriter
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.logging.log4j.LoggerLOGGER
-
Constructor Summary
Constructors Constructor Description XmlDataWriter(XmlWriter writer)XmlDataWriter(File file)XmlDataWriter(File file, Compressor compressor)XmlDataWriter(File file, String encoding)XmlDataWriter(File file, String encoding, Compressor compressor)XmlDataWriter(OutputStream os)XmlDataWriter(OutputStream os, String encoding)XmlDataWriter(PrintStream out)XmlDataWriter(PrintStream out, String encoding)XmlDataWriter(Writer writer)XmlDataWriter(String filename)XmlDataWriter(String filename, Compressor compressor)XmlDataWriter(String filename, String encoding)XmlDataWriter(String filename, String encoding, Compressor compressor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()XmlWritergetXmlWriter()static voidprint(Document doc, PrintStream out, String indent, boolean close, XmlWriter.Feature... features)Prints a Document to a PrintStream.static voidprint(Node node, boolean asDocument, PrintStream out, String indent, boolean close, XmlWriter.Feature... features)Prints a Node to a PrintStream.static voidsave(Document doc, File file, String indent, XmlWriter.Feature... features)Saves a Document to a File.static voidsave(Document doc, OutputStream os, String indent, XmlWriter.Feature... features)Saves a Document to an OutputStream.static voidsave(Document doc, Writer writer, String indent, XmlWriter.Feature... features)Saves a Document to a Writer.static voidsave(Document doc, String filename, String indent, XmlWriter.Feature... features)Saves a Document to a File.static voidsave(Node node, boolean asDocument, File file, String indent, XmlWriter.Feature... features)Saves a Node to a File.static voidsave(Node node, boolean asDocument, OutputStream os, String indent, XmlWriter.Feature... features)Saves a Node to an OutputStream.static voidsave(Node node, boolean asDocument, Writer writer, String indent, XmlWriter.Feature... features)Saves a Node to a Writer.static voidsave(Node node, boolean asDocument, String filename, String indent, XmlWriter.Feature... features)Saves a Node to a File.static StringtoString(Document doc, String indent, XmlWriter.Feature... features)static StringtoString(Node node, boolean asDocument, String indent, XmlWriter.Feature... features)voidwrite(Node node)Writes a node.static voidwrite(XmlWriter writer, Node node)Writes a node to an XmlWriter.static voidwrite(XmlWriter writer, Node node, boolean asDocument)Writes a node to an XmlWriter.
-
-
-
Constructor Detail
-
XmlDataWriter
public XmlDataWriter(XmlWriter writer)
-
XmlDataWriter
public XmlDataWriter(Writer writer)
-
XmlDataWriter
public XmlDataWriter(OutputStream os) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(OutputStream os, String encoding) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(PrintStream out) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(PrintStream out, String encoding) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(String filename, String encoding, Compressor compressor) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(String filename, String encoding) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(String filename, Compressor compressor) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(String filename) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(File file, String encoding, Compressor compressor) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(File file, String encoding) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(File file, Compressor compressor) throws IOException
- Throws:
IOException
-
XmlDataWriter
public XmlDataWriter(File file) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getXmlWriter
public final XmlWriter getXmlWriter()
- Returns:
- The underlying XmlWriter.
-
write
public void write(Node node) throws IOException
Writes a node.- Parameters:
node- The node.- Throws:
IOException- When an IO error occurs.
-
write
public static void write(XmlWriter writer, Node node, boolean asDocument) throws IOException
Writes a node to an XmlWriter.- Parameters:
writer- The XmlWriter.node- The node.asDocument- Iftrueandnodeis not a document, inserts XML heading<?xml version="1.0" encoding="UTF-8"?>before writing thenode.
Iffalseandnodeis not a document, directly writes the node.
Ifnodeis a document, this has no effect.- Throws:
IOException- When an IO error occurs.
-
write
public static void write(XmlWriter writer, Node node) throws IOException
Writes a node to an XmlWriter.If
nodeis not a document, XML heading<?xml version="1.0" encoding="UTF-8"?>is not inserted.
Usewrite(XmlWriter, Node, boolean)for that.- Parameters:
writer- The XmlWriter.node- The node.- Throws:
IOException- When an IO error occurs.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Throws:
IOException
-
print
public static void print(Node node, boolean asDocument, PrintStream out, String indent, boolean close, XmlWriter.Feature... features) throws IOException
Prints a Node to a PrintStream.- Parameters:
node- The node.asDocument- Iftrueandnodeis not a document, inserts XML heading<?xml version="1.0" encoding="UTF-8"?>before writing thenode.
Iffalseandnodeis not a document, directly writes the node.
Ifnodeis a document, this has no effect.out- The PrintStream.indent- Indent string. If not null, pretty printing is enabled.close- Iftrue,outis closed in the end.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
print
public static void print(Document doc, PrintStream out, String indent, boolean close, XmlWriter.Feature... features) throws IOException
Prints a Document to a PrintStream.- Parameters:
doc- The document.out- The PrintStream.indent- Indent string. If not null, pretty printing is enabled.close- Iftrue,outis closed in the end.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
save
public static void save(Node node, boolean asDocument, Writer writer, String indent, XmlWriter.Feature... features) throws IOException
Saves a Node to a Writer.- Parameters:
node- The node.asDocument- Iftrueandnodeis not a document, inserts XML heading<?xml version="1.0" encoding="UTF-8"?>before writing thenode.
Iffalseandnodeis not a document, directly writes the node.
Ifnodeis a document, this has no effect.writer- The writer.indent- Indent string. If not null, pretty printing is enabled.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
save
public static void save(Document doc, Writer writer, String indent, XmlWriter.Feature... features) throws IOException
Saves a Document to a Writer.- Parameters:
doc- The document.writer- The writer.indent- Indent string. If not null, pretty printing is enabled.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
save
public static void save(Node node, boolean asDocument, OutputStream os, String indent, XmlWriter.Feature... features) throws IOException
Saves a Node to an OutputStream.- Parameters:
node- The node.asDocument- Iftrueandnodeis not a document, inserts XML heading<?xml version="1.0" encoding="UTF-8"?>before writing thenode.
Iffalseandnodeis not a document, directly writes the node.
Ifnodeis a document, this has no effect.os- The output stream.indent- Indent string. If not null, pretty printing is enabled.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
save
public static void save(Document doc, OutputStream os, String indent, XmlWriter.Feature... features) throws IOException
Saves a Document to an OutputStream.- Parameters:
doc- The document.os- The output stream.indent- Indent string. If not null, pretty printing is enabled.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
save
public static void save(Node node, boolean asDocument, String filename, String indent, XmlWriter.Feature... features) throws IOException
Saves a Node to a File.- Parameters:
node- The node.asDocument- Iftrueandnodeis not a document, inserts XML heading<?xml version="1.0" encoding="UTF-8"?>before writing thenode.
Iffalseandnodeis not a document, directly writes the node.
Ifnodeis a document, this has no effect.filename- The file name.indent- Indent string. If not null, pretty printing is enabled.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
save
public static void save(Document doc, String filename, String indent, XmlWriter.Feature... features) throws IOException
Saves a Document to a File.- Parameters:
doc- The document.filename- The file name.indent- Indent string. If not null, pretty printing is enabled.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
save
public static void save(Node node, boolean asDocument, File file, String indent, XmlWriter.Feature... features) throws IOException
Saves a Node to a File.- Parameters:
node- The node.asDocument- Iftrueandnodeis not a document, inserts XML heading<?xml version="1.0" encoding="UTF-8"?>before writing thenode.
Iffalseandnodeis not a document, directly writes the node.
Ifnodeis a document, this has no effect.file- The file.indent- Indent string. If not null, pretty printing is enabled.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
save
public static void save(Document doc, File file, String indent, XmlWriter.Feature... features) throws IOException
Saves a Document to a File.- Parameters:
doc- The document.file- The file.indent- Indent string. If not null, pretty printing is enabled.features- The XmlWriter features to enable.- Throws:
IOException- When an IO error occurs.
-
toString
public static String toString(Document doc, String indent, XmlWriter.Feature... features)
-
toString
public static String toString(Node node, boolean asDocument, String indent, XmlWriter.Feature... features)
-
-