[jdom-interest] Fast Factory

Bradley S. Huffman hip at csa.cs.okstate.edu
Mon May 26 13:55:30 PDT 2003


Jason Hunter writes:

> Yes, this is one reason we were thinking of moving the factory into 
> org.jdom.  The other is that might just be a better logical place.

One of the problems with FastFactory as written, and extending JDOM objects
in general, is it depends heavily on protected fields. Maybe it's time
to make all inner fields private and put protected static constructor methods
in all JDOM classes (damn, there goes that method count up again :(  The 
creation methods can skip verification, but the normal constructors
and set* methods would still call Verifier (guess they could even be made
final).  Sort of a compromise, quick creation for those special cases like
building from SAX, otherwise verify on normal creation or any changes
to a object.

    Attribute.create(String localName, String value, int type,
                     Namespace namespace)
    CDATA.create(String value)
    Text.create(String value)
    Comment.create(String value)
    DocType.create(String elementName, String publicID, String systemID)
    Document.create(Element rootElement)
    Element.create(String localName, Namespace namespace)
    ProcessingInstruction.create(String target, String data)
    EntityRef.create(String name, String publicID, String systemID)

And maybe in Document/Element

    protected Parent setContent(Collection collection, int size)


Thoughts?

Brad



More information about the jdom-interest mailing list