[jdom-interest] How to ease traversal of JDOM tree

Laurent Bihanic laurent.bihanic at atosorigin.com
Tue Nov 20 09:19:36 PST 2001


philip.nelson at omniresources.com wrote:

> In addition, really nobody likes the idea of a
> comment or PI having setContent or other methods that made no sense.  
> 

That's not a problem. We could leave out the add/set/removeContent methods. As 
the proposed objective was to ease traversal of the tree, removing them 
doesn't hurt!
We could also remove getText() as it make no sense for EntityRef.

So, we are left with a proposal to basically define the methods found in all 
node classes in a single interface.

Yet, I think this is interesting because it would allow to get rid of all 
these addContent(Xxx) methods in Element for only 2 methods (addContent(Node) 
and addContent(String)) and thus treat all types of nodes equally, without 
resorting to instanceof tests.
Similarly, it would allow to have methods that process parts of a document and 
to invoke them with a subtree starting at any level (Document, Element, PI, ...).

Laurent




More information about the jdom-interest mailing list