|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--simkin.ExecutableRoot | +--simkin.TreeNodeObject
This class provides and Executable interface to a TreeNode
The method getValue, setValue and method all search for matching child labels within the TreeNode object. Only the first matching tag is used.
Constructor Summary | |
TreeNodeObject()
Default Constructor |
|
TreeNodeObject(java.lang.String location,
java.io.InputStream in)
Constructor |
|
TreeNodeObject(java.lang.String location,
TreeNode node)
Constructor |
Method Summary | |
TreeNodeObject |
addNode(java.lang.String label,
java.lang.String data)
this method adds a new child node with the given name and data |
boolean |
containsNode(java.lang.String label)
this method returns true if the node contains a child with the given label |
ExecutableIterator |
createIterator()
This method returns a TreeNodeObjectEnumerator object which is used in a foreach statement. |
ExecutableIterator |
createIterator(java.lang.String qualifier)
This method returns a TreeNodeObjectEnumerator object which is used in a foreach statement. |
protected TreeNodeObject |
createTreeNodeObject(java.lang.String location,
TreeNode node)
This method creates a new TreeNodeObject object to wrap a treenode. |
java.lang.String |
data()
returns the data for the underlying node |
void |
dump(Interpreter interp)
This method writes the entire node tree to stdout |
TreeNodeObjectEnumerator |
enumerate()
This method returns an object which can iterate over all the immediate child node of this node |
TreeNodeObjectEnumerator |
enumerate(java.lang.String label)
This method returns an object which can iterate over all the immediate child nodes of this node whose label matches the one given |
boolean |
equals(java.lang.Object o)
|
TreeNodeObject |
findChild(java.lang.String label)
this method finds a new child node with the given name |
TreeNodeObject |
findChild(java.lang.String label,
java.lang.String data)
this method finds a new child node with the given name and data |
boolean |
getAddIfNotPresent()
this returns the value of the flag controlling whether new elements are created as they are accessed |
java.util.Hashtable |
getInstanceVariables()
This method returns the instance variables for this object. |
java.lang.String |
getLocation()
returns the location of this node |
TreeNode |
getNode()
|
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 s,
java.lang.String attribute,
ExecutableContext ctxt)
this method retrieves a value from the in-memory treenode object. |
java.lang.Object |
getValueAt(java.lang.Object array_index,
java.lang.String attribute,
ExecutableContext ctxt)
this method retrieves a value from the in-memory treenode object. |
java.lang.String |
label()
returns the label for the underlying node |
void |
load(java.lang.String location,
java.io.InputStream stream)
loads the treenode from the given stream |
java.lang.Object |
method(java.lang.String s,
java.lang.Object[] args,
ExecutableContext ctxt)
this method attempts to find the named method within the in-memory treenode object. |
TreeNodeObject |
nthChild(int index)
this method finds the nth child node |
int |
numChildren()
|
boolean |
removeNode(java.lang.String label)
this method removes the first child node with the given label - it returns true if successfull |
void |
save(java.io.OutputStream out,
boolean compiled)
saves the treenode into the given stream |
void |
setAddIfNotPresent(boolean enable)
sets the flag controlling whether new elements are created as they are accessed |
void |
setLocation(java.lang.String location)
This method changes the location associated with this object |
void |
setNode(TreeNode node)
sets the node and clears the method cache |
void |
setValue(java.lang.String s,
java.lang.String attribute,
java.lang.Object v,
ExecutableContext ctxt)
this method stores a value in the in-memory treenode object. |
void |
setValueAt(java.lang.Object array_index,
java.lang.String attribute,
java.lang.Object v,
ExecutableContext ctxt)
this method stores a value in the in-memory treenode object. |
java.lang.String |
toString()
|
Methods inherited from class simkin.ExecutableRoot |
getAttributes |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TreeNodeObject()
public TreeNodeObject(java.lang.String location, TreeNode node)
location
- location of this nodenode
- the treenode to be storedpublic TreeNodeObject(java.lang.String location, java.io.InputStream in) throws java.io.IOException
location
- location of this nodein
- a stream containing the nodeMethod Detail |
public void setNode(TreeNode node)
public java.lang.String toString()
toString
in class java.lang.Object
public int numChildren()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public TreeNode getNode()
public void setValue(java.lang.String s, java.lang.String attribute, java.lang.Object v, ExecutableContext ctxt) throws java.lang.RuntimeException, FieldNotSupportedException
setValue
in interface Executable
setValue
in class ExecutableRoot
s
- the name of the valuev
- the value itselfattribute
- the name of the attribute to be set (can be null)ctxt
- the context the function is called within
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 foundpublic void setValueAt(java.lang.Object array_index, java.lang.String attribute, java.lang.Object v, ExecutableContext ctxt) throws java.lang.RuntimeException
setValueAt
in interface Executable
setValueAt
in class ExecutableRoot
array_index
- the index of the item to updatev
- the value itselfattribute
- the name of the attribute to be set (can be null)ctxt
- the context the function is called within
java.lang.RuntimeException
- - if there was a problem running the script (such as not having permission to access a field)public java.lang.Object getValueAt(java.lang.Object array_index, java.lang.String attribute, ExecutableContext ctxt) throws java.lang.RuntimeException
getValueAt
in interface Executable
getValueAt
in class ExecutableRoot
array_index
- the name of the valueattribute
- attribute name (null if no attribute specified)ctxt
- the context the function is called within
java.lang.RuntimeException
- - if there was a problem running the script (such as not having permission to access a field)public java.lang.Object getValue(java.lang.String s, java.lang.String attribute, ExecutableContext ctxt) throws java.lang.RuntimeException, FieldNotSupportedException
getValue
in interface Executable
getValue
in class ExecutableRoot
s
- the name of the valueattribute
- attribute name (null if no attribute specified)ctxt
- the context the function is called within
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 foundpublic TreeNodeObjectEnumerator enumerate()
public TreeNodeObjectEnumerator enumerate(java.lang.String label)
public void dump(Interpreter interp)
interp
- - interpreter to use for tracingpublic java.lang.Object method(java.lang.String s, java.lang.Object[] args, ExecutableContext ctxt) throws ParseException, java.lang.RuntimeException, MethodNotSupportedException
method
in interface Executable
method
in class ExecutableRoot
s
- the name of the methodargs
- an array of arguments to the method
ParseException
- if the code contained syntax errors
MethodNotSupportedException
- if the method could not be found
java.lang.RuntimeException
- if there was an error running the codepublic void load(java.lang.String location, java.io.InputStream stream) throws java.io.IOException
location
- the location of the node
java.io.IOException
public void save(java.io.OutputStream out, boolean compiled) throws java.io.IOException
out
- the stream to write tocompiled
- whether to store the treenode in compiled format
java.io.IOException
protected TreeNodeObject createTreeNodeObject(java.lang.String location, TreeNode node)
public void setAddIfNotPresent(boolean enable)
enable
- enables this feature (which by default is disabled)public boolean getAddIfNotPresent()
public TreeNodeObject addNode(java.lang.String label, java.lang.String data)
public boolean removeNode(java.lang.String label)
public TreeNodeObject findChild(java.lang.String label, java.lang.String data)
label
- the label to matchdata
- the data to match
public TreeNodeObject findChild(java.lang.String label)
label
- the label to match
public TreeNodeObject nthChild(int index)
index
- the index to find
public boolean containsNode(java.lang.String label)
public java.lang.String label()
public java.lang.String data()
public java.lang.String getLocation()
public ExecutableIterator createIterator()
createIterator
in interface Executable
createIterator
in class ExecutableRoot
public ExecutableIterator createIterator(java.lang.String qualifier)
createIterator
in interface Executable
createIterator
in class ExecutableRoot
qualifier
- - a string, children with a matching label will be returned
public void setLocation(java.lang.String location)
public java.lang.String getSource(java.lang.String location)
getSource
in interface Executable
getSource
in class ExecutableRoot
location
- the location of the method - in the format passed to the execute functions in the Interpreter
public java.util.Hashtable getInstanceVariables()
getInstanceVariables
in interface Executable
getInstanceVariables
in class ExecutableRoot
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |