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

Richard Cook rpc at prismtechnologies.com
Tue Jul 10 08:38:01 PDT 2001


Could it be a precondition that there is no element content, perhaps an
exception if there is; setText() is very convenient for data oriented xml,
but for mixed content you are really dealing with a list of text (and other)
nodes, and setText() seems an invalid operation (a bit like writing
myArrayList="fred" in java and expecting the first item to become "fred" and
the rest of the list to be obliterated). even getText() on something like
<txt>The <b>cat</b> sat on the <b> mat</b></txt> returns a surprising result
for someone who is scanning the text rather than thinking of structure.
removeContent could always be used if obliteration is the intent. The
problem is that behaviour of setText() is then different depending on the
xml source and may make app testing harder.

-----Original Message-----
From: jdom-interest-admin at jdom.org [mailto:jdom-interest-admin at jdom.org]On
Behalf Of Alex Rosen
Sent: 10 July 2001 15:49
To: 'Elliotte Rusty Harold'; 'JDOM Interest List'
Subject: RE: [jdom-interest] setText() to replace children?

The only problem with all these proposals is the lack of symmetry. If you
get
text by calling getText(), it's natural to set it via setText(), and if
that's
not the name of the method, you have to go looking for it, and figure out if
it
really does what you want it to do. Similarly for setContent() and
setChildren(). Whether that's a good enough reason to keep the current state
of
things, I don't know. I really like the intuitiveness of setText(), though.
In
the common case where you don't have mixed content, it feels a lot more
natural.

Alex

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com




More information about the jdom-interest mailing list