commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject [digester] Enhancing CallMethodRule to take target offset
Date Wed, 11 Feb 2004 22:56:05 GMT

As discussed on the user list, there appears to be a need to make calls
on objects other than the top-of-stack in a manner more flexible than
the limited SetNextRule and SetRootRule.

Attached is a patch which adds a "targetOffset" attribute to the
CallMethodRule to indicate which object on the digester stack gets
invoked. The default value for the offset is 0, which is the old
behaviour for CallMethodRule (invoke method on top object).

If this is ok, I can commit this myself [first use of new apache commit
rights - yay!]

(a) the test case uses SetNestedPropertiesRule. When factory methods for
this new rule were added to Digester, the main usage (no constructor
params) was omitted, so attached is a minor patch to fix this.

(b) several new constructors were added to CallMethodRule each taking an
int targetOffset as a first param. Selecting the target seems the
*first* thing to do, hence makes sense to me to make it the first

(c) In CallMethodRule, if target object for call is found to be null, a
deliberate exception with a useful message is now thrown rather than
throwing a NullPointerException. I used a SAXException as I couldn't see
anything more appropriate. Alternate suggestions welcome.

(d) I haven't added factory methods on Digester for the new
CallMethodRule constructors. This usage isn't wildly common, so I'm not
sure the factory methods are really needed. We can always add them later



View raw message