[jdom-interest] Re: protected setDocument() and setParent() use cases

Trimmer, Todd todd.trimmer at trizetto.com
Tue May 7 11:53:10 PDT 2002


From: Elliotte Rusty Harold <elharo at metalab.unc.edu>

Could somebody please remind me why there are protected setParent() and 
setDocument() methods in most of the classes in org.jdom?

    protected Element setParent(Element parent)
    protected Element setDocument(Document owner)

Why might a subclass need to use these?

-------------------------------------------------

So a markup language extending XML can enforce stricter parent rules. For
example, a TR subclass of Element might overload setParent so that only a
TBODY subclass of Element is allowed. If anything else is passed in, an
IllegalStateException (or some other Exception) is thrown.

Then again, can't this also be done in TBODY's custom FilterList handling
its children, making sure only TRs can be added? Yeah, that is better.

Gotta love them new filters =)

I'd like to see if someone can come up with use cases, too.


Todd Trimmer



More information about the jdom-interest mailing list