Package org.robolectric.res.android
Class NativeObjRegistry<T>
- java.lang.Object
-
- org.robolectric.res.android.NativeObjRegistry<T>
-
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 Summary
Constructors Constructor Description NativeObjRegistry(Class<T> theClass)NativeObjRegistry(Class<T> theClass, boolean debug)NativeObjRegistry(String name)NativeObjRegistry(String name, boolean debug)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclear()WARNING -- dangerous! Callunregister(long)instead!TgetNativeObject(long nativeId)Retrieve the native object for given id.longgetNativeObjectId(T o)Deprecated.Useregister(Object)instead.TpeekNativeObject(long nativeId)Similar togetNativeObject(long)but returns null if object with given id cannot be found.longregister(T o)Register and assign a new unique native id for given object (representing a C memory pointer).Tunregister(long nativeId)Unregister an object previously registered withregister(Object).voidunregister(T removed)Deprecated.Useunregister(long)instead.voidupdate(long nativeId, T o)Updates the native object for the given id.
-
-
-
Method Detail
-
getNativeObjectId
@Deprecated public long getNativeObjectId(T o)
Deprecated.Useregister(Object)instead.Retrieve the native id for given object. Assigns a new unique id to the object if not previously registered.
-
register
public long register(T o)
Register and assign a new unique native id for given object (representing a C memory pointer).- Throws:
IllegalStateException- if the object was previously registered
-
unregister
public T unregister(long nativeId)
Unregister an object previously registered withregister(Object).- Parameters:
nativeId- the unique id (representing a C memory pointer) of the object to unregister.- Throws:
IllegalStateException- if the object was never registered, or was previously unregistered.
-
unregister
@Deprecated public void unregister(T removed)
Deprecated.Useunregister(long)instead.
-
getNativeObject
public T getNativeObject(long nativeId)
Retrieve the native object for given id. Throws if object with that id cannot be found
-
update
public void update(long nativeId, T o)Updates the native object for the given id.- Throws:
IllegalStateException- if no object was registered with the given id before
-
peekNativeObject
public T peekNativeObject(long nativeId)
Similar togetNativeObject(long)but returns null if object with given id cannot be found.
-
clear
public void clear()
WARNING -- dangerous! Callunregister(long)instead!
-
-