[jdom-interest] Code Submission: SAXBuilder, SAXHandler, SAXFactory refactor...

Jerry Lawson jerry.lawson at virtualsummit.com
Mon Nov 20 07:54:40 PST 2000

I got your new files, and made one local change to your SAXBuilder.java:
in SAXBuilder.build(InputSource) instead of :
    Document doc = new Document(null);
I replaced it with:
    Document doc = getFactory ().createDocument(null);

I also modified your SAXFactory class to have a
    public Document createDocument (Element root) {
        return new Document(root);

Also, your javadoc {@link SAXBuilder.setFactory()} in
SAXFactory.java is broken. It should be (IMO):
{@link SAXBuilder#setFactory(SAXFactory)}

I'm hoping for your changes to get incorporated into standard
jdom distribution. In addition to solving my application problems,
I think they also address all this business about extending
Elements and Attributes for various different reasons.
Until then, my build script replaces the standard SAXBuilder.java
with your SAXBuilder.java and SAXHandler.java, and adds

James Strachan wrote:

> I've refactored my previous refactor ;-)
> I've attached modified SAXBuilder and SAXHandler which use a new class
> SAXFactory. SAXFactory is a collection of factory methods used by SAXHandler
> complete with default implementations. If you want to build custom
> implementations of (say) Element this should be achieveable with minimal
> code...
> public class MyFactory extends SAXFactory {
>     public Element createElement(String localName, Namespace
> elementNamespace) {
>         return new MyElement( localName, elementNamespace );
>     }
>     public Element createElement(String localName) {
>         return new MyElement(localName);
>     }
> }
>     ... then later
>     SAXBuilder builder = new SAXBuilder();
>     builder.setFactory( new MyFactory() );
> Note that using the same technique custom implementations of Attribute,
> CDATA, Namespace etc. can all easily be integrated without large numbers of
> new classes, APIs etc.
> Does this all seem OK with everyone?
> J.
> James Strachan
> =============
> email: james at metastuff.com
> web: http://www.metastuff.com
>                 Encoding: quoted-printable

Jerry Lawson                   Virtual Summit, Inc.
Virtual Programmer   jerry.lawson at virtualsummit.com

More information about the jdom-interest mailing list