Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] CanonicalXMLSerializer exceptions

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] CanonicalXMLSerializer exceptions
  • Date: Sat, 08 Nov 2003 22:37:46 -0500

Currently in CanonicalXMLSerializer methods such as setLineSeparator() and setMaxLength() ignore their arguments because the canonicalization algorithm sets certain required values for these properties. For example, in caonical XML the line break must be a linefeed. Therefore the code for setLineSeparator() looks like this:

public final void setLineSeparator(String lineSeparator) {
super.setLineSeparator("\n"); }

I have an open question as to whether I should throw an exception if someone passes in something else such as "\r". Is it better to silently do the right and required thing here? (current behavior) or should I warn clients when they attempt to do the wrong thing by throwing an IllegalArgumentException? I'm leaning toward throwing the exception, but I'm open to discussion and argument about this. I'd also be curious if anyone has references to suggested programming practices (e.g. Bloch item #s) that are squarely on point here.

Hmm, one more point that argues in favor of throwing the exception: the superclass (Serializer) variants of these methods to throw exceptions when illegal values such as NEL are passed to these methods. So it's not out of the question or unexpected for these methods to throw an IllegalArgumentException. On the other hand throwing the exception for different values the superclass will accept means I'd be tightening the preconditions on the subclass implementation. I think Bertrand Meyer (Object Oriented Software Construction) claims I'm not allowed to do that.

--
Elliotte





Archive powered by MHonArc 2.6.24.

Top of Page