org.apache.ignite.internal.processors.cache

## Interface CacheObject

All Superinterfaces:
  Message, Serializable

All Known Subinterfaces:
  KeyCacheObject

All Known Implementing Classes:
  BinaryEnumObjectImpl, BinaryObjectImpl, BinaryObjectOffheapImpl, CacheObjectAdapter, CacheObjectByteArrayImpl, CacheObjectImpl, KeyCacheObjectImpl, UserCacheObjectByteArrayImpl, UserCacheObjectImpl, UserKeyCacheObjectImpl

    public interface CacheObject
    extends Message

### Field Summary

Fields
`static byte` `TYPE_BINARY`
`static byte` `TYPE_BINARY_ENUM`
`static byte` `TYPE_BYTE_ARR`
`static byte` `TYPE_REGULAR`

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

`DIRECT_TYPE_SIZE`

### Method Summary

All Methods Instance Methods Abstract Methods
`byte` `cacheObjectType()`
`void` `finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr)`
`boolean` `isPlatformType()` Gets flag indicating whether object value is a platform type.
`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)`
`<T> T` `value(CacheObjectValueContext ctx, boolean cpy)`
`byte[]` `valueBytes(CacheObjectValueContext ctx)`
`int` `valueBytesLength(CacheObjectContext ctx)`

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

`directType, fieldsCount, onAckReceived, readFrom, writeTo`

### Field Detail

#### TYPE_REGULAR

    static final byte TYPE_REGULAR

See Also:
  Constant Field Values

#### TYPE_BYTE_ARR

    static final byte TYPE_BYTE_ARR

See Also:
  Constant Field Values

#### TYPE_BINARY

    static final byte TYPE_BINARY

See Also:
  Constant Field Values

#### TYPE_BINARY_ENUM

    static final byte TYPE_BINARY_ENUM

See Also:
  Constant Field Values

### Method Detail

#### value

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

Parameters:
  `ctx` - Context.
  `cpy` - If `true` need to copy value.
Returns:
  Value.

#### valueBytes

    byte[] valueBytes(CacheObjectValueContext ctx)
               throws IgniteCheckedException

Parameters:
  `ctx` - Context.
Returns:
  Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### valueBytesLength

    int valueBytesLength(CacheObjectContext ctx)
                  throws IgniteCheckedException

Parameters:
  `ctx` - Cache object context.
Returns:
  Size required to store this value object.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

    boolean putValue(ByteBuffer buf)
              throws IgniteCheckedException

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

    int putValue(long addr)
          throws IgniteCheckedException

Parameters:
  `addr` - Address tp write value to.
Returns:
  Number of bytes written.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

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

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.

#### cacheObjectType

    byte cacheObjectType()

Returns:
  Object type.

#### isPlatformType

    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.

Returns:
  Platform type flag.

#### prepareForCache

    CacheObject prepareForCache(CacheObjectContext ctx)

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

Parameters:
  `ctx` - Cache context.
Returns:
  Instance to store in cache.

#### finishUnmarshal

    void finishUnmarshal(CacheObjectValueContext ctx,
                         ClassLoader ldr)
                  throws IgniteCheckedException

Parameters:
  `ctx` - Context.
  `ldr` - Class loader.
Throws:
  `IgniteCheckedException` - If failed.

#### prepareMarshal

    void prepareMarshal(CacheObjectValueContext ctx)
                 throws IgniteCheckedException

Parameters:
  `ctx` - Context.
Throws:
  `IgniteCheckedException` - If failed.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.0
Release Date | : November 30 2018