[jdom-interest] insertChild in Element

trebor.a.rude at lmco.com trebor.a.rude at lmco.com
Wed Aug 30 12:43:26 PDT 2000


	A proxy implementation would be good. I know I found the whole List
thing confusing to begin with, but I assumed that was simply because I was
so used to using the DOM (which has all the modification interfaces on the
nodes themselves). A proxy implementation would give us the best of both
worlds, and be backwards-compatible to boot. I like it. Orginally, I was
concerned about cluttering the Element interface, but as long as it's the
standard List interface, it's not so bad.

	As for PartialList checking the types of its children, I agree. We
may also want to make it check whether or not an added item is actually the
same object as one of its parents, to prevent circular references (and thus
get tree-walkers into an infinite loop). Unfortunately, this might be quite
a performance hit.

> -----Original Message-----
> From:	Elliotte Rusty Harold [SMTP:elharo at metalab.unc.edu]
> Sent:	Wednesday, August 30, 2000 12:19 PM
> To:	Jason Hunter; James W. Howe
> Cc:	Brett McLaughlin; jdom-interest at jdom.org
> Subject:	Re: [jdom-interest] insertChild in Element
> 
> 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.
> 



More information about the jdom-interest mailing list