Class DecoderEmbedder<E>
java.lang.Object
org.jboss.netty.handler.codec.embedder.AbstractCodecEmbedder<E>
org.jboss.netty.handler.codec.embedder.DecoderEmbedder<E>
- All Implemented Interfaces:
CodecEmbedder<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()); embedder.offer(base64Data); String decoded = embedder.poll(); assert decoded.equals("foobar");
- See Also:
-
Field Summary
Fields inherited from class org.jboss.netty.handler.codec.embedder.AbstractCodecEmbedder
productQueue -
Constructor Summary
ConstructorsConstructorDescriptionDecoderEmbedder(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
Methods inherited from class org.jboss.netty.handler.codec.embedder.AbstractCodecEmbedder
finish, getChannel, getPipeline, isEmpty, peek, poll, pollAll, pollAll, size
-
Constructor Details
-
DecoderEmbedder
Creates a new embedder whose pipeline is composed of the specified handlers. -
DecoderEmbedder
Creates a new embedder whose pipeline is composed of the specified handlers.- Parameters:
bufferFactory- theChannelBufferFactoryto be used when creating a new buffer.
-
-
Method Details
-
offer
Description copied from interface:CodecEmbedderOffers an input object to the pipeline of this embedder.- Returns:
trueif and only if there is something to read in the product queue (seeCodecEmbedder.poll()andCodecEmbedder.peek())
-