simkin
Class ExecutableRoot

java.lang.Object
  |
  +--simkin.ExecutableRoot
All Implemented Interfaces:
Executable
Direct Known Subclasses:
TreeNodeObject, XMLElementObject

public class ExecutableRoot
extends java.lang.Object
implements Executable

This class provides an implementation of the Executable interface which can be conveniently extended

The class implements some commonly used methods via the method function:

It also implements all the methods of the Executable interface which means that derived classes need only implement the methods they need to override.

The class uses the Interpreter's reflection methods to look for public fields and method names which match those being accessed by the Simkin script.


Constructor Summary
ExecutableRoot()
           
 
Method Summary
 java.lang.Object getValue(java.lang.String field_name, java.lang.String attrib)
          This method calls the Interpreter's reflectiveGetValue method
 java.lang.Object getValueAt(java.lang.Object array_index, java.lang.String attrib)
          This method does nothing at this level
 java.lang.Object method(java.lang.String method_name, java.lang.Object[] arguments)
          The following methods are supported directly by this class:
static void setTracer(TraceCallback cb)
          This method sets the object which will receive trace calls when a trace is requested by a subclass
 void setValue(java.lang.String field_name, java.lang.String attrib, java.lang.Object value)
          This method calls the Interpreter's reflectiveSetValue method
 void setValueAt(java.lang.Object array_index, java.lang.String attrib, java.lang.Object value)
          This method does nothing at this level
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutableRoot

public ExecutableRoot()
Method Detail

setTracer

public static void setTracer(TraceCallback cb)
This method sets the object which will receive trace calls when a trace is requested by a subclass
Parameters:
cb - the object which will be called to output a trace message

setValue

public void setValue(java.lang.String field_name,
                     java.lang.String attrib,
                     java.lang.Object value)
              throws java.lang.RuntimeException,
                     java.lang.NoSuchFieldException
This method calls the Interpreter's reflectiveSetValue method
Specified by:
setValue in interface Executable
Following copied from interface: simkin.Executable
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,
                       java.lang.Object value)
                throws java.lang.RuntimeException
This method does nothing at this level
Specified by:
setValueAt in interface Executable
Following copied from interface: simkin.Executable
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)
                          throws java.lang.RuntimeException,
                                 java.lang.NoSuchFieldException
This method calls the Interpreter's reflectiveGetValue method
Specified by:
getValue in interface Executable
Following copied from interface: simkin.Executable
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)
                            throws java.lang.RuntimeException
This method does nothing at this level
Specified by:
getValueAt in interface Executable
Following copied from interface: simkin.Executable
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
The following methods are supported directly by this class:

trace(a) - sends a message to the trace output, takes a variable number of arguments

isObject(a) - returns true if a is an object (as opposed to an integer or string)

length(a) - returns the length of a (taken as a string)

charAt(str,index) - returns the character at the given index within the string

If the method is not one of these, the Interpreter's reflectiveMethodCall method is called

Specified by:
method in interface Executable
Returns:
true if the method is found