
public class DecoderEmbedder<T> extends Object
ChannelBuffer with Base64Decoder and
StringDecoder without setting up the ChannelPipeline and
other mock objects by yourself:
ChannelBuffer base64Data = ChannelBuffer.copiedBuffer("Zm9vYmFy", "ASCII");
DecoderEmbedder<String> embedder = new DecoderEmbedder<String>(
new Base64Decoder(), new StringDecoder());
embedded.offer(base64Data);
String decoded = embedded.poll();
assert decoded.equals("foobar");
EncoderEmbedder| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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()
|
boolean |
offer(Object input)
Offers an input object to the pipeline of this embedder.
|
T |
peek()
Reads an encoded or decoded output from the head of the product queue.
|
T |
poll()
Consumes an encoded or decoded output from the product queue.
|
public DecoderEmbedder(ChannelUpstreamHandler... handlers)
public DecoderEmbedder(ChannelBufferFactory bufferFactory, ChannelUpstreamHandler... handlers)
bufferFactory - the ChannelBufferFactory to be used when
creating a new buffer.public boolean offer(Object input)
CodecEmbeddertrue if and only if there is something to read in the
product queue (see CodecEmbedder.poll() and CodecEmbedder.peek())public boolean finish()
CodecEmbedderfinish in interface CodecEmbedder<T>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()
public final T poll()
CodecEmbedderpoll in interface CodecEmbedder<T>null if and only if there is no output object left in the
product queue.public final T peek()
CodecEmbedderCodecEmbedder.poll() is that it does not remove the
retrieved object from the product queue.peek in interface CodecEmbedder<T>null if and only if there is no output object left in the
product queue.Copyright © 2008-2013 JBoss, by Red Hat. All Rights Reserved.