Package com.esotericsoftware.kryo
Interface ReferenceResolver
-
- All Known Implementing Classes:
ListReferenceResolver,MapReferenceResolver
public interface ReferenceResolverWhen references are enabled, this tracks objects that have already been read or written, provides an ID for objects that are written, and looks up by ID objects that have been read.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddReadObject(int id, java.lang.Object object)Adds an object that has been read for the first time.intaddWrittenObject(java.lang.Object object)Returns a new ID for an object that is being written for the first time.java.lang.ObjectgetReadObject(java.lang.Class type, int id)Returns the object for the specified ID.intgetWrittenId(java.lang.Object object)Returns an ID for the object if it has been written previously, otherwise returns -1.intnextReadId(java.lang.Class type)Returns the ID for the next object that will be read.voidreset()Called byKryo.reset().voidsetKryo(Kryo kryo)Sets the Kryo instance that this ClassResolver will be used for.booleanuseReferences(java.lang.Class type)Returns true if references will be written for the specified type.
-
-
-
Method Detail
-
setKryo
void setKryo(Kryo kryo)
Sets the Kryo instance that this ClassResolver will be used for. This is called automatically by Kryo.
-
getWrittenId
int getWrittenId(java.lang.Object object)
Returns an ID for the object if it has been written previously, otherwise returns -1.
-
addWrittenObject
int addWrittenObject(java.lang.Object object)
Returns a new ID for an object that is being written for the first time.- Returns:
- The ID, which is stored more efficiently if it is positive and must not be -1 or -2.
-
nextReadId
int nextReadId(java.lang.Class type)
Returns the ID for the next object that will be read. This is called only the first time an object is encountered.- Parameters:
type- The type of object that will be read.- Returns:
- The ID, which is stored more efficiently if it is positive and must not be -1 or -2.
-
addReadObject
void addReadObject(int id, java.lang.Object object)Adds an object that has been read for the first time.- Parameters:
id- The ID fromnextReadId(Class).
-
getReadObject
java.lang.Object getReadObject(java.lang.Class type, int id)Returns the object for the specified ID. The ID and object are guaranteed to have been previously passed in a call toaddReadObject(int, Object).
-
reset
void reset()
Called byKryo.reset().
-
useReferences
boolean useReferences(java.lang.Class type)
Returns true if references will be written for the specified type.- Parameters:
type- Will never be a primitive type, but may be a primitive type wrapper.
-
-