Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Subclassing and check methods

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: jcowan AT reutershealth.com
  • To: "Bradley S. Huffman" <hip AT cs.okstate.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Subclassing and check methods
  • Date: Fri, 12 Mar 2004 11:12:20 -0500

Bradley S. Huffman scripsit:

> If I subclass Element and override checkInsertChild to check that elements
> with local name "foo" can only contain children with local name "bar", what
> do I do about setLocalName? Think about the case of replacing nodes in a
> document. Obviously I can create a "foo" element by recycling a existing
> element and using setLocalName, skipping the checks in checkInsertChild
> completely.

In ERH's brave new world, the check* methods are gone and you impose
the constraint by overriding setLocalName as well as insertChild, and
throw if someone tries to violate the constraint.

That reminds me. As part of this effort, the throwables for these
protected mutator methods should be broadened to XMLException.
(I know the clause has no actual effect on the compiler, but it's good
documentation to get it right.) I'd rather throw the same exception
from setLocalName and insertChild in this case (an IllegalAddException
or a new subclass of it), but currently setLocalName is (documented as)
only throwing IllegalNameException.

--
Samuel Johnson on playing the violin: John Cowan
"Difficult do you call it, Sir? jcowan AT reutershealth.com
I wish it were impossible." http://www.ccil.org/~cowan




Archive powered by MHonArc 2.6.24.

Top of Page