jist.runtime
Class EntityRef

java.lang.Object
  extended by jist.runtime.EntityRef
All Implemented Interfaces:
java.lang.reflect.InvocationHandler
Direct Known Subclasses:
EntityRefDist

public class EntityRef
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

Stores a reference to a (possibly remote) Entity object. A reference consists of a serialized reference to a Controller and an index within that Controller.

Since:
JIST1.0

Field Summary
static EntityRef NULL
          NULL reference constant.
 
Constructor Summary
EntityRef(int index)
          Initialise a new entity reference with given Controller and Entity IDs.
 
Method Summary
 boolean equals(java.lang.Object o)
          Test object equality.
 java.lang.Class getClassRef()
          Return class of referenced entity.
 ControllerRemote getController()
          Return controller of referenced entity.
 int getIndex()
          Return index of referenced entity.
 int hashCode()
          Return entity reference hashcode.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Called whenever a proxy entity reference is invoked.
 java.lang.String toString()
          Return toString of referenced entity.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final EntityRef NULL
NULL reference constant.

Constructor Detail

EntityRef

public EntityRef(int index)
Initialise a new entity reference with given Controller and Entity IDs.

Parameters:
index - entity ID
Method Detail

hashCode

public int hashCode()
Return entity reference hashcode.

Overrides:
hashCode in class java.lang.Object
Returns:
entity reference hashcode

equals

public boolean equals(java.lang.Object o)
Test object equality.

Overrides:
equals in class java.lang.Object
Parameters:
o - object to test equality
Returns:
object equality

getController

public ControllerRemote getController()
Return controller of referenced entity.

Returns:
controller of referenced entity

getIndex

public int getIndex()
Return index of referenced entity.

Returns:
index of referenced entity

toString

public java.lang.String toString()
Return toString of referenced entity.

Overrides:
toString in class java.lang.Object
Returns:
toString of referenced entity

getClassRef

public java.lang.Class getClassRef()
Return class of referenced entity.

Returns:
class of referenced entity

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Called whenever a proxy entity reference is invoked. Schedules the call at the appropriate Controller.

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Parameters:
proxy - proxy entity reference object whose method was invoked
method - method invoked on entity reference object
args - arguments of the method invocation
Returns:
result of blocking event; null return for non-blocking events
Throws:
java.lang.Throwable - whatever was thrown by blocking events; never for non-blocking events