public class XmlWriter extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
CLOSE
A constant for close.
|
static boolean |
OPEN
A constant for open.
|
Constructor and Description |
---|
XmlWriter(Writer writer)
Creates a new XML writer for the specified character stream.
|
XmlWriter(Writer writer,
String indentString)
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.
|
Modifier and Type | Method and Description |
---|---|
void |
addImpliedNamespace(String uri,
String prefix) |
void |
close()
Closes the underlying character stream.
|
void |
flush()
Flushs the underlying writer.
|
int |
getAdditionalIndent() |
TagDescription |
getTagDescription() |
boolean |
isAlwaysAddNamespace() |
boolean |
isAssumeDefaultNamespace() |
boolean |
isHtmlCompatiblityMode() |
boolean |
isLineEmpty() |
boolean |
isNamespaceDefined(String namespace) |
boolean |
isNamespacePrefixDefined(String prefix) |
boolean |
isWriteFinalLinebreak() |
void |
setAdditionalIndent(int additionalIndent) |
void |
setAlwaysAddNamespace(boolean b) |
void |
setAssumeDefaultNamespace(boolean assumeDefaultNamespace) |
void |
setEncoding(String encoding) |
void |
setHtmlCompatiblityMode(boolean htmlCompatiblityMode) |
void |
setLineEmpty(boolean lineEmpty) |
void |
setWriteFinalLinebreak(boolean writeFinalLinebreak) |
void |
writeCloseTag()
Writes a closing XML tag.
|
void |
writeComment(String comment)
Writes a comment into the generated xml file.
|
void |
writeNewLine()
Writes a linebreak to the writer.
|
void |
writeStream(Reader reader)
Copies the given reader to the character stream.
|
void |
writeTag(String namespace,
String name,
AttributeList attributes,
boolean close)
Writes an opening XML tag along with a list of attribute/value pairs.
|
void |
writeTag(String namespace,
String name,
boolean close)
Writes an opening XML tag that has no attributes.
|
void |
writeTag(String namespace,
String name,
String attributeName,
String attributeValue,
boolean close)
Writes an opening XML tag with an attribute/value pair.
|
void |
writeText(String text)
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.
|
public static final boolean CLOSE
public static final boolean OPEN
public XmlWriter(Writer writer)
writer
- the character stream.public XmlWriter(Writer writer, TagDescription tagDescription)
writer
- the character stream.tagDescription
- the tags that are safe for line breaks.public XmlWriter(Writer writer, String indentString)
writer
- the character stream.indentString
- the string used for indentation (should contain white space, for example four spaces).public XmlWriter(Writer writer, TagDescription tagDescription, String indentString)
writer
- the character stream.tagDescription
- the tags that are safe for line breaks.indentString
- the indent string.public XmlWriter(Writer writer, TagDescription tagDescription, String indentString, String lineSeparator)
writer
- the character stream.tagDescription
- the tags that are safe for line breaks.indentString
- the indent string.lineSeparator
- the line separator to be used.public void writeXmlDeclaration(String encoding) throws IOException
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).IOException
- if there is a problem writing to the character stream.public void writeTag(String namespace, String name, boolean close) throws IOException
namespace
- the namespace URI for the elementname
- the tag name.close
- a flag that controls whether or not the tag is closed immediately.IOException
- if there is an I/O problem.public void writeCloseTag() throws IOException
IOException
- if there is an I/O problem.public void writeTag(String namespace, String name, String attributeName, String attributeValue, boolean close) throws IOException
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.IOException
- if there is an I/O problem.public void writeTag(String namespace, String name, AttributeList attributes, boolean close) throws IOException
namespace
- the namespace URI for the elementname
- the tag name.attributes
- the attributes.close
- controls whether the tag is closed.IOException
- if there is an I/O problem.public void writeText(String text) throws IOException
text
- the text.IOException
- if there is a problem writing to the character stream.public void writeTextNormalized(String s, boolean transformNewLine) throws IOException
s
- the string to be written.transformNewLine
- whether to encode newlines using character-entities.IOException
- if an IO error occured.public void writeStream(Reader reader) throws IOException
reader
- the reader providing the text.IOException
- if there is a problem writing to the character stream.public void close() throws IOException
IOException
- if there is a problem closing the character stream.public void writeComment(String comment) throws IOException
comment
- the comment textIOException
- if there is a problem writing to the character stream.public void writeNewLine() throws IOException
IOException
- if there is a problem writing to the character stream.public void flush() throws IOException
IOException
- if something goes wrong.public boolean isNamespaceDefined(String namespace)
public void setAlwaysAddNamespace(boolean b)
public void setAssumeDefaultNamespace(boolean assumeDefaultNamespace)
public boolean isAssumeDefaultNamespace()
public boolean isAlwaysAddNamespace()
public void setHtmlCompatiblityMode(boolean htmlCompatiblityMode)
public boolean isHtmlCompatiblityMode()
public void setWriteFinalLinebreak(boolean writeFinalLinebreak)
public boolean isWriteFinalLinebreak()
public void setEncoding(String encoding)
public void setLineEmpty(boolean lineEmpty)
public boolean isLineEmpty()
public boolean isNamespacePrefixDefined(String prefix)
public int getAdditionalIndent()
public void setAdditionalIndent(int additionalIndent)
public TagDescription getTagDescription()
Copyright © 2002–2017 Pentaho Corporation. All rights reserved.