Package one.nio.serial
Class Serializer<T>
- java.lang.Object
-
- one.nio.serial.Serializer<T>
-
- All Implemented Interfaces:
Externalizable,Serializable
- Direct Known Subclasses:
CollectionSerializer,EnumSerializer,ExternalizableSerializer,GeneratedSerializer,HttpRequestSerializer,JavaTimeSerializer,MapSerializer,MethodSerializer,ObjectArraySerializer
public abstract class Serializer<T> extends Object implements Externalizable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSerializer(Class cls)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidcalcSize(T obj, CalcSizeStream css)Class<T>cls()byte[]code()static Objectdeserialize(byte[] data)booleanequals(Object obj)abstract TfromJson(JsonReader in)TfromString(String s)protected voidgenerateUid()inthashCode()static byte[]persist(Object obj)abstract Tread(DataStream in)voidreadExternal(ObjectInput in)static byte[]serialize(Object obj)static intsizeOf(Object obj)abstract voidskip(DataStream in)voidskipExternal(ObjectInput in)voidtoJson(StringBuilder sb)abstract voidtoJson(T obj, StringBuilder builder)StringtoString()longuid()protected StringuniqueName(String prefix)abstract voidwrite(T obj, DataStream out)voidwriteExternal(ObjectOutput out)
-
-
-
Constructor Detail
-
Serializer
protected Serializer(Class cls)
-
-
Method Detail
-
uid
public long uid()
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
skipExternal
public void skipExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
code
public byte[] code()
-
generateUid
protected final void generateUid()
-
toJson
public void toJson(StringBuilder sb)
-
calcSize
public abstract void calcSize(T obj, CalcSizeStream css) throws IOException
- Throws:
IOException
-
write
public abstract void write(T obj, DataStream out) throws IOException
- Throws:
IOException
-
read
public abstract T read(DataStream in) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
skip
public abstract void skip(DataStream in) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
toJson
public abstract void toJson(T obj, StringBuilder builder) throws IOException
- Throws:
IOException
-
fromJson
public abstract T fromJson(JsonReader in) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
fromString
public T fromString(String s) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
sizeOf
public static int sizeOf(Object obj) throws IOException
- Throws:
IOException
-
serialize
public static byte[] serialize(Object obj) throws IOException
- Throws:
IOException
-
persist
public static byte[] persist(Object obj) throws IOException
- Throws:
IOException
-
deserialize
public static Object deserialize(byte[] data) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
-