public class ElsaSerializerPojo extends ElsaSerializerBase implements Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
ElsaSerializerPojo.ClassInfo
Stores info about single class stored in MapDB.
|
static class |
ElsaSerializerPojo.FieldInfo
Stores info about single field stored in MapDB.
|
ElsaSerializerBase.Deser<A>, ElsaSerializerBase.DeserInt, ElsaSerializerBase.DeserLong, ElsaSerializerBase.DeserSingleton, ElsaSerializerBase.DeserStringLen, ElsaSerializerBase.Header, ElsaSerializerBase.Ser<A>, ElsaSerializerBase.UserSer| Modifier and Type | Field and Description |
|---|---|
protected static Method |
androidConstructor |
protected static Map<Class<?>,Constructor<?>> |
class2constuctor |
protected ElsaClassInfoResolver |
classInfoResolver |
protected ElsaClassCallback |
missingClassNotification |
protected static Method |
sunConstructor |
protected static Object |
sunReflFac |
classLoader, DESER_BYTE_ARRAY, headerDeser, objectStackType, 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_SHORT, SER_STRING, singletons, singletonsReverse, userDeser| Constructor and Description |
|---|
ElsaSerializerPojo() |
ElsaSerializerPojo(int objectStackType,
Object[] singletons,
Map<Class,ElsaSerializerBase.Ser> userSer,
Map<Class,Integer> userSerHeaders,
Map<Integer,ElsaSerializerBase.Deser> userDeser,
ElsaClassCallback missingClassNotification,
ElsaClassInfoResolver classInfoResolver) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertClassSerializable(Class<?> clazz) |
protected static Class |
classForName(String className,
ClassLoader loader) |
ElsaSerializerPojo.ClassInfo |
classInfoDeserialize(DataInput in) |
void |
classInfoSerialize(DataOutput out,
ElsaSerializerPojo.ClassInfo ci) |
int |
classToId(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,
ElsaStack objectStack)
override this method to extend ElsaSerializerBase functionality
|
protected ObjectStreamField[] |
fieldsForClass(Class<?> clazz) |
protected ElsaSerializerPojo.ClassInfo |
getClassInfo(int classId) |
Object |
getFieldValue(ElsaSerializerPojo.FieldInfo fieldInfo,
Object object) |
boolean |
isSerializable(Object o)
return true if mapdb knows howto serialize given object
|
static ElsaSerializerPojo.ClassInfo |
makeClassInfo(Class clazz) |
ElsaSerializerPojo.ClassInfo |
makeClassInfo(String className) |
protected void |
notifyMissingClassInfo(Class className) |
protected void |
serializeUnknownObject(DataOutput out,
Object obj,
ElsaStack objectStack)
override this method to extend ElsaSerializerBase functionality
|
void |
setFieldValue(ElsaSerializerPojo.FieldInfo fieldInfo,
Object object,
Object value) |
protected static boolean |
usesAdvancedSerialization(Class<?> clazz) |
clone, deserialize, deserialize, deserializeSingleton, initHeaderDeser, initSer, loadClass, loadClass2, loadClass2, loadClass3, newElsaStack, readBooleanArray, serialize, serialize, serializeClass, serializeObjectArray, writeBooleanArrayprotected final ElsaClassCallback missingClassNotification
protected final ElsaClassInfoResolver classInfoResolver
protected static Method sunConstructor
protected static Object sunReflFac
protected static Method androidConstructor
protected static Map<Class<?>,Constructor<?>> class2constuctor
public ElsaSerializerPojo()
public ElsaSerializerPojo(int objectStackType,
Object[] singletons,
Map<Class,ElsaSerializerBase.Ser> userSer,
Map<Class,Integer> userSerHeaders,
Map<Integer,ElsaSerializerBase.Deser> userDeser,
ElsaClassCallback missingClassNotification,
ElsaClassInfoResolver classInfoResolver)
public void classInfoSerialize(DataOutput out, ElsaSerializerPojo.ClassInfo ci) throws IOException
IOExceptionpublic ElsaSerializerPojo.ClassInfo classInfoDeserialize(DataInput in) throws IOException
IOExceptionprotected static Class classForName(String className, ClassLoader loader)
protected ElsaSerializerPojo.ClassInfo getClassInfo(int classId)
protected void notifyMissingClassInfo(Class className)
public static ElsaSerializerPojo.ClassInfo makeClassInfo(Class clazz)
public ElsaSerializerPojo.ClassInfo makeClassInfo(String className)
protected static boolean usesAdvancedSerialization(Class<?> clazz)
protected ObjectStreamField[] fieldsForClass(Class<?> clazz)
public boolean isSerializable(Object o)
ElsaSerializerBaseisSerializable in class ElsaSerializerBaseprotected void assertClassSerializable(Class<?> clazz) throws NotSerializableException, InvalidClassException
public Object getFieldValue(ElsaSerializerPojo.FieldInfo fieldInfo, Object object)
public void setFieldValue(ElsaSerializerPojo.FieldInfo fieldInfo, Object object, Object value)
public int classToId(String className)
protected void serializeUnknownObject(DataOutput out, Object obj, ElsaStack objectStack) throws IOException
ElsaSerializerBaseserializeUnknownObject in class ElsaSerializerBaseIOExceptionprotected Object deserializeUnknownHeader(DataInput in, int head, ElsaStack objectStack) throws IOException
ElsaSerializerBasedeserializeUnknownHeader in class ElsaSerializerBaseIOExceptionprotected <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 © 2016. All Rights Reserved.