[jdom-interest] Simplifications in Element
Shaun Smith
shauns at pixology.com
Fri May 23 06:15:56 PDT 2003
Mattias,
Could we not remove some duplication here?
How about:
If( null == child )
{
child = createChild(name);
}
Kind Regards,
Shaun.
-----------
/**
* Create child.
*/
public Element createChild(String name)
{
Element child = new Element(name);
this.addContent(child);
return child;
}
/**
* Add a new child with a text value
*/
public void setChildText(String name, String value)
{
Element child = this.getChild(name);
if(child == null)
{
child = new Element(name);
this.addContent(child);
}
child.setText(value);
}
More information about the jdom-interest
mailing list