simkin
Interface Executable

All Known Implementing Classes:
ExecutableRoot

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
 ExecutableIterator createIterator()
          This method returns an ExecutableIterator object which is used in a foreach statement.
 ExecutableIterator createIterator(java.lang.String qualifier)
          This method returns an ExecutableIterator object which is used in a foreach statement.
 java.util.Hashtable getAttributes()
          This method returns the attributes for this object
 java.util.Hashtable getInstanceVariables()
          This method returns the instance variables for this object
 java.lang.String getSource(java.lang.String location)
          This method returns the source for a scripted method described by the location
 java.lang.Object getValue(java.lang.String field_name, java.lang.String attrib_name, ExecutableContext ctxt)
          Called to get the value of a field
 java.lang.Object getValueAt(java.lang.Object array_index, java.lang.String attrib_name, ExecutableContext ctxt)
          Called to get the value of an object in this collection
 java.lang.Object method(java.lang.String method_name, java.lang.Object[] arguments, ExecutableContext ctxt)
          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, ExecutableContext ctxt)
          Called to set the value of a field.
 void setValueAt(java.lang.Object array_index, java.lang.String attrib_name, java.lang.Object value, ExecutableContext ctxt)
          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,
                     ExecutableContext ctxt)
              throws java.lang.RuntimeException,
                     FieldNotSupportedException
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
ctxt - the context the function is called within
Throws:
java.lang.RuntimeException - - if there was a problem running the script (such as not having permission to access a field)
FieldNotSupportedException - - 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,
                       ExecutableContext ctxt)
                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
ctxt - the context the function is called within
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,
                                 ExecutableContext ctxt)
                          throws java.lang.RuntimeException,
                                 FieldNotSupportedException
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)
ctxt - the context the function is called within
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)
FieldNotSupportedException - - if the field could not be found

getValueAt

public java.lang.Object getValueAt(java.lang.Object array_index,
                                   java.lang.String attrib_name,
                                   ExecutableContext ctxt)
                            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)
ctxt - the context the function is called within
Returns:
the value of the object (null if not present)
Throws:
java.lang.RuntimeException - - if there was a problem running the script
FieldNotSupportedException - - if the field could not be found

method

public java.lang.Object method(java.lang.String method_name,
                               java.lang.Object[] arguments,
                               ExecutableContext ctxt)
                        throws ParseException,
                               java.lang.RuntimeException,
                               MethodNotSupportedException
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
ctxt - the context the function is called within
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
ParseException
MethodNotSupportedException

createIterator

public ExecutableIterator createIterator()
This method returns an ExecutableIterator object which is used in a foreach statement. This version is unconditional.

Returns:
a new iterator object, or null if this object cannot be iterated

createIterator

public ExecutableIterator createIterator(java.lang.String qualifier)
This method returns an ExecutableIterator object which is used in a foreach statement. This version is qualified by a string which can be interpreted in any way.

Parameters:
qualifier - - a string that can be used to qualify the iteration in any way
Returns:
a new iterator object, or null if this object cannot be iterated

getSource

public java.lang.String getSource(java.lang.String location)
This method returns the source for a scripted method described by the location

Parameters:
location - the location of the method - in the format passed to the execute functions in the Interpreter
Returns:
the source for the method

getInstanceVariables

public java.util.Hashtable getInstanceVariables()
This method returns the instance variables for this object

Returns:
table a table to filled with references to the instance variables. Each entry in the table maps a name to an object

getAttributes

public java.util.Hashtable getAttributes()
This method returns the attributes for this object

Returns:
table a table to filled with the attribute values. Each entry in the table maps an attribute name to a value