Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 47097 invoked from network); 8 Jun 2003 06:03:19 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 8 Jun 2003 06:03:19 -0000 Received: (qmail 25656 invoked by uid 97); 8 Jun 2003 06:05:44 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 25648 invoked from network); 8 Jun 2003 06:05:44 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 8 Jun 2003 06:05:44 -0000 Received: (qmail 46889 invoked by uid 500); 8 Jun 2003 06:03:18 -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 46875 invoked by uid 500); 8 Jun 2003 06:03:17 -0000 Received: (qmail 46872 invoked from network); 8 Jun 2003 06:03:17 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 8 Jun 2003 06:03:17 -0000 Received: (qmail 73613 invoked by uid 1581); 8 Jun 2003 06:03:16 -0000 Date: 8 Jun 2003 06:03:16 -0000 Message-ID: <20030608060316.73612.qmail@icarus.apache.org> From: dgraham@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator Field.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N dgraham 2003/06/07 23:03:16 Modified: validator/src/share/org/apache/commons/validator Field.java Log: The new getArg(String, int) method did not meet the contract of the older getArg0(String) method. When the Arg for the given key is not found, it should try to return the default Arg at that position. PR# 20571 Revision Changes Path 1.18 +22 -9 jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java Index: Field.java =================================================================== RCS file: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- Field.java 8 Jun 2003 05:29:27 -0000 1.17 +++ Field.java 8 Jun 2003 06:03:16 -0000 1.18 @@ -331,20 +331,33 @@ /** * Gets the default Arg object at the given position. + * @return The default Arg or null if not found. */ public Arg getArg(int position) { return this.getArg(DEFAULT_ARG, position); } /** - * Gets the default Arg object at the given position. + * Gets the default Arg object at the given position. If the key + * finds a null value then the default value will try to be retrieved. + * @param key The name the Arg is stored under. If not found, the default Arg for + * the given position (if any) will be retrieved. + * @param position The Arg number to find. + * @return The Arg with the given name and position or null if not found. */ public Arg getArg(String key, int position) { - if (position >= this.args.length) { - return null; - } + if ((position >= this.args.length) || (this.args[position] == null)) { + return null; + } - return (args[position] == null) ? null : (Arg) args[position].get(key); + Arg arg = (Arg) args[position].get(key); + + // Didn't find default arg so exit, otherwise we would get into infinite recursion + if ((arg == null) && key.equals(DEFAULT_ARG)) { + return null; + } + + return (arg == null) ? this.getArg(position) : arg; } /** --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org