[jdom-interest] Typing of the parent

philip.nelson at omniresources.com philip.nelson at omniresources.com
Thu Feb 14 09:45:06 PST 2002

 The Decorator code I did for Brett's book will be affected by this as would
any "walk the tree" type of code.  Wouldn't jaxen be affected as well?

I think that Text and EntityRef should do the same thing as Element.  Sure
it makes sense for an attribute to know that it's parent is an element.
But, that's an easy check.  If each part of JDOM does this in a consistent
way, it's pretty easy for a subclasser to strap on a node implementation.
It's not that hard anyway, particularly now that String is replaced by Text
but consistency aids the intangible aspect of any api that makes it work
like you think it should.

-----Original Message-----
From: Jason Hunter
To: JDOM Interest
Sent: 2/13/02 7:26 PM
Subject: [jdom-interest] Typing of the parent

Recently we changed various JDOM classes like Comment and PI to instead
of having:

protected Document document;
protected Element parent;

They just have:

protected Object parent;

And the parent reference serves double-duty for each.  We've had Element
this way for a while, and we just brought the other classes in line.  It
saves around 4 bytes per instance.  The slightly annoying thing is that
this does affect some people doing fancy things in subclasses.  So
Question One is, how many of you really are affected?

Question Two is, for classes like EntityRef and Text which can only have
Element parents and can't be attached at the Document level, should we
change their:

protected Element parent;


protected Object parent;

for consistency?  Brad points out that some subclassers may prefer to
have a more abstracted notion of what is a parent.  The counter argument
is that Attribute should keep Element as its parent since to do
otherwise would feel strange, so why should Text be much different?

Opinions welcome.

To control your jdom-interest membership:

More information about the jdom-interest mailing list