[jdom-interest] Reference comparisons in SAXHandler.startElement

Keith_Hamasaki.DATAHOUSE at datahouse.com Keith_Hamasaki.DATAHOUSE at datahouse.com
Sat Mar 10 13:28:58 PST 2001

In the startElement method of SAXHandler (SAXBuilder.java) there are
reference comparisons on local name vs. qualified name, both in the passed
parameters and in the values returned by the Attributes object.  In at
least one implementation (Resin XML) this results in a
StringIndexOutOfBoundsException when the strings returned from the
Attributes object are .equal() but not ==, and control passes to the
following line:

String attPrefix = attQName.substring(0, attQName.indexOf(":"));

which is line 730 of the current CVS file.  It seems that since the
implementation of the Strings in question is dependent on the parser being
used, the comparison should be .equals(), or another way should be found to
formulate this condition.  Changing the comparison to .equals() fixes the
StringIndexOutOfBoundsException that we are seeing.  Unless, of course,
those strings are required to be reference equal, and if this is the case
then could someone please point me to where this is documented (I looked at
the SAX Javadoc but couldn't see anything) so that I can report this to the
parser implementers?

More information about the jdom-interest mailing list