Class Callback

  • All Implemented Interfaces:
    CB
    Direct Known Subclasses:
    NCallback

    public class Callback
    extends java.lang.Object
    implements CB
    This class is intended to be subclassed in order to invoke a particular method for a given object. The method invoke is used by callback lists to invoke all callbacks in their lists or by native callbacks to bind java and native callbacks.

    When a callback is registered, it is paired with a user data object which can be used when the callback is called. This object is stored in the userData field. The documentation does not mention the userData field since it is a protected field.But all classes subclassing Callback have access to this field. Its definition is : protected Object userData. Note that the content of userData is not the object passed as a parameter to any invoke method.
    For instance:
        [...]
        callbacks.addCallback(new MyCallback(), myObject) ;
        [...]
        callbacks.invokeCallbacks(anObject) ;
    
      class MyCallback extends Callback {
        public void invoke(Object data) {
          MyClass myObject = (myClass) userData ;
          AClass anObject = (AClass) data ;
          [...]
        }
      }
     
    • Constructor Summary

      Constructors 
      Constructor Description
      Callback()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void invoke​(java.lang.Object data)
      When subclassing Callback, fill the body of this method which will be called when the callback will be needed.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Callback

        public Callback()
    • Method Detail

      • invoke

        public void invoke​(java.lang.Object data)
        When subclassing Callback, fill the body of this method which will be called when the callback will be needed.
        Specified by:
        invoke in interface CB