That's what causes the illegal access exception.  The package is
openurl.  Class A is Servers; Class B is Server.  The rule

   <object-create-rule classname="openurl.Server" />

causes a class not found" exception. The rule

   <object-create-rule classname="openurl.Parser$Server" />

causes the illegal access exception that I mentioned in my original
email.  If I make the classes not static, I get an instantiation
exception.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Martin Cooper
Sent: Tuesday, October 17, 2006 10:29 PM
To: Jakarta Commons Users List
Subject: Re: [Digester] Can use inner classes?

On 10/17/06, Allen,Eva <[EMAIL PROTECTED]> wrote:
>
>
> I'm attempting to write a small parser as part of another larger 
> application.  I'd like to do something like the following:
>
> public class Parser {
>
> ...
>         ClassA s = new ClassA();
>         Digester d;
>         d.push(s);
>       ...
>         d.parse(inputStream);
>       ...
> }
> class ClassA {
>    LinkedList ClassB;
>    public void addClassB();
> }
> class ClassB {
>   String data1;
>   String data2;
>   String data3;
>   public getters and setters;
> }
>
> I'm using an xmlrules file looks like
> <digester-rules>
> ...
>    <pattern value="resolver">
>         <object-create-rule classname="ClassB" />
>         <set-properties-rule />
>         <set-next-rule methodname="addClassB" />
>
>         <pattern value="data1">
>                 <call-method-rule methodName="setData1" paramCount="0"
> />
>       </pattern>
>         ...
>    </pattern>
> ...
> </digester-rules>
>
> This all works fine as long as ClassA and ClassB are public classes.
> But as soon as I try to make them inner classes of the Parser class 
> this fails with an IllegalAccessException (Cannot access a member of 
> class ClassB with modifiers "").


This should be fine as long as your inner classes are both public and
static.

--
Martin Cooper


The Digester Developer Guide mentions something about this as a known
> limitation and says to ask on the mailing list if I think I'm 
> experiencing the problem it mentions.  So I'm asking.  Is there a way 
> around this or am I forced to have public classes for use with the 
> digester?
>
> Since I originally wrote this I've found that I could use the 
> FactoryCreateRule to create an object that doesn't have a no-argument 
> constructor, but I haven't been able to find a proper ruleset that 
> will allow me to do this.  Any suggestions?
> --
> Eva Allen
> Consulting Software Engineer, OCLC, Inc.
> 6565 Frantz Rd., Dublin, OH  43017
> 614.764.6009 | [EMAIL PROTECTED]
> Views contained herein are my own; they do not necessarily reflect 
> those of my employer
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to