Package org.postgresql.pljava.internal
Class VarlenaWrapper.Verifier.Base
java.lang.Object
org.postgresql.pljava.internal.VarlenaWrapper.Verifier
org.postgresql.pljava.internal.VarlenaWrapper.Verifier.Base
- Enclosing class:
VarlenaWrapper.Verifier
Verifier to be extended to verify byte streams for specific types.
A subclass should override VarlenaWrapper.Verifier.verify(java.io.InputStream)
with a method that reads
the InputStream and throws an exception unless the entire stream was
successfully read and represented a well-formed instance of the type.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.postgresql.pljava.internal.VarlenaWrapper.Verifier
VarlenaWrapper.Verifier.Base, VarlenaWrapper.Verifier.NoOp
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
cancel()
Cancel this verifier.final void
finish()
Wait for the verify task and rethrow any exception it might have thrown.final VarlenaWrapper.Verifier
schedule()
Set up theverify
method to be executed in another thread.final void
update
(InputStream is) Send the nextInputStream
of content to be verified.final void
update
(org.postgresql.pljava.internal.VarlenaWrapper.Output.State state, ByteBuffer bb) Convenience method that callsflip()
on a byte buffer, wraps it in aBufferWrapper
, and passes it toVarlenaWrapper.Verifier.update(java.io.InputStream)
.Methods inherited from class org.postgresql.pljava.internal.VarlenaWrapper.Verifier
call, verify
-
Constructor Details
-
Base
protected Base()
-
-
Method Details
-
schedule
Description copied from class:VarlenaWrapper.Verifier
Set up theverify
method to be executed in another thread.- Overrides:
schedule
in classVarlenaWrapper.Verifier
- Returns:
- This
Verifier
object.
-
update
Description copied from class:VarlenaWrapper.Verifier
Send the nextInputStream
of content to be verified.It is assumed, but not checked here, that any
InputStream
supplied to this method supportsmark
andreset
efficiently.If the verifier has already thrown an exception, it will be rethrown here in the current thread.
- Overrides:
update
in classVarlenaWrapper.Verifier
- Parameters:
is
- InputStream representing the next range of bytes to be verified.- Throws:
SQLException
- if a verification error has already been detected, the verifier has been cancelled, etc.
-
update
public final void update(org.postgresql.pljava.internal.VarlenaWrapper.Output.State state, ByteBuffer bb) throws SQLException Description copied from class:VarlenaWrapper.Verifier
Convenience method that callsflip()
on a byte buffer, wraps it in aBufferWrapper
, and passes it toVarlenaWrapper.Verifier.update(java.io.InputStream)
.Note that the
NoOp
version of this method does none of that; in particular, the byte buffer will not have been flipped. This should not be a problem, as the thread passing the buffer to this method had better make no further use of it anyway.- Overrides:
update
in classVarlenaWrapper.Verifier
- Parameters:
state
- The state object protecting the native memory.bb
- Byte buffer containing next range of content to verify.- Throws:
SQLException
- if a verification error has already been detected, the verifier has been cancelled, etc.
-
finish
Description copied from class:VarlenaWrapper.Verifier
Wait for the verify task and rethrow any exception it might have thrown.- Overrides:
finish
in classVarlenaWrapper.Verifier
- Throws:
SQLException
- any exception thrown by the verify method, or for unexpected conditions such as interruption while waiting.
-
cancel
Description copied from class:VarlenaWrapper.Verifier
Cancel this verifier.- Overrides:
cancel
in classVarlenaWrapper.Verifier
- Throws:
SQLException
-