XElement provides an interface to an XML element. An XElement represents an
XML element which contains:
Name (required)
Attributes (optional)
character data (optional)
other elements (optional)
It is important to understand the diffrence between an "field" XElement and
a non "field" XElement. If an XElement does not contain any sub elements, it
is considered a "field" XElement. The getField(String) and
getValue() functions will throw an XElementException if they
are used on non "attribute" objects. This give you a little bit type
checking (You'll get an exception if you try to access the character data of
an element that has sub elements).
If XElement is not an field, then it contains other XElements and optionaly
some text. The text data can be accessed with the getText()
method and the sub elements with the iterator() or with
getElementXXX() fuctions. Since XML and thus XElements provide a tree
type data structure, traversing the tree to access leaf data can be
cumbersom if you have a 'deep' tree. For example, you may have to do:
element.getElement("tree").getElement("branch").getElement("leaf")
access a XElement 3 levels deep in the tree. To access deep elements easier,
XElements lets you use 'reletive' names to access deep elements. Using
reletive names, you could access the same element in previous example doing:
element.getElement("tree/branch/leaf") When using relative
names, keep in mind that "." will get the current XElement, and ".." will
get parent XElement. Very similar to how URLs work.
author: Hiram Chirino (Cojonudo14@hotmail.com) version: $Revision: 57198 $
XElement(String objectName, Attributes atts) Constructs an XElement with it's parent and metatags set.
Method Summary
public void
add(String data) Adds and appends string data to the objects text.
public void
addElement(XElement subObject) Adds an XElement to the set of XElements that are contained by this
object.
public void
addField(String key, String value) Adds an XElement to the set of XElements that are contained by this
object.
public boolean
containsElement(String objectName) Tests to see if this object contains the specified object.
Parameters: objectName - The name of the object.
public boolean
containsField(String objectName) Tests to see if this object contains the specified attribute object.
Parameters: objectName - The name of the attribute object.
setAttribute(String key, String value) Sets/Adds a metatag value Only metatags whose value is not empty will
display when the toString() methods is called.
Constructs an XElement with it's parent and metatags set.
Parameters: objectName - the tag or element name that this object represents. Parameters: atts - Description of Parameter
Adds an XElement to the set of XElements that are contained by this
object.
Parameters: key - The feature to be added to the Field attribute Parameters: value - The feature to be added to the Field attribute
containsElement
public boolean containsElement(String objectName)(Code)
Tests to see if this object contains the specified object.
Parameters: objectName - The name of the object. Description of the Returned Value
containsField
public boolean containsField(String objectName)(Code)
Tests to see if this object contains the specified attribute object.
Parameters: objectName - The name of the attribute object. Description of the Returned Value
Constructs an empty object.
Parameters: is - Description of Parameter Description of the Returned Value exception: XElementException - Description of Exception exception: java.io.IOException - Description of Exception
Constructs an empty object.
Parameters: url - Description of Parameter Description of the Returned Value exception: XElementException - Description of Exception exception: java.io.IOException - Description of Exception
Returns the first object contained in this object named relativeName.
Parameters: relativeName - The name of the object to find The Element value throws: XElementException - if the object could not be found.
Gets the value of a contained attribute object.
Parameters: objectName - The name of the attribute object. The Field value throws: XElementException - if the object does not exist or if its not anattribute object.
Gets the character data that was within this object. This fuction can
only be used on objects that are attributes.
The Value value throws: XElementException - if the object was not an attribute object
Sets/Adds a metatag value Only metatags whose value is not empty will
display when the toString() methods is called.
Parameters: key - the name of the metatag Parameters: value - the value to set the metatag to.
Sets/Adds a attribute
Parameters: key - the name of the attribute element Parameters: value - the value to set the attribute to. exception: XElementException - Description of Exception
Gets the character data that was within this object. This fuction can
only be used on objects that are attributes.
Parameters: value - The new Value value throws: XElementException - if the object was not an attribute object
Serializes this object into a string.
Parameters: nestingLevel - how many tabs to prepend to output Parameters: indent - Description of Parameter Description of the Returned Value