org.apache.ignite.internal.binary

## Class BinaryUtils

- java.lang.Object
- - org.apache.ignite.internal.binary.BinaryUtils

    public class BinaryUtils
    extends Object

Binary utils.

### Field Summary

Fields
`static Map<Class,BinaryWriteReplacer>` `CLS_TO_WRITE_REPLACER` Map from class to associated write replacer.
`static int` `FIELD_ID_LEN` Field ID length.
`static boolean` `FIELDS_SORTED_ORDER` Whether to sort field in binary objects (doesn't affect Binarylizable).
`static short` `FLAG_COMPACT_FOOTER` Flag: compact footer, no field IDs.
`static short` `FLAG_CUSTOM_DOTNET_TYPE` Flag: raw data contains .NET type information.
`static short` `FLAG_HAS_RAW` Flag indicating that object has raw data.
`static short` `FLAG_HAS_SCHEMA` Flag: only raw data exists.
`static short` `FLAG_OFFSET_ONE_BYTE` Flag: offsets take 1 byte.
`static short` `FLAG_OFFSET_TWO_BYTES` Flag: offsets take 2 bytes.
`static Map<Byte,Class<?>>` `FLAG_TO_CLASS`
`static short` `FLAG_USR_TYP` Flag: user type.
`static int` `OFFSET_1` Offset which fits into 1 byte.
`static int` `OFFSET_2` Offset which fits into 2 bytes.
`static int` `OFFSET_4` Offset which fits into 4 bytes.
`static Map<Class<?>,Byte>` `PLAIN_CLASS_TO_FLAG`
`static Class<? extends Collection>` `SINGLETON_LIST_CLS` Class for SingletonList obtained at runtime.
`static boolean` `USE_STR_SERIALIZATION_VER_2`
`static boolean` `WRAP_TREES` Whether to skip TreeMap/TreeSet wrapping.

### Constructor Summary

Constructors
Constructor and Description
`BinaryUtils()`

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `checkProtocolVersion(byte protoVer)` Check protocol version.
`static BinaryArray` `doReadBinaryArray(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean detach, boolean deserialize, boolean isEnumArray)`
`static BinaryEnumObjectImpl` `doReadBinaryEnum(BinaryInputStream in, BinaryContext ctx)` Read binary enum.
`static BinaryObject` `doReadBinaryObject(BinaryInputStream in, BinaryContext ctx, boolean detach)`
`static boolean[]` `doReadBooleanArray(BinaryInputStream in)`
`static byte[]` `doReadByteArray(BinaryInputStream in)`
`static char[]` `doReadCharArray(BinaryInputStream in)`
`static Class` `doReadClass(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr)`
`static Class` `doReadClass(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, boolean deserialize)`
`static Class` `doReadClass(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, int typeId)`
`static String` `doReadClassName(BinaryInputStream in)`
`static Collection<?>` `doReadCollection(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean detach, boolean deserialize, BinaryCollectionFactory factory)`
`static Date` `doReadDate(BinaryInputStream in)`
`static Date[]` `doReadDateArray(BinaryInputStream in)`
`static BigDecimal` `doReadDecimal(BinaryInputStream in)`
`static BigDecimal[]` `doReadDecimalArray(BinaryInputStream in)`
`static double[]` `doReadDoubleArray(BinaryInputStream in)`
`static Enum<?>` `doReadEnum(BinaryInputStream in, Class<?> cls, boolean useCache)` Having target class in place we simply read ordinal and create final representation.
`static Object[]` `doReadEnumArray(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, Class<?> cls)`
`static float[]` `doReadFloatArray(BinaryInputStream in)`
`static int[]` `doReadIntArray(BinaryInputStream in)`
`static long[]` `doReadLongArray(BinaryInputStream in)`
`static Map<?,?>` `doReadMap(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean detach, boolean deserialize, BinaryMapFactory factory)`
`static @Nullable Object` `doReadObject(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles)`
`static Object[]` `doReadObjectArray(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean detach, boolean deserialize)`
`static Object` `doReadOptimized(BinaryInputStream in, BinaryContext ctx, @Nullable ClassLoader clsLdr)` Read object serialized using optimized marshaller.
`static Object` `doReadProxy(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles)`
`static short[]` `doReadShortArray(BinaryInputStream in)`
`static String` `doReadString(BinaryInputStream in)`
`static String[]` `doReadStringArray(BinaryInputStream in)`
`static Time` `doReadTime(BinaryInputStream in)`
`static Time[]` `doReadTimeArray(BinaryInputStream in)`
`static Timestamp` `doReadTimestamp(BinaryInputStream in)`
`static Timestamp[]` `doReadTimestampArray(BinaryInputStream in)`
`static UUID` `doReadUuid(BinaryInputStream in)`
`static UUID[]` `doReadUuidArray(BinaryInputStream in)`
`static int` `fieldIdLength(short flags)` Get field ID length.
`static int` `fieldOffsetLength(short flags)` Get offset length for the given flags.
`static int` `fieldOffsetRelative(BinaryPositionReadable stream, int pos, int fieldOffsetSize)` Get relative field offset.
`static String` `fieldTypeName(int typeId)`
`static IgniteBiTuple<Integer,Integer>` `footerAbsolute(BinaryPositionReadable in, int start)` Get object's footer.
`static int` `footerStartAbsolute(BinaryPositionReadable in, int start)` Get object's footer.
`static int` `footerStartRelative(BinaryPositionReadable in, int start)` Get footer start of the object.
`static boolean` `hasRaw(short flags)` Check if raw-only flag is set.
`static boolean` `hasSchema(short flags)` Check if raw-only flag is set.
`static boolean` `isBinarylizable(Class cls)` Check if class is binarylizable.
`static boolean` `isBinaryType(Class<?> cls)` Tells whether provided type is binary.
`static boolean` `isCompactFooter(short flags)` Check if "no-field-ids" flag is set.
`static boolean` `isCustomJavaSerialization(Class cls)` Determines whether class contains custom Java serialization logic.
`static boolean` `isFlagSet(short flags, short flag)` Check whether particular flag is set.
`static boolean` `isObjectArray(Class<?> cls)`
`static boolean` `isPlainArrayType(int type)` Checks whether an array type values can or can not contain references to other object.
`static boolean` `isPlainType(int type)`
`static boolean` `isSpecialCollection(Class cls)` Check if class represents a collection which must be treated specially.
`static boolean` `isSpecialMap(Class cls)` Check if class represents a map which must be treated specially.
`static boolean` `isUserType(short flags)` Check if user type flag is set.
`static boolean` `knownArray(Object arr)`
`static boolean` `knownCacheObject(Object obj)`
`static boolean` `knownCollection(Object col)`
`static boolean` `knownMap(Object map)`
`static int` `length(BinaryPositionReadable in, int start)` Get binary object length.
`static Map<String,Integer>` `mergeEnumValues(String typeName, @Nullable Map<String,Integer> oldValues, Map<String,Integer> newValues)` Merges enum value mappings and checks for conflicts.
`static BinaryMetadata` `mergeMetadata(@Nullable BinaryMetadata oldMeta, BinaryMetadata newMeta)` Merge old and new metas.
`static BinaryMetadata` `mergeMetadata(@Nullable BinaryMetadata oldMeta, BinaryMetadata newMeta, @Nullable Set<Integer> changedSchemas)` Merge old and new metas.
`static BinaryWriteMode` `mode(Class<?> cls)`
`static <V> Collection<V>` `newKnownCollection(Object col)` Attempts to create a new collection of the same known type.
`static <K,V> Map<K,V>` `newKnownMap(Object map)` Attempts to create a new map of the same known type.
`static <K,V> Map<K,V>` `newMap(Map<K,V> map)` Attempts to create a new map of the same type as `map` has.
`static <V> Set<V>` `newSet(Set<V> set)` Attempts to create a new set of the same type as `set` has.
`static int` `positionForHandle(BinaryInputStream in)` Get position to be used for handle.
`static String` `qualifiedFieldName(Class cls, String fieldName)` Create qualified field name.
`static Object[]` `rawArrayFromBinary(Object obj)`
`static int` `rawOffsetAbsolute(BinaryPositionReadable in, int start)` Get absolute raw offset of the object.
`static int` `rawOffsetRelative(BinaryPositionReadable in, int start)` Get relative raw offset of the object.
`static @Nullable IgniteUuid` `readIgniteUuid(BinaryRawReader in)` Read `IgniteUuid` instance.
`static Class` `resolveClass(BinaryContext ctx, int typeId, @Nullable String clsName, @Nullable ClassLoader ldr, boolean registerMeta)` Resolve the class.
`static int` `schemaInitialId()` Schema initial ID.
`static byte[]` `strToUtf8Bytes(String val)` Converts the string into UTF-8 byte array considering special symbols like the surrogates.
`static BinaryType` `type(BinaryContext ctx, BinaryObjectEx obj)` Create binary type which is used by users.
`static byte` `typeByClass(Class<?> cls)`
`static BinaryType` `typeProxy(BinaryContext ctx, BinaryObjectEx obj)` Create binary type proxy.
`static @Nullable Object` `unmarshal(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr)`
`static @Nullable Object` `unmarshal(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles)`
`static @Nullable Object` `unmarshal(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean detach)`
`static @Nullable Object` `unmarshal(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean detach, boolean deserialize)`
`static Object` `unwrapLazy(@Nullable Object obj)`
`static Iterator<Object>` `unwrapLazyIterator(Iterator<Object> delegate)`
`static int` `updateSchemaId(int schemaId, int fieldId)` Update schema ID when new field is added.
`static String` `utf8BytesToStr(byte[] arr, int off, int len)` Reconstructs string from UTF-8 bytes.
`static void` `validateEnumValues(String typeName, @Nullable Map<String,Integer> enumValues)` Checks enum values mapping.
`static boolean` `wrapTrees()`
`static void` `writeIgniteUuid(BinaryRawWriter out, @Nullable IgniteUuid val)` Write `IgniteUuid` instance.
`static void` `writePlainObject(BinaryWriterExImpl writer, Object val)` Write value with flag. e.g. writePlainObject(writer, (byte)77) will write two byte: {BYTE, 77}.
`static BinaryWriteReplacer` `writeReplacer(Class cls)` Get predefined write-replacer associated with class.

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

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

### Field Detail

#### PLAIN_CLASS_TO_FLAG

    public static final Map<Class<?>,Byte> PLAIN_CLASS_TO_FLAG

#### FLAG_TO_CLASS

    public static final Map<Byte,Class<?>> FLAG_TO_CLASS

#### USE_STR_SERIALIZATION_VER_2

    public static final boolean USE_STR_SERIALIZATION_VER_2

#### CLS_TO_WRITE_REPLACER

    public static final Map<Class,BinaryWriteReplacer> CLS_TO_WRITE_REPLACER

Map from class to associated write replacer.

#### SINGLETON_LIST_CLS

    public static final Class<? extends Collection> SINGLETON_LIST_CLS

Class for SingletonList obtained at runtime.

#### FLAG_USR_TYP

    public static final short FLAG_USR_TYP

Flag: user type.

See Also:
  Constant Field Values

#### FLAG_HAS_SCHEMA

    public static final short FLAG_HAS_SCHEMA

Flag: only raw data exists.

See Also:
  Constant Field Values

#### FLAG_HAS_RAW

    public static final short FLAG_HAS_RAW

Flag indicating that object has raw data.

See Also:
  Constant Field Values

#### FLAG_OFFSET_ONE_BYTE

    public static final short FLAG_OFFSET_ONE_BYTE

Flag: offsets take 1 byte.

See Also:
  Constant Field Values

#### FLAG_OFFSET_TWO_BYTES

    public static final short FLAG_OFFSET_TWO_BYTES

Flag: offsets take 2 bytes.

See Also:
  Constant Field Values

#### FLAG_COMPACT_FOOTER

    public static final short FLAG_COMPACT_FOOTER

Flag: compact footer, no field IDs.

See Also:
  Constant Field Values

#### FLAG_CUSTOM_DOTNET_TYPE

    public static final short FLAG_CUSTOM_DOTNET_TYPE

Flag: raw data contains .NET type information. Always 0 in Java. Keep it here for information only.

See Also:
  Constant Field Values

#### OFFSET_1

    public static final int OFFSET_1

Offset which fits into 1 byte.

See Also:
  Constant Field Values

#### OFFSET_2

    public static final int OFFSET_2

Offset which fits into 2 bytes.

See Also:
  Constant Field Values

#### OFFSET_4

    public static final int OFFSET_4

Offset which fits into 4 bytes.

See Also:
  Constant Field Values

#### FIELD_ID_LEN

    public static final int FIELD_ID_LEN

Field ID length.

See Also:
  Constant Field Values

#### WRAP_TREES

    public static final boolean WRAP_TREES

Whether to skip TreeMap/TreeSet wrapping.

#### FIELDS_SORTED_ORDER

    public static final boolean FIELDS_SORTED_ORDER

Whether to sort field in binary objects (doesn't affect Binarylizable).

### Constructor Detail

#### BinaryUtils

    public BinaryUtils()

### Method Detail

#### isUserType

    public static boolean isUserType(short flags)

Check if user type flag is set.

Parameters:
  `flags` - Flags.
Returns:
  `True` if set.

#### hasSchema

    public static boolean hasSchema(short flags)

Check if raw-only flag is set.

Parameters:
  `flags` - Flags.
Returns:
  `True` if set.

#### hasRaw

    public static boolean hasRaw(short flags)

Check if raw-only flag is set.

Parameters:
  `flags` - Flags.
Returns:
  `True` if set.

#### isCompactFooter

    public static boolean isCompactFooter(short flags)

Check if "no-field-ids" flag is set.

Parameters:
  `flags` - Flags.
Returns:
  `True` if set.

#### isFlagSet

    public static boolean isFlagSet(short flags,
                                    short flag)

Check whether particular flag is set.

Parameters:
  `flags` - Flags.
  `flag` - Flag.
Returns:
  `True` if flag is set in flags.

#### schemaInitialId

    public static int schemaInitialId()

Schema initial ID.

Returns:
  ID.

#### updateSchemaId

    public static int updateSchemaId(int schemaId,
                                     int fieldId)

Update schema ID when new field is added.

Parameters:
  `schemaId` - Current schema ID.
  `fieldId` - Field ID.
Returns:
  New schema ID.

#### fieldTypeName

    public static String fieldTypeName(int typeId)

Parameters:
  `typeId` - Field type ID.
Returns:
  Field type name or `null` if unknown.

#### writePlainObject

    public static void writePlainObject(BinaryWriterExImpl writer,
                                        Object val)

Write value with flag. e.g. writePlainObject(writer, (byte)77) will write two byte: {BYTE, 77}.

Parameters:
  `writer` - W
  `val` - Value.

#### unwrapLazy

    public static Object unwrapLazy(@Nullable
                                    @Nullable Object obj)

Parameters:
  `obj` - Value to unwrap.
Returns:
  Unwrapped value.

#### unwrapLazyIterator

    public static Iterator<Object> unwrapLazyIterator(Iterator<Object> delegate)

Parameters:
  `delegate` - Iterator to delegate.
Returns:
  New iterator.

#### isPlainType

    public static boolean isPlainType(int type)

Returns:
  `true` if content of serialized value cannot contain references to other object.

#### isPlainArrayType

    public static boolean isPlainArrayType(int type)

Checks whether an array type values can or can not contain references to other object.

Parameters:
  `type` - Array type.
Returns:
  `true` if content of serialized array value cannot contain references to other object.

#### typeByClass

    public static byte typeByClass(Class<?> cls)

Parameters:
  `cls` - Class.
Returns:
  Binary field type.

#### isBinaryType

    public static boolean isBinaryType(Class<?> cls)

Tells whether provided type is binary.

Parameters:
  `cls` - Class to check.
Returns:
  Whether type is binary.

#### wrapTrees

    public static boolean wrapTrees()

Returns:
  Whether tree structures should be wrapped.

#### knownMap

    public static boolean knownMap(Object map)

Parameters:
  `map` - Map to check.
Returns:
  `True` if this map type is supported.

#### newKnownMap

    public static <K,V> Map<K,V> newKnownMap(Object map)

Attempts to create a new map of the same known type. Will return null if map type is not supported.

Parameters:
  `map` - Map.
Returns:
  New map of the same type or null.

#### newMap

    public static <K,V> Map<K,V> newMap(Map<K,V> map)

Attempts to create a new map of the same type as `map` has. Otherwise returns new `HashMap` instance.

Parameters:
  `map` - Original map.
Returns:
  New map.

#### knownCollection

    public static boolean knownCollection(Object col)

Parameters:
  `col` - Collection to check.
Returns:
  True if this is a collection of a known type.

#### knownCacheObject

    public static boolean knownCacheObject(Object obj)

Parameters:
  `obj` - Object to check.
Returns:
  True if this is an object of a known type.

#### knownArray

    public static boolean knownArray(Object arr)

Parameters:
  `arr` - Array to check.
Returns:
  `true` if this array is of a known type.

#### newKnownCollection

    public static <V> Collection<V> newKnownCollection(Object col)

Attempts to create a new collection of the same known type. Will return null if collection type is unknown.

Parameters:
  `col` - Collection.
Returns:
  New empty collection.

#### newSet

    public static <V> Set<V> newSet(Set<V> set)

Attempts to create a new set of the same type as `set` has. Otherwise returns new `HashSet` instance.

Parameters:
  `set` - Original set.
Returns:
  New set.

#### checkProtocolVersion

    public static void checkProtocolVersion(byte protoVer)

Check protocol version.

Parameters:
  `protoVer` - Protocol version.

#### length

    public static int length(BinaryPositionReadable in,
                             int start)

Get binary object length.

Parameters:
  `in` - Input stream.
  `start` - Start position.
Returns:
  Length.

#### footerStartRelative

    public static int footerStartRelative(BinaryPositionReadable in,
                                          int start)

Get footer start of the object.

Parameters:
  `in` - Input stream.
  `start` - Object start position inside the stream.
Returns:
  Footer start.

#### footerStartAbsolute

    public static int footerStartAbsolute(BinaryPositionReadable in,
                                          int start)

Get object's footer.

Parameters:
  `in` - Input stream.
  `start` - Start position.
Returns:
  Footer start.

#### footerAbsolute

    public static IgniteBiTuple<Integer,Integer> footerAbsolute(BinaryPositionReadable in,
                                                                int start)

Get object's footer.

Parameters:
  `in` - Input stream.
  `start` - Start position.
Returns:
  Footer.

#### rawOffsetRelative

    public static int rawOffsetRelative(BinaryPositionReadable in,
                                        int start)

Get relative raw offset of the object.

Parameters:
  `in` - Input stream.
  `start` - Object start position inside the stream.
Returns:
  Raw offset.

#### rawOffsetAbsolute

    public static int rawOffsetAbsolute(BinaryPositionReadable in,
                                        int start)

Get absolute raw offset of the object.

Parameters:
  `in` - Input stream.
  `start` - Object start position inside the stream.
Returns:
  Raw offset.

#### fieldOffsetLength

    public static int fieldOffsetLength(short flags)

Get offset length for the given flags.

Parameters:
  `flags` - Flags.
Returns:
  Offset size.

#### fieldIdLength

    public static int fieldIdLength(short flags)

Get field ID length.

Parameters:
  `flags` - Flags.
Returns:
  Field ID length.

#### fieldOffsetRelative

    public static int fieldOffsetRelative(BinaryPositionReadable stream,
                                          int pos,
                                          int fieldOffsetSize)

Get relative field offset.

Parameters:
  `stream` - Stream.
  `pos` - Position.
  `fieldOffsetSize` - Field offset size.
Returns:
  Relative field offset.

#### mergeMetadata

    public static BinaryMetadata mergeMetadata(@Nullable
                                               @Nullable BinaryMetadata oldMeta,
                                               BinaryMetadata newMeta)

Merge old and new metas.

Parameters:
  `oldMeta` - Old meta.
  `newMeta` - New meta.
Returns:
  New meta if old meta was null, old meta if no changes detected, merged meta otherwise.
Throws:
  `BinaryObjectException` - If merge failed due to metadata conflict.

#### mergeMetadata

    public static BinaryMetadata mergeMetadata(@Nullable
                                               @Nullable BinaryMetadata oldMeta,
                                               BinaryMetadata newMeta,
                                               @Nullable
                                               @Nullable Set<Integer> changedSchemas)

Merge old and new metas.

Parameters:
  `oldMeta` - Old meta.
  `newMeta` - New meta.
  `changedSchemas` - Set for holding changed schemas.
Returns:
  New meta if old meta was null, old meta if no changes detected, merged meta otherwise.
Throws:
  `BinaryObjectException` - If merge failed due to metadata conflict.

#### mode

    public static BinaryWriteMode mode(Class<?> cls)

Parameters:
  `cls` - Class.
Returns:
  Mode.

#### isSpecialCollection

    public static boolean isSpecialCollection(Class cls)

Check if class represents a collection which must be treated specially.

Parameters:
  `cls` - Class.
Returns:
  `True` if this is a special collection class.

#### isSpecialMap

    public static boolean isSpecialMap(Class cls)

Check if class represents a map which must be treated specially.

Parameters:
  `cls` - Class.
Returns:
  `True` if this is a special map class.

#### doReadByteArray

    public static byte[] doReadByteArray(BinaryInputStream in)

Returns:
  Value.

#### doReadBooleanArray

    public static boolean[] doReadBooleanArray(BinaryInputStream in)

Returns:
  Value.

#### doReadShortArray

    public static short[] doReadShortArray(BinaryInputStream in)

Returns:
  Value.

#### doReadCharArray

    public static char[] doReadCharArray(BinaryInputStream in)

Returns:
  Value.

#### doReadIntArray

    public static int[] doReadIntArray(BinaryInputStream in)

Returns:
  Value.

#### doReadLongArray

    public static long[] doReadLongArray(BinaryInputStream in)

Returns:
  Value.

#### doReadFloatArray

    public static float[] doReadFloatArray(BinaryInputStream in)

Returns:
  Value.

#### doReadDoubleArray

    public static double[] doReadDoubleArray(BinaryInputStream in)

Returns:
  Value.

#### doReadDecimal

    public static BigDecimal doReadDecimal(BinaryInputStream in)

Returns:
  Value.

#### doReadString

    public static String doReadString(BinaryInputStream in)

Returns:
  Value.

#### doReadUuid

    public static UUID doReadUuid(BinaryInputStream in)

Returns:
  Value.

#### doReadDate

    public static Date doReadDate(BinaryInputStream in)

Returns:
  Value.

#### doReadTimestamp

    public static Timestamp doReadTimestamp(BinaryInputStream in)

Returns:
  Value.

#### doReadTime

    public static Time doReadTime(BinaryInputStream in)

Returns:
  Value.

#### doReadDecimalArray

    public static BigDecimal[] doReadDecimalArray(BinaryInputStream in)
                                           throws BinaryObjectException

Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadStringArray

    public static String[] doReadStringArray(BinaryInputStream in)
                                      throws BinaryObjectException

Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadUuidArray

    public static UUID[] doReadUuidArray(BinaryInputStream in)
                                  throws BinaryObjectException

Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadDateArray

    public static Date[] doReadDateArray(BinaryInputStream in)
                                  throws BinaryObjectException

Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadTimestampArray

    public static Timestamp[] doReadTimestampArray(BinaryInputStream in)
                                            throws BinaryObjectException

Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadTimeArray

    public static Time[] doReadTimeArray(BinaryInputStream in)
                                  throws BinaryObjectException

Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadBinaryObject

    public static BinaryObject doReadBinaryObject(BinaryInputStream in,
                                                  BinaryContext ctx,
                                                  boolean detach)

Returns:
  Value.

#### doReadClass

    public static Class doReadClass(BinaryInputStream in,
                                    BinaryContext ctx,
                                    ClassLoader ldr)
                             throws BinaryObjectException

Parameters:
  `in` - Binary input stream.
  `ctx` - Binary context.
  `ldr` - Class loader.
Returns:
  Class object specified at the input stream.
Throws:
  `BinaryObjectException` - If failed.

#### doReadClass

    public static Class doReadClass(BinaryInputStream in,
                                    BinaryContext ctx,
                                    ClassLoader ldr,
                                    boolean deserialize)
                             throws BinaryObjectException

Parameters:
  `in` - Binary input stream.
  `ctx` - Binary context.
  `ldr` - Class loader.
  `deserialize` - Doesn't load the class when the flag is `false`. Class information is skipped.
Returns:
  Class object specified at the input stream if `deserialize == true`. Otherwise returns `null`
Throws:
  `BinaryObjectException` - If failed.

#### doReadProxy

    public static Object doReadProxy(BinaryInputStream in,
                                     BinaryContext ctx,
                                     ClassLoader ldr,
                                     BinaryReaderHandlesHolder handles)

Returns:
  Value.

#### doReadClassName

    public static String doReadClassName(BinaryInputStream in)

Parameters:
  `in` - Input stream.
Returns:
  Class name.

#### doReadClass

    public static Class doReadClass(BinaryInputStream in,
                                    BinaryContext ctx,
                                    ClassLoader ldr,
                                    int typeId)
                             throws BinaryObjectException

Parameters:
  `in` - Binary input stream.
  `ctx` - Binary context.
  `ldr` - Class loader.
  `typeId` - Type id.
Returns:
  Class object specified at the input stream.
Throws:
  `BinaryObjectException` - If failed.

#### resolveClass

    public static Class resolveClass(BinaryContext ctx,
                                     int typeId,
                                     @Nullable
                                     @Nullable String clsName,
                                     @Nullable
                                     @Nullable ClassLoader ldr,
                                     boolean registerMeta)

Resolve the class.

Parameters:
  `ctx` - Binary context.
  `typeId` - Type ID.
  `clsName` - Class name.
  `ldr` - Class loaded.
Returns:
  Resovled class.

#### doReadBinaryEnum

    public static BinaryEnumObjectImpl doReadBinaryEnum(BinaryInputStream in,
                                                        BinaryContext ctx)

Read binary enum.

Parameters:
  `in` - Input stream.
  `ctx` - Binary context.
Returns:
  Enum.

#### doReadEnum

    public static Enum<?> doReadEnum(BinaryInputStream in,
                                     Class<?> cls,
                                     boolean useCache)
                              throws BinaryObjectException

Having target class in place we simply read ordinal and create final representation.

Parameters:
  `cls` - Enum class.
  `useCache` - True if class loader cache will be used, false otherwise.
Returns:
  Value.
Throws:
  `BinaryObjectException`

#### doReadEnumArray

    public static Object[] doReadEnumArray(BinaryInputStream in,
                                           BinaryContext ctx,
                                           ClassLoader ldr,
                                           Class<?> cls)
                                    throws BinaryObjectException

Parameters:
  `cls` - Enum class.
Returns:
  Value.
Throws:
  `BinaryObjectException`

#### doReadOptimized

    public static Object doReadOptimized(BinaryInputStream in,
                                         BinaryContext ctx,
                                         @Nullable
                                         @Nullable ClassLoader clsLdr)

Read object serialized using optimized marshaller.

Returns:
  Result.

#### doReadObject

    @Nullable
    public static @Nullable Object doReadObject(BinaryInputStream in,
                                                          BinaryContext ctx,
                                                          ClassLoader ldr,
                                                          BinaryReaderHandlesHolder handles)
                                                   throws BinaryObjectException

Returns:
  Object.
Throws:
  `BinaryObjectException` - In case of error.

#### unmarshal

    @Nullable
    public static @Nullable Object unmarshal(BinaryInputStream in,
                                                       BinaryContext ctx,
                                                       ClassLoader ldr)
                                                throws BinaryObjectException

Returns:
  Unmarshalled value.
Throws:
  `BinaryObjectException` - In case of error.

#### unmarshal

    @Nullable
    public static @Nullable Object unmarshal(BinaryInputStream in,
                                                       BinaryContext ctx,
                                                       ClassLoader ldr,
                                                       BinaryReaderHandlesHolder handles)
                                                throws BinaryObjectException

Returns:
  Unmarshalled value.
Throws:
  `BinaryObjectException` - In case of error.

#### unmarshal

    @Nullable
    public static @Nullable Object unmarshal(BinaryInputStream in,
                                                       BinaryContext ctx,
                                                       ClassLoader ldr,
                                                       BinaryReaderHandlesHolder handles,
                                                       boolean detach)
                                                throws BinaryObjectException

Returns:
  Unmarshalled value.
Throws:
  `BinaryObjectException` - In case of error.

#### unmarshal

    @Nullable
    public static @Nullable Object unmarshal(BinaryInputStream in,
                                                       BinaryContext ctx,
                                                       ClassLoader ldr,
                                                       BinaryReaderHandlesHolder handles,
                                                       boolean detach,
                                                       boolean deserialize)
                                                throws BinaryObjectException

Returns:
  Unmarshalled value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadObjectArray

    public static Object[] doReadObjectArray(BinaryInputStream in,
                                             BinaryContext ctx,
                                             ClassLoader ldr,
                                             BinaryReaderHandlesHolder handles,
                                             boolean detach,
                                             boolean deserialize)
                                      throws BinaryObjectException

Parameters:
  `in` - Binary input stream.
  `ctx` - Binary context.
  `ldr` - Class loader.
  `handles` - Holder for handles.
  `detach` - Detach flag.
  `deserialize` - Deep flag.
Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadBinaryArray

    public static BinaryArray doReadBinaryArray(BinaryInputStream in,
                                                BinaryContext ctx,
                                                ClassLoader ldr,
                                                BinaryReaderHandlesHolder handles,
                                                boolean detach,
                                                boolean deserialize,
                                                boolean isEnumArray)

Parameters:
  `in` - Binary input stream.
  `ctx` - Binary context.
  `ldr` - Class loader.
  `handles` - Holder for handles.
  `detach` - Detach flag.
  `deserialize` - Deep flag.
Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadCollection

    public static Collection<?> doReadCollection(BinaryInputStream in,
                                                 BinaryContext ctx,
                                                 ClassLoader ldr,
                                                 BinaryReaderHandlesHolder handles,
                                                 boolean detach,
                                                 boolean deserialize,
                                                 BinaryCollectionFactory factory)
                                          throws BinaryObjectException

Parameters:
  `deserialize` - Deep flag.
  `factory` - Collection factory.
Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### doReadMap

    public static Map<?,?> doReadMap(BinaryInputStream in,
                                     BinaryContext ctx,
                                     ClassLoader ldr,
                                     BinaryReaderHandlesHolder handles,
                                     boolean detach,
                                     boolean deserialize,
                                     BinaryMapFactory factory)
                              throws BinaryObjectException

Parameters:
  `deserialize` - Deep flag.
  `factory` - Map factory.
Returns:
  Value.
Throws:
  `BinaryObjectException` - In case of error.

#### positionForHandle

    public static int positionForHandle(BinaryInputStream in)

Get position to be used for handle. We assume here that the hdr byte was read, hence subtract -1.

Returns:
  Position for handle.

#### isBinarylizable

    public static boolean isBinarylizable(Class cls)

Check if class is binarylizable.

Parameters:
  `cls` - Class.
Returns:
  `True` if binarylizable.

#### isCustomJavaSerialization

    public static boolean isCustomJavaSerialization(Class cls)

Determines whether class contains custom Java serialization logic.

Parameters:
  `cls` - Class.
Returns:
  `true` if custom Java serialization logic exists, `false` otherwise.

#### qualifiedFieldName

    public static String qualifiedFieldName(Class cls,
                                            String fieldName)

Create qualified field name.

Parameters:
  `cls` - Class.
  `fieldName` - Field name.
Returns:
  Qualified field name.

#### writeIgniteUuid

    public static void writeIgniteUuid(BinaryRawWriter out,
                                       @Nullable
                                       @Nullable IgniteUuid val)

Write `IgniteUuid` instance.

Parameters:
  `out` - Writer.
  `val` - Value.

#### readIgniteUuid

    @Nullable
    public static @Nullable IgniteUuid readIgniteUuid(BinaryRawReader in)

Read `IgniteUuid` instance.

Parameters:
  `in` - Reader.
Returns:
  Value.

#### utf8BytesToStr

    public static String utf8BytesToStr(byte[] arr,
                                        int off,
                                        int len)

Reconstructs string from UTF-8 bytes.

Parameters:
  `arr` - array Byte array.
  `off` - offset Offset in the array.
  `len` - length Byte array lenght.
Returns:
  string Resulting string.

#### strToUtf8Bytes

    public static byte[] strToUtf8Bytes(String val)

Converts the string into UTF-8 byte array considering special symbols like the surrogates.

Parameters:
  `val` - String to convert.
Returns:
  Resulting byte array.

#### typeProxy

    public static BinaryType typeProxy(BinaryContext ctx,
                                       BinaryObjectEx obj)

Create binary type proxy.

Parameters:
  `ctx` - Context.
  `obj` - Binary object.
Returns:
  Binary type proxy.

#### type

    public static BinaryType type(BinaryContext ctx,
                                  BinaryObjectEx obj)

Create binary type which is used by users.

Parameters:
  `ctx` - Context.
  `obj` - Binary object.
Returns:
  Binary type.

#### writeReplacer

    public static BinaryWriteReplacer writeReplacer(Class cls)

Get predefined write-replacer associated with class.

Parameters:
  `cls` - Class.
Returns:
  Write replacer.

#### validateEnumValues

    public static void validateEnumValues(String typeName,
                                          @Nullable
                                          @Nullable Map<String,Integer> enumValues)
                                   throws BinaryObjectException

Checks enum values mapping.

Parameters:
  `typeName` - Name of the type.
  `enumValues` - Enum name to ordinal mapping.
Throws:
  `BinaryObjectException`

#### mergeEnumValues

    public static Map<String,Integer> mergeEnumValues(String typeName,
                                                      @Nullable
                                                      @Nullable Map<String,Integer> oldValues,
                                                      Map<String,Integer> newValues)
                                               throws BinaryObjectException

Merges enum value mappings and checks for conflicts. Possible conflicts: - same name is used for different ordinal values. - ordinal value is used more than once.

Parameters:
  `typeName` - Name of the type.
  `oldValues` - Old enum value mapping.
  `newValues` - New enum value mapping.
Throws:
  `BinaryObjectException` - in case of name or value conflict.

#### rawArrayFromBinary

    public static Object[] rawArrayFromBinary(Object obj)

Parameters:
  `obj` - `BinaryArray` or `Object[]`.
Returns:
  Objects array.

#### isObjectArray

    public static boolean isObjectArray(Class<?> cls)

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022