[jdom-interest] setText() to replace children?

Bart Read bart at wdi.co.uk
Wed Jul 11 02:14:12 PDT 2001


I have to broadly agree with Alex Rosen on this one.  getText() should just
get the text, possibly throwing a RuntimeException if there is mixed
content.  If you want all of the content you should use getContent().  I
think the function that setText() should perform is more open to debate.  My
personal opinion is that it should replace all child content of the element
in question.  If you want to set mixed content then there are more
appropriate methods: setContent(List content) and the various forms of
addContent().  If you're dealing with mixed content I really can't see why
you'd want to use getText() in the first place.  Conversely if you have an
element that only contains text do you really want to get back a List and
then have to cast the first object to a String in order to get at it?


=================================
Bart Read
Senior Developer
Abbotsbury Software Ltd
Abbotsbury, DORSET DT3 4JT
Tel: +44 (0) 1305 871644
E-mail: bart at wdi.co.uk
=================================


---------- Automatically inserted by mailhost.wdi.co.uk ------------ 
This message has been scanned for virus, trojans, illegal relays and
spam. If you have any comments, problems or questions please do not 
hesitate to contact:
Abbotsbury Software Ltd
Tel: +44 1305 871543 Fax: +44 1305 871688
Email: postmaster at wdi.co.uk
Web: http://www.wdi.co.uk/virus.phtml



More information about the jdom-interest mailing list