Module com.sun.xml.fastinfoset
Class StAXEventAllocatorBase
java.lang.Object
com.sun.xml.fastinfoset.stax.events.StAXEventAllocatorBase
- All Implemented Interfaces:
XMLEventAllocator
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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAttributes
(StartElementEvent event, XMLStreamReader streamReader) protected void
addNamespaces
(EndElementEvent event, XMLStreamReader streamReader) protected void
addNamespaces
(StartElementEvent event, XMLStreamReader streamReader) allocate
(XMLStreamReader streamReader) This method allocates an event given the current state of the XMLStreamReader.void
allocate
(XMLStreamReader streamReader, XMLEventConsumer consumer) 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.(package private) XMLEvent
getXMLEvent
(XMLStreamReader reader) This method creates an instance of the XMLEventAllocator.
-
Field Details
-
factory
XMLEventFactory factory
-
-
Constructor Details
-
StAXEventAllocatorBase
public StAXEventAllocatorBase()Creates a new instance of XMLEventAllocator
-
-
Method Details
-
newInstance
This method creates an instance of the XMLEventAllocator. This allows the XMLInputFactory to allocate a new instance per reader.- Specified by:
newInstance
in interfaceXMLEventAllocator
-
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.- Specified by:
allocate
in interfaceXMLEventAllocator
- Parameters:
streamReader
- The XMLStreamReader to allocate from- Returns:
- the event corresponding to the current reader state
- Throws:
XMLStreamException
-
allocate
public void allocate(XMLStreamReader streamReader, XMLEventConsumer consumer) throws XMLStreamException 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.- Specified by:
allocate
in interfaceXMLEventAllocator
- Parameters:
streamReader
- The XMLStreamReader to allocate fromconsumer
- The XMLEventConsumer to add to.- Throws:
XMLStreamException
-
getXMLEvent
-
addAttributes
-
addNamespaces
-
addNamespaces
-