Class StAXEventAllocatorBase
- java.lang.Object
-
- com.sun.xml.fastinfoset.stax.events.StAXEventAllocatorBase
-
- All Implemented Interfaces:
XMLEventAllocator
public class StAXEventAllocatorBase extends Object implements 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.
-
-
Constructor Summary
Constructors Constructor Description StAXEventAllocatorBase()Creates a new instance of XMLEventAllocator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAttributes(StartElementEvent event, XMLStreamReader streamReader)protected voidaddNamespaces(EndElementEvent event, XMLStreamReader streamReader)protected voidaddNamespaces(StartElementEvent event, XMLStreamReader streamReader)XMLEventallocate(XMLStreamReader streamReader)This method allocates an event given the current state of the XMLStreamReader.voidallocate(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.XMLEventAllocatornewInstance()This method creates an instance of the XMLEventAllocator.
-
-
-
Method Detail
-
newInstance
public XMLEventAllocator newInstance()
This method creates an instance of the XMLEventAllocator. This allows the XMLInputFactory to allocate a new instance per reader.- Specified by:
newInstancein interfaceXMLEventAllocator
-
allocate
public XMLEvent allocate(XMLStreamReader streamReader) throws XMLStreamException
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:
allocatein 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:
allocatein interfaceXMLEventAllocator- Parameters:
streamReader- The XMLStreamReader to allocate fromconsumer- The XMLEventConsumer to add to.- Throws:
XMLStreamException
-
addAttributes
protected void addAttributes(StartElementEvent event, XMLStreamReader streamReader)
-
addNamespaces
protected void addNamespaces(StartElementEvent event, XMLStreamReader streamReader)
-
addNamespaces
protected void addNamespaces(EndElementEvent event, XMLStreamReader streamReader)
-
-