public class NativeObjRegistry<T> extends Object
A unique id per object registry. Used to emulate android platform behavior of storing a long which represents a pointer to an object.
Constructor and Description |
---|
NativeObjRegistry(Class<T> theClass) |
NativeObjRegistry(Class<T> theClass,
boolean debug) |
NativeObjRegistry(String name) |
NativeObjRegistry(String name,
boolean debug) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
WARNING – dangerous! Call
unregister(long) instead! |
T |
getNativeObject(long nativeId)
Retrieve the native object for given id.
|
long |
getNativeObjectId(T o)
Deprecated.
Use
register(Object) instead. |
T |
peekNativeObject(long nativeId)
Similar to
getNativeObject(long) but returns null if object with given id cannot be found. |
long |
register(T o)
Register and assign a new unique native id for given object (representing a C memory pointer).
|
T |
unregister(long nativeId)
Unregister an object previously registered with
register(Object) . |
void |
unregister(T removed)
Deprecated.
Use
unregister(long) instead. |
public NativeObjRegistry(String name)
public NativeObjRegistry(String name, boolean debug)
@Deprecated public long getNativeObjectId(T o)
register(Object)
instead.Retrieve the native id for given object. Assigns a new unique id to the object if not previously registered.
public long register(T o)
Register and assign a new unique native id for given object (representing a C memory pointer).
IllegalStateException
- if the object was previously registeredpublic T unregister(long nativeId)
Unregister an object previously registered with register(Object)
.
nativeId
- the unique id (representing a C memory pointer) of the object to unregister.IllegalStateException
- if the object was never registered, or was previously unregistered.@Deprecated public void unregister(T removed)
unregister(long)
instead.public T getNativeObject(long nativeId)
Retrieve the native object for given id. Throws if object with that id cannot be found
public T peekNativeObject(long nativeId)
Similar to getNativeObject(long)
but returns null if object with given id cannot be found.
public void clear()
WARNING – dangerous! Call unregister(long)
instead!