org.omegahat.Environment.GUITools
Class FunctionListener

java.lang.Object
  |
  +--org.omegahat.Environment.GUITools.OmegaListener
        |
        +--org.omegahat.Environment.GUITools.FunctionListener

public class FunctionListener
extends OmegaListener

Base class extended by dynamically created classes used to implement a Java interface with an interpreted Function. This provides the basic methods for instantiating such an object, storing the function and Evaluator and utility methods for processing the arguments to a Java method to a form suitable for a function call.

Note that this class is potentially non thread-safe if one uses the arguments field. The automatically generated byte code does not use this anymore.


Field Summary
protected  List arguments
          Collection to which arguments to a Java method are added one at a time before being passed to the Function when it is evaluated as part of the method's body.
 
Fields inherited from class org.omegahat.Environment.GUITools.OmegaListener
callback, evaluator
 
Constructor Summary
FunctionListener()
          Degenerate constructor that allows the specification of the function and evaluator at a later time.
FunctionListener(double d, int[][] x, java.util.Vector v)
          Dummy constructor used only in testing inheritance of constructors!
FunctionListener(Function f)
          Constructor specifying the Function that is to be invoked in response to each method.
FunctionListener(Function f, Evaluator eval)
          Constructor specifying the Function that is to be invoked in response to each method and the The Evaluator which is to be used for the evaluation of the function call.
 
Method Summary
 void addArgument(boolean b)
          Convert a boolean to an Object (Boolean) and add it to the arguments collection.
 void addArgument(byte b)
          Convert a byte to an Object (Byte) and add it to the arguments collection.
 void addArgument(char c)
          Convert a char to an Object and add it to the arguments collection.
 void addArgument(double d)
          Convert a double to an Object (Double) and add it to the arguments collection.
 void addArgument(float f)
          Convert a float to an Object (Float) and add it to the arguments collection.
 void addArgument(int i)
          Convert an int to an Object (Integer) and add it to the arguments collection.
 void addArgument(long l)
          Convert a long to an Object (Long) and add it to the arguments collection.
 void addArgument(java.lang.Object o)
           
 void addArgument(short s)
          Convert a short to an Object (Short) and add it to the arguments collection.
 List arguments()
          Accessor to the value for the arguments field.
 List arguments(List l)
          Accessor to specify the value for the arguments field.
 java.lang.Object eval()
          Evaluate the function call using the current value of the arguments field as the arguments to the function.
 java.lang.Object eval(List l)
          Evaluate the function contained in this object with the elements of the specified List as arguments to the function.
 
Methods inherited from class org.omegahat.Environment.GUITools.OmegaListener
callback, callback, evaluator, evaluator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arguments

protected List arguments
Collection to which arguments to a Java method are added one at a time before being passed to the Function when it is evaluated as part of the method's body.

Using this makes the class non-thread safe. The new code in EvaluableInterfaceGenerator now takes care of using an instance of FunctionCallArguments list that is local to the method and passed to the eval(List) method

Constructor Detail

FunctionListener

public FunctionListener(Function f)
Constructor specifying the Function that is to be invoked in response to each method. The Evaluator is determined when needed.

FunctionListener

public FunctionListener(Function f,
                        Evaluator eval)
Constructor specifying the Function that is to be invoked in response to each method and the The Evaluator which is to be used for the evaluation of the function call.

FunctionListener

public FunctionListener()
Degenerate constructor that allows the specification of the function and evaluator at a later time.

FunctionListener

public FunctionListener(double d,
                        int[][] x,
                        java.util.Vector v)
Dummy constructor used only in testing inheritance of constructors!
Method Detail

arguments

public List arguments()
Accessor to the value for the arguments field.

arguments

public List arguments(List l)
Accessor to specify the value for the arguments field.

addArgument

public void addArgument(java.lang.Object o)

addArgument

public void addArgument(int i)
Convert an int to an Object (Integer) and add it to the arguments collection.

addArgument

public void addArgument(short s)
Convert a short to an Object (Short) and add it to the arguments collection.

addArgument

public void addArgument(double d)
Convert a double to an Object (Double) and add it to the arguments collection.

addArgument

public void addArgument(long l)
Convert a long to an Object (Long) and add it to the arguments collection.

addArgument

public void addArgument(byte b)
Convert a byte to an Object (Byte) and add it to the arguments collection.

addArgument

public void addArgument(char c)
Convert a char to an Object and add it to the arguments collection.

addArgument

public void addArgument(boolean b)
Convert a boolean to an Object (Boolean) and add it to the arguments collection.

addArgument

public void addArgument(float f)
Convert a float to an Object (Float) and add it to the arguments collection.

eval

public java.lang.Object eval()
Evaluate the function call using the current value of the arguments field as the arguments to the function.
Overrides:
eval in class OmegaListener

eval

public java.lang.Object eval(List l)
Evaluate the function contained in this object with the elements of the specified List as arguments to the function.