[jdom-interest] getElementById()

Hallvard Tratteberg hal at idi.ntnu.no
Thu Nov 14 04:58:36 PST 2002


Attila,

> This can be remedied if we explicitly mark a document as
> maintaining indexed IDs or not (i.e. Document.setUseIdIndexing(boolean)).
This way,
> ID indexing can be turned off for heavy tree manipulations and turned back
on for
> document querying. This seems to be the most flexible solution. With ID
> indexing turned off tree manipulations will be fast, and lookup by ID will
> be slow, while with ID indexing turned on it would be the other way round.

One way of doing this is make an IdDocument class, with methods for
manipulating elements and attributes that do this checking. If elements and
attributes are manipulated directly, this checking is not performed. This
also means that we don't need special sub-classes for Element and Attribute.
I have implemented the multi-subclass variant, with sub-classes for
Document, Element, Attribute and JDOMFactory (and even DocumentNavigator for
Jaxen), based on Laurent Bihanic's earlier work. It works and I've never
been bothered by the slow-down, but I've never needed the speed either.

Hallvard




More information about the jdom-interest mailing list