public class SerializerPojo extends SerializerBase implements Serializable
| Modifier and Type | Class and Description |
|---|---|
protected static class |
SerializerPojo.ClassInfo
Stores info about single class stored in MapDB.
|
protected static class |
SerializerPojo.FieldInfo
Stores info about single field stored in MapDB.
|
protected class |
SerializerPojo.ObjectInputStream2 |
protected class |
SerializerPojo.ObjectOutputStream2 |
SerializerBase.Deser<A>, SerializerBase.DeserInt, SerializerBase.DeserLong, SerializerBase.DeserSerializer, SerializerBase.DeserSingleton, SerializerBase.DeserStringLen, SerializerBase.FastArrayList<K>, SerializerBase.Header, SerializerBase.HeaderMapDB, SerializerBase.Ser<A>, SerializerBase.SerHeader, SerializerBase.SerHeaderSerializerSerializer.Array<T>, Serializer.BooleanSer, Serializer.CompressionDeflateWrapper<E>, Serializer.CompressionWrapper<E>, Serializer.EightByteSerializer<E>, Serializer.FourByteSerializer<E>, Serializer.IntegerSerializer, Serializer.LongSerializer| Modifier and Type | Field and Description |
|---|---|
protected static Method |
androidConstructor |
protected static Map<Class<?>,Constructor<?>> |
class2constuctor |
protected Serializer<SerializerPojo.ClassInfo> |
classInfoSerializer |
protected Fun.Function1<Class,String> |
classLoader |
protected static Fun.Function1<Class,String> |
DEFAULT_CLASS_LOADER |
protected Engine |
engine |
protected Fun.Function1Int<SerializerPojo.ClassInfo> |
getClassInfo |
protected Fun.Function0<SerializerPojo.ClassInfo[]> |
getClassInfos |
protected Fun.Function1<Object,String> |
getNamedObject |
protected Fun.Function1<String,Object> |
getNameForObject |
protected Fun.Function1<Void,String> |
notifyMissingClassInfo |
protected static Method |
sunConstructor |
protected static Object |
sunReflFac |
headerDeser, mapdb_all, mapdb_reverse, ser, SER_BOOLEAN, SER_BYTE, SER_BYTE_ARRAY, SER_CHAR, SER_DOUBLE, SER_FLOAT, SER_INT, SER_INT_ARRAY, SER_LONG, SER_LONG_ARRAY, SER_MA_BOOL, SER_MA_INT, SER_MA_LONG, SER_MA_STRING, SER_MA_VAR, SER_SHORT, SER_STRINGBASIC, BIG_DECIMAL, BIG_INTEGER, BOOLEAN, BOOLEAN_ARRAY, BYTE, BYTE_ARRAY, BYTE_ARRAY_NOSIZE, CHAR, CHAR_ARRAY, CLASS, DATE, DOUBLE, DOUBLE_ARRAY, FLOAT, FLOAT_ARRAY, ILLEGAL_ACCESS, INT_ARRAY, INTEGER, INTEGER_PACKED, INTEGER_PACKED_ZIGZAG, JAVA, LONG, LONG_ARRAY, LONG_PACKED, LONG_PACKED_ZIGZAG, RECID, RECID_ARRAY, SHORT, SHORT_ARRAY, STRING, STRING_ASCII, STRING_INTERN, STRING_NOSIZE, STRING_XXHASH, UUID| Constructor and Description |
|---|
SerializerPojo(Fun.Function1<String,Object> getNameForObject,
Fun.Function1<Object,String> getNamedObject,
Fun.Function1Int<SerializerPojo.ClassInfo> getClassInfo,
Fun.Function0<SerializerPojo.ClassInfo[]> getClassInfos,
Fun.Function1<Void,String> notifyMissingClassInfo,
Fun.Function1<Class,String> classLoader,
Engine engine) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertClassSerializable(SerializerPojo.ClassInfo[] classes,
Class<?> clazz) |
protected static Class |
classForName(String className,
ClassLoader loader) |
static int |
classToId(SerializerPojo.ClassInfo[] classes,
String className) |
protected <T> T |
createInstanceSkippinkConstructor(Class<T> clazz)
For pojo serialization we need to instantiate class without invoking its constructor.
|
protected Object |
deserializeUnknownHeader(DataInput in,
int head,
SerializerBase.FastArrayList<Object> objectStack)
override this method to extend SerializerBase functionality
|
protected static ObjectStreamField[] |
fieldsForClass(SerializerPojo.ClassInfo[] classes,
Class<?> clazz) |
protected Engine |
getEngine() |
Object |
getFieldValue(SerializerPojo.FieldInfo fieldInfo,
Object object) |
boolean |
isSerializable(Object o)
return true if mapdb knows howto serialize given object
|
SerializerPojo.ClassInfo |
makeClassInfo(String className) |
protected void |
serializeUnknownObject(DataOutput out,
Object obj,
SerializerBase.FastArrayList<Object> objectStack)
override this method to extend SerializerBase functionality
|
void |
setFieldValue(SerializerPojo.FieldInfo fieldInfo,
Object object,
Object value) |
protected static boolean |
usesAdvancedSerialization(Class<?> clazz) |
assertSerializable, deserialize, deserialize, deserializeClass, deserializeMapDB, equalsBinary, initHeaderDeser, initMapdb, initSer, isTrusted, readBooleanArray, serialize, serialize, serializeClass, serializeObjectArray, writeBooleanArrayequals, fixedSize, getBTreeKeySerializer, hashCode, valueArrayCopyOfRange, valueArrayDeleteValue, valueArrayDeserialize, valueArrayEmpty, valueArrayFromArray, valueArrayGet, valueArrayPut, valueArraySerialize, valueArraySize, valueArrayUpdateValprotected final Serializer<SerializerPojo.ClassInfo> classInfoSerializer
protected static final Fun.Function1<Class,String> DEFAULT_CLASS_LOADER
protected final Engine engine
protected final Fun.Function1<String,Object> getNameForObject
protected final Fun.Function1<Object,String> getNamedObject
protected final Fun.Function0<SerializerPojo.ClassInfo[]> getClassInfos
protected final Fun.Function1Int<SerializerPojo.ClassInfo> getClassInfo
protected final Fun.Function1<Void,String> notifyMissingClassInfo
protected final Fun.Function1<Class,String> classLoader
protected static Method sunConstructor
protected static Object sunReflFac
protected static Method androidConstructor
protected static Map<Class<?>,Constructor<?>> class2constuctor
public SerializerPojo(Fun.Function1<String,Object> getNameForObject, Fun.Function1<Object,String> getNamedObject, Fun.Function1Int<SerializerPojo.ClassInfo> getClassInfo, Fun.Function0<SerializerPojo.ClassInfo[]> getClassInfos, Fun.Function1<Void,String> notifyMissingClassInfo, Fun.Function1<Class,String> classLoader, Engine engine)
protected static Class classForName(String className, ClassLoader loader)
public SerializerPojo.ClassInfo makeClassInfo(String className)
protected static boolean usesAdvancedSerialization(Class<?> clazz)
protected static ObjectStreamField[] fieldsForClass(SerializerPojo.ClassInfo[] classes, Class<?> clazz)
public boolean isSerializable(Object o)
SerializerBaseisSerializable in class SerializerBaseprotected void assertClassSerializable(SerializerPojo.ClassInfo[] classes, Class<?> clazz) throws NotSerializableException, InvalidClassException
public Object getFieldValue(SerializerPojo.FieldInfo fieldInfo, Object object)
public void setFieldValue(SerializerPojo.FieldInfo fieldInfo, Object object, Object value)
public static int classToId(SerializerPojo.ClassInfo[] classes, String className)
protected Engine getEngine()
getEngine in class SerializerBaseprotected void serializeUnknownObject(DataOutput out, Object obj, SerializerBase.FastArrayList<Object> objectStack) throws IOException
SerializerBaseserializeUnknownObject in class SerializerBaseIOExceptionprotected Object deserializeUnknownHeader(DataInput in, int head, SerializerBase.FastArrayList<Object> objectStack) throws IOException
SerializerBasedeserializeUnknownHeader in class SerializerBaseIOExceptionprotected <T> T createInstanceSkippinkConstructor(Class<T> clazz)
For pojo serialization we need to instantiate class without invoking its constructor. There are two ways to do it:
Using proprietary API on Oracle JDK and OpenJDK sun.reflect.ReflectionFactory.getReflectionFactory().newConstructorForSerialization() more at http://www.javaspecialists.eu/archive/Issue175.html
Using ObjectInputStream.newInstance on Android
http://stackoverflow.com/a/3448384
If non of these works we fallback into usual reflection which requires an no-arg constructor
Copyright © 2015. All Rights Reserved.