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 <code>Arg</code> 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 <code>Arg</code> object at the given position. + * Gets the default <code>Arg</code> object at the given position. If the key + * finds a <code>null</code> 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]