Class AbstractStAXStreamProcessor

java.lang.Object
org.jdom2.output.support.AbstractOutputProcessor
org.jdom2.output.support.AbstractStAXStreamProcessor
All Implemented Interfaces:
StAXStreamProcessor

public abstract class AbstractStAXStreamProcessor extends AbstractOutputProcessor implements StAXStreamProcessor
This class provides a concrete implementation of StAXStreamProcessor for supporting the StAXStreamOutputter.

Overview

This class is marked abstract even though all methods are fully implemented. The process*(...) methods are public because they match the StAXStreamProcessor interface but the remaining methods are all protected.

People who want to create a custom StAXStreamProcessor for StAXStreamOutputter are able to extend this class and modify any functionality they want. Before sub-classing this you should first check to see if the Format class can get you the results you want.

Subclasses of this should have reentrant methods. This is easiest to accomplish simply by not allowing any instance fields. If your sub-class has an instance field/variable, then it's probably broken.

The Stacks

One significant feature of this implementation is that it creates and maintains both a NamespaceStack and FormatStack that are managed in the printElement(XMLStreamWriter, FormatStack, NamespaceStack, Element) method. The stacks are pushed and popped in that method only. They significantly improve the performance and readability of the code.

The NamespaceStack is only sent through to the printElement(XMLStreamWriter, FormatStack, NamespaceStack, Element) and printContent(XMLStreamWriter, FormatStack, NamespaceStack, Walker) methods, but the FormatStack is pushed through to all print* Methods.

An interesting read for people using this class: Apache Axiom notes on setPrefix().

Since:
JDOM2
Author:
Rolf Lear
See Also: