org.jboss.netty.handler.codec.marshalling

## Class MarshallingEncoder

- java.lang.Object
- - org.jboss.netty.handler.codec.oneone.OneToOneEncoder
  - - org.jboss.netty.handler.codec.marshalling.MarshallingEncoder

All Implemented Interfaces:
  ChannelDownstreamHandler, ChannelHandler

    @ChannelHandler.Sharable
    public class MarshallingEncoder
    extends OneToOneEncoder

`OneToOneEncoder` implementation which uses JBoss Marshalling to marshal an Object. Be aware that this `OneToOneEncoder` is not compatible with an other client that just use JBoss Marshalling as it includes the size of every `Object` that gets serialized in front of the `Object` itself. Use this with `MarshallingDecoder` See JBoss Marshalling website for more informations

### Nested Class Summary

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

`ChannelHandler.Sharable`

### Constructor Summary

Constructors
Constructor and Description
`MarshallingEncoder(MarshallerProvider provider)` Creates a new encoder with the estimated length of 512 bytes.
`MarshallingEncoder(MarshallerProvider provider, int estimatedLength)` Creates a new encoder.

### Method Summary

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

#### MarshallingEncoder

    public MarshallingEncoder(MarshallerProvider provider)

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

Parameters:
  `provider` - the `MarshallerProvider` to use

#### MarshallingEncoder

    public MarshallingEncoder(MarshallerProvider provider,
                      int estimatedLength)

Creates a new encoder.

Parameters:
  `provider` - the `MarshallerProvider` to use
  `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`