[jdom-interest] getText

tsasala at hifusion.com tsasala at hifusion.com
Wed Oct 4 09:58:44 PDT 2000


	would this work better?

	if(text !=null && text.trim().length() > 0) {
	....
	} 

Brett McLaughlin wrote:
> 
> OK. Executive decision.
> 
> getText() no longer returns null, it returns the empty String, when
> there is either no content or empty content, etc.
> 
> The only negative I heard was that comparison to null was less costly
> than comparison to "" with .equals(). This is true; however, I think the
> typical code ends up being this anyway:
> 
> String text = element.getText();
> if ((text != null) && (!text.equals("")) {
>   System.out.println("Element text is " + text);
> }
> 
> in which case you use both. So you actually save this way.
> 
> So I'm putting it in CVS now.
> 
> -Brett
> 
> --
> Brett McLaughlin, Enhydra Strategist
> Lutris Technologies, Inc.
> 1200 Pacific Avenue, Suite 300
> Santa Cruz, CA 95060 USA
> http://www.lutris.com
> http://www.enhydra.org
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Thomas M. Sasala, Senior Developer             tsasala at hifusion.com     + 
+ HiFusion, Inc.                                 (W) 703.848.4441         +
+ 8180 Greensboro Dr, #500                       (F) 703.848.4420         +
+ McLean, VA  22102                                                       + 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



More information about the jdom-interest mailing list