Interface Datum.Input<T extends InputStream & Datum>

All Superinterfaces:
AutoCloseable, Closeable, Datum
Enclosing interface:
Datum

public static interface Datum.Input<T extends InputStream & Datum> extends Datum
Interface through which PL/Java code reads the content of an existing PostgreSQL datum.
  • Method Details

    • pin

      default void pin() throws SQLException
      Throws:
      SQLException
    • pinUnlessReleased

      default boolean pinUnlessReleased()
    • unpin

      default void unpin()
    • buffer

      ByteBuffer buffer() throws SQLException
      Returns a read-only ByteBuffer covering the content of the datum.

      When the datum is a varlena, the "content" does not include the four-byte header. When implementing an adapter for a varlena datatype, note carefully whether offsets used in the PostgreSQL C code are relative to the start of the content or the start of the varlena overall. If the latter, they will need adjustment when indexing into the ByteBuffer.

      If the byte order of the buffer will matter, it should be explicitly set.

      The buffer may window native memory allocated by PostgreSQL, so pin() and unpin() should surround accesses through it. Like Datum itself, the ByteBuffer should be used only within an Adapter, and not exposed to other code.

      Throws:
      SQLException
    • inputStream

      T inputStream() throws SQLException
      Returns an InputStream that presents the same bytes contained in the buffer returned by buffer().

      When necessary, the InputStream will handle pinning the buffer when reading, so the InputStream can safely be exposed to other code, if it is a reasonable way to present the contents of the datatype in question.

      The stream supports mark and reset.

      Throws:
      SQLException