Class VarlenaWrapper.Output
- java.lang.Object
-
- java.io.OutputStream
-
- org.postgresql.pljava.internal.VarlenaWrapper.Output
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,VarlenaWrapper
- 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 aResourceOwner
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.postgresql.pljava.internal.VarlenaWrapper
VarlenaWrapper.Input, VarlenaWrapper.Output, VarlenaWrapper.Verifier
-
-
Method Summary
Modifier and Type Method Description long
adopt(DualState.Key cookie)
Return the varlena address to native code and dissociate the varlena from Java.void
close()
void
free()
Actually free aVarlenaWrapper.Output
.void
setVerifier(VarlenaWrapper.Verifier v)
Set theVerifier
to be used on content written to this varlena.String
toString()
String
toString(Object o)
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 JavatoString()
method should passthis
).void
write(byte[] b, int off, int len)
void
write(int b)
-
Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
-
-
-
Method Detail
-
setVerifier
public void setVerifier(VarlenaWrapper.Verifier v) throws IOException
Set theVerifier
to be used on content written to this varlena.A verifier must be set, either to
NoOp
or a datatype-specific subclass ofBase
, 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 anOutputStream
without allowing the verifier to be changed.- Throws:
IOException
-
write
public void write(int b) throws IOException
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
free
public void free() throws IOException
Actually free aVarlenaWrapper.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(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 interfaceVarlenaWrapper
- Parameters:
cookie
- Capability held by native code.- Throws:
SQLException
-
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 JavatoString()
method should passthis
).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 interfaceVarlenaWrapper
- Parameters:
o
- An object whose class name (possibly abbreviated) should be used to prefix the returned string.- Returns:
- Description of this object.
-
-