Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 92357 invoked from network); 6 May 2005 06:01:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 May 2005 06:01:30 -0000 Received: (qmail 80456 invoked by uid 500); 6 May 2005 06:03:41 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 80270 invoked by uid 500); 6 May 2005 06:03:39 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 80252 invoked by uid 500); 6 May 2005 06:03:39 -0000 Received: (qmail 80248 invoked by uid 99); 6 May 2005 06:03:39 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 05 May 2005 23:03:39 -0700 Received: (qmail 92284 invoked by uid 65534); 6 May 2005 06:01:06 -0000 Message-ID: <20050506060106.92283.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r168528 - /jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/digester/CallMethodRule.java Date: Fri, 06 May 2005 06:01:05 -0000 To: commons-cvs@jakarta.apache.org From: skitching@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: skitching Date: Thu May 5 23:01:05 2005 New Revision: 168528 URL: http://svn.apache.org/viewcvs?rev=3D168528&view=3Drev Log: Updated javadoc and comments to clarify behaviour when param values to be passed to the target method are null. Modified: jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/diges= ter/CallMethodRule.java Modified: jakarta/commons/proper/digester/trunk/src/java/org/apache/commons= /digester/CallMethodRule.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/digester/trunk/sr= c/java/org/apache/commons/digester/CallMethodRule.java?rev=3D168528&r1=3D16= 8527&r2=3D168528&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/diges= ter/CallMethodRule.java (original) +++ jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/diges= ter/CallMethodRule.java Thu May 5 23:01:05 2005 @@ -59,7 +59,14 @@ * attribute name but the attribute does not exist) then the method will * not be invoked. If a CallMethodRule is expecting more than one paramete= r, * then it is always invoked, regardless of whether the parameters were - * available or not (missing parameters are passed as null values).

+ * available or not; missing parameters are converted to the appropriate t= arget + * type by calling ConvertUtils.convert. Note that the default ConvertUtils + * converters for the String type returns a null when passed a null, meani= ng + * that CallMethodRule will passed null for all String parameters for which + * there is no parameter info available from the XML. However parameters of + * type Float and Integer will be passed a real object containing a zero v= alue + * as that is the output of the default ConvertUtils converters for those + * types when passed a null. See the beautils documentation for more info.=

* *

Note that when a constructor is used with paramCount=3D0, indicating= that * the body of the element is to be passed to the target method, an empty=20 @@ -485,20 +492,27 @@ } } =20 - // 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 + // In the case where the target method takes a single parameter + // and that parameter does not exist (the CallParamRule never + // executed or the CallParamRule was intended to set the param= eter + // from an attribute but the attribute wasn't present etc) then + // skip the method call. + // + // This is useful when a class has a "default" value that shou= ld + // only be overridden if data is present in the XML. I don't + // know why this should only apply to methods taking *one* + // parameter, but it always has been so we can't change it now. if (paramCount =3D=3D 1 && parameters[0] =3D=3D null) { return; } =20 } else if (paramTypes !=3D null && paramTypes.length !=3D 0) { + // Having paramCount =3D=3D 0 and paramTypes.length =3D=3D 1 i= ndicates + // that we have the special case where the target method has o= ne + // parameter being the body text of the current element. =20 - // 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 + // There is no body text included in the source XML file, + // so skip the method call if (bodyText =3D=3D null) { return; } @@ -510,6 +524,11 @@ paramTypes[0] =3D "abc".getClass(); } =20 + } else { + // When paramCount is zero and paramTypes.length is zero it + // means that we truly are calling a method with no parameters. + // Nothing special needs to be done here. + ; } =20 // Construct the parameter values array we will need --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org