[jdom-interest] getChildTextNormalize()

Alex Rosen arosen at silverstream.com
Mon Oct 1 16:37:06 PDT 2001


So, I've dusted off the helper I was writing a while ago and checked it in
to jdom-contrib.
(http://cvs.jdom.org/cgi-bin/viewcvs.cgi/jdom-contrib/src/java/org/jdom/cont
rib/helpers/).

This can replace all of the trim, normalize, and getChildText methods in
Element. They become:

String val = element.getText().trim();
String val = TextHelper.normalize(element.getText());
String val = TextHelper.getChildText(element, "childname");
String val = TextHelper.getChildTextTrim(element, "childname");
String val = TextHelper.getChildTextNormalize(element, "childname");

(Note that getText() will never return null, but getChild() might, hence the
need for the last 3 methods.)

This is intended to be a starting point. I'm happy to take opinions as to
the name of the class, which Element methods we should remove or keep, or
whether this is a good idea at all.

Alex




More information about the jdom-interest mailing list