[jdom-interest] SAXBuilder and Piccolo
Martin Schulz
schulz at videotron.ca
Tue Nov 26 16:04:49 PST 2002
Jason,
Actually, the suggested change works, since I am already using it.
The jaxpParser object is indeed passed to the Method.invoke() unchanged
as before.
Only the parserClass variable disappears, more because it would become a
misnomer than out of necessity.
No other changes are necessary, and I don't think the class hierarchy
needs to be examined manually.
[ Reflection uses the same Method class for static and non-static
methods, and Class.getMethod() does not distinguish between them
either. ]
For illustration, here's the relevant section of the changed code:
// jaxpParser = factory.newSAXParser();
Method newSAXParser =
factoryClass.getMethod("newSAXParser", null);
Object jaxpParser = newSAXParser.invoke(factory, null);
// parser = ((SAXParser)jaxpParser).getXMLReader();
Method getXMLReader =
Class.forName("javax.xml.parsers.SAXParser").getMethod("getXMLReader",
null);
parser = (XMLReader)getXMLReader.invoke(jaxpParser, null);
Thanks!
Martin
-----Original Message-----
From: jdom-interest-admin at jdom.org [mailto:jdom-interest-admin at jdom.org]
On Behalf Of Jason Hunter
Sent: November 26, 2002 1:10 PM
To: Martin Schulz
Cc: jdom-interest at jdom.org; yuval at bluecast.com
Subject: Re: [jdom-interest] SAXBuilder and Piccolo
Hmm, wouldn't your suggested change be equivalent to
SAXParser.getXMLReader(), which would fail because SAXParser doesn't
have a static getXMLReader() method? I think we still need to use the
"jaxpParser" returned by "newSAXParser".
But how about this. Instead of invoking the call on getClass() we
should instead use getClass() and then getSuperclass() to find the
public class, then invoke the method on that. Thoughts?
-jh-
Martin Schulz wrote:
>
> After thinking this through, I suggest to replace in
> SAXBuilder.createParser():
>
> Class parserClass = jaxpParser.getClass();
> Method getXMLReader =
> parserClass.getMethod("getXMLReader", null);
>
> with the more appropriate:
>
> Method getXMLReader =
>
> Class.forName("javax.xml.parsers.SAXParser").getMethod("getXMLReader",
> null);
>
> The reason is that parserClass needlessly refers to the implementing
> class of the SAXParser, whereas non-reflecting
> code such as
> parser = factory.newSAXParser().getXMLReader();
> would only access the implementing class via the SAXParser interface.
> The implementing class may be unaccessible (as is the case with
> Piccolo).
>
> Martin
>
> -----Original Message-----
> From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]
> On Behalf Of Jason Hunter
> Sent: November 15, 2002 4:24 PM
> To: Martin Schulz
> Cc: jdom-interest at jdom.org; yuval at bluecast.com
> Subject: Re: [jdom-interest] SAXBuilder and Piccolo
>
> > Shouldn't the inner class JAXPSAXParser be declared public (if I do
> > that, it works for me), and why hasn't this been noted before?
>
> Seems like it, but it's an internal class to Piccolo, so you may want
to
> ask them. Perhaps they aren't anticipating such usage.
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.385 / Virus Database: 217 - Release Date: 04/09/2002
>
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
rhost.com
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.385 / Virus Database: 217 - Release Date: 04/09/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.385 / Virus Database: 217 - Release Date: 04/09/2002
More information about the jdom-interest
mailing list