Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.netty.handler.codec.compression
Class ZlibEncoder

    java.lang.Object
      org.jboss.netty.handler.codec.oneone.OneToOneEncoder
          org.jboss.netty.handler.codec.compression.ZlibEncoder

All Implemented Interfaces:
  ChannelDownstreamHandler, ChannelHandler, LifeCycleAwareChannelHandler

    public class ZlibEncoder

extends OneToOneEncoder
implements LifeCycleAwareChannelHandler

Compresses a `ChannelBuffer` using the deflate algorithm.

Version:
  $Rev: 2241 $, $Date: 2010-04-16 13:12:43 +0900 (Fri, 16 Apr 2010) $
Author:
  The Netty Project, Trustin Lee

Nested Class Summary

Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
`ChannelHandler.Sharable`

Constructor Summary
`ZlibEncoder()` Creates a new zlib encoder with the default compression level (`6`) and the default wrapper (`ZlibWrapper.ZLIB`).
`ZlibEncoder(byte[] dictionary)` Creates a new zlib encoder with the default compression level (`6`) and the specified preset dictionary.
`ZlibEncoder(int compressionLevel)` Creates a new zlib encoder with the specified `compressionLevel` and the default wrapper (`ZlibWrapper.ZLIB`).
`ZlibEncoder(int compressionLevel, byte[] dictionary)` Creates a new zlib encoder with the specified `compressionLevel` and the specified preset dictionary.
`ZlibEncoder(ZlibWrapper wrapper)` Creates a new zlib encoder with the default compression level (`6`) and the specified wrapper.
`ZlibEncoder(ZlibWrapper wrapper, int compressionLevel)` Creates a new zlib encoder with the specified `compressionLevel` and the specified wrapper.

Method Summary
`void` | `afterAdd(ChannelHandlerContext ctx)`
`void` | `afterRemove(ChannelHandlerContext ctx)`
`void` | `beforeAdd(ChannelHandlerContext ctx)`
`void` | `beforeRemove(ChannelHandlerContext ctx)`
`ChannelFuture` | `close()`
`protected Object` | `encode(ChannelHandlerContext ctx, Channel channel, Object msg)` Transforms the specified message into another message and return the transformed message.
`void` | `handleDownstream(ChannelHandlerContext ctx, ChannelEvent evt)` Handles the specified downstream event.
`boolean` | `isClosed()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ZlibEncoder

    public ZlibEncoder()

  Creates a new zlib encoder with the default compression level (`6`) and the default wrapper (`ZlibWrapper.ZLIB`).

  Throws:
    `CompressionException` - if failed to initialize zlib

### ZlibEncoder

    public ZlibEncoder(int compressionLevel)

  Creates a new zlib encoder with the specified `compressionLevel` and the default wrapper (`ZlibWrapper.ZLIB`).

  Parameters:
    `compressionLevel` - `1` yields the fastest compression and `9` yields the best compression. `0` means no compression. The default compression level is `6`.
  Throws:
    `CompressionException` - if failed to initialize zlib

### ZlibEncoder

    public ZlibEncoder(ZlibWrapper wrapper)

  Creates a new zlib encoder with the default compression level (`6`) and the specified wrapper.

  Throws:
    `CompressionException` - if failed to initialize zlib

### ZlibEncoder

    public ZlibEncoder(ZlibWrapper wrapper,
                       int compressionLevel)

  Creates a new zlib encoder with the specified `compressionLevel` and the specified wrapper.

  Parameters:
    `compressionLevel` - `1` yields the fastest compression and `9` yields the best compression. `0` means no compression. The default compression level is `6`.
  Throws:
    `CompressionException` - if failed to initialize zlib

### ZlibEncoder

    public ZlibEncoder(byte[] dictionary)

  Creates a new zlib encoder with the default compression level (`6`) and the specified preset dictionary. The wrapper is always `ZlibWrapper.ZLIB` because it is the only format that supports the preset dictionary.

  Parameters:
    `dictionary` - the preset dictionary
  Throws:
    `CompressionException` - if failed to initialize zlib

### ZlibEncoder

    public ZlibEncoder(int compressionLevel,
                       byte[] dictionary)

  Creates a new zlib encoder with the specified `compressionLevel` and the specified preset dictionary. The wrapper is always `ZlibWrapper.ZLIB` because it is the only format that supports the preset dictionary.

  Parameters:
    `compressionLevel` - `1` yields the fastest compression and `9` yields the best compression. `0` means no compression. The default compression level is `6`.
    `dictionary` - the preset dictionary
  Throws:
    `CompressionException` - if failed to initialize zlib

Method Detail

### close

    public ChannelFuture close()

### isClosed

    public boolean isClosed()

### encode

    protected Object encode(ChannelHandlerContext ctx,
                            Channel channel,
                            Object msg)
                     throws Exception

  Description copied from class: `OneToOneEncoder`
  Transforms the specified message into another message and return the transformed message. Note that you can not return `null`, unlike you can in `OneToOneDecoder.decode(ChannelHandlerContext, Channel, Object)`; you must return something, at least `ChannelBuffers.EMPTY_BUFFER`.

  Specified by:
    `encode` in class `OneToOneEncoder`
  Throws:
    `Exception`

### handleDownstream

    public void handleDownstream(ChannelHandlerContext ctx,
                                 ChannelEvent evt)
                          throws Exception

  Description copied from interface: `ChannelDownstreamHandler`
  Handles the specified downstream event.

  Specified by:
    `handleDownstream` in interface `ChannelDownstreamHandler`
  Overrides:
    `handleDownstream` in class `OneToOneEncoder`
  Parameters:
    `ctx` - the context object for this handler
    `evt` - the downstream event to process or intercept
  Throws:
    `Exception`

### beforeAdd

    public void beforeAdd(ChannelHandlerContext ctx)
                   throws Exception

  Specified by:
    `beforeAdd` in interface `LifeCycleAwareChannelHandler`
  Throws:
    `Exception`

### afterAdd

    public void afterAdd(ChannelHandlerContext ctx)
                  throws Exception

  Specified by:
    `afterAdd` in interface `LifeCycleAwareChannelHandler`
  Throws:
    `Exception`

### beforeRemove

    public void beforeRemove(ChannelHandlerContext ctx)
                      throws Exception

  Specified by:
    `beforeRemove` in interface `LifeCycleAwareChannelHandler`
  Throws:
    `Exception`

### afterRemove

    public void afterRemove(ChannelHandlerContext ctx)
                     throws Exception

  Specified by:
    `afterRemove` in interface `LifeCycleAwareChannelHandler`
  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.