Hi folks,

what about adding new rules to digester? In my project I have two rules I can share:

1) AddToMapRule

Ctors:
    AddToMapRule(int stackPosition, String key)
    AddToMapRule(Map map, String key)

The rule will peek the top level element of the stack and put it into a map. The map 
can be provided from the outside or is expected at the given stack position (generated 
by a previous rule). The key is requested as property from the top level element using 
the PropertyUtils.

Example:
    digester.addObjectCreate("data", HashMap.class);
    digester.addSetNext("data", "setItems");
    digester.addObjectCreate("data/item", Item.class);
    digester.addRule("data/item", new AddToMapRule(1, "id"));
    digester.addCallMethod("data/item/id", "setId", 0, new Class[] { Integer.class });
    digester.addCallMethod("data/item/origin", "setOrigin", 0);


2) DateFormatterRule

Ctors:
    DateFormatterRule(DateFormat format)

The rule is used to convert an entry to a Date and push it onto the stack. The rule 
was not realized as Parameter rule, since the API prohibits the call of peekParams and 
pushParams (package scope instead of protected). See also Alex' mail about the subject.

Example:
    digester.addRule("data/item/time", new DateFormatterRule(new 
SimpleDateFormat("yyyy/MM/dd hh:mm:ss"));
    digester.addSetNext("data/item/time", "setTime");


All of the rules support toString, the logger and have unit tests.

Are you interested and what do I have to do for the donation?

Regards,
J�rg

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

Reply via email to