Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 91782 invoked by uid 500); 3 Sep 2001 10:27:47 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 91773 invoked by uid 500); 3 Sep 2001 10:27:47 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 3 Sep 2001 10:25:52 -0000 Message-ID: <20010903102552.54706.qmail@icarus.apache.org> From: mman@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/org/apache/cocoon/acting AbstractValidatorAction.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mman 01/09/03 03:25:52 Modified: src/org/apache/cocoon/acting AbstractValidatorAction.java Log: 'nullable' and 'default' attributes specified as follows now override the globale values specified by global parameter description Revision Changes Path 1.9 +34 -16 xml-cocoon2/src/org/apache/cocoon/acting/AbstractValidatorAction.java Index: AbstractValidatorAction.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/acting/AbstractValidatorAction.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- AbstractValidatorAction.java 2001/08/28 18:14:30 1.8 +++ AbstractValidatorAction.java 2001/09/03 10:25:52 1.9 @@ -1,4 +1,4 @@ -// $Id: AbstractValidatorAction.java,v 1.8 2001/08/28 18:14:30 mman Exp $ +// $Id: AbstractValidatorAction.java,v 1.9 2001/09/03 10:25:52 mman Exp $ package org.apache.cocoon.acting; import org.apache.avalon.framework.configuration.Configurable; @@ -97,7 +97,7 @@ * * @author Martin Man <Martin.Man@seznam.cz> * @author Christian Haul -* @version CVS $Revision: 1.8 $ $Date: 2001/08/28 18:14:30 $ +* @version CVS $Revision: 1.9 $ $Date: 2001/09/03 10:25:52 $ */ public abstract class AbstractValidatorAction extends AbstractComplementaryConfigurableAction @@ -174,8 +174,8 @@ Configuration conf, Map params, boolean is_string) { Object param = params.get (name); String value = null; - String dflt = getDefault (conf); - boolean nullable = getNullable (conf); + String dflt = getDefault (conf, constraints); + boolean nullable = getNullable (conf, constraints); getLogger().debug ("VALIDATOR: validating string parameter " + name + " (encoded in a string: " + is_string + ")"); @@ -277,11 +277,11 @@ private ValidatorActionHelper validateLong (String name, Configuration constraints, Configuration conf, Map params, boolean is_string) { Object param = params.get (name); - boolean nullable = getNullable(conf); + boolean nullable = getNullable (conf, constraints); Long value = null; Long dflt = null; { - String tmp = getDefault(conf); + String tmp = getDefault (conf, constraints); if ( tmp != null ) dflt = Long.decode(tmp); } @@ -371,11 +371,11 @@ private ValidatorActionHelper validateDouble (String name, Configuration constraints, Configuration conf, Map params, boolean is_string) { Object param = params.get (name); - boolean nullable = getNullable(conf); + boolean nullable = getNullable (conf, constraints); Double value = null; Double dflt = null; { - String tmp = getDefault(conf); + String tmp = getDefault (conf, constraints); if ( tmp!=null ) dflt = Double.valueOf(tmp); } @@ -542,32 +542,50 @@ } /** - * Returns the value of 'nullable' attribute from given configuration. + * Returns the value of 'nullable' attribute from given configuration or + * from given constraints, value present in constrints takes precedence, + * false when attribute is not present in either of them. */ - private boolean getNullable (Configuration conf) { + private boolean getNullable (Configuration conf, Configuration cons) { /* check nullability */ try { - String tmp = conf.getAttribute ("nullable", "no"); + String tmp = cons.getAttribute ("nullable", "no"); if ("yes".equals (tmp) || "true".equals (tmp)) { return true; } } catch (Exception e) { + try { + String tmp = conf.getAttribute ("nullable", "no"); + if ("yes".equals (tmp) || "true".equals (tmp)) { + return true; + } + } catch (Exception e1) { + } } return false; } /** - * Returns the default value from given configuration. + * Returns the default value from given configuration or constraints. + * Value present in constraints takes precedence, null is returned when no + * default attribute is present in eiher of them. */ - private String getDefault (Configuration conf) { + private String getDefault (Configuration conf, Configuration cons) { String dflt = null; try { - dflt = conf.getAttribute ("default", ""); + dflt = cons.getAttribute ("default", ""); if ("".equals (dflt.trim ())) { return null; } } catch (Exception e) { - return null; + try { + dflt = conf.getAttribute ("default", ""); + if ("".equals (dflt.trim ())) { + return null; + } + } catch (Exception e1) { + return null; + } } return dflt; } @@ -627,5 +645,5 @@ } -// $Id: AbstractValidatorAction.java,v 1.8 2001/08/28 18:14:30 mman Exp $ +// $Id: AbstractValidatorAction.java,v 1.9 2001/09/03 10:25:52 mman Exp $ // vim: set et ts=4 sw=4: ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org