Class InputBuffer<T,S,X extends java.lang.Throwable>
- java.lang.Object
-
- com.amazon.corretto.crypto.provider.InputBuffer<T,S,X>
-
- Type Parameters:
T- result typeS- state typeX- exception which can be thrown upon completion
- All Implemented Interfaces:
java.lang.Cloneable
public class InputBuffer<T,S,X extends java.lang.Throwable> extends java.lang.Object implements java.lang.CloneableClass to handle buffering data prior to passing it through to the native code. It buffers it up into fewer (larger) chunks to avoid incurring marshalling overhead. The first time a handler is called it will be anInitialUpdatehandler (if present). All subsequent calls are guaranteed to go to standardUpdatehandlers. If all of the data can be buffered prior to callingdoFinal(), then this class will attempt to use theSinglePasshandler if available.The following handlers must be set.
All
ByteBufferhandlers default to calling theirInputBuffer.ArrayStateConsumerequivalents. All InitialUpdate handlers default to calling their Update equivalents.withSinglePass(ArrayFunction)defaults to calling the update and doFinal steps.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceInputBuffer.ArrayFunction<T,X extends java.lang.Throwable>static interfaceInputBuffer.ArrayStateConsumer<S>static interfaceInputBuffer.ByteBufferBiConsumer<S>static interfaceInputBuffer.ByteBufferFunction<S>static interfaceInputBuffer.FinalHandlerFunction<T,R,X extends java.lang.Throwable>static interfaceInputBuffer.StateSupplier<S>
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected InputBuffer<T,S,X>clone()WARNING! This only does a shallow copy of the handlers, so any which refer to external state (so, any values not passed in as arguments) may be incorrect and need to be fixed prior to use.TdoFinal()voidreset()intsize()voidupdate(byte val)voidupdate(byte[] src, int offset, int length)voidupdate(java.nio.ByteBuffer src)InputBuffer<T,S,X>withDoFinal(InputBuffer.FinalHandlerFunction<S,T,X> handler)InputBuffer<T,S,X>withInitialStateSupplier(InputBuffer.StateSupplier<S> supplier)InputBuffer<T,S,X>withInitialUpdater(InputBuffer.ArrayFunction<S,java.lang.RuntimeException> handler)InputBuffer<T,S,X>withInitialUpdater(InputBuffer.ByteBufferFunction<S> handler)InputBuffer<T,S,X>withSinglePass(InputBuffer.ArrayFunction<T,X> handler)InputBuffer<T,S,X>withStateCloner(java.util.function.Function<S,S> cloner)InputBuffer<T,S,X>withUpdater(InputBuffer.ArrayStateConsumer<S> handler)InputBuffer<T,S,X>withUpdater(InputBuffer.ByteBufferBiConsumer<S> handler)
-
-
-
Method Detail
-
reset
public void reset()
-
size
public int size()
-
withInitialUpdater
public InputBuffer<T,S,X> withInitialUpdater(InputBuffer.ArrayFunction<S,java.lang.RuntimeException> handler)
-
withUpdater
public InputBuffer<T,S,X> withUpdater(InputBuffer.ArrayStateConsumer<S> handler)
-
withInitialUpdater
public InputBuffer<T,S,X> withInitialUpdater(InputBuffer.ByteBufferFunction<S> handler)
-
withUpdater
public InputBuffer<T,S,X> withUpdater(InputBuffer.ByteBufferBiConsumer<S> handler)
-
withDoFinal
public InputBuffer<T,S,X> withDoFinal(InputBuffer.FinalHandlerFunction<S,T,X> handler)
-
withSinglePass
public InputBuffer<T,S,X> withSinglePass(InputBuffer.ArrayFunction<T,X> handler)
-
withStateCloner
public InputBuffer<T,S,X> withStateCloner(java.util.function.Function<S,S> cloner)
-
withInitialStateSupplier
public InputBuffer<T,S,X> withInitialStateSupplier(InputBuffer.StateSupplier<S> supplier)
-
update
public void update(java.nio.ByteBuffer src)
-
update
public void update(byte[] src, int offset, int length)
-
update
public void update(byte val)
-
doFinal
public T doFinal() throws X extends java.lang.Throwable
- Throws:
X extends java.lang.Throwable
-
clone
protected InputBuffer<T,S,X> clone() throws java.lang.CloneNotSupportedException
WARNING! This only does a shallow copy of the handlers, so any which refer to external state (so, any values not passed in as arguments) may be incorrect and need to be fixed prior to use.- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-