public class PortableUtils 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 |
|---|
PortableUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkProtocolVersion(byte protoVer)
Check protocol version.
|
static boolean[] |
doReadBooleanArray(PortableInputStream in) |
static byte[] |
doReadByteArray(PortableInputStream in) |
static char[] |
doReadCharArray(PortableInputStream in) |
static Class |
doReadClass(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr) |
static Class |
doReadClass(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr,
int typeId) |
static Collection<?> |
doReadCollection(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles,
boolean deserialize,
Class<? extends Collection> cls) |
static Date |
doReadDate(PortableInputStream in) |
static Date[] |
doReadDateArray(PortableInputStream in) |
static BigDecimal |
doReadDecimal(PortableInputStream in) |
static BigDecimal[] |
doReadDecimalArray(PortableInputStream in) |
static double[] |
doReadDoubleArray(PortableInputStream in) |
static Enum<?> |
doReadEnum(PortableInputStream in,
Class<?> cls)
Having target class in place we simply read ordinal and create final representation.
|
static Object[] |
doReadEnumArray(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr,
Class<?> cls) |
static float[] |
doReadFloatArray(PortableInputStream in) |
static int[] |
doReadIntArray(PortableInputStream in) |
static long[] |
doReadLongArray(PortableInputStream in) |
static Map<?,?> |
doReadMap(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles,
boolean deserialize,
Class<? extends Map> cls) |
static Map.Entry<?,?> |
doReadMapEntry(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles,
boolean deserialize) |
static Object |
doReadObject(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles) |
static Object[] |
doReadObjectArray(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles,
boolean deserialize) |
static Object |
doReadOptimized(PortableInputStream in,
PortableContext ctx,
ClassLoader clsLdr)
Read object serialized using optimized marshaller.
|
static BinaryObject |
doReadPortableObject(PortableInputStream in,
PortableContext ctx) |
static short[] |
doReadShortArray(PortableInputStream in) |
static String |
doReadString(PortableInputStream in) |
static String[] |
doReadStringArray(PortableInputStream in) |
static Timestamp |
doReadTimestamp(PortableInputStream in) |
static Timestamp[] |
doReadTimestampArray(PortableInputStream in) |
static UUID |
doReadUuid(PortableInputStream in) |
static UUID[] |
doReadUuidArray(PortableInputStream 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(PortablePositionReadable stream,
int pos,
int fieldOffsetSize)
Get relative field offset.
|
static int |
fieldTypeId(String typeName) |
static String |
fieldTypeName(int typeId) |
static IgniteBiTuple<Integer,Integer> |
footerAbsolute(PortablePositionReadable in,
int start)
Get object's footer.
|
static int |
footerStartAbsolute(PortablePositionReadable in,
int start)
Get object's footer.
|
static int |
footerStartRelative(PortablePositionReadable 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 |
isCompactFooter(short flags)
Check if "no-field-ids" flag is set.
|
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 |
isPortableType(Class<?> cls)
Tells whether provided type is portable.
|
static boolean |
isUserType(short flags)
Check if user type flag is set.
|
static int |
length(PortablePositionReadable in,
int start)
Get portable 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(PortableInputStream in)
Get position to be used for handle.
|
static int |
rawOffsetAbsolute(PortablePositionReadable in,
int start)
Get absolute raw offset of the object.
|
static int |
rawOffsetRelative(PortablePositionReadable in,
int start)
Get relative raw offset of the object.
|
static Class |
resolveClass(PortableContext 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(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr) |
static Object |
unmarshal(PortableInputStream in,
PortableContext ctx,
ClassLoader ldr,
BinaryReaderHandlesHolder handles) |
static Object |
unmarshal(PortableInputStream in,
PortableContext 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 isPortableType(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(PortablePositionReadable in, int start)
in - Input stream.start - Start position.public static int footerStartRelative(PortablePositionReadable in, int start)
in - Input stream.start - Object start position inside the stream.public static int footerStartAbsolute(PortablePositionReadable in, int start)
in - Input stream.start - Start position.public static IgniteBiTuple<Integer,Integer> footerAbsolute(PortablePositionReadable in, int start)
in - Input stream.start - Start position.public static int rawOffsetRelative(PortablePositionReadable in, int start)
in - Input stream.start - Object start position inside the stream.public static int rawOffsetAbsolute(PortablePositionReadable 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(PortablePositionReadable 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(PortableInputStream in)
public static boolean[] doReadBooleanArray(PortableInputStream in)
public static short[] doReadShortArray(PortableInputStream in)
public static char[] doReadCharArray(PortableInputStream in)
public static int[] doReadIntArray(PortableInputStream in)
public static long[] doReadLongArray(PortableInputStream in)
public static float[] doReadFloatArray(PortableInputStream in)
public static double[] doReadDoubleArray(PortableInputStream in)
public static BigDecimal doReadDecimal(PortableInputStream in)
public static String doReadString(PortableInputStream in)
public static UUID doReadUuid(PortableInputStream in)
public static Date doReadDate(PortableInputStream in)
public static Timestamp doReadTimestamp(PortableInputStream in)
public static BigDecimal[] doReadDecimalArray(PortableInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static String[] doReadStringArray(PortableInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static UUID[] doReadUuidArray(PortableInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static Date[] doReadDateArray(PortableInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static Timestamp[] doReadTimestampArray(PortableInputStream in) throws BinaryObjectException
BinaryObjectException - In case of error.public static BinaryObject doReadPortableObject(PortableInputStream in, PortableContext ctx)
public static Class doReadClass(PortableInputStream in, PortableContext ctx, ClassLoader ldr) throws BinaryObjectException
BinaryObjectExceptionpublic static Class doReadClass(PortableInputStream in, PortableContext ctx, ClassLoader ldr, int typeId) throws BinaryObjectException
typeId - Type id.BinaryObjectExceptionpublic static Class resolveClass(PortableContext ctx, int typeId, @Nullable String clsName, @Nullable ClassLoader ldr, boolean deserialize)
ctx - Portable context.typeId - Type ID.clsName - Class name.ldr - Class loaded.public static Enum<?> doReadEnum(PortableInputStream in, Class<?> cls) throws BinaryObjectException
cls - Enum class.BinaryObjectExceptionpublic static Object[] doReadEnumArray(PortableInputStream in, PortableContext ctx, ClassLoader ldr, Class<?> cls) throws BinaryObjectException
cls - Enum class.BinaryObjectExceptionpublic static Object doReadOptimized(PortableInputStream in, PortableContext ctx, @Nullable ClassLoader clsLdr)
@Nullable public static Object doReadObject(PortableInputStream in, PortableContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles) throws BinaryObjectException
BinaryObjectException - In case of error.@Nullable public static Object unmarshal(PortableInputStream in, PortableContext ctx, ClassLoader ldr) throws BinaryObjectException
BinaryObjectException - In case of error.@Nullable public static Object unmarshal(PortableInputStream in, PortableContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles) throws BinaryObjectException
BinaryObjectException - In case of error.@Nullable public static Object unmarshal(PortableInputStream in, PortableContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean detach) throws BinaryObjectException
BinaryObjectException - In case of error.public static Object[] doReadObjectArray(PortableInputStream in, PortableContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean deserialize) throws BinaryObjectException
deserialize - Deep flag.BinaryObjectException - In case of error.public static Collection<?> doReadCollection(PortableInputStream in, PortableContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean deserialize, @Nullable Class<? extends Collection> cls) throws BinaryObjectException
deserialize - Deep flag.cls - Collection class.BinaryObjectException - In case of error.public static Map<?,?> doReadMap(PortableInputStream in, PortableContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean deserialize, @Nullable Class<? extends Map> cls) throws BinaryObjectException
deserialize - Deep flag.cls - Map class.BinaryObjectException - In case of error.public static Map.Entry<?,?> doReadMapEntry(PortableInputStream in, PortableContext ctx, ClassLoader ldr, BinaryReaderHandlesHolder handles, boolean deserialize) throws BinaryObjectException
deserialize - Deserialize flag flag.BinaryObjectException - In case of error.public static int positionForHandle(PortableInputStream in)
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.0-b1 Release Date : December 1 2015