[jdom-interest] insertChild in Element

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Aug 30 11:19:06 PDT 2000


At 6:31 PM +0200 8/30/00, Jason Hunter wrote:
>Then you need the ability to remove a particular child by index too.
>And the ability to remove all children, remove a child by name, remove
>all children with a name, add a set of children, remove a set of
>children, and so on.
>
>All these things are easily done with the List returned by getChildren()
>using standard Java APIs.  I think it's better to give people access to
>the List for them to manipulate as they like than reproduce all the List
>functionality in Element.
>

Lately I'm not so sure of that. Certainly, the getting the children 
and then operating on the list doesn't seem to be obvious. What if 
Element and Document implemented List instead of containing a List? 
Would this be more obvious? Would it be more closely reflect people's 
mental models of XML elements?

It would be fairly easy to make the change. Just use the Proxy design 
pattern where the Element is the proxy for the partial list.

On a related note, I'm also thinking that PartialList needs to check 
the types of the objects that are added to it. It shouldn't be 
possible to store a Frame or an InputStream or a File or a BigInteger 
or anything except the relevant JDOM types into the content of an 
element. Right now you can.

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list