org.apache.ignite.internal.direct

## Class DirectMessageReader

- java.lang.Object
- - org.apache.ignite.internal.direct.DirectMessageReader

All Implemented Interfaces:
  MessageReader

    public class DirectMessageReader
    extends Object
    implements MessageReader

Message reader implementation.

### Constructor Summary

Constructors
Constructor and Description
`DirectMessageReader(MessageFactory msgFactory, byte protoVer)`

### Method Summary

Methods
`void` `afterInnerMessageRead(boolean finished)` Callback called after inner message is read.
`boolean` `afterMessageRead(Class<? extends Message> msgCls)` Callback that must be invoked by a message implementation after message body finished decoding.
`void` `beforeInnerMessageRead()` Callback called before inner message is read.
`boolean` `beforeMessageRead()` Callback that must be invoked by a message implementation before message body started decoding.
`void` `incrementState()` Increments read state.
`boolean` `isLastRead()` Tells whether last invocation of any of `readXXX(...)`
`BitSet` `readBitSet(String name)` Reads `BitSet`.
`boolean` `readBoolean(String name)` Reads `boolean` value.
`boolean[]` `readBooleanArray(String name)` Reads `boolean` array.
`byte` `readByte(String name)` Reads `byte` value.
`byte[]` `readByteArray(String name)` Reads `byte` array.
`char` `readChar(String name)` Reads `char` value.
`char[]` `readCharArray(String name)` Reads `char` array.
`<C extends Collection<?>> C` `readCollection(String name, MessageCollectionItemType itemType)` Reads collection.
`double` `readDouble(String name)` Reads `double` value.
`double[]` `readDoubleArray(String name)` Reads `double` array.
`float` `readFloat(String name)` Reads `float` value.
`float[]` `readFloatArray(String name)` Reads `float` array.
`IgniteUuid` `readIgniteUuid(String name)` Reads `IgniteUuid`.
`int` `readInt(String name)` Reads `int` value.
`int[]` `readIntArray(String name)` Reads `int` array.
`long` `readLong(String name)` Reads `long` value.
`long[]` `readLongArray(String name)` Reads `long` array.
`<M extends Map<?,?>> M` `readMap(String name, MessageCollectionItemType keyType, MessageCollectionItemType valType, boolean linked)` Reads map.
`<T extends Message> T` `readMessage(String name)` Reads nested message.
`<T> T[]` `readObjectArray(String name, MessageCollectionItemType itemType, Class<T> itemCls)` Reads array of objects.
`short` `readShort(String name)` Reads `short` value.
`short[]` `readShortArray(String name)` Reads `short` array.
`String` `readString(String name)` Reads `String`.
`UUID` `readUuid(String name)` Reads `UUID`.
`void` `reset()` Resets this reader.
`void` `setBuffer(ByteBuffer buf)` Sets but buffer to read from.
`void` `setCurrentReadClass(Class<? extends Message> msgCls)` Sets type of message currently read.
`int` `state()` Gets current read state.

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

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

### Constructor Detail

#### DirectMessageReader

    public DirectMessageReader(MessageFactory msgFactory,
                       byte protoVer)

Parameters:
  `msgFactory` - Message factory.
  `protoVer` - Protocol version.

### Method Detail

#### setBuffer

    public void setBuffer(ByteBuffer buf)

Sets but buffer to read from.

Specified by:
  `setBuffer` in interface `MessageReader`
Parameters:
  `buf` - Byte buffer.

#### setCurrentReadClass

    public void setCurrentReadClass(Class<? extends Message> msgCls)

Sets type of message currently read.

Specified by:
  `setCurrentReadClass` in interface `MessageReader`
Parameters:
  `msgCls` - Message type.

#### beforeMessageRead

    public boolean beforeMessageRead()

Callback that must be invoked by a message implementation before message body started decoding.

Specified by:
  `beforeMessageRead` in interface `MessageReader`
Returns:
  `True` if reading can proceed, `false` otherwise.

#### afterMessageRead

    public boolean afterMessageRead(Class<? extends Message> msgCls)

Callback that must be invoked by a message implementation after message body finished decoding.

Specified by:
  `afterMessageRead` in interface `MessageReader`
Parameters:
  `msgCls` -
Returns:
  `True` if reading can proceed, `false` otherwise.

#### readByte

    public byte readByte(String name)

Reads `byte` value.

Specified by:
  `readByte` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `byte` value.

#### readShort

    public short readShort(String name)

Reads `short` value.

Specified by:
  `readShort` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `short` value.

#### readInt

    public int readInt(String name)

Reads `int` value.

Specified by:
  `readInt` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `int` value.

#### readLong

    public long readLong(String name)

Reads `long` value.

Specified by:
  `readLong` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `long` value.

#### readFloat

    public float readFloat(String name)

