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.serialization
Class ObjectEncoder

    java.lang.Object
      org.jboss.netty.handler.codec.oneone.OneToOneEncoder
          org.jboss.netty.handler.codec.serialization.ObjectEncoder

All Implemented Interfaces:
  ChannelDownstreamHandler, ChannelHandler

    @ChannelHandler.Sharable
    public class ObjectEncoder

extends OneToOneEncoder

An encoder which serializes a Java object into a `ChannelBuffer`.

Please note that the serialized form this encoder produces is not compatible with the standard `ObjectInputStream`. Please use `ObjectDecoder` or `ObjectDecoderInputStream` to ensure the interoperability with this encoder.

Version:
  $Rev:231 $, $Date:2008-06-12 16:44:50 +0900 (목, 12 6월 2008) $
Author:
  The Netty Project, Trustin Lee

Nested Class Summary

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

Constructor Summary
`ObjectEncoder()` Creates a new encoder with the estimated length of 512 bytes.
`ObjectEncoder(int estimatedLength)` Creates a new encoder.

Method Summary
`protected Object` | `encode(ChannelHandlerContext ctx, Channel channel, Object msg)` Transforms the specified message into another message and return the transformed message.

Methods inherited from class org.jboss.netty.handler.codec.oneone.OneToOneEncoder
`handleDownstream`

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

Constructor Detail

### ObjectEncoder

    public ObjectEncoder()

  Creates a new encoder with the estimated length of 512 bytes.

### ObjectEncoder

    public ObjectEncoder(int estimatedLength)

  Creates a new encoder.

  Parameters:
    `estimatedLength` - the estimated byte length of the serialized form of an object. If the length of the serialized form exceeds this value, the internal buffer will be expanded automatically at the cost of memory bandwidth. If this value is too big, it will also waste memory bandwidth. To avoid unnecessary memory copy or allocation cost, please specify the properly estimated value.

Method Detail

### 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`

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.