Top Description Methods
org.jdom2.output.support

public Interface StAXEventProcessor

Known Direct Implementers
org.jdom2.output.support.AbstractStAXEventProcessor
Imports
java.util.List, javax.xml.stream.XMLEventFactory, .XMLStreamException, javax.xml.stream.util.XMLEventConsumer, org.jdom2.Attribute, .CDATA, .Comment, .Content, .DocType, .Document, .Element, .EntityRef, .ProcessingInstruction, .Text, org.jdom2.output.Format, .XMLOutputter

This interface provides a base support for the XMLOutputter.

People who want to create a custom XMLOutputProcessor for XMLOutputter are able to implement this interface with the following notes and restrictions:

  1. The XMLOutputter will call one, and only one of the process(XMLEventConsumer,Format,*) methods each time the XMLOutputter is requested to output some JDOM content. It is thus safe to assume that a process(XMLEventConsumer,Format,*) method can set up any infrastructure needed to process the content, and that the XMLOutputter will not re-call that method, or some other process(XMLEventConsumer,Format,*) method for the same output sequence.
  2. The process methods should be thread-safe and reentrant: The same process(XMLEventConsumer,Format,*) method may (will) be called concurrently from different threads.

The AbstractXMLOutputProcessor class is a full implementation of this interface and is fully customisable. People who want a custom XMLOutputter are encouraged to extend the AbstractXMLOutputProcessor rather than do a full re-implementation of this interface.

Author
Rolf Lear
Since
JDOM2
See Also
XMLOutputter, AbstractXMLOutputProcessor

Method Summary

Modifier and TypeMethod and Description
public void
process(XMLEventConsumer
XMLEventConsumer to use.
out
,
Format
Format instance specifying output style
format
,
XMLEventFactory
XMLEventFactory for creating XMLEvent instances.
eventfactory
,
Document
Document to format.
doc
)

This will print the Document to the given XMLEventConsumer.

public void
process(XMLEventConsumer
XMLEventConsumer to use.
out
,
Format
Format instance specifying output style
format
,
XMLEventFactory
XMLEventFactory for creating XMLEvent instances.
eventfactory
,
DocType
DocType to output.
doctype
)

Print out the DocType.

public void
process(XMLEventConsumer
XMLEventConsumer to use.
out
,
Format
Format instance specifying output style
format
,
XMLEventFactory
XMLEventFactory for creating XMLEvent instances.
eventfactory
,
Element
Element to output.
element
)

Print out an Element, including its Attributes, and all contained (child) elements, etc.

public void
process(XMLEventConsumer
XMLEventConsumer to use.
out
,
Format
Format instance specifying output style
format
,
XMLEventFactory
XMLEventFactory for creating XMLEvent instances.
eventfactory
,
List<? extends Content>
List of nodes.
list
)

This will handle printing out a list of nodes.

public void
process(XMLEventConsumer
XMLEventConsumer to use.
out
,
Format
Format instance specifying output style
format
,
XMLEventFactory
XMLEventFactory for creating XMLEvent instances.
eventfactpry
,
CDATA
CDATA to output.
cdata
)

Print out a CDATA node.

public void
process(XMLEventConsumer
XMLEventConsumer to use.
out
,
Format
Format instance specifying output style
format
,
XMLEventFactory
XMLEventFactory for creating XMLEvent instances.
eventfactory
,
Text
Text to output.
text
)

Print out a Text node.

public void
process(XMLEventConsumer
XMLEventConsumer to use.
out
,
Format
Format instance specifying output style
format
,
XMLEventFactory
XMLEventFactory for creating XMLEvent instances.
eventfactory
,
Comment
Comment to output.
comment
)

Print out a Comment.

public void
process(XMLEventConsumer
XMLEventConsumer to use.
out
,
Format
Format instance specifying output style
format
,
XMLEventFactory
XMLEventFactory for creating XMLEvent instances.
eventfactory
,
ProcessingInstruction
ProcessingInstruction to output.
pi
)

Print out a ProcessingInstruction.

public void
process(XMLEventConsumer
XMLEventConsumer to use.
out
,
Format
Format instance specifying output style
format
,
XMLEventFactory
XMLEventFactory for creating XMLEvent instances.
eventfactory
,
EntityRef
EntityRef to output.
entity
)

Print out a EntityRef.

Method Detail

processback to summary
public void process(XMLEventConsumer out, Format format, XMLEventFactory eventfactory, Document doc) throws XMLStreamException

This will print the Document to the given XMLEventConsumer.

Warning

using your own XMLEventConsumer may cause the outputter's preferred character encoding to be ignored. If you use encodings other than UTF-8, we recommend using the method that takes an OutputStream instead.

