commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Carreira <>
Subject Re: [Digester] How can I build a Calendar from XML pieces?
Date Mon, 07 Apr 2003 16:46:30 GMT
Is there any way to build re-usable components which have sub-rules? 
i.e., if I created a CalendarRule, could I have it have sub-rules which 
would get events for the <date> and <time> elements below the root which 
  the CalendarRule is added to watch, no matter what path that was added 
to monitor? Or do I have to create those other rules and always put them 
into the digester by hand?


Jason Carreira wrote:
> Calendar = java.util.Calendar
> I was going to get one with a Calendar.getInstance().
> The problem with the BeanProperySetterRule and CallParamRule is that 
> what I need to do is:
> 1) create a java.util.Date from the <date> element
> 2) call calendar.set(date.getYear(), date.getMonth(),date.getDate())
> 3) If <time> is there, it needs to set the time fields on the calendar, 
> too.
> I guess I'm going to need a custom rule...
> Jason
> robert burrell donkin wrote:
>> hi jason
>> (this answer will probably be a little vague since i don't know the 
>> structure of your objects.)
>> if i've understood you correctly, you need to create a calendar 
>> object. if this object is a bean (with a constructor which doesn't 
>> need to know the data and time information and setters for these 
>> properties) then you can probably create it with a rule mapped to 
>> <CreateDate> and then set the properties with BeanPropertySetterRule's 
>> mapped to <Date> and <Time>.
>> if the calendar isn't bean like and it configures itself by a method 
>> taking the <Date> and <Time> data, then you can use a CallMethodRule

>> and CallParamRule's.
>> if the calendar needs to have the date and time passed into the 
>> constructor, then i'm not sure any of the standard rules will work and 
>> you might need to create a custom Rule implementation.
>> hope this helps.
>> - robert
>> On Friday, April 4, 2003, at 07:21 PM, Jason Carreira wrote:
>>> Hi,
>>> I'm new to Digester and trying to replace some Castor XML binding 
>>> with Digester rules. We've got one complex XSD type which is a 
>>> structure like this:
>>>         <CreateDate>
>>>             <Date>2002-04-16</Date>
>>>             <Time>10:27:31.0</Time>
>>>         </CreateDate>
>>> In our current code, the <Date> element builds a Castor Date and the 
>>> <Time> element, which is optional, builds a Castor Time object. We've 
>>> got translation code which takes the year, month, and day from the 
>>> Date object and the time fields from the Time object (if it's there) 
>>> and builds a Calendar from it to be used in our domain models.
>>> I'm looking to bypass the Castor objects and translation and just 
>>> build our domain models from the XML using Digester. My current 
>>> question is, how would I go about translating the above structure 
>>> into a Calendar? Part of the problem is that the ObjectFactory stuff 
>>> only takes attributes,
>>>  not sub-elements or the body text, otherwise I could create an 
>>> ObjectFactory.
>>> Thanks very much,
>>> Jason Carreira
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>>> For additional commands, e-mail:

View raw message