org.apache.ignite.marshaller

## Class AbstractMarshaller

- java.lang.Object
- - org.apache.ignite.marshaller.AbstractMarshaller

All Implemented Interfaces:
  Marshaller

Direct Known Subclasses:
  JdkMarshaller, OptimizedMarshaller

    public abstract class AbstractMarshaller
    extends Object
    implements Marshaller

Base class for marshallers. Provides default implementations of methods that work with byte array or `GridByteArrayList`. These implementations use `GridByteArrayInputStream` or `GridByteArrayOutputStream` to marshal and unmarshal objects.

### Field Summary

Fields
`protected MarshallerContext` `ctx` Context.
`static int` `DFLT_BUFFER_SIZE` Default initial buffer size for the `GridByteArrayOutputStream`.

### Constructor Summary

Constructors
Constructor and Description
`AbstractMarshaller()`

### Method Summary

Methods
`byte[]` `marshal(Object obj)` Marshals object to byte array.
`void` `setContext(MarshallerContext ctx)` Sets marshaller context.
`<T> T` `unmarshal(byte[] arr, ClassLoader clsLdr)` Unmarshals object from byte array using given class loader.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.marshaller.Marshaller

`marshal, unmarshal`

### Field Detail

#### DFLT_BUFFER_SIZE

    public static final int DFLT_BUFFER_SIZE

Default initial buffer size for the `GridByteArrayOutputStream`.

See Also:
  Constant Field Values

#### ctx

    protected MarshallerContext ctx

Context.

### Constructor Detail

#### AbstractMarshaller

    public AbstractMarshaller()

### Method Detail

#### setContext

    public void setContext(MarshallerContext ctx)

Sets marshaller context.

Specified by:
  `setContext` in interface `Marshaller`
Parameters:
  `ctx` - Marshaller context.

#### marshal

    public byte[] marshal(@Nullable
                 Object obj)
                   throws IgniteCheckedException

Marshals object to byte array.

Specified by:
  `marshal` in interface `Marshaller`
Parameters:
  `obj` - Object to marshal.
Returns:
  Byte array.
Throws:
  `IgniteCheckedException` - If marshalling failed.

#### unmarshal

    public <T> T unmarshal(byte[] arr,
                  @Nullable
                  ClassLoader clsLdr)
                throws IgniteCheckedException

Unmarshals object from byte array using given class loader.

Specified by:
  `unmarshal` in interface `Marshaller`
Type Parameters:
  `T` - Type of unmarshalled object.
Parameters:
  `arr` - Byte array.
  `clsLdr` - Class loader to use.
Returns:
  Unmarshalled object.
Throws:
  `IgniteCheckedException` - If unmarshalling failed.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0
Release Date | : March 31 2015