com.fasterxml.aalto.evt

## Class EventAllocatorImpl

- java.lang.Object
- - org.codehaus.stax2.ri.evt.Stax2EventAllocatorImpl
  - - com.fasterxml.aalto.evt.EventAllocatorImpl

- All Implemented Interfaces:
    XMLEventAllocator, XMLStreamConstants

      public final class EventAllocatorImpl
      extends org.codehaus.stax2.ri.evt.Stax2EventAllocatorImpl

  Specialized event allocator implementation. Beyond additions needed to support DTD entities, implements non-location-preserving optimization.
  Author:
    Tatu Saloranta

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `_cfgPreserveLocation`
    `protected Location` | `_lastLocation` Last used location info; only relevant to non-accurate-location allocators.

    - ### Fields inherited from interface javax.xml.stream.XMLStreamConstants

      `ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `EventAllocatorImpl(boolean preserveLocation)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `XMLEvent` | `allocate(XMLStreamReader r)`
    `static EventAllocatorImpl` | `getDefaultInstance()`
    `static EventAllocatorImpl` | `getFastInstance()`
    `protected Location` | `getLocation(XMLStreamReader r)` Method used to get the `Location` object to use for an event to create.
    `XMLEventAllocator` | `newInstance()` Default implementation assumes that the caller knows how to share instances, and so need not create new copies.

    - ### Methods inherited from class org.codehaus.stax2.ri.evt.Stax2EventAllocatorImpl

      `allocate, createDTD, createEntityReference, createStartElement`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _cfgPreserveLocation

          protected final boolean _cfgPreserveLocation

    - #### _lastLocation

          protected Location _lastLocation

      Last used location info; only relevant to non-accurate-location allocators.

  - ### Constructor Detail

    - #### EventAllocatorImpl

          protected EventAllocatorImpl(boolean preserveLocation)

      Parameters:
        `preserveLocation` - 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.

  - ### Method Detail

    - #### getDefaultInstance

          public static EventAllocatorImpl getDefaultInstance()

    - #### getFastInstance

          public static EventAllocatorImpl getFastInstance()

    - #### newInstance

          public XMLEventAllocator newInstance()

      Default implementation assumes that the caller knows how to share instances, and so need not create new copies.

      Note: if this class is sub-classes, this method should be redefined if assumptions about shareability do not hold.

      Specified by:
        `newInstance` in interface `XMLEventAllocator`
      Overrides:
        `newInstance` in class `org.codehaus.stax2.ri.evt.Stax2EventAllocatorImpl`

    - #### allocate

          public XMLEvent allocate(XMLStreamReader r)
                            throws XMLStreamException

      Specified by:
        `allocate` in interface `XMLEventAllocator`
      Overrides:
        `allocate` in class `org.codehaus.stax2.ri.evt.Stax2EventAllocatorImpl`
      Throws:
        `XMLStreamException`

    - #### getLocation

          protected Location getLocation(XMLStreamReader r)

      Method used to get the `Location` object to use for an event to create. Base implementation just calls stream reader's accessors, but sub-classes may choose to use other methods (esp. when not in "preserve location" mode).
      Overrides:
        `getLocation` in class `org.codehaus.stax2.ri.evt.Stax2EventAllocatorImpl`

Copyright © 2018 FasterXML. All rights reserved.