[jdom-interest] Re: Factories for Element creation

Jason Hunter jhunter at collab.net
Tue Oct 31 20:32:55 PST 2000

> Problem with creating your own builder, (ie, MySAXBuilder), is that
> it'd only work for SAX, and you'd have to Do It Again 
> for MyDOMBuilder,
> or MyJDBCBuilder.  A Factory of some flavor would do wonders.  Have
> a BuilderBase with hooks for a factory, and derive FooBuilder from
> it.  Instantly, everything would work. ;)
>         -bob

Problem with a BuilderBase is that you'd have to know beforehand all the
possible createElement() arguments that might be necessary to create the
element.  Because you're wanting this general, it can't leverage any
builder internals to pass anything except the standard info.  Therefore,
I see problems for anything above the trivial situation, for example
wanting a special element that knows where in the source file it came
from.  With a subclass, you can take advantage of special builder
abilities in a specific subclass.

But the beauty of the JDOM model is you can use whatever builder you
want!  If you or anyone wants to write a builder like SAXBuilder that
supports factories, JDOM works perfectly well with that builder.  It's
only an issue of whether the builder classes would be official in
org.jdom or not.  Making them official would essentially require
refactoring the API to support factories, and as you know I'm not eager
to see that.


More information about the jdom-interest mailing list