java.lang .Object javanet.staxutils .StreamWriterDelegate javanet.staxutils .IndentingXMLStreamWriter IndentingXMLStreamWriter public class IndentingXMLStreamWriter extends StreamWriterDelegate (Code) A filter that indents an XML stream. To apply it, construct a filter that
contains another
XMLStreamWriter , which you pass to the constructor.
Then call methods of the filter instead of the contained stream. For example:
XMLStreamWriter stream = ...
stream = new
IndentingXMLStreamWriter (stream);
stream.writeStartDocument();
...
The filter inserts characters to format the document as an outline, with
nested elements indented. Basically, it inserts a line break and whitespace
before:
each DTD, processing instruction or comment that's not preceded by data
each starting tag that's not preceded by data
each ending tag that's preceded by nested elements but not data
This works well with 'data-oriented' XML, wherein each element contains
either data or nested elements but not both. It can work badly with other
styles of XML. For example, the data in a 'mixed content' document are apt to
be polluted with indentation characters.
author: John Kristian
Method Summary protected voidafterData () Note that data were written.protected voidafterEndDocument () Note that a document was ended.protected voidafterEndElement () Note that an element was ended.protected voidafterMarkup () Note that markup or indentation was written.protected voidafterStartElement () Note that an element was started.protected voidbeforeEndElement () Prepare to end an element, by writing a new line and indentation.protected voidbeforeMarkup () Prepare to write markup, by writing a new line and indentation.protected voidbeforeStartElement () Prepare to start an element, by allocating stack space.public String getIndent () public static String getLineSeparator () public String getNewLine () public voidsetIndent (String indent) Set the characters for one level of indentation.public voidsetNewLine (String newLine) Set the characters that introduce a new line.public voidwriteCData (String data) public voidwriteCharacters (String text) public voidwriteCharacters (char[] text, int start, int len) public voidwriteComment (String data) public voidwriteDTD (String dtd) public voidwriteEmptyElement (String localName) public voidwriteEmptyElement (String namespaceURI, String localName) public voidwriteEmptyElement (String prefix, String localName, String namespaceURI) public voidwriteEndDocument () public voidwriteEndElement () public voidwriteEntityRef (String name) protected voidwriteNewLine (int indentation) Write a line separator followed by indentation.public voidwriteProcessingInstruction (String target) public voidwriteProcessingInstruction (String target, String data) public voidwriteStartDocument () public voidwriteStartDocument (String version) public voidwriteStartDocument (String encoding, String version) public voidwriteStartElement (String localName) public voidwriteStartElement (String namespaceURI, String localName) public voidwriteStartElement (String prefix, String localName, String namespaceURI)
DEFAULT_INDENT final public static String DEFAULT_INDENT (Code) Two spaces; the default indentation.
NORMAL_END_OF_LINE final public static String NORMAL_END_OF_LINE (Code) "\n"; the normalized representation of end-of-line in XML .
afterData protected void afterData()(Code) Note that data were written.
afterEndDocument protected void afterEndDocument()(Code) Note that a document was ended.
afterEndElement protected void afterEndElement()(Code) Note that an element was ended.
afterMarkup protected void afterMarkup()(Code) Note that markup or indentation was written.
afterStartElement protected void afterStartElement()(Code) Note that an element was started.
beforeEndElement protected void beforeEndElement()(Code) Prepare to end an element, by writing a new line and indentation.
beforeMarkup protected void beforeMarkup()(Code) Prepare to write markup, by writing a new line and indentation.
beforeStartElement protected void beforeStartElement()(Code) Prepare to start an element, by allocating stack space.
writeNewLine protected void writeNewLine(int indentation) throws XMLStreamException (Code) Write a line separator followed by indentation.
Methods inherited from javanet.staxutils.StreamWriterDelegate public void close() throws XMLStreamException (Code) (Java Doc) public void flush() throws XMLStreamException (Code) (Java Doc) public NamespaceContext getNamespaceContext()(Code) (Java Doc) public String getPrefix(String uri) throws XMLStreamException (Code) (Java Doc) public Object getProperty(String name) throws IllegalArgumentException (Code) (Java Doc) public void setDefaultNamespace(String uri) throws XMLStreamException (Code) (Java Doc) public void setNamespaceContext(NamespaceContext context) throws XMLStreamException (Code) (Java Doc) public void setPrefix(String prefix, String uri) throws XMLStreamException (Code) (Java Doc) public void writeAttribute(String localName, String value) throws XMLStreamException (Code) (Java Doc) public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException (Code) (Java Doc) public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException (Code) (Java Doc) public void writeCData(String data) throws XMLStreamException (Code) (Java Doc) public void writeCharacters(String text) throws XMLStreamException (Code) (Java Doc) public void writeCharacters(char[] text, int start, int len) throws XMLStreamException (Code) (Java Doc) public void writeComment(String data) throws XMLStreamException (Code) (Java Doc) public void writeDTD(String dtd) throws XMLStreamException (Code) (Java Doc) public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException (Code) (Java Doc) public void writeEmptyElement(String localName) throws XMLStreamException (Code) (Java Doc) public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException (Code) (Java Doc) public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException (Code) (Java Doc) public void writeEndDocument() throws XMLStreamException (Code) (Java Doc) public void writeEndElement() throws XMLStreamException (Code) (Java Doc) public void writeEntityRef(String name) throws XMLStreamException (Code) (Java Doc) public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException (Code) (Java Doc) public void writeProcessingInstruction(String target) throws XMLStreamException (Code) (Java Doc) public void writeProcessingInstruction(String target, String data) throws XMLStreamException (Code) (Java Doc) public void writeStartDocument() throws XMLStreamException (Code) (Java Doc) public void writeStartDocument(String version) throws XMLStreamException (Code) (Java Doc) public void writeStartDocument(String encoding, String version) throws XMLStreamException (Code) (Java Doc) public void writeStartElement(String localName) throws XMLStreamException (Code) (Java Doc) public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException (Code) (Java Doc) public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException (Code) (Java Doc)