com.hazelcast.nio.serialization
Class DefaultData

java.lang.Object
  extended by com.hazelcast.nio.serialization.DefaultData

public final class DefaultData
extends Object


Constructor Summary
DefaultData()
           
DefaultData(int type, byte[] data)
           
DefaultData(int type, byte[] data, int partitionHash)
           
DefaultData(int type, byte[] data, int partitionHash, byte[] header)
           
 
Method Summary
 int dataSize()
          Returns size of binary data
 boolean equals(Object o)
           
 byte[] getData()
          Returns byte array representation of internal binary format.
 byte[] getHeader()
          Returns byte array representation of header.
 int getHeapCost()
          Returns approximate heap cost of this Data object in bytes.
 int getPartitionHash()
          Returns partition hash calculated for serialized object.
 int getType()
          Returns serialization type of binary form.
 long hash64()
          Returns 64-bit hash code for this Data object.
 int hashCode()
           
 boolean hasPartitionHash()
          Returns true if Data has partition hash, false otherwise.
 int headerSize()
          Returns size of header.
 boolean isPortable()
          Returns true if this Data is created from a Portable object, false otherwise.
 int readIntHeader(int offset, ByteOrder order)
          Reads an integer header from given offset using given ByteOrder.
 void setData(byte[] array)
           
 void setHeader(byte[] header)
           
 void setPartitionHash(int partitionHash)
           
 void setType(int type)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultData

public DefaultData()

DefaultData

public DefaultData(int type,
                   byte[] data)

DefaultData

public DefaultData(int type,
                   byte[] data,
                   int partitionHash)

DefaultData

public DefaultData(int type,
                   byte[] data,
                   int partitionHash,
                   byte[] header)
Method Detail

dataSize

public int dataSize()
Description copied from interface: Data
Returns size of binary data

Returns:
data size

getPartitionHash

public int getPartitionHash()
Description copied from interface: Data
Returns partition hash calculated for serialized object. Partition hash is used to determine partition of a Data and is calculated using PartitioningStrategy during serialization.

If partition hash is not set then standard hashCode() is used.

Returns:
partition hash
See Also:
PartitionAware, PartitioningStrategy, SerializationService.toData(Object, com.hazelcast.core.PartitioningStrategy)

hasPartitionHash

public boolean hasPartitionHash()
Description copied from interface: Data
Returns true if Data has partition hash, false otherwise.

Returns:
true if Data has partition hash, false otherwise.

headerSize

public int headerSize()
Description copied from interface: Data
Returns size of header.

Returns:
size of header

getHeader

public byte[] getHeader()
Description copied from interface: Data
Returns byte array representation of header. Header is used to store Portable metadata during serialization and consists of factoryId, classId and version for each Portable field that source object contains.

Returns:
header

getData

public byte[] getData()
Description copied from interface: Data
Returns byte array representation of internal binary format.

Returns:
binary data

setData

public void setData(byte[] array)

setPartitionHash

public void setPartitionHash(int partitionHash)

getType

public int getType()
Description copied from interface: Data
Returns serialization type of binary form. It's defined by Serializer.getTypeId()

Returns:
serializer type id

setType

public void setType(int type)

setHeader

public void setHeader(byte[] header)

readIntHeader

public int readIntHeader(int offset,
                         ByteOrder order)
Description copied from interface: Data
Reads an integer header from given offset using given ByteOrder.

Parameters:
offset - offset of integer header
order - byte order
Returns:
integer header

getHeapCost

public int getHeapCost()
Description copied from interface: Data
Returns approximate heap cost of this Data object in bytes.

Returns:
approximate heap cost

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

hash64

public long hash64()
Description copied from interface: Data
Returns 64-bit hash code for this Data object.

Returns:
64-bit hash code

isPortable

public boolean isPortable()
Description copied from interface: Data
Returns true if this Data is created from a Portable object, false otherwise.

Returns:
true if source object is Portable, false otherwise.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.