commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Kitching" <>
Subject RE: Digester:
Date Wed, 08 May 2002 22:51:27 GMT
Hi Kris/Craig,

I've been following your emails with interest.

As a user of digester, I also miss an easy way of mapping an
xml atribute onto a setter method. This seems *such* a common
particularly as the xml convention for attribute names is xxx-yyy-xxx
but the
Java convention is xxxYyyZzz.

Yes, the bean approach and the CallMethodRule approach handle it, but
each needs
more than one line of code :-)

Kris' rule that uses a HashMap is interesting, but it doesn't seem quite
right to
me, and I can't see for the moment how it can be implemented in the
xmlrules format.

May I suggest this alternative API?
Extend the SetProperties rule to take an optional hashmap that it scans
trying to use introspection, ie:

in code:
   HashMap x = new HashMap();
   x.put("prop-name", "method-name");
   digester.addSetProperties(pattern, hashMap);

in xml format (ie using xml-rules):
  <pattern value="some-pattern">
    <create-object-rule class="foo"/>
      <property-mapping attribute="some-attr" method="some-method"/>

This shouldn't break any existing code or xmlrules..

Hope this isn't too far off the beam..


-----Original Message-----
From: [] 
Sent: Thursday, May 09, 2002 12:58 AM
To: Jakarta Commons Developers List
Subject: Re: Digester:

Thanks for the feedback. See intermixed comments.

Quoting "Craig R. McClanahan" <>:

> > For instance, if I've got an element:
> >
> > <proc name="shutdown" proc-type="admin"/>
> >
> > and a bean with a procedureType property, how can I get the value of
> the
> > proc-type attribute into the procedureType property?
> >
> > I've gone ahead and written my own rule to handle it, but it seems
> like
> > such a common occurrence that I must have missed something. Thanks 
> > for any pointers.
> >

[rest of discussion removed]

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message