Top Description Fields Constructors Methods
org.jdom2.input

public Class StAXEventBuilder

extends Object
Class Inheritance
Imports
java.util.Iterator, javax.xml.namespace.QName, javax.xml.stream.XMLEventReader, .XMLStreamConstants, .XMLStreamException, javax.xml.stream.events.Characters, .StartElement, .XMLEvent, org.jdom2.AttributeType, .Comment, .DefaultJDOMFactory, .DocType, .Document, .Element, .JDOMException, .JDOMFactory, .Namespace, .ProcessingInstruction, org.jdom2.input.stax.DTDParser

Builds a JDOM Document from a StAX-based XMLEventReader.

XMLEventReaders are pre-configured and as a result JDOM is not able to alter whether the input is validated, or whether the Events have escaped entities or not. These (and other) characteristics are configurable by setting the correct features and properties on the XMLInputFactory when it is used to create the XMLStreamReader.

Useful configuration to set, or know about is:

From a JDOM perspective XMLStreamReaders are more efficient than XMLEventReaders. Where possible use an XMLStreamReader.

If you happen to be looking at the source code, pay careful attention to the imports so you know what type of instance is being processed, whether it is a StAX class, or a JDOM class, because there are name conflicts.

Author
Rolf Lear

Field Summary

Modifier and TypeField and Description
private JDOMFactory
factory

The factory to use for parsing

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Document

Returns:

Document resultant Document object
build
(XMLEventReader
XMLEventReader to read from
events
)

This builds a document from the supplied XMLEventReader.

public JDOMFactory

Returns:

the factory in use
getFactory
()

Returns the current org.jdom2.JDOMFactory in use.

private static final Document

Returns:

the parsed Document
process
(final JDOMFactory
the JDOMFactory to use
factory
,
final XMLEventReader
the XMLEventReader to read from
events
)

Create a Document from an XMLEventReader

private static final Element
processElement(final JDOMFactory factory, final StartElement event)

public void
setFactory(JDOMFactory
JDOMFactory to use
factory
)

This sets a custom JDOMFactory for the builder.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoryback to summary
private JDOMFactory factory

The factory to use for parsing

Constructor Detail

StAXEventBuilderback to summary
public StAXEventBuilder()

Method Detail

buildback to summary
public Document build(XMLEventReader events) throws JDOMException

This builds a document from the supplied XMLEventReader.

The JDOMContent will be built by the current JDOMFactory.

Parameters
events:XMLEventReader

XMLEventReader to read from

Returns:Document

Document resultant Document object

Exceptions
JDOMException:
when errors occur in parsing
getFactoryback to summary
public JDOMFactory getFactory()

Returns the current org.jdom2.JDOMFactory in use.

Returns:JDOMFactory

the factory in use

processback to summary
private static final Document process(final JDOMFactory factory, final XMLEventReader events) throws JDOMException

Create a Document from an XMLEventReader

Parameters
factory:JDOMFactory

the JDOMFactory to use

events:XMLEventReader

the XMLEventReader to read from

Returns:Document

the parsed Document

Exceptions
JDOMException:
if there is any issue (XMLStreamExceptions are wrapped).
processElementback to summary
private static final Element processElement(final JDOMFactory factory, final StartElement event)
setFactoryback to summary
public void setFactory(JDOMFactory factory)

This sets a custom JDOMFactory for the builder. Use this to build the tree with your own subclasses of the JDOM classes.

Parameters
factory:JDOMFactory

JDOMFactory to use