[jdom-interest] getChildTextNormalize()

rpcee rpcee at operamail.com
Tue Oct 2 09:49:16 PDT 2001


The source seems to indicate getChildText*() methods return null rather than 
"" if getChild() returns null, whereas the getText*() methods don't appear to 
return null. ie

  Element e = getChild("c");
  if (e == null) {
    return "";
  }  else {
    return e.getTextTrim();
  }

is actually equivalent to:

  String childText = e.getChildTextTrim("c");
  if (e == null) {
    return "";
  } else {
    return childText;
  }

Obviously you might be happy to return null but presumably at some point there 
would have to be a null test?


>===== Original Message From "Kent C. Johnson" <kentyman23 at hotmail.com> =====
>Alex (and All),
>
>Agreed about the trimText(), it was just a thought.
>
>I too agree it's bad to have methods in a parent that merely call methods in
>a child.  However, there is something to be said for the null-checking
>getChildText() does.  Since it doesn't just call getChild().getText(), it
>can be said that it has it's own functionality, namely returning "" if
>getChild() == null, and if not, returning the wrap of getChild().getText().
>Sounds a lot like a loop-hole too keep it in, but that may be a good thing.
>I think if everyone wanted the EXACT right OOP way to do things, they might
>lean more towards DOM.  But it seems to me (through my occasional use) that
>JDOM is more about convenience.  Not convenience to the point of excessive
>clutter, but a happy medium.
>
>Do you agree?
>
>Regards, and sorry to open this "Pandora's Box" as Jason called it, :)
>Kent
>
>
>>From: "Alex Rosen" <arosen at silverstream.com>
>>To: "'Kent C. Johnson'" <kentyman23 at hotmail.com>, <jdom-interest at jdom.org>
>>Subject: RE: [jdom-interest] getChildTextNormalize()
>>Date: Tue, 2 Oct 2001 10:57:43 -0400
>>
>>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.
>>
>>Alex
>>
>
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost
.com




More information about the jdom-interest mailing list