Class VarlenaWrapper.Input.Stream

java.lang.Object
java.io.InputStream
org.postgresql.pljava.internal.ByteBufferInputStream
org.postgresql.pljava.internal.VarlenaWrapper.Input.Stream
All Implemented Interfaces:
Closeable, AutoCloseable, VarlenaWrapper
Enclosing class:
VarlenaWrapper.Input

public class VarlenaWrapper.Input.Stream extends ByteBufferInputStream implements VarlenaWrapper
  • Constructor Details

    • Stream

      public Stream()
  • Method Details

    • 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
    • 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
    • toString

      public String toString(Object o)
      Description copied from interface: VarlenaWrapper
      Return a string describing this object in a way useful for debugging, prefixed with the name (abbreviated for comfort) of the class of the object passed in (the normal Java toString() method should pass this).

      Subclasses or consumers are encouraged to call this method and append further details specific to the subclass or consumer. The convention should be that the recursion will stop at some class that will actually construct the abbreviated class name of o and use it to prefix the returned value.

      Specified by:
      toString in interface VarlenaWrapper
      Parameters:
      o - An object whose class name (possibly abbreviated) should be used to prefix the returned string.
      Returns:
      Description of this object.
    • verify

      public void verify(VarlenaWrapper.Verifier 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.

      Throws:
      SQLException
    • buffer

      protected ByteBuffer buffer() throws IOException
      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
      Throws:
      IOException
    • adopt

      public long adopt(DualState.Key cookie) throws SQLException
      Description copied from interface: VarlenaWrapper
      Return the varlena address to native code and dissociate the varlena from Java.
      Specified by:
      adopt in interface VarlenaWrapper
      Parameters:
      cookie - Capability held by native code.
      Throws:
      SQLException