org.jscience.architecture.traffic.xml
Class XMLElement

java.lang.Object
  extended by org.jscience.architecture.traffic.xml.XMLElement

public class XMLElement
extends java.lang.Object

DOCUMENT ME!


Field Summary
protected  java.util.Vector attributes
          DOCUMENT ME!
protected  java.lang.String name
          DOCUMENT ME!
 
Constructor Summary
XMLElement(java.lang.String name)
          Make a new XMLElement
XMLElement(java.lang.String name, XMLAttribute[] attList)
          Make a new XMLElement with the specified name and attributes
 
Method Summary
 void addAttribute(XMLAttribute attribute)
          Add a new attribute to the attribute list
 java.lang.Object clone()
           
 XMLAttribute getAttribute(java.lang.String name)
          Get the (first) attribute with a certain name
protected  int getAttributeIndex(java.lang.String name)
          Get the index of an attribute in the attribute array
 XMLAttribute[] getAttributesArray()
          DOCUMENT ME!
 java.lang.String getCloseTag()
          DOCUMENT ME!
 java.lang.String getName()
          DOCUMENT ME!
 java.lang.String getOpenTag()
          DOCUMENT ME!
static XMLElement parse(java.lang.String string)
          Parse a new XML element from a string which contains a XML tag
 void removeAllAttributes()
          Reset the attribute list (make it empty)
 void removeAttribute(java.lang.String name)
          Remove the (first) attribute with this name
 void setAttribute(XMLAttribute attribute)
          Change the attribute with the name of the parameter attribute to the value of the parameter attribute.
 void setName(java.lang.String name)
          Change the name of this XML element
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
DOCUMENT ME!


attributes

protected java.util.Vector attributes
DOCUMENT ME!

Constructor Detail

XMLElement

public XMLElement(java.lang.String name)
Make a new XMLElement

Parameters:
name - The name of the new element

XMLElement

public XMLElement(java.lang.String name,
                  XMLAttribute[] attList)
Make a new XMLElement with the specified name and attributes

Parameters:
name - The name of the new element
attList - An array that contains the attributes for this element (instances of gld.xml.XMLAttribute)
Method Detail

getName

public java.lang.String getName()
DOCUMENT ME!

Returns:
The name of this XML element

setName

public void setName(java.lang.String name)
Change the name of this XML element

Parameters:
name - The new name

addAttribute

public void addAttribute(XMLAttribute attribute)
Add a new attribute to the attribute list

Parameters:
attribute - The new attribute

removeAttribute

public void removeAttribute(java.lang.String name)
                     throws java.util.NoSuchElementException
Remove the (first) attribute with this name

Parameters:
name - The name of the attribute which has to be removed
Throws:
java.util.NoSuchElementException - If an attribute with that name cannot be found.

getAttributeIndex

protected int getAttributeIndex(java.lang.String name)
                         throws java.util.NoSuchElementException
Get the index of an attribute in the attribute array

Parameters:
name - The name to search for
Returns:
The index of the attribute
Throws:
java.util.NoSuchElementException - If an attribute with that name cannot be found.

getAttribute

public XMLAttribute getAttribute(java.lang.String name)
                          throws java.util.NoSuchElementException
Get the (first) attribute with a certain name

Parameters:
name - The name to search for
Returns:
The found attribute
Throws:
java.util.NoSuchElementException - If an attribute with that name cannot be found.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

removeAllAttributes

public void removeAllAttributes()
Reset the attribute list (make it empty)


getAttributesArray

public XMLAttribute[] getAttributesArray()
DOCUMENT ME!

Returns:
The attribute list in array form

setAttribute

public void setAttribute(XMLAttribute attribute)
Change the attribute with the name of the parameter attribute to the value of the parameter attribute. If an attribute with the name of the parameter doesn't exist, then add the parameter attribute to the attribute list.

Parameters:
attribute - The attribute to set.

getOpenTag

public java.lang.String getOpenTag()
DOCUMENT ME!

Returns:
a string which represents the XML tag which opens this element in the XML file

getCloseTag

public java.lang.String getCloseTag()
DOCUMENT ME!

Returns:
Returns a string which represents the XML tag which closes this element in the XML file.

parse

public static XMLElement parse(java.lang.String string)
                        throws XMLTreeException
Parse a new XML element from a string which contains a XML tag

Parameters:
string - The string to parse
Returns:
DOCUMENT ME!
Throws:
XMLTreeException - If the string doesn't contain a valid XML tag.