[jdom-interest] no getChildTextNormalize() ?

rpcee rpcee at operamail.com
Thu Sep 27 13:39:55 PDT 2001


Thanks, that changes things - I should read the source.
One more question - could getChild() return a "Null" Element object rather 
than null so that getChild("x").someMethod() would always work regardless of 
whether someMethod() also had a convenience method.

>===== Original Message From Jason Hunter <jhunter at apache.org> =====
>> I'm not sure how these methods are more convenient? Does it save 
keystrokes? I
>> don't think it affects maintenance or readability of the application one 
way
>> or the other. I guess there is a small negative affect on the library 
source.
>>
>> In JBuilder and presumably jEdit, VAJava etc I can type
>>
>>     getChild("c").getTextTrim(); in 20 keystrokes, and
>>
>>     getChildTextTrim("c"); in 17.
>>
>> Using a 5 letter template/abbreviation I can do either in 10, and typing it
>> out straight is only 6 chars different.
>
>getChild() may return null in which case your first example would throw
>a NullPointerException.  getChildTextTrim() knows enough to not throw an
>exception.  A fair comparison is:
>
>  return e.getChildTextTrim("c");
>
>  versus
>
>  Element e = getChild("c");
>  if (e != null) {
>    return e.getTextTrim();
>  }
>  else {
>    return "";
>  }
>
>-jh-




More information about the jdom-interest mailing list