Top Description Fields Constructors Methods
com.sun.xml.fastinfoset.stax.events

public Class StAXEventAllocatorBase

extends Object
implements XMLEventAllocator
Class Inheritance
All Implemented Interfaces
javax.xml.stream.util.XMLEventAllocator
Imports
javax.xml.stream.XMLEventFactory, .XMLStreamConstants, .XMLStreamException, .XMLStreamReader, javax.xml.stream.events.Namespace, .XMLEvent, javax.xml.stream.util.XMLEventAllocator, .XMLEventConsumer, com.sun.xml.fastinfoset.CommonResourceBundle

allows a user to register a way to allocate events given an XMLStreamReader. The XMLEventAllocator can be set on an XMLInputFactory using the property "javax.xml.stream.allocator"

This base class uses EventFactory to create events as recommended in the JavaDoc of XMLEventAllocator. However, creating new object per each event reduces performance. The implementation of EventReader therefore will set the Allocator to StAXEventAllocator which implements the Allocate methods without creating new objects.

The spec for the first Allocate method states that it must NOT modify the state of the Reader while the second MAY. For consistency, both Allocate methods in this implementation will NOT modify the state.

Field Summary

Modifier and TypeField and Description
pack-priv XMLEventFactory

Constructor Summary

AccessConstructor and Description
public
StAXEventAllocatorBase()

Creates a new instance of XMLEventAllocator

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
protected void
public XMLEvent

Returns:

the event corresponding to the current reader state
allocate
(XMLStreamReader
The XMLStreamReader to allocate from
streamReader
)

Implements javax.xml.stream.util.XMLEventAllocator.allocate.

This method allocates an event given the current state of the XMLStreamReader.

public void
allocate(XMLStreamReader
The XMLStreamReader to allocate from
streamReader
,
XMLEventConsumer
The XMLEventConsumer to add to.
consumer
)

Implements javax.xml.stream.util.XMLEventAllocator.allocate.

This method allocates an event or set of events given the current state of the XMLStreamReader and adds the event or set of events to the consumer that was passed in.

pack-priv XMLEvent
public XMLEventAllocator
newInstance()

Implements javax.xml.stream.util.XMLEventAllocator.newInstance.

This method creates an instance of the XMLEventAllocator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoryback to summary
pack-priv XMLEventFactory factory

Constructor Detail

StAXEventAllocatorBaseback to summary
public StAXEventAllocatorBase()

Creates a new instance of XMLEventAllocator

Method Detail

addAttributesback to summary
protected void addAttributes(StartElementEvent event, XMLStreamReader streamReader)
addNamespacesback to summary
protected void addNamespaces(StartElementEvent event, XMLStreamReader streamReader)
addNamespacesback to summary
protected void addNamespaces(EndElementEvent event, XMLStreamReader streamReader)
allocateback to summary
public XMLEvent allocate(XMLStreamReader streamReader) throws XMLStreamException

Implements javax.xml.stream.util.XMLEventAllocator.allocate.

This method allocates an event given the current state of the XMLStreamReader. If this XMLEventAllocator does not have a one-to-one mapping between reader state and events this method will return null.

Parameters
streamReader:XMLStreamReader

The XMLStreamReader to allocate from

Returns:XMLEvent

the event corresponding to the current reader state

Annotations
@Override
Exceptions
XMLStreamException:

Doc from javax.xml.stream.util.XMLEventAllocator.allocate.

if an error occurs

allocateback to summary
public void allocate(XMLStreamReader streamReader, XMLEventConsumer consumer) throws XMLStreamException

Implements javax.xml.stream.util.XMLEventAllocator.allocate.

This method allocates an event or set of events given the current state of the XMLStreamReader and adds the event or set of events to the consumer that was passed in.

Parameters
streamReader:XMLStreamReader

The XMLStreamReader to allocate from

consumer:XMLEventConsumer

The XMLEventConsumer to add to.

Annotations
@Override
Exceptions
XMLStreamException:

Doc from javax.xml.stream.util.XMLEventAllocator.allocate.

if an error occurs

getXMLEventback to summary
pack-priv XMLEvent getXMLEvent(XMLStreamReader reader)
newInstanceback to summary
public XMLEventAllocator newInstance()

Implements javax.xml.stream.util.XMLEventAllocator.newInstance.

This method creates an instance of the XMLEventAllocator. This allows the XMLInputFactory to allocate a new instance per reader.

Annotations
@Override