craigmcc 01/08/25 13:30:16
Modified: digester/src/java/org/apache/commons/digester
CallMethodRule.java
Log:
In CallMethodRule, skip the method call if the argument text is coming
from the body text, but there was no body text in the XML file. This is
consistent with the recent change to skip the call if the specified
attribute name was not included.
Also, for consistency with behavior elsewhere in Digester, trim leading
and trailing whitespace from the body text before using it as a parameter
value.
Revision Changes Path
1.9 +26 -14
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CallMethodRule.java 2001/08/25 15:20:59 1.8
+++ CallMethodRule.java 2001/08/25 20:30:16 1.9
@@ -1,7 +1,7 @@
/*
- * $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 $
+ * $Header:
/home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/CallMethodRule.java,v
1.9 2001/08/25 20:30:16 craigmcc Exp $
+ * $Revision: 1.9 $
+ * $Date: 2001/08/25 20:30:16 $
*
* ====================================================================
*
@@ -77,7 +77,7 @@
*
* @author Craig McClanahan
* @author Scott Sanders
- * @version $Revision: 1.8 $ $Date: 2001/08/25 15:20:59 $
+ * @version $Revision: 1.9 $ $Date: 2001/08/25 20:30:16 $
*/
public class CallMethodRule extends Rule {
@@ -231,7 +231,7 @@
public void body(String bodyText) throws Exception {
if (paramCount == 0)
- this.bodyText = bodyText;
+ this.bodyText = bodyText.trim();
}
@@ -244,22 +244,34 @@
// Retrieve or construct the parameter values array
String parameters[] = null;
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 = (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,
+ // skip the method call
+ if (paramCount == 1 && parameters[0] == null) {
+ return;
+ }
+
+ } else {
+
+ // In the case where the parameter for the method
+ // is taken from the body text, but there is no
+ // body text included in the source XML file,
+ // skip the method call
+ if (bodyText == null) {
+ return;
+ }
+
parameters = new String[1];
parameters[0] = bodyText;
if (paramTypes.length == 0) {
paramTypes = new Class[1];
paramTypes[0] = "abc".getClass();
}
+
}
// Construct the parameter values array we will need