org.apache.ignite.internal.binary

## Class BinaryMarshaller

- java.lang.Object
- - org.apache.ignite.marshaller.AbstractMarshaller
  - - org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller
    - - org.apache.ignite.internal.binary.BinaryMarshaller

All Implemented Interfaces:
  Marshaller

    public class BinaryMarshaller
    extends AbstractNodeNameAwareMarshaller

Implementation of `Marshaller` that lets to serialize and deserialize all objects in the binary format.

### Field Summary

### Fields inherited from class org.apache.ignite.marshaller.AbstractMarshaller

`ctx, DFLT_BUFFER_SIZE`

### Constructor Summary

Constructors
Constructor and Description
`BinaryMarshaller()`

### Method Summary

Methods
`static boolean` `available()` Checks whether `BinaryMarshaller` is able to work on the current JVM.
`GridBinaryMarshaller` `binaryMarshaller()`
`protected byte[]` `marshal0(Object obj)` Marshals object to byte array.
`protected void` `marshal0(Object obj, OutputStream out)` Marshals object to the output stream.
`void` `onUndeploy(ClassLoader ldr)` Undeployment callback invoked when class loader is being undeployed.
`protected <T> T` `unmarshal0(byte[] bytes, ClassLoader clsLdr)` Unmarshals object from byte array using given class loader.
`protected <T> T` `unmarshal0(InputStream in, ClassLoader clsLdr)` Unmarshals object from the input stream using given class loader.

### Methods inherited from class org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller

`marshal, marshal, nodeName, unmarshal, unmarshal`

### Methods inherited from class org.apache.ignite.marshaller.AbstractMarshaller

`getContext, setContext`

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

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

### Constructor Detail

#### BinaryMarshaller

    public BinaryMarshaller()

### Method Detail

#### available

    public static boolean available()

Checks whether `BinaryMarshaller` is able to work on the current JVM.

As long as `BinaryMarshaller` uses JVM-private API, which is not guaranteed to be available on all JVM, this method should be called to ensure marshaller could work properly.

Result of this method is automatically checked in constructor.

Returns:
  `true` if `BinaryMarshaller` can work on the current JVM or `false` if it can't.

#### marshal0

    protected byte[] marshal0(@Nullable
                  Object obj)
                       throws IgniteCheckedException

Marshals object to byte array.

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

#### marshal0

    protected void marshal0(@Nullable
                Object obj,
                OutputStream out)
                     throws IgniteCheckedException

Marshals object to the output stream. This method should not close given output stream.

Specified by:
  `marshal0` in class `AbstractNodeNameAwareMarshaller`
Parameters:
  `obj` - Object to marshal.
  `out` - Output stream to marshal into.
Throws:
  `IgniteCheckedException` - If marshalling failed.

#### unmarshal0

    protected <T> T unmarshal0(byte[] bytes,
                   @Nullable
                   ClassLoader clsLdr)
                    throws IgniteCheckedException

Unmarshals object from byte array using given class loader.

Specified by:
  `unmarshal0` in class `AbstractNodeNameAwareMarshaller`
Type Parameters:
  `T` - Type of unmarshalled object.
Parameters:
  `bytes` - Byte array.
  `clsLdr` - Class loader to use.
Returns:
  Unmarshalled object.
Throws:
  `IgniteCheckedException` - If unmarshalling failed.

#### unmarshal0

    protected <T> T unmarshal0(InputStream in,
                   @Nullable
                   ClassLoader clsLdr)
                    throws IgniteCheckedException

Unmarshals object from the input stream using given class loader. This method should not close given input stream.

Specified by:
  `unmarshal0` in class `AbstractNodeNameAwareMarshaller`
Type Parameters:
  `T` - Type of unmarshalled object.
Parameters:
  `in` - Input stream.
  `clsLdr` - Class loader to use.
Returns:
  Unmarshalled object.
Throws:
  `IgniteCheckedException` - If unmarshalling failed.

#### onUndeploy

    public void onUndeploy(ClassLoader ldr)

Undeployment callback invoked when class loader is being undeployed. Some marshallers may want to clean their internal state that uses the undeployed class loader somehow.

Specified by:
  `onUndeploy` in class `AbstractMarshaller`
Parameters:
  `ldr` - Class loader being undeployed.

#### binaryMarshaller

    public GridBinaryMarshaller binaryMarshaller()

Returns:
  GridBinaryMarshaller instance.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.0.0
Release Date | : April 30 2017