|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.netty.handler.codec.embedder.DecoderEmbedder<E>
public class DecoderEmbedder<E>
A helper that wraps a decoder so that it can be used without doing actual
I/O in unit tests or higher level codecs. For example, you can decode a
Base64-encoded ChannelBuffer with Base64Decoder and
StringDecoder without setting up the ChannelPipeline and
other mock objects by yourself:
ChannelBufferbase64Data =ChannelBuffers.copiedBuffer("Zm9vYmFy", CharsetUtil.US_ASCII);DecoderEmbedder<String> embedder = newDecoderEmbedder<String>( newBase64Decoder(), newStringDecoder()); embedded.offer(base64Data); String decoded = embedded.poll(); assert decoded.equals("foobar");
EncoderEmbedder| Constructor Summary | |
|---|---|
DecoderEmbedder(ChannelBufferFactory bufferFactory,
ChannelUpstreamHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified handlers. |
|
DecoderEmbedder(ChannelUpstreamHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified handlers. |
|
| Method Summary | ||
|---|---|---|
boolean |
finish()
Signals the pipeline that the encoding or decoding has been finished and no more data will be offered. |
|
protected Channel |
getChannel()
Returns the virtual Channel which will be used as a mock
during encoding and decoding. |
|
protected boolean |
isEmpty()
Returns true if and only if the produce queue is empty and
therefore poll() will return null. |
|
boolean |
offer(java.lang.Object input)
Offers an input object to the pipeline of this embedder. |
|
E |
peek()
Reads an encoded or decoded output from the head of the product queue. |
|
E |
poll()
Consumes an encoded or decoded output from the product queue. |
|
java.lang.Object[] |
pollAll()
Consumes all encoded or decoded output from the product queue. |
|
|
pollAll(T[] a)
Consumes all encoded or decoded output from the product queue. |
|
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 |
| Constructor Detail |
|---|
public DecoderEmbedder(ChannelUpstreamHandler... handlers)
public DecoderEmbedder(ChannelBufferFactory bufferFactory,
ChannelUpstreamHandler... handlers)
bufferFactory - the ChannelBufferFactory to be used when
creating a new buffer.| Method Detail |
|---|
public boolean offer(java.lang.Object input)
CodecEmbedder
true if and only if there is something to read in the
product queue (see CodecEmbedder.poll() and CodecEmbedder.peek())public boolean finish()
CodecEmbedder
finish in interface CodecEmbedder<E>true if and only if there is something to read in the
product queue (see CodecEmbedder.poll() and CodecEmbedder.peek())protected final Channel getChannel()
Channel which will be used as a mock
during encoding and decoding.
protected final boolean isEmpty()
true if and only if the produce queue is empty and
therefore poll() will return null.
public final E poll()
CodecEmbedder
poll in interface CodecEmbedder<E>null if and only if there is no output object left in the
product queue.public final E peek()
CodecEmbedderCodecEmbedder.poll() is that it does not remove the
retrieved object from the product queue.
peek in interface CodecEmbedder<E>null if and only if there is no output object left in the
product queue.public final java.lang.Object[] pollAll()
CodecEmbedderCollection.toArray() except that
the product queue is cleared.
pollAll in interface CodecEmbedder<E>public final <T> T[] pollAll(T[] a)
CodecEmbedderCollection.toArray(Object[])
except that the product queue is cleared.
pollAll in interface CodecEmbedder<E>public final int size()
CodecEmbedder
size in interface CodecEmbedder<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||