Class XmlWriter
java.lang.Object
org.pentaho.reporting.libraries.xmlns.writer.XmlWriterSupport
org.pentaho.reporting.libraries.xmlns.writer.XmlWriter
A class for writing XML to a character stream.
- Author:
- Thomas Morgner
-
Field Summary
Fields inherited from class org.pentaho.reporting.libraries.xmlns.writer.XmlWriterSupport
CLOSE, CLOSE_TAG_DECREASE, INDENT_ONLY, OPEN, OPEN_TAG_INCREASE
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new XML writer for the specified character stream.Creates a new XML writer for the specified character stream.XmlWriter
(Writer writer, TagDescription tagDescription) Default Constructor.XmlWriter
(Writer writer, TagDescription tagDescription, String indentString) Creates a new XMLWriter instance.XmlWriter
(Writer writer, TagDescription tagDescription, String indentString, String lineSeparator) Creates a new XMLWriter instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the underlying character stream.void
flush()
Flushs the underlying writer.void
Writes a closing XML tag.void
writeComment
(String comment) Writes a comment into the generated xml file.void
Writes a linebreak to the writer.void
writeStream
(Reader reader) Copies the given reader to the character stream.void
Writes an opening XML tag that has no attributes.void
Writes an opening XML tag with an attribute/value pair.void
writeTag
(String namespace, String name, AttributeList attributes, boolean close) Writes an opening XML tag along with a list of attribute/value pairs.void
Writes some text to the character stream.void
writeTextNormalized
(String s, boolean transformNewLine) Writes the given text into the stream using a streaming xml-normalization method.void
writeXmlDeclaration
(String encoding) Writes the XML declaration that usually appears at the top of every XML file.Methods inherited from class org.pentaho.reporting.libraries.xmlns.writer.XmlWriterSupport
addImpliedNamespace, copyNamespaces, getAdditionalIndent, getCurrentIndentLevel, getLineSeparator, getNamespaces, getTagDescription, indent, indentForClose, isAlwaysAddNamespace, isAssumeDefaultNamespace, isHtmlCompatiblityMode, isLineEmpty, isNamespaceDefined, isNamespacePrefixDefined, isWriteFinalLinebreak, normalize, normalizeLocal, setAdditionalIndent, setAlwaysAddNamespace, setAssumeDefaultNamespace, setHtmlCompatiblityMode, setLineEmpty, setWriteFinalLinebreak, writeCloseTag, writeComment, writeNewLine, writeTag, writeTag, writeTag, writeTextNormalized
-
Constructor Details
-
XmlWriter
Creates a new XML writer for the specified character stream. By default, four spaces are used for indentation.- Parameters:
writer
- the character stream.
-
XmlWriter
Default Constructor. The created XMLWriterSupport will not have no safe tags and starts with an indention level of 0.- Parameters:
writer
- the character stream.tagDescription
- the tags that are safe for line breaks.
-
XmlWriter
-
XmlWriter
Creates a new XMLWriter instance.- Parameters:
writer
- the character stream.tagDescription
- the tags that are safe for line breaks.indentString
- the indent string.
-
XmlWriter
public XmlWriter(Writer writer, TagDescription tagDescription, String indentString, String lineSeparator) Creates a new XMLWriter instance.- Parameters:
writer
- the character stream.tagDescription
- the tags that are safe for line breaks.indentString
- the indent string.lineSeparator
- the line separator to be used.
-
-
Method Details
-
writeXmlDeclaration
Writes the XML declaration that usually appears at the top of every XML file.- Parameters:
encoding
- the encoding that should be declared (this has to match the encoding of the writer, or funny things may happen when parsing the xml file later).- Throws:
IOException
- if there is a problem writing to the character stream.
-
writeTag
Writes an opening XML tag that has no attributes.- Parameters:
namespace
- the namespace URI for the elementname
- the tag name.close
- a flag that controls whether or not the tag is closed immediately.- Throws:
IOException
- if there is an I/O problem.
-
writeCloseTag
Writes a closing XML tag.- Throws:
IOException
- if there is an I/O problem.
-
writeTag
public void writeTag(String namespace, String name, String attributeName, String attributeValue, boolean close) throws IOException Writes an opening XML tag with an attribute/value pair.- Parameters:
namespace
- the namespace URI for the elementname
- the tag name.attributeName
- the attribute name.attributeValue
- the attribute value.close
- controls whether the tag is closed.- Throws:
IOException
- if there is an I/O problem.
-
writeTag
public void writeTag(String namespace, String name, AttributeList attributes, boolean close) throws IOException Writes an opening XML tag along with a list of attribute/value pairs.- Parameters:
namespace
- the namespace URI for the elementname
- the tag name.attributes
- the attributes.close
- controls whether the tag is closed.- Throws:
IOException
- if there is an I/O problem.
-
writeText
Writes some text to the character stream.- Parameters:
text
- the text.- Throws:
IOException
- if there is a problem writing to the character stream.
-
writeTextNormalized
Writes the given text into the stream using a streaming xml-normalization method.- Parameters:
s
- the string to be written.transformNewLine
- whether to encode newlines using character-entities.- Throws:
IOException
- if an IO error occured.
-
writeStream
Copies the given reader to the character stream. This method should be used for large chunks of data.- Parameters:
reader
- the reader providing the text.- Throws:
IOException
- if there is a problem writing to the character stream.
-
close
Closes the underlying character stream.- Throws:
IOException
- if there is a problem closing the character stream.
-
writeComment
Writes a comment into the generated xml file.- Parameters:
comment
- the comment text- Throws:
IOException
- if there is a problem writing to the character stream.
-
writeNewLine
Writes a linebreak to the writer.- Throws:
IOException
- if there is a problem writing to the character stream.
-
flush
Flushs the underlying writer.- Throws:
IOException
- if something goes wrong.
-