bill.util.xml
Class SimpleXMLObjectList

java.lang.Object
  |
  +--bill.util.xml.SimpleXMLObjectList

public class SimpleXMLObjectList
extends Object

Holds a list of sibling object that have the same name. Since XML allows multiple objects at the same level to have the same name, we use a list to facilitate this.


Constructor Summary
SimpleXMLObjectList(String name)
           
 
Method Summary
 boolean equals(Object other)
          Checks if two SimpleXMLObjectList objects are equal.
 Vector getList()
          Retrieves the list of SimpleXMLObjects contained in this object.
 String getName()
          Retrieves the name of this object.
 int getNumberOfObjects()
          Retrieves the number of objects that are are being held in this list.
 SimpleXMLObject getObject(int index)
          Retrieves a specific SimpleXMLObject by its index in the list of known SimpleXMLObjects.
 void removeObject(int index)
          Removes the specified objet instance from the list of objects.
 void setName(String name)
          Sets the name of this object.
 String toXML()
          Dumps out the object in valid XML string representation.
 SimpleXMLObject updateObject(String value)
          Updates the first SimpleXMLObject in this list object.
 SimpleXMLObject updateObject(String value, int index)
          Updates (or adds if it does not exist) a SimpleXMLObject from this list object at the specified index.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleXMLObjectList

public SimpleXMLObjectList(String name)
Method Detail

getName

public String getName()
Retrieves the name of this object.
Returns:
The name of this object.

setName

public void setName(String name)
Sets the name of this object.
Parameters:
name - The new name of this object.

getList

public Vector getList()
Retrieves the list of SimpleXMLObjects contained in this object.
Returns:
The list of SimpleXMLObjects.

getObject

public SimpleXMLObject getObject(int index)
Retrieves a specific SimpleXMLObject by its index in the list of known SimpleXMLObjects.
Parameters:
index - The index (0 based) into the list of SimpleXMLObjects.
Returns:
Returns the specified index's object, or null if their is no list item with that index.

getNumberOfObjects

public int getNumberOfObjects()
Retrieves the number of objects that are are being held in this list.
Returns:
The number of objects.

removeObject

public void removeObject(int index)
Removes the specified objet instance from the list of objects.
Parameters:
index - The index of the objet to be removed from the list.

toXML

public String toXML()
Dumps out the object in valid XML string representation.
Returns:
The XML in string format.

updateObject

public SimpleXMLObject updateObject(String value)
Updates the first SimpleXMLObject in this list object. If the list has no SimpleXMLObjects, than one is created.
Parameters:
value - The value of the new list object.
Returns:
Returns the newly created object.

updateObject

public SimpleXMLObject updateObject(String value,
                                    int index)
Updates (or adds if it does not exist) a SimpleXMLObject from this list object at the specified index. If additional blank objects need to be created to get to this index that is done. For example, if there are currently two objects in the list and I say to update an object at index 4, then indexes 2, 3, and 4 are created. Note that if an object already exists at the specified index and null is passed as the value, than the existing value is left unchanged.
Parameters:
value - The value of the new list object.
index - Index to add the object to the list at (0 based).
Returns:
Returns the newly created or updated object.

equals

public boolean equals(Object other)
Checks if two SimpleXMLObjectList objects are equal. They are concidered equal if their names.
Overrides:
equals in class Object
Parameters:
other - The other object to check for equality.
Returns:
Returns true if the object are equal, returns false otherwise.