Package org.jgrapes.io.util
Class ManagedBufferStreamer
java.lang.Object
org.jgrapes.io.util.ManagedBufferStreamer
- All Implemented Interfaces:
InputConsumer
- Direct Known Subclasses:
JsonReader
Starts a thread with a synchronous consumer of input provided by a
Reader
which is fed with data from ManagedBuffer
s
(usually obtained from Input
events).- Since:
- 2.8.0
-
Constructor Summary
ConstructorDescriptionManagedBufferStreamer
(Consumer<Reader> processor) Instantiates a new managed buffer streamer. -
Method Summary
Modifier and TypeMethodDescriptionSets the charset to be used iffeed(ManagedBuffer)
is invoked withManagedBuffer<ByteBuffer>
.<W extends Buffer>
voidfeed
(ManagedBuffer<W> buffer) Feed data to underlying the reader (see {@link ManagedBufferReader#feed).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jgrapes.io.util.InputConsumer
feed
-
Constructor Details
-
ManagedBufferStreamer
Instantiates a new managed buffer streamer.- Parameters:
processor
- the processor
-
-
Method Details
-
charset
Sets the charset to be used iffeed(ManagedBuffer)
is invoked withManagedBuffer<ByteBuffer>
.Defaults to UTF-8. Must be set before the first invocation of
feed(ManagedBuffer)
.- Parameters:
charset
- the charset- Returns:
- the managed buffer streamer
-
feed
Feed data to underlying the reader (see {@link ManagedBufferReader#feed).- Specified by:
feed
in interfaceInputConsumer
- Parameters:
buffer
- the buffer- Throws:
IOException
- Signals that an I/O exception has occurred.
-