Reads `float` value.

Specified by:
  `readFloat` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `float` value.

#### readDouble

    public double readDouble(String name)

Reads `double` value.

Specified by:
  `readDouble` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `double` value.

#### readChar

    public char readChar(String name)

Reads `char` value.

Specified by:
  `readChar` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `char` value.

#### readBoolean

    public boolean readBoolean(String name)

Reads `boolean` value.

Specified by:
  `readBoolean` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `boolean` value.

#### readByteArray

    @Nullable
    public byte[] readByteArray(String name)

Reads `byte` array.

Specified by:
  `readByteArray` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `byte` array.

#### readShortArray

    @Nullable
    public short[] readShortArray(String name)

Reads `short` array.

Specified by:
  `readShortArray` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `short` array.

#### readIntArray

    @Nullable
    public int[] readIntArray(String name)

Reads `int` array.

Specified by:
  `readIntArray` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `int` array.

#### readLongArray

    @Nullable
    public long[] readLongArray(String name)

Reads `long` array.

Specified by:
  `readLongArray` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `long` array.

#### readFloatArray

    @Nullable
    public float[] readFloatArray(String name)

Reads `float` array.

Specified by:
  `readFloatArray` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `float` array.

#### readDoubleArray

    @Nullable
    public double[] readDoubleArray(String name)

Reads `double` array.

Specified by:
  `readDoubleArray` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `double` array.

#### readCharArray

    @Nullable
    public char[] readCharArray(String name)

Reads `char` array.

Specified by:
  `readCharArray` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `char` array.

#### readBooleanArray

    @Nullable
    public boolean[] readBooleanArray(String name)

Reads `boolean` array.

Specified by:
  `readBooleanArray` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `boolean` array.

#### readString

    public String readString(String name)

Reads `String`.

Specified by:
  `readString` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `String`.

#### readBitSet

    public BitSet readBitSet(String name)

Reads `BitSet`.

Specified by:
  `readBitSet` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `BitSet`.

#### readUuid

    public UUID readUuid(String name)

Reads `UUID`.

Specified by:
  `readUuid` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `UUID`.

#### readIgniteUuid

    public IgniteUuid readIgniteUuid(String name)

Reads `IgniteUuid`.

Specified by:
  `readIgniteUuid` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  `IgniteUuid`.

#### readMessage

    @Nullable
    public <T extends Message> T readMessage(String name)

Reads nested message.

Specified by:
  `readMessage` in interface `MessageReader`
Parameters:
  `name` - Field name.
Returns:
  Message.

#### readObjectArray

    public <T> T[] readObjectArray(String name,
                          MessageCollectionItemType itemType,
                          Class<T> itemCls)

Reads array of objects.

Specified by:
  `readObjectArray` in interface `MessageReader`
Parameters:
  `name` - Field name.
  `itemType` - Array component type.
  `itemCls` - Array component class.
Returns:
  Array of objects.

#### readCollection

    public <C extends Collection<?>> C readCollection(String name,
                                             MessageCollectionItemType itemType)

Reads collection.

Specified by:
  `readCollection` in interface `MessageReader`
Parameters:
  `name` - Field name.
  `itemType` - Collection item type.
Returns:
  Collection.

#### readMap

    public <M extends Map<?,?>> M readMap(String name,
                                 MessageCollectionItemType keyType,
                                 MessageCollectionItemType valType,
                                 boolean linked)

Reads map.

Specified by:
  `readMap` in interface `MessageReader`
Parameters:
  `name` - Field name.
  `keyType` - Map key type.
  `valType` - Map value type.
  `linked` - Whether `LinkedHashMap` should be created.
Returns:
  Map.

#### isLastRead

    public boolean isLastRead()

Tells whether last invocation of any of `readXXX(...)` methods has fully written the value. `False` is returned if there were not enough remaining bytes in byte buffer.

Specified by:
  `isLastRead` in interface `MessageReader`
Returns:
  Whether las value was fully read.

#### state

    public int state()

Gets current read state.

Specified by:
  `state` in interface `MessageReader`
Returns:
  Read state.

#### incrementState

    public void incrementState()

Increments read state.

Specified by:
  `incrementState` in interface `MessageReader`

#### beforeInnerMessageRead

    public void beforeInnerMessageRead()

Callback called before inner message is read.

Specified by:
  `beforeInnerMessageRead` in interface `MessageReader`

#### afterInnerMessageRead

    public void afterInnerMessageRead(boolean finished)

Callback called after inner message is read.

Specified by:
  `afterInnerMessageRead` in interface `MessageReader`
Parameters:
  `finished` - Whether message was fully read.

#### reset

    public void reset()

Resets this reader.

Specified by:
  `reset` in interface `MessageReader`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0.final
Release Date | : December 29 2015