public final class NodeBuilder extends Object
NodeBuilder
object is used to create either an
input node or an output node for a given source or destination.
If an InputNode
is required for reading an XML
document then a reader must be provided to read the content from.
If an OutputNode
is required then a destination is
required. The provided output node can be used to generate well
formed XML to the specified writer.
Constructor and Description |
---|
NodeBuilder() |
Modifier and Type | Method and Description |
---|---|
static InputNode |
read(InputStream source)
This is used to create an
InputNode that can be
used to read XML from the specified stream. |
static InputNode |
read(Reader source)
This is used to create an
InputNode that can be
used to read XML from the specified reader. |
static OutputNode |
write(Writer result)
This is used to create an
OutputNode that can be
used to write a well formed XML document. |
static OutputNode |
write(Writer result,
Format format)
This is used to create an
OutputNode that can be
used to write a well formed XML document. |
public NodeBuilder()
public static InputNode read(InputStream source) throws Exception
InputNode
that can be
used to read XML from the specified stream. The stream will
be positioned at the root element in the XML document.source
- this contains the contents of the XML sourceException
- thrown if there is an I/O exceptionpublic static InputNode read(Reader source) throws Exception
InputNode
that can be
used to read XML from the specified reader. The reader will
be positioned at the root element in the XML document.source
- this contains the contents of the XML sourceException
- thrown if there is an I/O exceptionpublic static OutputNode write(Writer result) throws Exception
OutputNode
that can be
used to write a well formed XML document. The writer specified
will have XML elements, attributes, and text written to it as
output nodes are created and populated.result
- this contains the result of the generated XMLException
- this is thrown if there is an I/O errorpublic static OutputNode write(Writer result, Format format) throws Exception
OutputNode
that can be
used to write a well formed XML document. The writer specified
will have XML elements, attributes, and text written to it as
output nodes are created and populated.result
- this contains the result of the generated XMLformat
- this is the format to use for the documentException
- this is thrown if there is an I/O error