[jdom-interest] building jdom trees

Jason Hunter jhunter at collab.net
Wed Mar 7 11:23:26 PST 2001


Richard Cook wrote:
> 
> Probably a silly question, but SAXHandler creates Element objects directly
> via new, so is it not possible to build a JDOM tree which contains Element
> subclasses? Do I have to build the JDom tree then create some sort of clone
> which adapts each Element to the interface I need?

Yes, as discussed quite recently, we plan to allow SAXBuilder to take a
factory.

> Also Element::equals(Object) is final and uses "==", which means I can't
> change it; this is presumably a necessity I shouldn't change?

Yep, that's in the FAQ.

> I have a tendency to write element.getChildren().get(i) and suchlike, I
> notice that getChildren() builds a PartialList each time so obviously this
> is inefficient (actually I guess LinkedList.get(i) also loops and I should
> use an iterator?); is there a set of performance hints anywhere?

Jools is rewriting PartialList.  A much better implementation is coming
soon.  As for performance hints, always use iterators and not indexed
access.

-jh-



More information about the jdom-interest mailing list