[jdom-interest] Fast Factory

Hallvard Trætteberg hal at idi.ntnu.no
Tue May 27 07:22:02 PDT 2003


Concerning subclassing:

Implementing support for id-handling requires subclassing of Document,
Element, Attribute and JDOMFactory. The subclasses handles changes to
the document, that change the set of active identifiers, e.g. changing
the type and value of attributes and adding and removing Elements. 

In the implementation of this that I use (based in Laurent Bihanic's), I
had to change ContentList to sequence adding to the list and setting the
parent "correctly". In the official implementation, ContentList first
sets the parent of the child Element (Element.setParent), then adds it
to the list. This means that the state of the parent-child relationship
is incorrect during and after the setParent call, which is a problem
when overriding setParent to note the change in the Element hierarchy.
I've changed the order in my JDOM copy, i.e. add to content list first,
then setParent.

I'd really like JDOM to change the internals to make my additions work,
but it is difficult to argue that JDOM currently is wrong, only that id
support was difficult to add without this change (the alternative would
be to subclass ContentList, but then there was no way to control which
ContentList class was instantiated (no Factory)).

Hallvard

> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org] On Behalf Of Elliotte Rusty
Harold
> Sent: 27. mai 2003 15:20
> Subject: RE: [jdom-interest] Fast Factory
> 
> At 7:07 AM -0400 5/27/03, Rolf Lear wrote:
> 
> There are three prime reasons for subclassing:
> 
> 1. To change the storage model; e.g. to sit JDOM on top of an
> underlying native XML database.
> 
> 2. To add additional methods that are useful in the local
> environment, but are not present in JDOM; e.g. 
> verifyElementAgainstDatabase or readElementAsInt
> 
> 3. To make more specific classes for a specific application, e.g.
> HTMLPElement, HTMLDivElement, HTMLTableElement, etc.
> -- 
> 
>    Elliotte Rusty Harold




More information about the jdom-interest mailing list