Class AbstractCodecEmbedder<E>
- java.lang.Object
-
- org.jboss.netty.handler.codec.embedder.AbstractCodecEmbedder<E>
-
- All Implemented Interfaces:
CodecEmbedder<E>
- Direct Known Subclasses:
DecoderEmbedder,EncoderEmbedder
abstract class AbstractCodecEmbedder<E> extends java.lang.Object implements CodecEmbedder<E>
A skeletalCodecEmbedderimplementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAbstractCodecEmbedder.EmbeddedChannelPipelineprivate classAbstractCodecEmbedder.EmbeddedChannelSink
-
Field Summary
Fields Modifier and Type Field Description private Channelchannelprivate ChannelPipelinepipeline(package private) java.util.Queue<java.lang.Object>productQueueprivate AbstractCodecEmbedder.EmbeddedChannelSinksink
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCodecEmbedder(ChannelBufferFactory bufferFactory, ChannelHandler... handlers)Creates a new embedder whose pipeline is composed of the specified handlers.protectedAbstractCodecEmbedder(ChannelHandler... handlers)Creates a new embedder whose pipeline is composed of the specified handlers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidconfigurePipeline(ChannelHandler... handlers)booleanfinish()Signals the pipeline that the encoding or decoding has been finished and no more data will be offered.private voidfireInitialEvents()protected ChannelgetChannel()Returns the virtualChannelwhich will be used as a mock during encoding and decoding.ChannelPipelinegetPipeline()Returns theChannelPipelinethat handles the input.protected booleanisEmpty()Epeek()Reads an encoded or decoded output from the head of the product queue.Epoll()Consumes an encoded or decoded output from the product queue.java.lang.Object[]pollAll()Consumes all encoded or decoded output from the product queue.<T> T[]pollAll(T[] a)Consumes all encoded or decoded output from the product queue.intsize()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 Detail
-
channel
private final Channel channel
-
pipeline
private final ChannelPipeline pipeline
-
sink
private final AbstractCodecEmbedder.EmbeddedChannelSink sink
-
productQueue
final java.util.Queue<java.lang.Object> productQueue
-
-
Constructor Detail
-
AbstractCodecEmbedder
protected AbstractCodecEmbedder(ChannelHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified handlers.
-
AbstractCodecEmbedder
protected AbstractCodecEmbedder(ChannelBufferFactory bufferFactory, ChannelHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified handlers.- Parameters:
bufferFactory- theChannelBufferFactoryto be used when creating a new buffer.
-
-
Method Detail
-
fireInitialEvents
private void fireInitialEvents()
-
configurePipeline
private void configurePipeline(ChannelHandler... handlers)
-
finish
public boolean finish()
Description copied from interface:CodecEmbedderSignals the pipeline that the encoding or decoding has been finished and no more data will be offered.- Specified by:
finishin interfaceCodecEmbedder<E>- Returns:
trueif and only if there is something to read in the product queue (seeCodecEmbedder.poll()andCodecEmbedder.peek())
-
getChannel
protected final Channel getChannel()
Returns the virtualChannelwhich will be used as a mock during encoding and decoding.
-
isEmpty
protected final boolean isEmpty()
-
poll
public final E poll()
Description copied from interface:CodecEmbedderConsumes an encoded or decoded output from the product queue. The output object is generated by the offered input objects.- Specified by:
pollin interfaceCodecEmbedder<E>- Returns:
- an encoded or decoded object.
nullif and only if there is no output object left in the product queue.
-
peek
public final E peek()
Description copied from interface:CodecEmbedderReads 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:
peekin interfaceCodecEmbedder<E>- Returns:
- an encoded or decoded object.
nullif and only if there is no output object left in the product queue.
-
pollAll
public final java.lang.Object[] pollAll()
Description copied from interface:CodecEmbedderConsumes 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:
pollAllin 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:CodecEmbedderConsumes 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:
pollAllin 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:CodecEmbedderReturns the number of encoded or decoded output in the product queue.- Specified by:
sizein interfaceCodecEmbedder<E>
-
getPipeline
public ChannelPipeline getPipeline()
Description copied from interface:CodecEmbedderReturns theChannelPipelinethat handles the input.- Specified by:
getPipelinein interfaceCodecEmbedder<E>
-
-