public class PrettyPrintingXmlWriter extends Object
| Constructor and Description |
|---|
PrettyPrintingXmlWriter(OutputStream output)
Creates a xml writer instance using UTF-8 encoding.
|
PrettyPrintingXmlWriter(OutputStream output,
String encoding)
Creates a xml writer instance.
|
PrettyPrintingXmlWriter(Writer output,
String encoding)
Creates a xml writer instance using the specified writer.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getEncoding()
Returnd the encoding used by this xml writer.
|
void |
indentIfPrettyPrinting(int level)
Prints the indentation if we're pretty-printing.
|
boolean |
isPrettyPrinting()
Determines whether the output shall be pretty-printed.
|
void |
printlnIfPrettyPrinting()
Prints a newline if we're pretty-printing.
|
void |
setDefaultNamespace(String uri)
Sets the default namespace.
|
void |
setPrettyPrinting(boolean prettyPrinting)
Specifies whether the output shall be pretty-printed.
|
protected void |
throwException(Exception baseEx)
Rethrows the given exception, wrapped in a
DdlUtilsXMLException. |
void |
writeAttribute(String namespaceUri,
String localPart,
String value)
Writes an XML attribute.
|
void |
writeCData(String data)
Writes a CDATA segment.
|
void |
writeCharacters(String data)
Writes a text segment.
|
void |
writeDocumentEnd()
Writes the end of the XML document, i.e.
|
void |
writeDocumentStart()
Writes the start of the XML document, i.e.
|
void |
writeElementEnd()
Writes the end of the current XML element.
|
void |
writeElementStart(String namespaceUri,
String localPart)
Writes the start of the indicated XML element.
|
void |
writeNamespace(String prefix,
String namespaceUri)
Writes a xmlns attribute to the stream.
|
public PrettyPrintingXmlWriter(OutputStream output) throws DdlUtilsXMLException
output - The target to write the data XML toDdlUtilsXMLExceptionpublic PrettyPrintingXmlWriter(OutputStream output, String encoding) throws DdlUtilsXMLException
output - The target to write the data XML toencoding - The encoding of the XML fileDdlUtilsXMLExceptionpublic PrettyPrintingXmlWriter(Writer output, String encoding) throws DdlUtilsXMLException
output - The target to write the data XML toencoding - The encoding of the writerDdlUtilsXMLExceptionpublic String getEncoding()
protected void throwException(Exception baseEx) throws DdlUtilsXMLException
DdlUtilsXMLException. This
method allows subclasses to throw their own subclasses of this exception.baseEx - The original exceptionDdlUtilsXMLException - The wrapped exceptionpublic boolean isPrettyPrinting()
true if the output is pretty-printedpublic void setPrettyPrinting(boolean prettyPrinting)
prettyPrinting - true if the output is pretty-printedpublic void setDefaultNamespace(String uri) throws DdlUtilsXMLException
uri - The namespace uriDdlUtilsXMLExceptionpublic void printlnIfPrettyPrinting()
throws DdlUtilsXMLException
DdlUtilsXMLExceptionpublic void indentIfPrettyPrinting(int level)
throws DdlUtilsXMLException
level - The indentation levelDdlUtilsXMLExceptionpublic void writeDocumentStart()
throws DdlUtilsXMLException
DdlUtilsXMLExceptionpublic void writeDocumentEnd()
throws DdlUtilsXMLException
DdlUtilsXMLExceptionpublic void writeNamespace(String prefix, String namespaceUri) throws DdlUtilsXMLException
prefix - The prefix for the namespace, use null or an empty string for the default namespacenamespaceUri - The namespace uri, can be nullDdlUtilsXMLExceptionpublic void writeElementStart(String namespaceUri, String localPart) throws DdlUtilsXMLException
namespaceUri - The namespace uri, can be nulllocalPart - The local part of the element's qnameDdlUtilsXMLExceptionpublic void writeElementEnd()
throws DdlUtilsXMLException
DdlUtilsXMLExceptionpublic void writeAttribute(String namespaceUri, String localPart, String value) throws DdlUtilsXMLException
namespaceUri - The namespace uri, can be nulllocalPart - The local part of the attribute's qnamevalue - The value; if null then no attribute is writtenDdlUtilsXMLExceptionpublic void writeCData(String data) throws DdlUtilsXMLException
data - The data to writeDdlUtilsXMLExceptionpublic void writeCharacters(String data) throws DdlUtilsXMLException
data - The data to writeDdlUtilsXMLExceptionCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.