wyvern.util
Class XMLSimple.Element

java.lang.Object
  extended bywyvern.util.XMLSimple.Element
Enclosing class:
XMLSimple

public static class XMLSimple.Element
extends java.lang.Object

Simple representation of an XML Element. Has a name, a HashMap of attrs, and an ArrayList of children. The attrs list may be empty, but not null. The keys and values are the names and values of the attributes (both Strings).

The ArrayList of children may also be empty, but not null. The child list elements are also Elements.

Version:
1.0, Jun 28, 2003
Author:
Steve Yegge

Constructor Summary
XMLSimple.Element(java.lang.String name)
          Constructs a new Element
 
Method Summary
 void addChild(XMLSimple.Element child)
          Adds a child to the list.
 java.util.HashMap getAttrs()
          Returns the attributes map for this Element.
 java.util.ArrayList getChildren()
          Returns a list of the child elements of this element.
 XMLSimple.Element[] getElements()
          Returns the children as an array.
 java.lang.String getName()
          Returns the name of this element.
 XMLParams toParams()
          Most of the XML requests for the client/server protocol are a "request" element with nested "param" elements, each with "name" and "value" attributes.
 java.lang.String toString()
          Returns debugging representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XMLSimple.Element

public XMLSimple.Element(java.lang.String name)
Constructs a new Element

Method Detail

getAttrs

public java.util.HashMap getAttrs()
Returns the attributes map for this Element.


getName

public java.lang.String getName()
Returns the name of this element.


getChildren

public java.util.ArrayList getChildren()
Returns a list of the child elements of this element.

Returns:
a list of Elements (can be empty)

getElements

public XMLSimple.Element[] getElements()
Returns the children as an array.


addChild

public void addChild(XMLSimple.Element child)
Adds a child to the list.


toString

public java.lang.String toString()
Returns debugging representation.


toParams

public XMLParams toParams()
Most of the XML requests for the client/server protocol are a "request" element with nested "param" elements, each with "name" and "value" attributes. This method extracts all the names and values and puts them in a hash for super-easy lookup.

Example: a request element with one param child, <param> name="op" value="play"/>, would return a hash with the key "op" and the value "play".

Returns:
a hashtable of params - always non-null, but may be empty if we had no "param" element children