commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject Re: Digester frustrations
Date Wed, 23 Mar 2005 01:08:59 GMT
Martin Cooper wrote:
> In general, in source code, you do reference inner classes with the
> dot notation. However, in this case, you are providing the name of the
> class file as a string, and class files use the $ notation instead.
> (You can verify this by looking at the directory in which javac
> creates your class files.)

Yep, I knew how the class got named when compiled... I guess I didn't 
realize I was giving it the name of a class file.

> The inner classes need to be static because non-static inner classes
> can only exist within an instance of their enclosing class, and cannot
> be instantiated on their own. (I think this is probably one of the
> most misunderstood aspects of inner classes. ;)

Hmmm... I think it's safe to say had such a question been on my SCJP 
test I would have gotten it wrong!  I don't think I was aware of that, I 
didn't think there was any problem doing:

OuterClass.InnerClass ic = new OuterClass.InnerClass()

...regardless of whether InnerClass was static or not.

Thanks for teaching me something today Martin! :)

Frank

> --
> Martin Cooper
> 
> 
> 
>>Frank
>>
>>Martin Cooper wrote:
>>
>>>On Tue, 22 Mar 2005 16:34:35 -0500 (EST), Frank W. Zammetti
>>><fzlists@omnytex.com> wrote:
>>>
>>>
>>>>One small problem remains...
>>>>
>>>>Does Digester not allow you to use inner classes as the target object?  I
>>>>found that I could only get this to work when I made the inner ConfigData
>>>>class NOT an inner class.  I realized too I had to fully-qualify the
>>>>class, but it didn't seem to matter being an inner class, it wouldn't work
>>>>no matter what I put.
>>>>
>>>>Is this a shortcoming?  Is there a reason if it is?  Thanks!
>>>
>>>
>>>As long as the inner class is public and static, and you use a '$' as
>>>the separator, you should be fine. I'm pretty sure I've done this
>>>myself.
>>>
>>>--
>>>Martin Cooper
>>>
>>>
>>>
>>>
>>>>--
>>>>Frank W. Zammetti
>>>>Founder and Chief Software Architect
>>>>Omnytex Technologies
>>>>http://www.omnytex.com
>>>>
>>>>On Tue, March 22, 2005 4:11 pm, Frank W. Zammetti said:
>>>>
>>>>
>>>>>Ugh.  I got it...
>>>>>
>>>>>The rules were set up wrong.  The root of the XML document is
>>>>>AppAvailabilityFilterConfig, not AppAvailabilityFilter as I had.
>>>>>
>>>>>My head HURTS.
>>>>>
>>>>>--
>>>>>Frank W. Zammetti
>>>>>Founder and Chief Software Architect
>>>>>Omnytex Technologies
>>>>>http://www.omnytex.com
>>>>>
>>>>>On Tue, March 22, 2005 3:43 pm, Frank W. Zammetti said:
>>>>>
>>>>>
>>>>>>Hey all... I'm trying to use Digester myself for the first time and
I'm
>>>>>>getting very frustrated...  Here's what I have:
>>>>>>
>>>>>>Digester digester = new Digester();
>>>>>>digester.setValidating(false);
>>>>>>digester.addObjectCreate("AppAvailabilityFilter",
>>>>>>"AppAvailabilityFilter.ConfigData");
>>>>>>digester.addBeanPropertySetter("AppAvailabilityFilter/mondayStartTime",
>>>>>>"mondayStartTime");
>>>>>>digester.addBeanPropertySetter("AppAvailabilityFilter/mondaEndTime",
>>>>>>"mondayEndTime");
>>>>>>// I get InputStream isConfigFile here, I have verified I have it
by
>>>>>>printing out the contents
>>>>>>configData = (ConfigData)digester.parse(isConfigFile);
>>>>>>configData.setConfigDataSet();
>>>>>>
>>>>>>configData is a static member of the class this code belongs to.
>>>>>>ConfigData is a inner class.  Here's the relevant snippet:
>>>>>>
>>>>>>private int mondayStartTime;
>>>>>>private int mondayEndTime;
>>>>>>public void setMondayStartTime(String mondayStartTime) {
>>>>>> this.mondayStartTime = Integer.parseInt(mondayStartTime);
>>>>>>}
>>>>>>public int getMondayStartTime() {
>>>>>> return mondayStartTime;
>>>>>>}
>>>>>>
>>>>>>As you can probably guess, I have the same things for every day of
the
>>>>>>week.  Lastly, here's the XML file:
>>>>>>
>>>>>><?xml version="1.0" encoding="UTF-8"?>
>>>>>><AppAvailabilityFilterConfig>
>>>>>> <mondayStartTime>0100</mondayStartTime>
>>>>>> <mondayEndTime>2300</mondayEndTime>
>>>>>></AppAvailabilityFilterConfig>
>>>>>>
>>>>>>The problem is that it gets all the way to the line:
>>>>>>
>>>>>>configData.setConfigDataSet();
>>>>>>
>>>>>>...no exceptions are thrown, no messages from Digester, etc.  But,
that
>>>>>>line causes a NullPointerException, so I can only assume that means
>>>>>>Digester did not create the object and/or could not populate it properly
>>>>>>so returned null (or ate an exception and didn't report it?)
>>>>>>
>>>>>>Anyone spot a problem here?  I'm getting ready to throw myself out
a
>>>>>>window.  Thanks all!
>>>>>>
>>>>>>--
>>>>>>Frank W. Zammetti
>>>>>>Founder and Chief Software Architect
>>>>>>Omnytex Technologies
>>>>>>http://www.omnytex.com
>>>>>>
>>>>>>---------------------------------------------------------------------
>>>>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>>>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>>
>>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>
>>--
>>Frank W. Zammetti
>>Founder and Chief Software Architect
>>Omnytex Technologies
>>http://www.omnytex.com
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
> 
> 
> 
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message