Parameters
out:XMLEventConsumer

XMLEventConsumer to use.

format:Format

Format instance specifying output style

eventfactory:XMLEventFactory

XMLEventFactory for creating XMLEvent instances.

doc:Document

Document to format.

Exceptions
XMLStreamException:
if there's any problem writing.
NullPointerException:
if the input content is null
processback to summary
public void process(XMLEventConsumer out, Format format, XMLEventFactory eventfactory, DocType doctype) throws XMLStreamException

Print out the DocType.

Parameters
out:XMLEventConsumer

XMLEventConsumer to use.

format:Format

Format instance specifying output style

eventfactory:XMLEventFactory

XMLEventFactory for creating XMLEvent instances.

doctype:DocType

DocType to output.

Exceptions
XMLStreamException:
if there's any problem writing.
NullPointerException:
if the input content is null
processback to summary
public void process(XMLEventConsumer out, Format format, XMLEventFactory eventfactory, Element element) throws XMLStreamException

Print out an Element, including its Attributes, and all contained (child) elements, etc.

Parameters
out:XMLEventConsumer

XMLEventConsumer to use.

format:Format

Format instance specifying output style

eventfactory:XMLEventFactory

XMLEventFactory for creating XMLEvent instances.

element:Element

Element to output.

Exceptions
XMLStreamException:
if there's any problem writing.
NullPointerException:
if the input content is null
processback to summary
public void process(XMLEventConsumer out, Format format, XMLEventFactory eventfactory, List<? extends Content> list) throws XMLStreamException

This will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".

Parameters
out:XMLEventConsumer

XMLEventConsumer to use.

format:Format

Format instance specifying output style

eventfactory:XMLEventFactory

XMLEventFactory for creating XMLEvent instances.

list:List<? extends Content>

List of nodes.

Exceptions
XMLStreamException:
if there's any problem writing.
NullPointerException:
if the input list is null or contains null members
ClassCastException:
if any of the list members are not Content
processback to summary
public void process(XMLEventConsumer out, Format format, XMLEventFactory eventfactpry, CDATA cdata) throws XMLStreamException

Print out a CDATA node.

Parameters
out:XMLEventConsumer

XMLEventConsumer to use.

format:Format

Format instance specifying output style

eventfactpry:XMLEventFactory

XMLEventFactory for creating XMLEvent instances.

cdata:CDATA

CDATA to output.

Exceptions
XMLStreamException:
if there's any problem writing.
NullPointerException:
if the input content is null
processback to summary
public void process(XMLEventConsumer out, Format format, XMLEventFactory eventfactory, Text text) throws XMLStreamException

Print out a Text node. Performs the necessary entity escaping and whitespace stripping.

Parameters
out:XMLEventConsumer

XMLEventConsumer to use.

format:Format

Format instance specifying output style

eventfactory:XMLEventFactory

XMLEventFactory for creating XMLEvent instances.

text:Text

Text to output.

Exceptions
XMLStreamException:
if there's any problem writing.
NullPointerException:
if the input content is null
processback to summary
public void process(XMLEventConsumer out, Format format, XMLEventFactory eventfactory, Comment comment) throws XMLStreamException

Print out a Comment.

Parameters
out:XMLEventConsumer

XMLEventConsumer to use.

format:Format

Format instance specifying output style

eventfactory:XMLEventFactory

XMLEventFactory for creating XMLEvent instances.

comment:Comment

Comment to output.

Exceptions
XMLStreamException:
if there's any problem writing.
NullPointerException:
if the input content is null
processback to summary
public void process(XMLEventConsumer out, Format format, XMLEventFactory eventfactory, ProcessingInstruction pi) throws XMLStreamException

Print out a ProcessingInstruction.

Parameters
out:XMLEventConsumer

XMLEventConsumer to use.

format:Format

Format instance specifying output style

eventfactory:XMLEventFactory

XMLEventFactory for creating XMLEvent instances.

pi:ProcessingInstruction

ProcessingInstruction to output.

Exceptions
XMLStreamException:
if there's any problem writing.
NullPointerException:
if the input content is null
processback to summary
public void process(XMLEventConsumer out, Format format, XMLEventFactory eventfactory, EntityRef entity) throws XMLStreamException

Print out a EntityRef.

Parameters
out:XMLEventConsumer

XMLEventConsumer to use.

format:Format

Format instance specifying output style

eventfactory:XMLEventFactory

XMLEventFactory for creating XMLEvent instances.

entity:EntityRef

EntityRef to output.

Exceptions
XMLStreamException:
if there's any problem writing.
NullPointerException:
if the input content is null