org.jboss.netty.handler.codec.embedder
类 DecoderEmbedder<E>

java.lang.Object
  继承者 org.jboss.netty.handler.codec.embedder.DecoderEmbedder<E>
所有已实现的接口:
CodecEmbedder<E>

public class DecoderEmbedder<E>
extends java.lang.Object

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:

 ChannelBuffer base64Data = ChannelBuffers.copiedBuffer("Zm9vYmFy", CharsetUtil.US_ASCII);

 DecoderEmbedder<String> embedder = new DecoderEmbedder<String>(
         new Base64Decoder(), new StringDecoder());

 embedded.offer(base64Data);

 String decoded = embedded.poll();
 assert decoded.equals("foobar");
 

另请参见:
EncoderEmbedder

构造方法摘要
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.
 
方法摘要
 boolean finish()
          Signals the pipeline that the encoding or decoding has been finished and no more data will be offered.
 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.
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

DecoderEmbedder

public DecoderEmbedder(ChannelUpstreamHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified handlers.


DecoderEmbedder

public DecoderEmbedder(ChannelBufferFactory bufferFactory,
                       ChannelUpstreamHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified handlers.

参数:
bufferFactory - the ChannelBufferFactory to be used when creating a new buffer.
方法详细信息

offer

public boolean offer(java.lang.Object input)
从接口 CodecEmbedder 复制的描述
Offers an input object to the pipeline of this embedder.

返回:
true if and only if there is something to read in the product queue (see CodecEmbedder.poll() and CodecEmbedder.peek())

finish

public boolean finish()
从接口 CodecEmbedder 复制的描述
Signals the pipeline that the encoding or decoding has been finished and no more data will be offered.

指定者:
接口 CodecEmbedder<E> 中的 finish
返回:
true if and only if there is something to read in the product queue (see CodecEmbedder.poll() and CodecEmbedder.peek())

poll

public final E poll()
从接口 CodecEmbedder 复制的描述
Consumes an encoded or decoded output from the product queue. The output object is generated by the offered input objects.

指定者:
接口 CodecEmbedder<E> 中的 poll
返回:
an encoded or decoded object. null if and only if there is no output object left in the product queue.

peek

public final E peek()
从接口 CodecEmbedder 复制的描述
Reads an encoded or decoded output from the head of the product queue. The difference from CodecEmbedder.poll() is that it does not remove the retrieved object from the product queue.

指定者:
接口 CodecEmbedder<E> 中的 peek
返回:
an encoded or decoded object. null if and only if there is no output object left in the product queue.

pollAll

public final java.lang.Object[] pollAll()
从接口 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 with Collection.toArray() except that the product queue is cleared.

指定者:
接口 CodecEmbedder<E> 中的 pollAll
返回:
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)
从接口 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 with Collection.toArray(Object[]) except that the product queue is cleared.

指定者:
接口 CodecEmbedder<E> 中的 pollAll
返回:
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()
从接口 CodecEmbedder 复制的描述
Returns the number of encoded or decoded output in the product queue.

指定者:
接口 CodecEmbedder<E> 中的 size