[jdom-interest] DataConversionException javadoc and other issues
Elliotte Rusty Harold
elharo at metalab.unc.edu
Sun May 4 12:10:21 PDT 2003
The Javadoc for the DataConversionException constructor (see
http://www.jdom.org/docs/apidocs/org/jdom/DataConversionException.html)
is very misleading. It has nothing to do with missing attributes, and
everything to do with a string not being able to be converted to a
number.
I was just going to submit a patch, but then I began to wonder whther
we still needed this exception class at all. It is only thrown, as
near as I can see, by four methods in Attribute: getIntValue(),
getFloatValue(), getDoubleValue(), getLongValue. If getIntValue() or
getFloatValue(), etc. fail the natural response is a
NumberFormatException. Would it be better to throw that and delete
DataConversionException completely?
The big difference is that DataConversionException is checked and
NumberFormatException is not. I think that this case does satisfy
the criterion for checked excepitons that, (following Bloch) " the
exceptional condition cannot be prevented by proper use of the API
/and/ the programmer using the API can take some useful action once
confronted with the exception"
Last May, Jason objected that NumberFormatException was inappropriate
for getBooleanValue. There's no BooleanFormatException. The
java.lang.Boolean class interprets all non-true strings as false. I
don't think we should go that far, but even if we keep
DataConversionException the JavaDoc needs to be fixed.
--
Elliotte Rusty Harold
elharo at metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
http://www.cafeconleche.org/books/xmljava
http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA
More information about the jdom-interest
mailing list