Class DatumImpl.IStream<T extends DatumImpl.Input>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Datum
,DatumImpl
- Enclosing interface:
DatumImpl
InputStream
view of a Datum.Input
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.postgresql.pljava.adt.spi.Datum
Datum.Accessor<B,
L extends Datum.Layout>, Datum.Layout Nested classes/interfaces inherited from interface org.postgresql.pljava.pg.DatumImpl
DatumImpl.Input, DatumImpl.IStream<T extends DatumImpl.Input>
-
Field Summary
Fields inherited from class org.postgresql.pljava.internal.ByteBufferInputStream
m_lock, m_open
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
adopt()
Dissociate the datum from Java and return its address to native code.protected ByteBuffer
buffer()
Return theByteBuffer
being wrapped, or throw an exception if the memory windowed by the buffer should no longer be accessed.void
close()
protected void
pin()
Pin resources if necessary during a reading operation.protected void
unpin()
Unpin resources if necessary after a reading operation.void
Apply aVerifier
to the input data.Methods inherited from class org.postgresql.pljava.internal.ByteBufferInputStream
available, mark, markSupported, read, read, reset, skip
Methods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
m_datum
-
-
Constructor Details
-
IStream
- Throws:
SQLException
-
-
Method Details
-
toString
-
pin
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 classByteBufferInputStream
- 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 classByteBufferInputStream
-
buffer
Description copied from class:ByteBufferInputStream
Return theByteBuffer
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 byunpin()
(whose default implementations in this class do nothing). If a subclass overridespin
with a version that throws the appropriate exception in either case or both, it is then redundant and unnecessary forbuffer
to check the same conditions.- Specified by:
buffer
in classByteBufferInputStream
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classByteBufferInputStream
- Throws:
IOException
-
adopt
Description copied from interface:DatumImpl
Dissociate the datum from Java and return its address to native code.- Specified by:
adopt
in interfaceDatumImpl
- Throws:
SQLException
-
verify
Apply aVerifier
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.- Specified by:
verify
in interfaceDatum
- Specified by:
verify
in interfaceDatumImpl
- Throws:
SQLException
-