simkin
Interface Executable

All Known Implementing Classes:
ExecutableRoot, Interpreter

public interface Executable

This interface is implemented by objects which want to override the method and field access which uses Java introspection by default.

An executable object is considered by the interpreter to consists of properties and methods. The interface defines 3 major functions:


Method Summary
 java.lang.Object getValue(java.lang.String field_name, java.lang.String attrib_name)
          Called to get the value of a field
 java.lang.Object getValueAt(java.lang.Object array_index, java.lang.String attrib_name)
          Called to get the value of an object in this collection
 java.lang.Object method(java.lang.String method_name, java.lang.Object[] arguments)
          Called if a Simkin script calls a method on this object.
 void setValue(java.lang.String field_name, java.lang.String attrib_name, java.lang.Object value)
          Called to set the value of a field.
 void setValueAt(java.lang.Object array_index, java.lang.String attrib_name, java.lang.Object value)
          Called to set an object into this collection.
 

Method Detail

setValue

public void setValue(java.lang.String field_name,
                     java.lang.String attrib_name,
                     java.lang.Object value)
              throws java.lang.RuntimeException,
                     java.lang.NoSuchFieldException
Called to set the value of a field. If an attribute name is given, the value is stored as an attribute of the given element, otherwise as a text value
Parameters:
field_name - the name of the field
attrib_name - the name of the attribute to be set (can be null)
value - the value to be set
Throws:
java.lang.RuntimeException - - if there was a problem running the script (such as not having permission to access a field)
java.lang.NoSuchFieldException - - if the field could not be found

setValueAt

public void setValueAt(java.lang.Object array_index,
                       java.lang.String attrib_name,
                       java.lang.Object value)
                throws java.lang.RuntimeException
Called to set an object into this collection.
Parameters:
array_index - an object whose value indicates the index of the item in the collection
attrib_name - the name of the attribute to be set (can be null)
value - the value to be set
Throws:
java.lang.RuntimeException - - if there was a problem running the script

getValue

public java.lang.Object getValue(java.lang.String field_name,
                                 java.lang.String attrib_name)
                          throws java.lang.RuntimeException,
                                 java.lang.NoSuchFieldException
Called to get the value of a field
Parameters:
field_name - the name of the field
attrib_name - attribute name (null if no attribute specified)
Returns:
the value of the field (or null, if the field is not supported)
Throws:
java.lang.RuntimeException - - if there was a problem running the script (such as not having permission to access a field)
java.lang.NoSuchFieldException - - if the field could not be found

getValueAt

public java.lang.Object getValueAt(java.lang.Object array_index,
                                   java.lang.String attrib_name)
                            throws java.lang.RuntimeException
Called to get the value of an object in this collection
Parameters:
array_index - an object whose value indicates the index of the item in the collection
attrib_name - attribute name (null if no attribute specified)
Returns:
the value of the object (null if not present)
Throws:
java.lang.RuntimeException - - if there was a problem running the script
java.lang.NoSuchFieldException - - if the field could not be found

method

public java.lang.Object method(java.lang.String method_name,
                               java.lang.Object[] arguments)
                        throws ParseException,
                               java.lang.RuntimeException,
                               java.lang.NoSuchMethodException
Called if a Simkin script calls a method on this object.
Parameters:
method_name - the name of the method
arguments - an array of arguments passed to the method
Returns:
the function's return value
Throws:
java.lang.RuntimeException - - if there was a problem running the script (such as divide by zero)
java.lang.NoSuchMethodException - - if the method could not be found