org.apache.ignite.internal.processors.cache

## Class CacheObjectByteArrayImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.CacheObjectByteArrayImpl

All Implemented Interfaces:
  Externalizable, Serializable, CacheObject, Message

Direct Known Subclasses:
  UserCacheObjectByteArrayImpl

    public class CacheObjectByteArrayImpl
    extends Object
    implements CacheObject, Externalizable

Cache object over byte array.

See Also:
  Serialized Form

### Field Summary

Fields
`protected byte[]` `val`

### Fields inherited from interface org.apache.ignite.internal.processors.cache.CacheObject

`TYPE_BINARY, TYPE_BINARY_ENUM, TYPE_BYTE_ARR, TYPE_REGULAR`

### Fields inherited from interface org.apache.ignite.plugin.extensions.communication.Message

`DIRECT_TYPE_SIZE`

### Constructor Summary

Constructors
Constructor and Description
`CacheObjectByteArrayImpl()` Required by `Message`.
`CacheObjectByteArrayImpl(byte[] val)`

### Method Summary

All Methods Instance Methods Concrete Methods
`byte` `cacheObjectType()`
`short` `directType()` Gets message type.
`byte` `fieldsCount()` Gets fields count.
`void` `finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr)`
`boolean` `isPlatformType()` Gets flag indicating whether object value is a platform type.
`void` `onAckReceived()` Method called when ack message received.
`CacheObject` `prepareForCache(CacheObjectContext ctx)` Prepares cache object for cache (e.g. copies user-provided object if needed).
`void` `prepareMarshal(CacheObjectValueContext ctx)`
`boolean` `putValue(ByteBuffer buf)`
`boolean` `putValue(ByteBuffer buf, int off, int len)`
`int` `putValue(long addr)`
`void` `readExternal(ObjectInput in)`
`boolean` `readFrom(ByteBuffer buf, MessageReader reader)` Reads this message from provided byte buffer.
`String` `toString()`
`<T> T` `value(CacheObjectValueContext ctx, boolean cpy)`
`<T> T` `value(CacheObjectValueContext ctx, boolean cpy, ClassLoader ldr)` Deserializes a value from an internal representation.
`byte[]` `valueBytes(CacheObjectValueContext ctx)`
`int` `valueBytesLength(CacheObjectContext ctx)`
`void` `writeExternal(ObjectOutput out)`
`boolean` `writeTo(ByteBuffer buf, MessageWriter writer)` Writes this message to provided byte buffer.

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

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

### Field Detail

#### val

    protected byte[] val

### Constructor Detail

#### CacheObjectByteArrayImpl

    public CacheObjectByteArrayImpl()

Required by `Message`.

#### CacheObjectByteArrayImpl

    public CacheObjectByteArrayImpl(byte[] val)

Parameters:
  `val` - Value.

### Method Detail

#### finishUnmarshal

    public void finishUnmarshal(CacheObjectValueContext ctx,
                                ClassLoader ldr)
                         throws IgniteCheckedException

Specified by:
  `finishUnmarshal` in interface `CacheObject`
Parameters:
  `ctx` - Context.
  `ldr` - Class loader.
Throws:
  `IgniteCheckedException` - If failed.

#### value

    @Nullable
    public <T> T value(CacheObjectValueContext ctx,
                                 boolean cpy)

Specified by:
  `value` in interface `CacheObject`
Parameters:
  `ctx` - Context.
  `cpy` - If `true` need to copy value.
Returns:
  Value.

#### value

    @Nullable
    public <T> T value(CacheObjectValueContext ctx,
                                 boolean cpy,
                                 ClassLoader ldr)

Deserializes a value from an internal representation.

Specified by:
  `value` in interface `CacheObject`
Parameters:
  `ctx` - Context.
  `cpy` - If `true` need to copy value.
  `ldr` - Class loader, if it is `null`, default class loader will be used.
Returns:
  Value.

#### valueBytes

    public byte[] valueBytes(CacheObjectValueContext ctx)
                      throws IgniteCheckedException

Specified by:
  `valueBytes` in interface `CacheObject`
Parameters:
  `ctx` - Context.
Returns:
  Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

    public boolean putValue(ByteBuffer buf)
                     throws IgniteCheckedException

Specified by:
  `putValue` in interface `CacheObject`
Parameters:
  `buf` - Buffer to write value to.
Returns:
  `True` if value was successfully written, `false` if there was not enough space in the buffer.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

    public int putValue(long addr)
                 throws IgniteCheckedException

Specified by:
  `putValue` in interface `CacheObject`
Parameters:
  `addr` - Address tp write value to.
Returns:
  Number of bytes written.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

    public boolean putValue(ByteBuffer buf,
                            int off,
                            int len)
                     throws IgniteCheckedException

Specified by:
  `putValue` in interface `CacheObject`
Parameters:
  `buf` - Buffer to write value to.
  `off` - Offset in source binary data.
  `len` - Length of the data to write.
Returns:
  `True` if value was successfully written, `false` if there was not enough space in the buffer.
Throws:
  `IgniteCheckedException` - If failed.

#### valueBytesLength

    public int valueBytesLength(CacheObjectContext ctx)
                         throws IgniteCheckedException

Specified by:
  `valueBytesLength` in interface `CacheObject`
Parameters:
  `ctx` - Cache object context.
Returns:
  Size required to store this value object.
Throws:
  `IgniteCheckedException` - If failed.

#### cacheObjectType

    public byte cacheObjectType()

Specified by:
  `cacheObjectType` in interface `CacheObject`
Returns:
  Object type.

#### isPlatformType

    public boolean isPlatformType()

Gets flag indicating whether object value is a platform type. Platform types will be automatically deserialized on public API cache operations regardless whether `IgniteCache.withKeepBinary()` is used or not.

Specified by:
  `isPlatformType` in interface `CacheObject`
Returns:
  Platform type flag.

#### prepareForCache

    public CacheObject prepareForCache(CacheObjectContext ctx)

Prepares cache object for cache (e.g. copies user-provided object if needed).

Specified by:
  `prepareForCache` in interface `CacheObject`
Parameters:
  `ctx` - Cache context.
Returns:
  Instance to store in cache.

#### prepareMarshal

    public void prepareMarshal(CacheObjectValueContext ctx)
                        throws IgniteCheckedException

Specified by:
  `prepareMarshal` in interface `CacheObject`
Parameters:
  `ctx` - Context.
Throws:
  `IgniteCheckedException` - If failed.

#### onAckReceived

    public void onAckReceived()

Method called when ack message received.

Specified by:
  `onAckReceived` in interface `Message`

#### writeTo

    public boolean writeTo(ByteBuffer buf,
                           MessageWriter writer)

Writes this message to provided byte buffer.

Specified by:
  `writeTo` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `writer` - Writer.
Returns:
  Whether message was fully written.

#### readFrom

    public boolean readFrom(ByteBuffer buf,
                            MessageReader reader)

Reads this message from provided byte buffer.

Specified by:
  `readFrom` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `reader` - Reader.
Returns:
  Whether message was fully read.

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### directType

    public short directType()

Gets message type.

Specified by:
  `directType` in interface `Message`
Returns:
  Message type.

#### fieldsCount

    public byte fieldsCount()

Gets fields count.

Specified by:
  `fieldsCount` in interface `Message`
Returns:
  Fields count.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.11.1
Release Date | : December 20 2021