Package io.helidon.common.reactive.valve
Class InputStreamValve
- java.lang.Object
-
- io.helidon.common.reactive.valve.InputStreamValve
-
- All Implemented Interfaces:
Pausable,Valve<ByteBuffer>
public class InputStreamValve extends Object implements Valve<ByteBuffer>
The InputStreamValve is aByteBufferbasedValvethat transforms a possibly blockingInputStreaminto the Valve.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Collector<ByteBuffer,ByteArrayOutputStream,ByteBuffer>byteBuffer2Collector()A collector ofByteBufferinstances into a singleByteBufferinstance.static Collector<ByteBuffer,ByteArrayOutputStream,byte[]>byteBufferByteArrayCollector()A collector ofByteBufferinstances into a single byte array.static Collector<ByteBuffer,ByteArrayOutputStream,String>byteBufferStringCollector(Charset charset)A collector ofByteBufferinstances into aStringof the provided charset.protected booleancanContinueProcessing()Implementation oftryProcess()which initially was accepted bycanProcess()should call this method before every iteration to be sure, that processing can continue (is not paused).protected booleancanProcess()Implementation oftryProcess()method should call this to reserve initial handle processing (if possible).protected RunnablegetOnComplete()protected BiConsumer<T,Pausable>getOnData()protected Consumer<Throwable>getOnError()voidhandle(BiConsumer<T,Pausable> onData, Consumer<Throwable> onError, Runnable onComplete)protected voidhandleError(Throwable thr)protected ByteBuffermoreData()voidpause()Pause data chunks flow untilPausable.resume().protected booleanpaused()protected voidreleaseProcessing()voidresume()Resume data chunks flow afterPausable.pause().protected voidtryProcess()Implements item handling / processing.
-
-
-
Method Detail
-
moreData
protected ByteBuffer moreData() throws Throwable
- Throws:
Throwable
-
byteBufferStringCollector
public static Collector<ByteBuffer,ByteArrayOutputStream,String> byteBufferStringCollector(Charset charset)
A collector ofByteBufferinstances into aStringof the provided charset.- Parameters:
charset- the desired charset of the returned string- Returns:
- a string representation of the collected byte buffers
-
byteBuffer2Collector
public static Collector<ByteBuffer,ByteArrayOutputStream,ByteBuffer> byteBuffer2Collector()
A collector ofByteBufferinstances into a singleByteBufferinstance.- Returns:
- a single byte buffer from the collected byte buffers
-
byteBufferByteArrayCollector
public static Collector<ByteBuffer,ByteArrayOutputStream,byte[]> byteBufferByteArrayCollector()
A collector ofByteBufferinstances into a single byte array.- Returns:
- a single byte array from the collected byte buffers
-
tryProcess
protected void tryProcess()
Implements item handling / processing. Implementation can usecanProcess()andcanContinueProcessing()method to ensure, that processing is done by a single thread at a time.
-
pause
public void pause()
Description copied from interface:PausablePause data chunks flow untilPausable.resume().
-
resume
public void resume()
Description copied from interface:PausableResume data chunks flow afterPausable.pause().
-
handle
public void handle(BiConsumer<T,Pausable> onData, Consumer<Throwable> onError, Runnable onComplete)
-
canProcess
protected boolean canProcess()
Implementation oftryProcess()method should call this to reserve initial handle processing (if possible). The same method should callcanContinueProcessing()before every iteration to be sure, that handle processing should continue.- Returns:
trueonly if method can process (handle) item
-
canContinueProcessing
protected boolean canContinueProcessing()
Implementation oftryProcess()which initially was accepted bycanProcess()should call this method before every iteration to be sure, that processing can continue (is not paused).- Returns:
trueonly if method can continue with handle processing
-
paused
protected boolean paused()
-
releaseProcessing
protected void releaseProcessing()
-
handleError
protected void handleError(Throwable thr)
-
getOnData
protected BiConsumer<T,Pausable> getOnData()
-
getOnComplete
protected Runnable getOnComplete()
-
-