java.lang.Object
org.xbib.content.xml.stream.EventWriterDelegate
org.xbib.content.xml.stream.IndentingXMLEventWriter
- All Implemented Interfaces:
XMLEventConsumer,XMLEventWriter,Indentation
A filter that indents an XML stream. To apply it, construct a filter that
contains another
XMLEventWriter, which you pass to the constructor.
Then call methods of the filter instead of the contained stream. For example:
The filter inserts characters to format the document as an outline, with nested elements indented. Basically, it inserts a line break and whitespace before:XMLEventWriterstream = ... stream = newIndentingXMLEventWriter(stream); stream.add(...);
- 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
Indentation can be adjusted by setting the newLine and indent properties. But set them to whitespace only, for best results. Non-whitespace is apt to cause problems, for example when this class attempts to insert newLine before the root element.
-
Field Summary
Fields inherited from class org.xbib.content.xml.stream.EventWriterDelegate
outFields inherited from interface org.xbib.content.xml.stream.Indentation
DEFAULT_INDENT, NORMAL_END_OF_LINE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidThe characters used for one level of indentation.voidSet the characters used for one level of indentation.Methods inherited from class org.xbib.content.xml.stream.EventWriterDelegate
add, close, flush, getNamespaceContext, getPrefix, setDefaultNamespace, setNamespaceContext, setPrefix
-
Constructor Details
-
IndentingXMLEventWriter
-
-
Method Details
-
getIndent
Description copied from interface:IndentationThe characters used for one level of indentation.- Specified by:
getIndentin interfaceIndentation- Returns:
- the indentation string
-
setIndent
Description copied from interface:IndentationSet the characters used for one level of indentation. The default isIndentation.DEFAULT_INDENT. "\t" is a popular alternative.- Specified by:
setIndentin interfaceIndentation- Parameters:
indent- the indentation string
-
add
- Specified by:
addin interfaceXMLEventConsumer- Specified by:
addin interfaceXMLEventWriter- Overrides:
addin classEventWriterDelegate- Throws:
XMLStreamException
-
beforeMarkup
- Throws:
XMLStreamException
-
afterMarkup
protected void afterMarkup() -
afterData
protected void afterData() -
beforeStartElement
- Throws:
XMLStreamException
-
afterStartElement
protected void afterStartElement() -
beforeEndElement
protected void beforeEndElement() -
afterEndElement
protected void afterEndElement() -
afterEndDocument
- Throws:
XMLStreamException
-