Class VarlenaWrapper.Output

java.lang.Object
java.io.OutputStream
org.postgresql.pljava.internal.VarlenaWrapper.Output
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, Datum, VarlenaWrapper, DatumImpl
Enclosing interface:
VarlenaWrapper

public static class VarlenaWrapper.Output extends OutputStream implements VarlenaWrapper
A class by which Java writes the content of a varlena as an OutputStream. Associated with a ResourceOwner to bound the lifetime of the native reference; the chosen resource owner must be one that will be released no later than the memory context containing the varlena.
  • Method Details

    • setVerifier

      public void setVerifier(VarlenaWrapper.Verifier v) throws IOException
      Set the Verifier to be used on content written to this varlena.

      A verifier must be set, either to NoOp or a datatype-specific subclass of Base, before writing can succeed.

      On construction, no verifier is set, so the datatype-specific code can determine whether the NoOp or a specific verifier will be needed. This method can only be called once, so that this class could then be exposed to client code as an OutputStream without allowing the verifier to be changed.

      Throws:
      IOException
    • write

      public void write(int b) throws IOException
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Overrides:
      write in class OutputStream
      Throws:
      IOException
    • close

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

      public void free() throws IOException
      Actually free a VarlenaWrapper.Output.

      close() does not do so, because the typical use of this class is to write to an instance, close it, then let some native code adopt it. If it turns out one won't be adopted and must be freed, use this method.

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

      public String toString()
      Overrides:
      toString in class Object
    • 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 DatumImpl
      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.