[jdom-interest] Visitor (was: API Inertia)

Joseph Bowbeer jozart at csi.com
Thu May 3 21:06:42 PDT 2001

Here's another follow-up on Visitable/Visitor from Paul Jakubik that I
wanted to share with the list.

Joseph Bowbeer wrote:

> Would you suggest that JDOM define a Visitor interface
> (to be implemented by clients) and provide a default
> implementation (AbstractVisitor) as a convenience?

Paul Jakubik ( pauljakubik at yahoo.com ) replied:

I think Visitor would be a good addition to JDOM. I
also think that providing some sort of default
do-nothing AbstractVisitor would be good since users
would not have to implement methods called for node
types they don't care about.

I think both of these could be added very easily,
doing so removes one of the big arguments for
providing a generic Node in the API (it becomes an
implementation decision instead of an API decision),
and I think people will have an easier time using the
Visitor API than trying to implement the API
themselves. So while Visitor can be confusing to
implement for people not familiar with it, I think it
is pretty easy to use (certainly much easier than
writing SAX handlers). I would find it a lot easier to
use than manually iterating, and I'd guess there are
others who would feel the same, though I don't know
how many.


More information about the jdom-interest mailing list