[jdom-interest] setText() to replace children?
Elliotte Rusty Harold
elharo at metalab.unc.edu
Tue Jul 10 07:16:54 PDT 2001
At 6:27 PM -0500 7/9/01, Brett McLaughlin wrote:
>One item in the TODO file:
>
>* Consider if setText() should not replace children
>
>I think setText() should set the text of the element, removing any other
>text in the element. However, I don't think any other children (such as PIs,
>comments, etc) should be affected. Does anyone agree/disagree? I'd like to
>get rid of this one in a few days.
>
I disagree. It should either replace all content or throw an exception. But it shouldn't replace just some part of the content.
Actually, here's an idea: suppose we remove setText() completely and replace it with this overloaded method:
public Element setContent(String text)
Thsi would replace the contents of the element with the argument, just like the other setContent() method does.
Oh, and could somebody remind me why there's both a setContent(List) and a setChildren(List) method in Element? Is one of them deprecated and going away?
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible, 2nd Edition (Hungry Minds, 2001) |
| http://www.ibiblio.org/xml/books/bible2/ |
| http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list