| 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 void | afterData() Note that data were written. | protected void | afterEndDocument() Note that a document was ended. | protected void | afterEndElement() Note that an element was ended. | protected void | afterMarkup() Note that markup or indentation was written. | protected void | afterStartElement() Note that an element was started. | protected void | beforeEndElement() Prepare to end an element, by writing a new line and indentation. | protected void | beforeMarkup() Prepare to write markup, by writing a new line and indentation. | protected void | beforeStartElement() Prepare to start an element, by allocating stack space. | public String | getIndent() | public static String | getLineSeparator() | public String | getNewLine() | public void | setIndent(String indent) Set the characters for one level of indentation. | public void | setNewLine(String newLine) Set the characters that introduce a new line. | public void | writeCData(String data) | public void | writeCharacters(String text) | public void | writeCharacters(char[] text, int start, int len) | public void | writeComment(String data) | public void | writeDTD(String dtd) | public void | writeEmptyElement(String localName) | public void | writeEmptyElement(String namespaceURI, String localName) | public void | writeEmptyElement(String prefix, String localName, String namespaceURI) | public void | writeEndDocument() | public void | writeEndElement() | public void | writeEntityRef(String name) | protected void | writeNewLine(int indentation) Write a line separator followed by indentation. | public void | writeProcessingInstruction(String target) | public void | writeProcessingInstruction(String target, String data) | public void | writeStartDocument() | public void | writeStartDocument(String version) | public void | writeStartDocument(String encoding, String version) | public void | writeStartElement(String localName) | public void | writeStartElement(String namespaceURI, String localName) | public void | writeStartElement(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)
|
|
|