Package org.jgrapes.io.util
Class CharBufferWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
An
Writer
that is backed by CharBuffer
s obtained from a
queue.When a byte buffer is full, an Output
event (default) is
generated and a new buffer is fetched from the queue.
-
Field Summary
Fields inherited from class org.jgrapes.io.util.AbstractBufferWriter
buffer, channel
-
Constructor Summary
ConstructorDescriptionCharBufferWriter
(IOSubchannel channel) Creates a new instance that usesOutput
events to dispatch buffers on the given channel, using the channel’s response pipeline.CharBufferWriter
(IOSubchannel channel, EventPipeline eventPipeline) Creates a new instance that usesOutput
events to dispatch buffers on the given channel, using the given event pipeline. -
Method Summary
Modifier and TypeMethodDescriptionappend
(char ch) append
(CharSequence csq) append
(CharSequence csq, int start, int end) protected void
Ensure that a buffer for output data is available.setEventAssociations
(Map<Object, Object> associations) Configure associations that are applied to the generated Output events, seeEvent.setAssociated(java.lang.Object, java.lang.Object)
.Suppresses sending of a close event when the stream is closed.Suppresses setting the end of record flag when the stream is flushed or closed.void
write
(char[] data, int offset, int length) void
Methods inherited from class org.jgrapes.io.util.AbstractBufferWriter
close, flush, flush, write, write, write
Methods inherited from class java.io.Writer
nullWriter
-
Constructor Details
-
CharBufferWriter
Creates a new instance that usesOutput
events to dispatch buffers on the given channel, using the given event pipeline.- Parameters:
channel
- the channel to fire events oneventPipeline
- the event pipeline used for firing events
-
CharBufferWriter
Creates a new instance that usesOutput
events to dispatch buffers on the given channel, using the channel’s response pipeline.- Parameters:
channel
- the channel to fire events on
-
-
Method Details
-
sendInputEvents
Description copied from class:AbstractBufferWriter
- Overrides:
sendInputEvents
in classAbstractBufferWriter<CharBuffer>
- Returns:
- this object for easy chaining
-
suppressClose
Description copied from class:AbstractBufferWriter
Suppresses sending of a close event when the stream is closed.- Overrides:
suppressClose
in classAbstractBufferWriter<CharBuffer>
- Returns:
- this object for easy chaining
-
suppressEndOfRecord
Description copied from class:AbstractBufferWriter
Suppresses setting the end of record flag when the stream is flushed or closed.- Overrides:
suppressEndOfRecord
in classAbstractBufferWriter<CharBuffer>
- Returns:
- this object for easy chaining
- See Also:
-
setEventAssociations
Description copied from class:AbstractBufferWriter
Configure associations that are applied to the generated Output events, seeEvent.setAssociated(java.lang.Object, java.lang.Object)
.- Overrides:
setEventAssociations
in classAbstractBufferWriter<CharBuffer>
- Parameters:
associations
- the associations to apply- Returns:
- this object for easy chaining
-
ensureBufferAvailable
Ensure that a buffer for output data is available.- Specified by:
ensureBufferAvailable
in classAbstractBufferWriter<CharBuffer>
- Throws:
InterruptedException
- the interrupted exception
-
write
- Specified by:
write
in classAbstractBufferWriter<CharBuffer>
-
write
- Specified by:
write
in classAbstractBufferWriter<CharBuffer>
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-