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
public static class VarlenaWrapper.Verifier.Base extends 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
Constructors Modifier Constructor Description protected
Base()
-
Method Summary
Modifier and Type Method Description void
cancel()
Cancel this verifier.void
finish()
Wait for the verify task and rethrow any exception it might have thrown.VarlenaWrapper.Verifier
schedule()
Set up theverify
method to be executed in another thread.void
update(InputStream is)
Send the nextInputStream
of content to be verified.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
-
-
-
-
Method Detail
-
schedule
public final VarlenaWrapper.Verifier 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
public final void update(InputStream is) throws SQLException
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
public final void finish() throws SQLException
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
public final void cancel() throws SQLException
Description copied from class:VarlenaWrapper.Verifier
Cancel this verifier.- Overrides:
cancel
in classVarlenaWrapper.Verifier
- Throws:
SQLException
-
-