[jdom-interest] Typing of the parent

Jason Hunter jhunter at servlets.com
Wed Feb 13 17:26:23 PST 2002


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;

to

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.

-jh-



More information about the jdom-interest mailing list