xdc.services.getset
Class Fxn

java.lang.Object
  extended by xdc.services.getset.Fxn
All Implemented Interfaces:
org.mozilla.javascript.Callable
Direct Known Subclasses:
AutoFxn

public class Fxn
extends java.lang.Object
implements org.mozilla.javascript.Callable

A scheduled function in a Group. Each Fxn must be idempotent. That is, if the Fxn has just been run then running it again immediately should have no additional effect; i.e., Fxn f is idempotent iff running "f(); f()" is always equivalent to running just "f()". Examples of such functions are those that just copy a value from one location to another without changing it, or only changing its data representation.


Constructor Summary
Fxn(Group group, org.mozilla.javascript.Callable body)
          Create a new Fxn that will execute the given body, as scheduled by the given Group.
 
Method Summary
 Fxn addInput(xdc.services.intern.xsr.Value.Observable obj, int index)
          Mark a given array element as a formal input to the Fxn.
 Fxn addInput(xdc.services.intern.xsr.Value.Observable obj, java.lang.String name)
          Mark the given field as a formal input to the Fxn.
 Fxn addOutput(xdc.services.intern.xsr.Value.Observable obj, int index)
          Mark a given array element as a formal output of the Fxn.
 Fxn addOutput(xdc.services.intern.xsr.Value.Observable obj, java.lang.String name)
          Mark the given field of the object as a formal output of the Fxn.
 java.lang.Object call(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, org.mozilla.javascript.Scriptable thisObj, java.lang.Object[] args)
          A setter that is called whenever one of the inputs of the Fxn changes in value.
 boolean getStale()
          Get whether this Fxn needs to be executed.
 java.lang.Object getStatus()
          Get the exit status from the last time this Fxn was executed.
 void run()
          Execute the Fxn body.
 void setStale(boolean stale)
          Set whether the Fxn needs to be executed, typically because one of the inputs has changed value.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Fxn

public Fxn(Group group,
           org.mozilla.javascript.Callable body)
Create a new Fxn that will execute the given body, as scheduled by the given Group.

Method Detail

getStatus

public java.lang.Object getStatus()
Get the exit status from the last time this Fxn was executed.

Returns:
null if the Fxn executed successfully, else an Object.

addInput

public Fxn addInput(xdc.services.intern.xsr.Value.Observable obj,
                    java.lang.String name)
Mark the given field as a formal input to the Fxn. The Fxn will be re-executed whenever the value of the field changes.


addInput

public Fxn addInput(xdc.services.intern.xsr.Value.Observable obj,
                    int index)
Mark a given array element as a formal input to the Fxn.


addOutput

public Fxn addOutput(xdc.services.intern.xsr.Value.Observable obj,
                     java.lang.String name)
Mark the given field of the object as a formal output of the Fxn. A field can't be both an input and output of an Fxn -- if so, it will be ignored as an input. This enables correct scheduling of Fxns with outputs that are updated by read-modify-write, for example if stored as a single bit in an integer.


addOutput

public Fxn addOutput(xdc.services.intern.xsr.Value.Observable obj,
                     int index)
Mark a given array element as a formal output of the Fxn.


getStale

public boolean getStale()
Get whether this Fxn needs to be executed.


setStale

public void setStale(boolean stale)
Set whether the Fxn needs to be executed, typically because one of the inputs has changed value. This method should only be called by the Fxn's scheduling Group.


run

public void run()
Execute the Fxn body.


call

public java.lang.Object call(org.mozilla.javascript.Context cx,
                             org.mozilla.javascript.Scriptable scope,
                             org.mozilla.javascript.Scriptable thisObj,
                             java.lang.Object[] args)
A setter that is called whenever one of the inputs of the Fxn changes in value. Ignores the change if the input is also an output.

Specified by:
call in interface org.mozilla.javascript.Callable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object