|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--simkin.ExecutableRoot | +--simkin.XMLElementObject
This object is a container for an XML element, and exposes an interface to it to Simkin The class implements methods from the Executable interface.
The method getValue, setValue and method all search for matching element tags within the XML document. Only the first matching tag is used.
This class supports the following fields:
Constructor Summary | |
XMLElementObject()
Default Constructor |
|
XMLElementObject(java.lang.String location,
org.w3c.dom.Element elem)
Constructor which takes an Element |
Method Summary | |
XMLElementObject |
addElement(java.lang.String tag_name)
adds a new element with the given tag name to this element |
boolean |
containsElement(java.lang.String tag_name)
returns true if this element contains an element with the given tag name |
void |
copyAttributesInto(org.w3c.dom.Element other)
This method clears the other elements attributes and copies from ours into it |
void |
copyItemsInto(org.w3c.dom.Element other)
Clears the other element and does a deep copy of the children of this node into that one |
ExecutableIterator |
createIterator()
This method returns an XMLElementObjectEnumerator object which is used in a foreach statement. |
ExecutableIterator |
createIterator(java.lang.String qualifier)
This method returns an XMLElementObjectEnumerator object which is used in a foreach statement. |
protected XMLElementObject |
createXMLElementObject(java.lang.String location,
org.w3c.dom.Element elem)
This method creates a new XML Element object to wrap an element. |
void |
dump()
This method writes the entire XML element out to the tracer |
XMLElementObjectEnumerator |
enumerate()
This method returns an object which can iterate over all the immediate child elements of this element |
XMLElementObjectEnumerator |
enumerate(java.lang.String tagName)
This method returns an object which can iterate over all the immediate child elements of this element whose tagname matches the one given |
boolean |
equals(java.lang.Object o)
tests for equality with another object, using the string value |
static org.w3c.dom.Element |
findChild(org.w3c.dom.Element parent,
int index)
returns the nth child element |
static org.w3c.dom.Element |
findChild(org.w3c.dom.Element parent,
java.lang.String tagname)
returns a child element |
static org.w3c.dom.Element |
findChild(org.w3c.dom.Element parent,
java.lang.String tagname,
java.lang.String attribute,
java.lang.String value)
returns a child element with the given attribute set to the given value |
boolean |
getAddIfNotPresent()
this returns the value of the flag controlling whether new elements are created as they are accessed |
java.lang.String |
getAttribute(java.lang.String name)
This method returns the value of an attribute attached to this element. |
java.util.Hashtable |
getAttributes()
This method returns the attributes for this object. |
static java.lang.String |
getData(org.w3c.dom.Element element)
retrieves the text data from an element |
org.w3c.dom.Element |
getElement()
This method returns the XML Element being held by the object. |
java.util.Hashtable |
getInstanceVariables()
This method returns the instance variables for this object. |
java.lang.String |
getLocation()
returns the location of this element |
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 name,
java.lang.String attrib,
ExecutableContext ctxt)
Retrieves a field from the XML. |
java.lang.Object |
getValueAt(java.lang.Object array_index,
java.lang.String attrib,
ExecutableContext ctxt)
Retrieves the nth child element from this element. |
java.lang.Object |
method(java.lang.String s,
java.lang.Object[] args,
ExecutableContext ctxt)
this method attempts to execute a method stored in the XML. |
void |
setAddIfNotPresent(boolean enable)
sets the flag controlling whether new elements are created as they are accessed |
void |
setAttribute(java.lang.String name,
java.lang.String value)
Sets an attribute on this node |
static void |
setData(org.w3c.dom.Element element,
java.lang.String data)
sets the text data for a node by looking for the first CDATA and TEXT child node |
protected void |
setElement(org.w3c.dom.Element elem)
This method updates the associated element and clears the parse tree cache |
void |
setValue(java.lang.String name,
java.lang.String attrib,
java.lang.Object v,
ExecutableContext ctxt)
sets the value of an item in the element. |
void |
setValueAt(java.lang.Object array_index,
java.lang.String attrib,
java.lang.Object v,
ExecutableContext ctxt)
sets the value of an item in the element. |
java.lang.String |
tagName()
this method returns the tag name of this object (taken from the code element) |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XMLElementObject()
public XMLElementObject(java.lang.String location, org.w3c.dom.Element elem)
location
- location of this elementelem
- the element to be storedMethod Detail |
protected void setElement(org.w3c.dom.Element elem)
elem
- - the new Elementpublic java.lang.String toString()
toString
in class java.lang.Object
public void setValue(java.lang.String name, java.lang.String attrib, java.lang.Object v, ExecutableContext ctxt) throws java.lang.RuntimeException, FieldNotSupportedException
setValue
in interface Executable
setValue
in class ExecutableRoot
name
- the name of the element tag to set (null if it's the overall element)attrib
- the name of the attribute to set (null to set text for the element)v
- the value to be setctxt
- 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)
java.lang.NoSuchFieldException
- - if the field could not be found
FieldNotSupportedException
- - if the field could not be foundpublic void setValueAt(java.lang.Object array_index, java.lang.String attrib, java.lang.Object v, ExecutableContext ctxt) throws java.lang.RuntimeException
setValueAt
in interface Executable
setValueAt
in class ExecutableRoot
array_index
- the position of the element in the listattrib
- the name of the attribute to set (null to set text for the element)v
- the value to be setctxt
- the context the function is called within
java.lang.RuntimeException
- - if there was a problem running the scriptpublic void copyAttributesInto(org.w3c.dom.Element other)
public void copyItemsInto(org.w3c.dom.Element other)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public org.w3c.dom.Element getElement()
public java.lang.Object getValueAt(java.lang.Object array_index, java.lang.String attrib, ExecutableContext ctxt) throws java.lang.RuntimeException
getValueAt
in interface Executable
getValueAt
in class ExecutableRoot
array_index
- the array indexattrib
- the attribute name to retrievectxt
- the context the function is called within
java.lang.RuntimeException
- - if there was a problem running the scriptpublic java.lang.Object getValue(java.lang.String name, java.lang.String attrib, ExecutableContext ctxt) throws java.lang.RuntimeException, FieldNotSupportedException
getValue
in interface Executable
getValue
in class ExecutableRoot
name
- the tag name containing the dataattrib
- the attribute name to retrievectxt
- 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 static java.lang.String getData(org.w3c.dom.Element element)
element
-
public static void setData(org.w3c.dom.Element element, java.lang.String data)
element
- the element to be changeddata
- the data to be setpublic static org.w3c.dom.Element findChild(org.w3c.dom.Element parent, java.lang.String tagname)
parent
- the parent elementtagname
- the tag name of the element
public static org.w3c.dom.Element findChild(org.w3c.dom.Element parent, int index)
parent
- the parent element
public static org.w3c.dom.Element findChild(org.w3c.dom.Element parent, java.lang.String tagname, java.lang.String attribute, java.lang.String value)
parent
- the parent elementtagname
- the tag name of the elementattribute
- name of the attributevalue
- value of the named attribute
public void setAttribute(java.lang.String name, java.lang.String value)
public java.lang.String getAttribute(java.lang.String name)
protected XMLElementObject createXMLElementObject(java.lang.String location, org.w3c.dom.Element elem)
public XMLElementObjectEnumerator enumerate()
public XMLElementObjectEnumerator enumerate(java.lang.String tagName)
public void dump()
public 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
java.lang.RuntimeException
- if there was an error running the code
MethodNotSupportedException
- if the method could not be foundpublic java.lang.String tagName()
public XMLElementObject addElement(java.lang.String tag_name)
public boolean containsElement(java.lang.String tag_name)
public void setAddIfNotPresent(boolean enable)
enable
- enables this feature (which by default is disabled)public boolean getAddIfNotPresent()
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 tag name will be returned
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
public java.util.Hashtable getAttributes()
getAttributes
in interface Executable
getAttributes
in class ExecutableRoot
public java.lang.String getLocation()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |