Class AbstractCodecEmbedder<E>
java.lang.Object
org.jboss.netty.handler.codec.embedder.AbstractCodecEmbedder<E>
- All Implemented Interfaces:
CodecEmbedder<E>
- Direct Known Subclasses:
DecoderEmbedder
,EncoderEmbedder
A skeletal
CodecEmbedder
implementation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Channel
private final ChannelPipeline
private final AbstractCodecEmbedder<E>.EmbeddedChannelSink
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractCodecEmbedder
(ChannelBufferFactory bufferFactory, ChannelHandler... handlers) Creates a new embedder whose pipeline is composed of the specified handlers.protected
AbstractCodecEmbedder
(ChannelHandler... handlers) Creates a new embedder whose pipeline is composed of the specified handlers. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
configurePipeline
(ChannelHandler... handlers) boolean
finish()
Signals the pipeline that the encoding or decoding has been finished and no more data will be offered.private void
protected final Channel
Returns the virtualChannel
which will be used as a mock during encoding and decoding.Returns theChannelPipeline
that handles the input.protected final boolean
isEmpty()
final E
peek()
Reads an encoded or decoded output from the head of the product queue.final E
poll()
Consumes an encoded or decoded output from the product queue.final Object[]
pollAll()
Consumes all encoded or decoded output from the product queue.final <T> T[]
pollAll
(T[] a) Consumes all encoded or decoded output from the product queue.final int
size()
Returns the number of encoded or decoded output in the product queue.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jboss.netty.handler.codec.embedder.CodecEmbedder
offer
-
Field Details
-
channel
-
pipeline
-
sink
-
productQueue
-
-
Constructor Details
-
AbstractCodecEmbedder
Creates a new embedder whose pipeline is composed of the specified handlers. -
AbstractCodecEmbedder
Creates a new embedder whose pipeline is composed of the specified handlers.- Parameters:
bufferFactory
- theChannelBufferFactory
to be used when creating a new buffer.
-
-
Method Details
-
fireInitialEvents
private void fireInitialEvents() -
configurePipeline
-
finish
public boolean finish()Description copied from interface:CodecEmbedder
Signals the pipeline that the encoding or decoding has been finished and no more data will be offered.- Specified by:
finish
in interfaceCodecEmbedder<E>
- Returns:
true
if and only if there is something to read in the product queue (seeCodecEmbedder.poll()
andCodecEmbedder.peek()
)
-
getChannel
Returns the virtualChannel
which will be used as a mock during encoding and decoding. -
isEmpty
protected final boolean isEmpty() -
poll
Description copied from interface:CodecEmbedder
Consumes an encoded or decoded output from the product queue. The output object is generated by the offered input objects.- Specified by:
poll
in interfaceCodecEmbedder<E>
- Returns:
- an encoded or decoded object.
null
if and only if there is no output object left in the product queue.
-
peek
Description copied from interface:CodecEmbedder
Reads an encoded or decoded output from the head of the product queue. The difference fromCodecEmbedder.poll()
is that it does not remove the retrieved object from the product queue.- Specified by:
peek
in interfaceCodecEmbedder<E>
- Returns:
- an encoded or decoded object.
null
if and only if there is no output object left in the product queue.
-
pollAll
Description copied from interface:CodecEmbedder
Consumes all encoded or decoded output from the product queue. The output object is generated by the offered input objects. The behavior of this method is identical withCollection.toArray()
except that the product queue is cleared.- Specified by:
pollAll
in interfaceCodecEmbedder<E>
- Returns:
- an array of all encoded or decoded objects. An empty array is returned if and only if there is no output object left in the product queue.
-
pollAll
public final <T> T[] pollAll(T[] a) Description copied from interface:CodecEmbedder
Consumes all encoded or decoded output from the product queue. The output object is generated by the offered input objects. The behavior of this method is identical withCollection.toArray(Object[])
except that the product queue is cleared.- Specified by:
pollAll
in interfaceCodecEmbedder<E>
- Returns:
- an array of all encoded or decoded objects. An empty array is returned if and only if there is no output object left in the product queue.
-
size
public final int size()Description copied from interface:CodecEmbedder
Returns the number of encoded or decoded output in the product queue.- Specified by:
size
in interfaceCodecEmbedder<E>
-
getPipeline
Description copied from interface:CodecEmbedder
Returns theChannelPipeline
that handles the input.- Specified by:
getPipeline
in interfaceCodecEmbedder<E>
-