Class BinaryEnumObjectImpl
- java.lang.Object
-
- org.apache.ignite.internal.binary.BinaryEnumObjectImpl
-
- All Implemented Interfaces:
Externalizable,Serializable,Cloneable,BinaryObject,BinaryObjectEx,CacheObject,Message
public class BinaryEnumObjectImpl extends Object implements BinaryObjectEx, Externalizable, CacheObject
Binary enum object.- See Also:
- Serialized Form
-
-
Field Summary
-
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 Description BinaryEnumObjectImpl()Externalizablesupport.BinaryEnumObjectImpl(BinaryContext ctx, byte[] arr)BinaryEnumObjectImpl(BinaryContext ctx, int typeId, @Nullable String clsName, int ord)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description bytecacheObjectType()@Nullable StringclassName()BinaryObjectclone()Copies this binary object.<T> Tdeserialize()Gets fully deserialized instance of binary object.<T> Tdeserialize(@Nullable ClassLoader ldr)Gets fully deserialized instance of binary object.shortdirectType()Gets message type.StringenumName()Get name for this enum object.intenumOrdinal()Get ordinal for this enum object.booleanequals(Object obj)<F> Ffield(String fieldName)Gets field value.bytefieldsCount()Gets fields count.voidfinishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr)booleanhasField(String fieldName)Checks whether field exists in the object.inthashCode()booleanisFlagSet(short flag)Check if flag set.booleanisPlatformType()Gets flag indicating whether object value is a platform type.voidonAckReceived()Method called when ack message received.CacheObjectprepareForCache(CacheObjectContext ctx)Prepares cache object for cache (e.g. copies user-provided object if needed).voidprepareMarshal(CacheObjectValueContext ctx)intputValue(long addr)booleanputValue(ByteBuffer buf)booleanputValue(ByteBuffer buf, int off, int len)@Nullable BinaryTyperawType()Get raw type.voidreadExternal(ObjectInput in)booleanreadFrom(ByteBuffer buf, MessageReader reader)Reads this message from provided byte buffer.intsize()Get the size of the objectBinaryObjectBuildertoBuilder()Creates a newBinaryObjectBuilderbased on this binary object.StringtoString()BinaryTypetype()Gets type information for this binary object.inttypeId()<T> Tvalue(CacheObjectValueContext ctx, boolean cpy)<T> Tvalue(CacheObjectValueContext ctx, boolean cpy, ClassLoader ldr)Deserializes a value from an internal representation.byte[]valueBytes(CacheObjectValueContext cacheCtx)intvalueBytesLength(CacheObjectContext ctx)voidwriteExternal(ObjectOutput out)booleanwriteTo(ByteBuffer buf, MessageWriter writer)Writes this message to provided byte buffer.
-
-
-
Constructor Detail
-
BinaryEnumObjectImpl
public BinaryEnumObjectImpl()
Externalizablesupport.
-
BinaryEnumObjectImpl
public BinaryEnumObjectImpl(BinaryContext ctx, int typeId, @Nullable @Nullable String clsName, int ord)
Constructor.- Parameters:
ctx- Context.typeId- Type ID.clsName- Class name.ord- Ordinal.
-
BinaryEnumObjectImpl
public BinaryEnumObjectImpl(BinaryContext ctx, byte[] arr)
- Parameters:
ctx- Context.arr- Array.
-
-
Method Detail
-
className
@Nullable public @Nullable String className()
- Returns:
- Class name.
-
typeId
public int typeId()
- Specified by:
typeIdin interfaceBinaryObjectEx- Returns:
- Type ID.
-
type
public BinaryType type() throws BinaryObjectException
Gets type information for this binary object.- Specified by:
typein interfaceBinaryObject- Returns:
- Binary object type information.
- Throws:
BinaryObjectException- In case of error.
-
rawType
@Nullable public @Nullable BinaryType rawType() throws BinaryObjectException
Get raw type.- Specified by:
rawTypein interfaceBinaryObjectEx- Returns:
- Raw type
- Throws:
BinaryObjectException- If failed.
-
isFlagSet
public boolean isFlagSet(short flag)
Check if flag set.- Specified by:
isFlagSetin interfaceBinaryObjectEx- Parameters:
flag- flag to check.- Returns:
trueif flag is set,falseotherwise.
-
field
public <F> F field(String fieldName) throws BinaryObjectException
Gets field value.- Specified by:
fieldin interfaceBinaryObject- Type Parameters:
F- Type of the field value.- Parameters:
fieldName- Field name.- Returns:
- Field value.
- Throws:
BinaryObjectException- In case of any other error.
-
hasField
public boolean hasField(String fieldName)
Checks whether field exists in the object.- Specified by:
hasFieldin interfaceBinaryObject- Parameters:
fieldName- Field name.- Returns:
Trueif field exists.
-
deserialize
public <T> T deserialize(@Nullable @Nullable ClassLoader ldr) throws BinaryObjectExceptionGets fully deserialized instance of binary object. Ifldrwas not specified, configured class loader will be usedIgniteConfiguration.getClassLoader().- Specified by:
deserializein interfaceBinaryObject- Type Parameters:
T- Type of the deserialized object.- Parameters:
ldr- Class loader.- Returns:
- Fully deserialized instance of binary object.
- Throws:
BinaryInvalidTypeException- If class doesn't exist.BinaryObjectException- In case of any other error.
-
deserialize
public <T> T deserialize() throws BinaryObjectExceptionGets fully deserialized instance of binary object.- Specified by:
deserializein interfaceBinaryObject- Type Parameters:
T- Type of the deserialized object.- Returns:
- Fully deserialized instance of binary object.
- Throws:
BinaryInvalidTypeException- If class doesn't exist.BinaryObjectException- In case of any other error.
-
clone
public BinaryObject clone() throws CloneNotSupportedException
Copies this binary object.- Specified by:
clonein interfaceBinaryObject- Overrides:
clonein classObject- Returns:
- Copy of this binary object.
- Throws:
CloneNotSupportedException
-
toBuilder
public BinaryObjectBuilder toBuilder() throws BinaryObjectException
Creates a newBinaryObjectBuilderbased on this binary object. The following codeBinaryObjectBuilder builder = binaryObject.toBuilder();
is equivalent toBinaryObjectBuilder builder = ignite.binary().builder(binaryObject);
- Specified by:
toBuilderin interfaceBinaryObject- Returns:
- Binary object builder.
- Throws:
BinaryObjectException- If builder cannot be created.
-
enumOrdinal
public int enumOrdinal() throws BinaryObjectExceptionGet ordinal for this enum object. UseBinaryType.isEnum()to check if object is of enum type.- Specified by:
enumOrdinalin interfaceBinaryObject- Returns:
- Ordinal.
- Throws:
BinaryObjectException- If object is not enum.
-
enumName
public String enumName() throws BinaryObjectException
Get name for this enum object. UseBinaryType.isEnum()to check if object is of enum type.- Specified by:
enumNamein interfaceBinaryObject- Returns:
- Name.
- Throws:
BinaryObjectException- If object is not enum.
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
value
@Nullable public <T> T value(CacheObjectValueContext ctx, boolean cpy)
- Specified by:
valuein interfaceCacheObject- Parameters:
ctx- Context.cpy- Iftrueneed 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:
valuein interfaceCacheObject- Parameters:
ctx- Context.cpy- Iftrueneed to copy value.ldr- Class loader, if it isnull, default class loader will be used.- Returns:
- Value.
-
valueBytes
public byte[] valueBytes(CacheObjectValueContext cacheCtx) throws IgniteCheckedException
- Specified by:
valueBytesin interfaceCacheObject- Parameters:
cacheCtx- Context.- Returns:
- Value bytes.
- Throws:
IgniteCheckedException- If failed.
-
putValue
public boolean putValue(ByteBuffer buf) throws IgniteCheckedException
- Specified by:
putValuein interfaceCacheObject- Parameters:
buf- Buffer to write value to.- Returns:
Trueif value was successfully written,falseif there was not enough space in the buffer.- Throws:
IgniteCheckedException- If failed.
-
putValue
public int putValue(long addr) throws IgniteCheckedException- Specified by:
putValuein interfaceCacheObject- 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:
putValuein interfaceCacheObject- Parameters:
buf- Buffer to write value to.off- Offset in source binary data.len- Length of the data to write.- Returns:
Trueif value was successfully written,falseif there was not enough space in the buffer.- Throws:
IgniteCheckedException- If failed.
-
valueBytesLength
public int valueBytesLength(CacheObjectContext ctx) throws IgniteCheckedException
- Specified by:
valueBytesLengthin interfaceCacheObject- Parameters:
ctx- Cache object context.- Returns:
- Size required to store this value object.
- Throws:
IgniteCheckedException- If failed.
-
cacheObjectType
public byte cacheObjectType()
- Specified by:
cacheObjectTypein interfaceCacheObject- 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 whetherIgniteCache.withKeepBinary()is used or not.- Specified by:
isPlatformTypein interfaceCacheObject- 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:
prepareForCachein interfaceCacheObject- Parameters:
ctx- Cache context.- Returns:
- Instance to store in cache.
-
finishUnmarshal
public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException
- Specified by:
finishUnmarshalin interfaceCacheObject- Parameters:
ctx- Context.ldr- Class loader.- Throws:
IgniteCheckedException- If failed.
-
prepareMarshal
public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException
- Specified by:
prepareMarshalin interfaceCacheObject- Parameters:
ctx- Context.- Throws:
IgniteCheckedException- If failed.
-
onAckReceived
public void onAckReceived()
Method called when ack message received.- Specified by:
onAckReceivedin interfaceMessage
-
directType
public short directType()
Gets message type.- Specified by:
directTypein interfaceMessage- Returns:
- Message type.
-
fieldsCount
public byte fieldsCount()
Gets fields count.- Specified by:
fieldsCountin interfaceMessage- Returns:
- Fields count.
-
writeTo
public boolean writeTo(ByteBuffer buf, MessageWriter writer)
Writes this message to provided byte buffer.
-
readFrom
public boolean readFrom(ByteBuffer buf, MessageReader reader)
Reads this message from provided byte buffer.
-
size
public int size()
Get the size of the object- Specified by:
sizein interfaceBinaryObject- Returns:
- Size of the object
-
-