Class StaxStreamIO

java.lang.Object
org.apache.sis.internal.storage.xml.stream.StaxStreamIO
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
StaxStreamReader, StaxStreamWriter

abstract class StaxStreamIO extends Object implements AutoCloseable
Common base class for StaxStreamReader and StaxStreamWriter. StaxStreamIO subclasses are not used directly (they are Apache SIS internal mechanic); they are rather used as helper classes for DataStore implementations. Those DataStores will typically manage StaxStreamReader and StaxStreamWriter instances on which they delegate their read and write operations.

Multi-threading

This class and subclasses are not tread-safe. Synchronization shall be done by the DataStore that contains the StaxStreamIO instances.
Since:
0.8
Version:
0.8
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The (un)marshaller pool, fetched when first needed.
    protected final StaxDataStore
    The data store for which this reader or writer has been created.
    (package private) AutoCloseable
    The underlying stream to close when this StaxStreamIO reader or writer is closed, or null if none.
  • Constructor Summary

    Constructors
    Constructor
    Description
    For sub-classes constructors.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the input or output stream and releases any resources used by this XML reader or writer.
    protected final Errors
    Returns the error resources in the current locale.
    (package private) final MarshallerPool
    Returns the shared marshaller pool.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • owner

      protected final StaxDataStore owner
      The data store for which this reader or writer has been created.
    • stream

      The underlying stream to close when this StaxStreamIO reader or writer is closed, or null if none. This may be the same reference than StaxDataStore.stream, but not necessarily if we had to create a new stream for reading the data one more time.
    • jaxb

      private MarshallerPool jaxb
      The (un)marshaller pool, fetched when first needed. The same pool is shared by all StaxStreamIO instances created by the same StaxDataStoreProvider, but we nevertheless store a reference here in order to reduce the amount of synchronizations done every time we need a (un)marshaller.
  • Constructor Details

    • StaxStreamIO

      StaxStreamIO(StaxDataStore owner)
      For sub-classes constructors.
      Parameters:
      owner - the data store for which this reader or writer is created.
  • Method Details

    • getMarshallerPool

      final MarshallerPool getMarshallerPool() throws JAXBException
      Returns the shared marshaller pool.
      Throws:
      JAXBException
    • close

      public void close() throws Exception
      Closes the input or output stream and releases any resources used by this XML reader or writer. This reader or writer cannot be used anymore after this method has been invoked.
      Specified by:
      close in interface AutoCloseable
      Throws:
      XMLStreamException - if an error occurred while releasing XML reader/writer resources.
      IOException - if an error occurred while closing the input or output stream.
      Exception
    • errors

      protected final Errors errors()
      Returns the error resources in the current locale.