* Set the enclosed <code>PARAM<code> children.
* @param newObjectParams The new parameters.
*/
public void setObjectParams (Hashtable newObjectParams)
{
NodeList kids;
Node node;
Tag tag;
String paramName;
String paramValue;
Vector attributes;
TextNode string;
kids = getChildren ();
if (null == kids)
kids = new NodeList ();
else
// erase objectParams from kids
for (int i = 0; i < kids.size (); )
{
node = kids.elementAt (i);
if (node instanceof Tag)
if (((Tag)node).getTagName ().equals ("PARAM"))
{
kids.remove (i);
// remove whitespace too
if (i < kids.size ())
{
node = kids.elementAt (i);
if (node instanceof TextNode)
{
string = (TextNode)node;
if (0 == string.getText ().trim ().length ())
kids.remove (i);
}
}
}
else
i++;
else
i++;
}
// add newObjectParams to kids
for (Enumeration e = newObjectParams.keys (); e.hasMoreElements (); )
{
attributes = new Vector (); // should the tag copy the attributes?
paramName = (String)e.nextElement ();
paramValue = (String)newObjectParams.get (paramName);
attributes.addElement (new Attribute ("PARAM", null));
attributes.addElement (new Attribute (" "));
attributes.addElement (new Attribute ("VALUE", paramValue, '"'));
attributes.addElement (new Attribute (" "));
attributes.addElement (new Attribute ("NAME", paramName.toUpperCase (), '"'));
tag = new TagNode (null, 0, 0, attributes);
kids.add (tag);
}
//set kids as new children
setChildren (kids);
}