Class ArraySerializer
java.lang.Object
com.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>
com.github.tommyettinger.kryo.gdx.ArraySerializer
public class ArraySerializer
extends com.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>
Serializes libGDX
Array objects.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.utils.Arraycopy(com.esotericsoftware.kryo.Kryo kryo, com.badlogic.gdx.utils.Array original) protected com.badlogic.gdx.utils.Array<?>create(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends com.badlogic.gdx.utils.Array> type, int size) Used byread(Kryo, Input, Class)to create the new object.protected com.badlogic.gdx.utils.ArraycreateCopy(com.esotericsoftware.kryo.Kryo kryo, com.badlogic.gdx.utils.Array original) Used bycopy(Kryo, Array)to create the new object.com.esotericsoftware.kryo.Serializercom.badlogic.gdx.utils.Arrayread(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends com.badlogic.gdx.utils.Array> type) voidsetElementClass(Class elementClass) The concrete class of the collection elements, or null if it is not known.voidsetElementClass(Class elementClass, com.esotericsoftware.kryo.Serializer serializer) Sets bothsetElementClass(Class)andsetElementSerializer(Serializer).voidsetElementsCanBeNull(boolean elementsCanBeNull) voidsetElementSerializer(com.esotericsoftware.kryo.Serializer elementSerializer) The serializer to be used for elements in collection, or null to use the serializer registered withKryofor each element's type.voidwrite(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, com.badlogic.gdx.utils.Array collection) protected voidwriteHeader(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, com.badlogic.gdx.utils.Array collection) Can be overidden to write data needed forcreate(Kryo, Input, Class, int).Methods inherited from class com.esotericsoftware.kryo.Serializer
getAcceptsNull, isImmutable, setAcceptsNull, setImmutable
-
Constructor Details
-
ArraySerializer
public ArraySerializer()
-
-
Method Details
-
setElementsCanBeNull
- Parameters:
elementsCanBeNull- False if all elements are not null. This saves 1 byte per element if elementClass is set. True if it is not known (default).
-
setElementClass
The concrete class of the collection elements, or null if it is not known. This saves 1-2 bytes per element. Only set to a non-null value if the elements in the collection are known to all be instances of this class (or null). -
getElementClass
-
setElementClass
Sets bothsetElementClass(Class)andsetElementSerializer(Serializer). -
setElementSerializer
The serializer to be used for elements in collection, or null to use the serializer registered withKryofor each element's type. Default is null. -
getElementSerializer
-
write
public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, com.badlogic.gdx.utils.Array collection) - Specified by:
writein classcom.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>
-
writeHeader
protected void writeHeader(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, com.badlogic.gdx.utils.Array collection) Can be overidden to write data needed forcreate(Kryo, Input, Class, int). The default implementation does nothing. -
create
protected com.badlogic.gdx.utils.Array<?> create(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends com.badlogic.gdx.utils.Array> type, int size) Used byread(Kryo, Input, Class)to create the new object. This can be overridden to customize object creation (eg to call a constructor with arguments), optionally reading bytes written inwriteHeader(Kryo, Output, Array). The default implementation usesKryo.newInstance(Class)with special cases for ArrayList and HashSet. -
read
public com.badlogic.gdx.utils.Array read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends com.badlogic.gdx.utils.Array> type) - Specified by:
readin classcom.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>
-
createCopy
protected com.badlogic.gdx.utils.Array createCopy(com.esotericsoftware.kryo.Kryo kryo, com.badlogic.gdx.utils.Array original) Used bycopy(Kryo, Array)to create the new object. This can be overridden to customize object creation, eg to call a constructor with arguments. The default implementation usesKryo.newInstance(Class). -
copy
public com.badlogic.gdx.utils.Array copy(com.esotericsoftware.kryo.Kryo kryo, com.badlogic.gdx.utils.Array original) - Overrides:
copyin classcom.esotericsoftware.kryo.Serializer<com.badlogic.gdx.utils.Array>
-