Class 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 Detail

      • NativeObjRegistry

        public NativeObjRegistry​(Class<T> theClass)
      • NativeObjRegistry

        public NativeObjRegistry​(Class<T> theClass,
                                 boolean debug)
      • NativeObjRegistry

        public NativeObjRegistry​(String name)
      • NativeObjRegistry

        public NativeObjRegistry​(String name,
                                 boolean debug)
    • Method Detail

      • getNativeObjectId

        @Deprecated
        public long getNativeObjectId​(T o)
        Deprecated.
        Use register(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 with register(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.
      • 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 to getNativeObject(long) but returns null if object with given id cannot be found.
      • clear

        public void clear()
        WARNING -- dangerous! Call unregister(long) instead!