org.apache.ignite.internal.portable

## Class PortableObjectImpl

- java.lang.Object
- - org.apache.ignite.internal.portable.PortableObjectEx
  - - org.apache.ignite.internal.portable.PortableObjectImpl

All Implemented Interfaces:
  Externalizable, Serializable, Cloneable, PortableObject, CacheObject, KeyCacheObject, Message

    public final class PortableObjectImpl
    extends PortableObjectEx
    implements Externalizable, Message, CacheObject, KeyCacheObject

Portable object implementation.

See Also:
  Serialized Form

### Field Summary

Fields
`static byte` `TYPE_PORTABLE`

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

`TYPE_BYTE_ARR, TYPE_REGULAR`

### Constructor Summary

Constructors
Constructor and Description
`PortableObjectImpl()` For `Externalizable`.
`PortableObjectImpl(PortableContext ctx, byte[] arr, int start)`

### Method Summary

Methods
`byte[]` `array()`
`PortableObject` `clone()` Copies this portable object.
`PortableContext` `context()`
`void` `context(PortableContext ctx)`
`<T> T` `deserialize()` Gets fully deserialized instance of portable object.
`PortableObject` `detach()`
`boolean` `detachAllowed()`
`void` `detachAllowed(boolean detachAllowed)`
`boolean` `detached()`
`byte` `directType()` Gets message type.
`protected <F> F` `field(org.apache.ignite.internal.portable.PortableReaderContext rCtx, String fieldName)`
`<F> F` `field(String fieldName)` Gets field value.
`byte` `fieldsCount()` Gets fields count.
`void` `finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr)`
`protected boolean` `hasArray()`
`boolean` `hasField(String fieldName)` Checks whether field is set.
`int` `hashCode()`
`boolean` `internal()`
`int` `length()`
`PortableMetadata` `metaData()` Gets meta data for this portable object.
`long` `offheapAddress()`
`CacheObject` `prepareForCache(CacheObjectContext ctx)` Prepares cache object for cache (e.g. copies user-provided object if needed).
`void` `prepareMarshal(CacheObjectContext ctx)`
`void` `readExternal(ObjectInput in)`
`boolean` `readFrom(ByteBuffer buf, MessageReader reader)` Reads this message from provided byte buffer.
`int` `start()`
`byte` `type()`
`int` `typeId()` Gets portable object type ID.
`<T> T` `value(CacheObjectContext ctx, boolean cpy)`
`byte[]` `valueBytes(CacheObjectContext ctx)`
`void` `writeExternal(ObjectOutput out)`
`boolean` `writeTo(ByteBuffer buf, MessageWriter writer)` Writes this message to provided byte buffer.

### Methods inherited from class org.apache.ignite.internal.portable.PortableObjectEx

`equals, toString`

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

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### TYPE_PORTABLE

    public static final byte TYPE_PORTABLE

See Also:
  Constant Field Values

### Constructor Detail

#### PortableObjectImpl

    public PortableObjectImpl()

For `Externalizable`.

#### PortableObjectImpl

    public PortableObjectImpl(PortableContext ctx,
                      byte[] arr,
                      int start)

Parameters:
  `ctx` - Context.
  `arr` - Array.
  `start` - Start.

### Method Detail

#### type

    public byte type()

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

#### internal

    public boolean internal()

Specified by:
  `internal` in interface `KeyCacheObject`
Returns:
  `True` if internal cache key.

#### value

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

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

#### valueBytes

    public byte[] valueBytes(CacheObjectContext ctx)
                      throws IgniteCheckedException

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

#### 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.

#### finishUnmarshal

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

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

#### prepareMarshal

    public void prepareMarshal(CacheObjectContext ctx)
                        throws IgniteCheckedException

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

#### length

    public int length()

Specified by:
  `length` in class `PortableObjectEx`
Returns:
  Length.

#### detach

    public PortableObject detach()

Returns:
  Detached portable object.

#### detached

    public boolean detached()

Returns:
  Detached or not.

#### detachAllowed

    public boolean detachAllowed()

Returns:
  `True` if detach is allowed.

#### detachAllowed

    public void detachAllowed(boolean detachAllowed)

Parameters:
  `detachAllowed` - Detach allowed flag.

#### context

    public PortableContext context()

Returns:
  Context.

#### context

    public void context(PortableContext ctx)

Parameters:
  `ctx` - Context.

#### array

    public byte[] array()

Specified by:
  `array` in class `PortableObjectEx`
Returns:
  Object array if object is array based, otherwise `null`.

#### start

    public int start()

Specified by:
  `start` in class `PortableObjectEx`
Returns:
  Object start.

#### offheapAddress

    public long offheapAddress()

Specified by:
  `offheapAddress` in class `PortableObjectEx`
Returns:
  Object offheap address is object is offheap based, otherwise 0.

#### hasArray

    protected boolean hasArray()

Specified by:
  `hasArray` in class `PortableObjectEx`
Returns:
  `True` if object is array based.

#### typeId

    public int typeId()

Gets portable object type ID.

Specified by:
  `typeId` in interface `PortableObject`
Returns:
  Type ID.

#### metaData

    @Nullable
    public PortableMetadata metaData()
                              throws PortableException

Gets meta data for this portable object.

Specified by:
  `metaData` in interface `PortableObject`
Returns:
  Meta data.
Throws:
  `PortableException` - In case of error.

#### field

    @Nullable
    public <F> F field(String fieldName)
            throws PortableException

Gets field value.

Specified by:
  `field` in interface `PortableObject`
Parameters:
  `fieldName` - Field name.
Returns:
  Field value.
Throws:
  `PortableException` - In case of any other error.

#### field

    @Nullable
    protected <F> F field(org.apache.ignite.internal.portable.PortableReaderContext rCtx,
                       String fieldName)

Specified by:
  `field` in class `PortableObjectEx`
Parameters:
  `rCtx` - Reader context.
  `fieldName` - Field name.
Returns:
  Field name.

#### hasField

    public boolean hasField(String fieldName)

Checks whether field is set.

Specified by:
  `hasField` in interface `PortableObject`
Parameters:
  `fieldName` - Field name.
Returns:
  `true` if field is set.

#### deserialize

    @Nullable
    public <T> T deserialize()
                  throws PortableException

Gets fully deserialized instance of portable object.

Specified by:
  `deserialize` in interface `PortableObject`
Returns:
  Fully deserialized instance of portable object.
Throws:
  `PortableInvalidClassException` - If class doesn't exist.
  `PortableException` - In case of any other error.

#### clone

    public PortableObject clone()
                         throws CloneNotSupportedException

Copies this portable object.

Specified by:
  `clone` in interface `PortableObject`
Overrides:
  `clone` in class `PortableObjectEx`
Returns:
  Copy of this portable object.
Throws:
  `CloneNotSupportedException`

#### hashCode

    public int hashCode()

Specified by:
  `hashCode` in interface `KeyCacheObject`
Overrides:
  `hashCode` in class `Object`
Returns:
  Key hash code.

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

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

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

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

#### 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.

#### directType

    public byte 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.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.4.0
Release Date | : September 24 2015