Exceptions in Attribues(2), AttributesImpl

"Karl Waclawek" <[email protected]> Fri, 14 Nov 2003 20:16:34 -0500
Newsgroups gmane.text.xml.sax.devel
Message-ID <001b01c3ab16$1c3436c0$0207a8c0@karl>
I ran across what appears as inconsistency to me looking
at the Attributes(32) specs and the implementation of AttributesImpl.

In the Attributes interface, the getValue(), getType(), getURI(),
getQName() and getLocalName() methods are all supposed to
return a null value when no attribute matching the parameters
passed to the functions is found.

However, the corresponding setXXX() methods do throw
an ArrayIndexOutOfBoundsException.

Also, in the Attributes2 interface, all isXXX() methods throw
either an ArrayIndexOutOfBoundsException or an
IllegalArgumentException.

This looks inconsistent to me, although I can understand
technically that those methods do not have return types
that would allow to pass such error information back,
only an object result type allows to pass null (meaning error).

IMO, this does not warrant the inconsistency.
I also think that calling the getXXX() methods with an incorrect
index or non-existing name should be considered an error
and throw an exception, especially when the getIndex() methods 
already provide an exception free way to check if an attribute exists.

Is there any good reason I have overlooked why it should
be the way it is?

Karl



-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
_______________________________________________
List: sax-devel, [email protected]
See:  http://www.saxproject.org/
https://lists.sourceforge.net/lists/listinfo/sax-devel