Class VarlenaWrapper.Input.Stream
- All Implemented Interfaces:
Closeable,AutoCloseable,VarlenaWrapper
- Enclosing class:
VarlenaWrapper.Input
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.postgresql.pljava.internal.VarlenaWrapper
VarlenaWrapper.Input, VarlenaWrapper.Output, VarlenaWrapper.Verifier -
Field Summary
Fields inherited from class org.postgresql.pljava.internal.ByteBufferInputStream
m_lock, m_open -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongadopt(DualState.Key cookie) Return the varlena address to native code and dissociate the varlena from Java.protected ByteBufferbuffer()Return theByteBufferbeing wrapped, or throw an exception if the memory windowed by the buffer should no longer be accessed.voidclose()protected voidpin()Pin resources if necessary during a reading operation.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).protected voidunpin()Unpin resources if necessary after a reading operation.voidApply aVerifierto the input data.Methods inherited from class org.postgresql.pljava.internal.ByteBufferInputStream
available, mark, markSupported, read, read, reset, skipMethods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
Stream
public Stream()
-
-
Method Details
-
pin
Description copied from class:ByteBufferInputStreamPin 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:
pinin classByteBufferInputStream- Throws:
IOException
-
unpin
protected void unpin()Description copied from class:ByteBufferInputStreamUnpin resources if necessary after a reading operation.This default implementation does nothing.
- Overrides:
unpinin classByteBufferInputStream
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classByteBufferInputStream- Throws:
IOException
-
toString
Description copied from interface:VarlenaWrapperReturn 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
oand use it to prefix the returned value.- Specified by:
toStringin interfaceVarlenaWrapper- Parameters:
o- An object whose class name (possibly abbreviated) should be used to prefix the returned string.- Returns:
- Description of this object.
-
verify
Apply aVerifierto 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
Description copied from class:ByteBufferInputStreamReturn theByteBufferbeing wrapped, or throw an exception if the memory windowed by the buffer should no longer be accessed.The monitor on
ByteBufferInputStream.m_lockis held when this method is called.This method also should throw an exception if
ByteBufferInputStream.m_openis 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 byunpin()(whose default implementations in this class do nothing). If a subclass overridespinwith a version that throws the appropriate exception in either case or both, it is then redundant and unnecessary forbufferto check the same conditions.- Specified by:
bufferin classByteBufferInputStream- Throws:
IOException
-
adopt
Description copied from interface:VarlenaWrapperReturn the varlena address to native code and dissociate the varlena from Java.- Specified by:
adoptin interfaceVarlenaWrapper- Parameters:
cookie- Capability held by native code.- Throws:
SQLException
-