public class DefaultEventAllocator extends ElemCallback implements XMLEventAllocator, XMLStreamConstants
XMLEventAllocator
, to be
used with Woodstox' event reader.
One of few complications here is the way start elements are constructed. The pattern used is double-indirection, needed to get a callback from the stream reader, with data we need for constructing even Object... but without stream reader having any understanding of event Objects per se.
03-Dec-2004, TSa: One additional twist is that it's now possible to create slightly faster event handling, by indicating that the fully accurate Location information is not necessary. If so, allocator will just use one shared Location object passed to all event objects constructed.
Modifier and Type | Field and Description |
---|---|
protected boolean |
mAccurateLocation |
protected Location |
mLastLocation
Last used location info; only relevant to non-accurate-location
allocators.
|
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
Modifier | Constructor and Description |
---|---|
protected |
DefaultEventAllocator(boolean accurateLocation) |
Modifier and Type | Method and Description |
---|---|
XMLEvent |
allocate(XMLStreamReader r) |
void |
allocate(XMLStreamReader r,
XMLEventConsumer consumer) |
static DefaultEventAllocator |
getDefaultInstance() |
static DefaultEventAllocator |
getFastInstance() |
XMLEventAllocator |
newInstance() |
Object |
withStartElement(Location loc,
QName name,
BaseNsContext nsCtxt,
ElemAttrs attrs,
boolean wasEmpty) |
protected final boolean mAccurateLocation
protected Location mLastLocation
protected DefaultEventAllocator(boolean accurateLocation)
accurateLocation
- If true, allocator will construct instances
that have accurate location information; if false, instances
will only have some generic shared Location info. Latter option
will reduce memory usage/thrashing a bit, and may improve speed.public static DefaultEventAllocator getDefaultInstance()
public static DefaultEventAllocator getFastInstance()
public XMLEvent allocate(XMLStreamReader r) throws XMLStreamException
allocate
in interface XMLEventAllocator
XMLStreamException
public void allocate(XMLStreamReader r, XMLEventConsumer consumer) throws XMLStreamException
allocate
in interface XMLEventAllocator
XMLStreamException
public XMLEventAllocator newInstance()
newInstance
in interface XMLEventAllocator
public Object withStartElement(Location loc, QName name, BaseNsContext nsCtxt, ElemAttrs attrs, boolean wasEmpty)
withStartElement
in class ElemCallback
Copyright © 2018 FasterXML. All rights reserved.