[jdom-interest] getChildTextNormalize()

philip.nelson at omniresources.com philip.nelson at omniresources.com
Tue Oct 2 20:39:43 PDT 2001

> I could live with any of this either way. I agree that 
> consistency is a good
> thing, but I'm not sure I see the value of a trimText() that 
> just calls
> String.trim(). philip.nelson (Phil?) didn't seem to like the idea of
> getChildText() because it's mixing levels inappropriately. I 
> tend to agree,
> but I don't feel very strongly about it.

I don't feel real strongly about it either but don't want to add a lot of
new methods to Element that probably don't belong there.  getChildText() was
added/kept for a common use case involving web.xml files I think.  Hmmm, who
might have wanted that?

In the signatures where I first put my 2 cents in, I was just trying to
offer a way to cover the null pointer problem with getChild().  Something

String text = Helper.getText(yourElement.getChild("name")) //return the text
or ""
String text = Helper.getTextTrim(yourElement.getChild("name")) 
String text = Helper.getTextNormalized(yourElement.getChild("name"))

You get the idea.  These are a little shorter than the other helper ideas
presented so far and do pretty much the same thing.

More information about the jdom-interest mailing list