public class EncoderEmbedder<E>
extends java.lang.Object
String into a Base64-encoded ChannelBuffer with
Base64Encoder and StringEncoder without setting up the
ChannelPipeline and other mock objects by yourself:
String data = "foobar";EncoderEmbedder<ChannelBuffer> embedder = newEncoderEmbedder<>( newBase64Encoder(), newStringEncoder()); embedder.offer(data);ChannelBufferencoded = embedder.poll(); assert encoded.toString(CharsetUtil.US_ASCII).equals("Zm9vYmFy");
DecoderEmbedder| 构造器和说明 |
|---|
EncoderEmbedder(ChannelBufferFactory bufferFactory,
ChannelDownstreamHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified
handlers.
|
EncoderEmbedder(ChannelDownstreamHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified
handlers.
|
| 限定符和类型 | 方法和说明 |
|---|---|
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. |
ChannelPipeline |
getPipeline()
Returns the
ChannelPipeline that handles the input. |
protected boolean |
isEmpty()
|
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.
|
<T> T[] |
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.
|
public EncoderEmbedder(ChannelDownstreamHandler... handlers)
public EncoderEmbedder(ChannelBufferFactory bufferFactory, ChannelDownstreamHandler... handlers)
bufferFactory - the ChannelBufferFactory to be used when
creating a new buffer.public boolean offer(java.lang.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 在接口中 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()
public final E poll()
CodecEmbedderpoll 在接口中 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 在接口中 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 在接口中 CodecEmbedder<E>public final <T> T[] pollAll(T[] a)
CodecEmbedderCollection.toArray(Object[])
except that the product queue is cleared.pollAll 在接口中 CodecEmbedder<E>public final int size()
CodecEmbeddersize 在接口中 CodecEmbedder<E>public ChannelPipeline getPipeline()
CodecEmbedderChannelPipeline that handles the input.getPipeline 在接口中 CodecEmbedder<E>