Class DatumImpl.IStream<T extends DatumImpl.Input>

All Implemented Interfaces:
Closeable, AutoCloseable, Datum, DatumImpl
Enclosing interface:
DatumImpl

public static class DatumImpl.IStream<T extends DatumImpl.Input> extends ByteBufferInputStream implements DatumImpl
InputStream view of a Datum.Input.
  • Field Details

  • Constructor Details

  • Method Details

    • toString

      public String toString(Object o)
      Specified by:
      toString in interface DatumImpl
    • pin

      protected void pin() throws IOException
      Description copied from class: ByteBufferInputStream
      Pin resources if necessary during a reading operation.

      This default implementation does nothing. A subclass should override it if (in addition to synchronizing on m_lock), some pinning of a resource is needed during access operations.

      Overrides:
      pin in class ByteBufferInputStream
      Throws:
      IOException
    • unpin

      protected void unpin()
      Description copied from class: ByteBufferInputStream
      Unpin resources if necessary after a reading operation.

      This default implementation does nothing.

      Overrides:
      unpin in class ByteBufferInputStream
    • buffer

      protected ByteBuffer buffer()
      Description copied from class: ByteBufferInputStream
      Return the ByteBuffer being wrapped, or throw an exception if the memory windowed by the buffer should no longer be accessed.

      The monitor on ByteBufferInputStream.m_lock is held when this method is called.

      This method also should throw an exception if ByteBufferInputStream.m_open is false. It is called everywhere that should happen, so it is the perfect place for the test, and allows the implementing class to use a customized message in the exception.

      All uses of the buffer in this class are preceded by pin() and followed by unpin() (whose default implementations in this class do nothing). If a subclass overrides pin with a version that throws the appropriate exception in either case or both, it is then redundant and unnecessary for buffer to check the same conditions.

      Specified by:
      buffer in class ByteBufferInputStream
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class ByteBufferInputStream
      Throws:
      IOException
    • adopt

      public long adopt() throws SQLException
      Description copied from interface: DatumImpl
      Dissociate the datum from Java and return its address to native code.
      Specified by:
      adopt in interface DatumImpl
      Throws:
      SQLException
    • verify

      public void verify(Verifier.OfStream v) throws SQLException
      Apply a Verifier to the input data.

      This should only be necessary if the input wrapper is being used directly as an output item, and needs verification that it conforms to the format of the target type.

      The current position must be at the beginning of the stream. The verifier must leave it at the end to confirm the entire stream was examined. There should be no need to reset the position here, as the only anticipated use is during an adopt, and the native code will only care about the varlena's address.

      Specified by:
      verify in interface Datum
      Specified by:
      verify in interface DatumImpl
      Throws:
      SQLException