jvanzyl 01/08/25 08:20:59
Modified: digester/src/java/org/apache/commons/digester
CallMethodRule.java
Log:
- added a simple condition to end() where the method specified with
addCallMethod() is not invoked when there is only a single parameter
and it is null. This handles the case where the parameter is an attribute
that is not actually defined in block currently being parsed.
Craig I am not entirely sure if this handles the case where the parameter
is taken from bodyText, but the testbed passes and if you could look at
what I did or suggest another course of action I would be happy to continue
exploring the digester classes.
This fixes the problem I have where a default value in a bean is set and
should only be overriden when the specified attribute actually has a
value.
Revision Changes Path
1.8 +13 -5
jakarta-commons/digester/src/java/org/apache/commons/digester/CallMethodRule.java
Index: CallMethodRule.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/CallMethodRule.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CallMethodRule.java 2001/08/20 19:18:42 1.7
+++ CallMethodRule.java 2001/08/25 15:20:59 1.8
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/CallMethodRule.java,v
1.7 2001/08/20 19:18:42 craigmcc Exp $
- * $Revision: 1.7 $
- * $Date: 2001/08/20 19:18:42 $
+ * $Header:
/home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/CallMethodRule.java,v
1.8 2001/08/25 15:20:59 jvanzyl Exp $
+ * $Revision: 1.8 $
+ * $Date: 2001/08/25 15:20:59 $
*
* ====================================================================
*
@@ -77,7 +77,7 @@
*
* @author Craig McClanahan
* @author Scott Sanders
- * @version $Revision: 1.7 $ $Date: 2001/08/20 19:18:42 $
+ * @version $Revision: 1.8 $ $Date: 2001/08/25 15:20:59 $
*/
public class CallMethodRule extends Rule {
@@ -243,8 +243,16 @@
// Retrieve or construct the parameter values array
String parameters[] = null;
- if (paramCount > 0)
+ if (paramCount > 0) {
parameters = (String[]) digester.popParams();
+
+ // In the case where the parameter for the method
+ // is taken from an attribute, and that attribute
+ // isn't actually defined in the source XML file.
+ if (paramCount == 1 && parameters[0] == null) {
+ return;
+ }
+ }
else {
parameters = new String[1];
parameters[0] = bodyText;