public class BinaryUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
FIELD_ID_LEN
Field ID length.
|
static short |
FLAG_COMPACT_FOOTER
Flag: compact footer, no field IDs.
|
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 |
| Constructor and Description |
|---|
BinaryUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkProtocolVersion(byte protoVer)
Check protocol version.
|
static BinaryObject |
doReadBinaryObject(BinaryInputStream in,
BinaryContext ctx) |
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,
int typeId) |
static Collection<?> |
doReadCollection(BinaryInputStream in,
BinaryContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles,
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)
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 deserialize,
BinaryMapFactory factory) |
static Object |
doReadObject(BinaryInputStream in,
BinaryContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles) |
static Object[] |
doReadObjectArray(BinaryInputStream in,
BinaryContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles,
boolean deserialize) |
static Object |
doReadOptimized(BinaryInputStream in,
BinaryContext ctx,
ClassLoader clsLdr)
Read object serialized using optimized marshaller.
|
static short[] |
doReadShortArray(BinaryInputStream in) |
static String |
doReadString(BinaryInputStream in) |
static String[] |
doReadStringArray(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 int |
fieldTypeId(String typeName) |
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 |
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 |
isUserType(short flags)
Check if user type flag is set.
|
static int |
length(BinaryPositionReadable in,
int start)
Get binary object length.
|
static BinaryMetadata |
mergeMetadata(BinaryMetadata oldMeta,
BinaryMetadata newMeta)
Merge old and new metas.
|
static BinaryWriteMode |
mode(Class<?> cls) |
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 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 Class |
resolveClass(BinaryContext ctx,
int typeId,
String clsName,
ClassLoader ldr,
boolean deserialize)
Resolve the class.
|
static int |
schemaInitialId()
Schema initial ID.
|
static byte |
typeByClass(Class<?> cls) |
static Object |
unmarshal(BinaryInputStream in,
BinaryContext ctx,
ClassLoader ldr) |
static Object |
unmarshal(BinaryInputStream in,
BinaryContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles) |
static Object |
unmarshal(BinaryInputStream in,
BinaryContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles,
boolean detach) |
static Object |
unwrapLazy(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 void |
writePlainObject(BinaryWriterExImpl writer,
Object val)
Write value with flag. e.g. writePlainObject(writer, (byte)77) will write two byte: {BYTE, 77}.
|
public static final short FLAG_USR_TYP
public static final short FLAG_HAS_SCHEMA
public static final short FLAG_HAS_RAW
public static final short FLAG_OFFSET_ONE_BYTE
public static final short FLAG_OFFSET_TWO_BYTES
public static final short FLAG_COMPACT_FOOTER
public static final int OFFSET_1
public static final int OFFSET_2
public static final int OFFSET_4
public static final int FIELD_ID_LEN
public static boolean isUserType(short flags)
flags - Flags.True if set.public static boolean hasSchema(short flags)
flags - Flags.True if set.public static boolean hasRaw(short flags)
flags - Flags.True if set.public static boolean isCompactFooter(short flags)
flags - Flags.True if set.public static int schemaInitialId()
public static int updateSchemaId(int schemaId,
int fieldId)
schemaId - Current schema ID.fieldId - Field ID.public static int fieldTypeId(String typeName)
typeName - Field type name.public static String fieldTypeName(int typeId)
typeId - Field type ID.public static void writePlainObject(BinaryWriterExImpl writer, Object val)
writer - Wval - Value.public static Object unwrapLazy(@Nullable Object obj)
obj - Value to unwrap.public static Iterator<Object> unwrapLazyIterator(Iterator<Object> delegate)
delegate - Iterator to delegate.public static boolean isPlainType(int type)
true if content of serialized value cannot contain references to other object.public static boolean isPlainArrayType(int type)
type - Array type.true if content of serialized array value cannot contain references to other object.public static byte typeByClass(Class<?> cls)
cls - Class.public static boolean isBinaryType(Class<?> cls)
cls - Class to check.public static <K,V> Map<K,V> newMap(Map<K,V> map)
map has. Otherwise returns new HashMap instance.map - Original map.public static <V> Set<V> newSet(Set<V> set)
set has. Otherwise returns new HashSet instance.set - Original set.public static void checkProtocolVersion(byte protoVer)
protoVer - Protocol version.public static int length(BinaryPositionReadable in, int start)
in - Input stream.start - Start position.public static int footerStartRelative(BinaryPositionReadable in, int start)
in - Input stream.start - Object start position inside the stream.public static int footerStartAbsolute(BinaryPositionReadable in, int start)
in - Input stream.start - Start position.public static IgniteBiTuple<Integer,Integer> footerAbsolute(BinaryPositionReadable in, int start)
in - Input stream.start - Start position.public static int rawOffsetRelative(BinaryPositionReadable in, int start)
in - Input stream.start - Object start position inside the stream.public static int rawOffsetAbsolute(BinaryPositionReadable in, int start)
in - Input stream.start - Object start position inside the stream.public static int fieldOffsetLength(short flags)
flags - Flags.public static int fieldIdLength(short flags)
flags - Flags.public static int fieldOffsetRelative(BinaryPositionReadable stream, int pos, int fieldOffsetSize)
stream - Stream.pos - Position.fieldOffsetSize - Field offset size.public static BinaryMetadata mergeMetadata(@Nullable BinaryMetadata oldMeta, BinaryMetadata newMeta)
oldMeta - Old meta.newMeta - New meta.BinaryObjectException - If merge failed due to metadata conflict.public static BinaryWriteMode mode(Class<?> cls)
cls - Class.public static byte[] doReadByteArray(BinaryInputStream in)
public static boolean[] doReadBooleanArray(BinaryInputStream in)
public static short[] doReadShortArray(BinaryInputStream in)
public static char[] doReadCharArray(BinaryInputStream in)
public static int[] doReadIntArray(BinaryInputStream in)
public static long[] doReadLongArray(BinaryInputStream in)
public static float[] doReadFloatArray(BinaryInputStream in)
public static double[] doReadDoubleArray(BinaryInputStream in)
public static BigDecimal doReadDecimal(BinaryInputStream in)
public static String doReadString(BinaryInputStream in)
public static UUID doReadUuid(BinaryInputStream in)
public static Date doReadDate(BinaryInputStream in)
public static Timestamp doReadTimestamp(BinaryInputStream in)
public static BigDecimal[] doReadDecimalArray(BinaryInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static String[] doReadStringArray(BinaryInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static UUID[] doReadUuidArray(BinaryInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static Date[] doReadDateArray(BinaryInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static Timestamp[] doReadTimestampArray(BinaryInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static BinaryObject doReadBinaryObject(BinaryInputStream in, BinaryContext ctx)
public static Class doReadClass(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr) throws BinaryObjectException
BinaryObjectExceptionpublic static Class doReadClass(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, int typeId) throws BinaryObjectException
typeId - Type id.BinaryObjectExceptionpublic static Class resolveClass(BinaryContext ctx, int typeId, @Nullable String clsName, @Nullable ClassLoader ldr, boolean deserialize)
ctx - Binary context.typeId - Type ID.clsName - Class name.ldr - Class loaded.public static Enum<?> doReadEnum(BinaryInputStream in, Class<?> cls) throws BinaryObjectException
cls - Enum class.BinaryObjectExceptionpublic static Object[] doReadEnumArray(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, Class<?> cls) throws BinaryObjectException
cls - Enum class.BinaryObjectExceptionpublic static Object doReadOptimized(BinaryInputStream in, BinaryContext ctx, @Nullable ClassLoader clsLdr)
@Nullable public static Object doReadObject(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles) throws BinaryObjectException
BinaryObjectException - In case of error.@Nullable public static Object unmarshal(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr) throws BinaryObjectException
BinaryObjectException - In case of error.@Nullable public static Object unmarshal(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles) throws BinaryObjectException
BinaryObjectException - In case of error.@Nullable public static Object unmarshal(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean detach) throws BinaryObjectException
BinaryObjectException - In case of error.public static Object[] doReadObjectArray(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean deserialize) throws BinaryObjectException
deserialize - Deep flag.BinaryObjectException - In case of error.public static Collection<?> doReadCollection(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean deserialize, BinaryCollectionFactory factory) throws BinaryObjectException
deserialize - Deep flag.factory - Collection factory.BinaryObjectException - In case of error.public static Map<?,?> doReadMap(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean deserialize, BinaryMapFactory factory) throws BinaryObjectException
deserialize - Deep flag.factory - Map factory.BinaryObjectException - In case of error.public static int positionForHandle(BinaryInputStream in)
public static boolean isBinarylizable(Class cls)
cls - Class.True if binarylizable.public static boolean isCustomJavaSerialization(Class cls)
cls - Class.true if custom Java serialization logic exists, false otherwise.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.0.final Release Date : December 29 2015