Package org.jgrapes.io.util
Class CharBufferWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
An
Writer that is backed by CharBuffers 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
ConstructorsConstructorDescriptionCharBufferWriter(IOSubchannel channel) Creates a new instance that usesOutputevents to dispatch buffers on the given channel, using the channel’s response pipeline.CharBufferWriter(IOSubchannel channel, EventPipeline eventPipeline) Creates a new instance that usesOutputevents 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 voidEnsure 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.voidwrite(char[] data, int offset, int length) voidMethods inherited from class org.jgrapes.io.util.AbstractBufferWriter
close, flush, flush, write, write, writeMethods inherited from class java.io.Writer
nullWriter
-
Constructor Details
-
CharBufferWriter
Creates a new instance that usesOutputevents 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 usesOutputevents 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:
sendInputEventsin classAbstractBufferWriter<CharBuffer>- Returns:
- this object for easy chaining
-
suppressClose
Description copied from class:AbstractBufferWriterSuppresses sending of a close event when the stream is closed.- Overrides:
suppressClosein classAbstractBufferWriter<CharBuffer>- Returns:
- this object for easy chaining
-
suppressEndOfRecord
Description copied from class:AbstractBufferWriterSuppresses setting the end of record flag when the stream is flushed or closed.- Overrides:
suppressEndOfRecordin classAbstractBufferWriter<CharBuffer>- Returns:
- this object for easy chaining
- See Also:
-
setEventAssociations
Description copied from class:AbstractBufferWriterConfigure associations that are applied to the generated Output events, seeEvent.setAssociated(java.lang.Object, java.lang.Object).- Overrides:
setEventAssociationsin 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:
ensureBufferAvailablein classAbstractBufferWriter<CharBuffer>- Throws:
InterruptedException- the interrupted exception
-
write
- Specified by:
writein classAbstractBufferWriter<CharBuffer>
-
write
- Specified by:
writein classAbstractBufferWriter<CharBuffer>
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-