mman 01/08/28 11:14:30
Modified: src/org/apache/cocoon/acting AbstractValidatorAction.java
Log:
nullable parameters are not tested against their constraints if they are null
or set to default value.
Revision Changes Path
1.8 +249 -240
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AbstractValidatorAction.java 2001/08/20 13:55:09 1.7
+++ AbstractValidatorAction.java 2001/08/28 18:14:30 1.8
@@ -1,4 +1,4 @@
-// $Id: AbstractValidatorAction.java,v 1.7 2001/08/20 13:55:09 dims Exp $
+// $Id: AbstractValidatorAction.java,v 1.8 2001/08/28 18:14:30 mman Exp $
package org.apache.cocoon.acting;
import org.apache.avalon.framework.configuration.Configurable;
@@ -20,44 +20,44 @@
*
* <pre>
* <root>
- * <parameter name="username" type="string" nullable="no"/>
- * <parameter name="role" type="string" nullable="no"/>
- * <parameter name="oldpassword" type="string" nullable="no"/>
- * <parameter name="newpassword" type="string" nullable="no"/>
- * <parameter name="renewpassword" type="string" nullable="no"/>
- * <parameter name="id" type="long" nullable="no"/>
- * <parameter name="sallary" type="double" nullable="no"/>
- * <parameter name="theme" type="string" nullable="yes"
default="dflt"/>
- * <constraint-set name="is-logged-in">
- * <validate name="username"/>
- * <validate name="role"/>
- * </constraint-set>
+* <parameter name="username" type="string" nullable="no"/>
+* <parameter name="role" type="string" nullable="no"/>
+* <parameter name="oldpassword" type="string" nullable="no"/>
+* <parameter name="newpassword" type="string" nullable="no"/>
+* <parameter name="renewpassword" type="string" nullable="no"/>
+* <parameter name="id" type="long" nullable="no"/>
+* <parameter name="sallary" type="double" nullable="no"/>
+* <parameter name="theme" type="string" nullable="yes"
default="dflt"/>
+* <constraint-set name="is-logged-in">
+* <validate name="username"/>
+* <validate name="role"/>
+* </constraint-set>
*
- * <constraint-set name="is-in-admin-role">
- * <validate name="username"/>
- * <validate name="role" equals-to="admin"/>
- * </constraint-set>
+* <constraint-set name="is-in-admin-role">
+* <validate name="username"/>
+* <validate name="role" equals-to="admin"/>
+* </constraint-set>
*
- * <constraint-set name="new-passwords-match">
- * <validate name="oldpassword"/>
- * <validate name="newpassword"/>
- * <validate name="renewpassword"
- * equals-to-param="newpass"/>
- * </constraint-set>
+* <constraint-set name="new-passwords-match">
+* <validate name="oldpassword"/>
+* <validate name="newpassword"/>
+* <validate name="renewpassword"
+* equals-to-param="newpass"/>
+* </constraint-set>
* </root>
* </pre>
*
* <h3>The types recognized by validator and their attributes</h3>
* <table border="1">
- * <tr>
- * <td><b>string</b></td><td>nullable="yes|no" default="str"</td>
- * </tr>
- * <tr>
- * <td><b>long</b></td><td>nullable="yes|no" default="123123"</td>
- * </tr>
- * <tr>
- * <td><b>double</b></td><td>nullable="yes|no" default="0.5"</td>
- * </tr>
+* <tr>
+* <td><b>string</b></td><td>nullable="yes|no" default="str"</td>
+* </tr>
+* <tr>
+* <td><b>long</b></td><td>nullable="yes|no" default="123123"</td>
+* </tr>
+* <tr>
+* <td><b>double</b></td><td>nullable="yes|no" default="0.5"</td>
+* </tr>
* </table>
* Default value takes place only when specified parameter is nullable and
* really is null or empty. Long numbers may be specified in decimal, hex or
@@ -66,39 +66,39 @@
* <h3>Constraints</h3>
* <table border="1">
* <tr>
- * <td>matches-regex</td><td>POSIX regular expression</td>
+* <td>matches-regex</td><td>POSIX regular expression</td>
* </tr>
* <tr>
- * <td>min-len</td><td>positive integer</td>
+* <td>min-len</td><td>positive integer</td>
* </tr>
* <tr>
- * <td>max-len</td><td>positive integer</td>
+* <td>max-len</td><td>positive integer</td>
* </tr>
* <tr>
- * <td>min</td><td>Double / Long</td>
+* <td>min</td><td>Double / Long</td>
* </tr>
* <tr>
- * <td>max</td><td>Double / Long</td>
+* <td>max</td><td>Double / Long</td>
* </tr>
* </table>
- * Constraints can be defined globally for a parameter and can be overridden
- * by redefinition in a constraint-set. Thus if e.g. a database field can take
- * at maximum 200 character, this property can be set globally.
- *
- *
- * <h3>The attributes recognized in "constraint-set"</h3>
- * <table>
- * <tr>
- * <td>equals-to-param</td><td>parameter name</td>
- * </tr>
- * <tr>
- * <td>equals-to</td><td>string constant</td>
- * </tr>
- * </table>
- * @author Martin Man <[EMAIL PROTECTED]>
- * @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
- * @version CVS $Revision: 1.7 $ $Date: 2001/08/20 13:55:09 $
- */
+* Constraints can be defined globally for a parameter and can be overridden
+* by redefinition in a constraint-set. Thus if e.g. a database field can take
+* at maximum 200 character, this property can be set globally.
+*
+*
+* <h3>The attributes recognized in "constraint-set"</h3>
+* <table>
+* <tr>
+* <td>equals-to-param</td><td>parameter name</td>
+* </tr>
+* <tr>
+* <td>equals-to</td><td>string constant</td>
+* </tr>
+* </table>
+* @author Martin Man <[EMAIL PROTECTED]>
+* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
+* @version CVS $Revision: 1.8 $ $Date: 2001/08/28 18:14:30 $
+*/
public abstract class AbstractValidatorAction
extends AbstractComplementaryConfigurableAction
implements Configurable
@@ -165,7 +165,7 @@
}
return null;
}
-
+
/**
* Validates nullability and default value for given parameter. If given
* constraints are not null they are validated as well.
@@ -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);
+ boolean nullable = getNullable (conf);
getLogger().debug ("VALIDATOR: validating string parameter "
+ name + " (encoded in a string: " + is_string + ")");
@@ -183,23 +183,26 @@
if (value == null) {
getLogger().debug ("VALIDATOR: string parameter "
+ name + " is null");
- if ( !nullable ){
- return new ValidatorActionHelper ( value,
ValidatorActionResult.ISNULL );}
- else
- value = dflt;
+ if ( !nullable ) {
+ return new ValidatorActionHelper ( value,
+ ValidatorActionResult.ISNULL );
+ } else {
+ value = dflt;
+ return new ValidatorActionHelper (value);
+ }
}
if (constraints != null) {
String eq = constraints.getAttribute ("equals-to", "");
String eqp = constraints.getAttribute ("equals-to-param", "");
- String regex = conf.getAttribute ("matches-regex", "");
- regex = constraints.getAttribute ( "matches-regex", regex);
+ String regex = conf.getAttribute ("matches-regex", "");
+ regex = constraints.getAttribute ( "matches-regex", regex);
- Long minlen = getAttributeAsLong (conf, "min-len", null);
- minlen = getAttributeAsLong (constraints, "min-len", minlen);
+ Long minlen = getAttributeAsLong (conf, "min-len", null);
+ minlen = getAttributeAsLong (constraints, "min-len", minlen);
- Long maxlen = getAttributeAsLong (conf, "max-len", null);
- maxlen = getAttributeAsLong (constraints, "max-len", maxlen);
+ Long maxlen = getAttributeAsLong (conf, "max-len", null);
+ maxlen = getAttributeAsLong (constraints, "max-len", maxlen);
// Validate whether param is equal to constant
if (!"".equals (eq)) {
@@ -207,7 +210,7 @@
+ name + " should be equal to " + eq);
if (!value.equals (eq)) {
getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
}
}
@@ -219,49 +222,49 @@
+ name + " should be equal to " + params.get (eqp));
if (!value.equals (params.get (eqp))) {
getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ }
+ }
+
+ // Validate whether param length is at least of minimum length
+ if (minlen != null) {
+ getLogger().debug ("VALIDATOR: string parameter "
+ + name + " should be at least " + minlen + " characters
long");
+ if ( value.length() < minlen.longValue() ) {
+ getLogger().debug ("VALIDATOR: and it is shorter (" +
+ value.length() + ")" );
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOSMALL);
+ }
+ }
+
+ // Validate whether param length is at most of maximum length
+ if (maxlen != null) {
+ getLogger().debug ("VALIDATOR: string parameter "
+ + name + " should be at most " + maxlen + " characters
long");
+
+ if ( value.length() > maxlen.longValue() ) {
+ getLogger().debug ("VALIDATOR: and it is longer (" +
+ value.length() + ")" );
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOLARGE);
+ }
+ }
+
+ // Validate wheter param matches regular expression
+ if (!"".equals (regex)) {
+ getLogger().debug ("VALIDATOR: string parameter " + name +
+ " should match regexp \"" + regex + "\"" );
+ try {
+ RE r = new RE ( regex );
+ if ( !r.match(value) ) {
+ getLogger().debug("VALIDATOR: and it does not match");
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ };
+ } catch ( RESyntaxException rese ) {
+ getLogger().error ("VALIDATOR: string parameter " + name +
+ " regex error ", rese);
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
}
}
-
- // Validate whether param length is at least of minimum length
- if (minlen != null) {
- getLogger().debug ("VALIDATOR: string parameter "
- + name + " should be at least " + minlen + " characters long");
- if ( value.length() < minlen.longValue() ) {
- getLogger().debug ("VALIDATOR: and it is shorter (" +
- value.length() + ")" );
- return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOSMALL);
- }
- }
-
- // Validate whether param length is at most of maximum length
- if (maxlen != null) {
- getLogger().debug ("VALIDATOR: string parameter "
- + name + " should be at most " + maxlen + "
characters long");
-
- if ( value.length() > maxlen.longValue() ) {
- getLogger().debug ("VALIDATOR: and it is longer (" +
- value.length() + ")" );
- return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOLARGE);
- }
- }
-
- // Validate wheter param matches regular expression
- if (!"".equals (regex)) {
- getLogger().debug ("VALIDATOR: string parameter " + name +
- " should match regexp \"" + regex + "\"" );
- try {
- RE r = new RE ( regex );
- if ( !r.match(value) ) {
- getLogger().debug("VALIDATOR: and it does not match");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
- };
- } catch ( RESyntaxException rese ) {
- getLogger().error ("VALIDATOR: string parameter " + name +
- " regex error ", rese);
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
- }
- }
}
return new ValidatorActionHelper(value);
@@ -274,13 +277,13 @@
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);
Long value = null;
- Long dflt = null;
- {
- String tmp = getDefault(conf);
- if ( tmp != null ) dflt = Long.decode(tmp);
- }
+ Long dflt = null;
+ {
+ String tmp = getDefault(conf);
+ if ( tmp != null ) dflt = Long.decode(tmp);
+ }
getLogger().debug ("VALIDATOR: validating long parameter "
+ name + " (encoded in a string: " + is_string + ")");
@@ -288,30 +291,33 @@
if (value == null) {
getLogger().debug ("VALIDATOR: long parameter "
+ name + " is null");
- if (!nullable)
- return new ValidatorActionHelper ( value,
ValidatorActionResult.ISNULL);
- else
- value=dflt;
+ if (!nullable) {
+ return new ValidatorActionHelper ( value,
+ ValidatorActionResult.ISNULL);
+ } else {
+ value = dflt;
+ return new ValidatorActionHelper (value);
+ }
}
if (constraints != null) {
Long eq = getAttributeAsLong (constraints, "equals-to", null);
String eqp = constraints.getAttribute ("equals-to-param", "");
- Long min = getAttributeAsLong (conf, "min", null);
- min = getAttributeAsLong ( constraints, "min", min);
+ Long min = getAttributeAsLong (conf, "min", null);
+ min = getAttributeAsLong ( constraints, "min", min);
- Long max = getAttributeAsLong (conf, "max",null);
- max = getAttributeAsLong (constraints, "max", max);
+ Long max = getAttributeAsLong (conf, "max",null);
+ max = getAttributeAsLong (constraints, "max", max);
// Validate whether param is equal to constant
if (eq != null) {
getLogger().debug ("VALIDATOR: long parameter "
+ name + " should be equal to " + eq);
- if (!value.equals(eq)) {
- getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
- }
+ if (!value.equals(eq)) {
+ getLogger().debug ("VALIDATOR: and it is not");
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ }
}
// Validate whether param is equal to another param
@@ -320,40 +326,40 @@
if (!"".equals (eqp)) {
getLogger().debug ("VALIDATOR: long parameter "
+ name + " should be equal to " + params.get (eqp));
- // Request parameter is stored as string.
- // Need to convert it beforehand.
- try {
- Long _eqp = new Long ( Long.parseLong((String) params.get(eqp)) );
- if (!value.equals (_eqp)) {
- getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
- }
- } catch ( NumberFormatException nfe ) {
- getLogger().debug("VALIDATOR: long parameter "+ name +": "+eqp+"
is no long", nfe);
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
- }
- }
-
- // Validate wheter param is at least min
- if (min != null) {
- getLogger().debug ("VALIDATOR: long parameter "
- + name + " should be at least " + min);
-
- if (min.compareTo(value)>0) {
- getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOSMALL);
- }
- }
-
- // Validate wheter param is at most max
- if (max != null) {
- getLogger().debug ("VALIDATOR: long parameter "
- + name + " should be at most " + max);
- if (max.compareTo(value)<0) {
- getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOLARGE);
- }
- }
+ // Request parameter is stored as string.
+ // Need to convert it beforehand.
+ try {
+ Long _eqp = new Long ( Long.parseLong((String) params.get(eqp))
);
+ if (!value.equals (_eqp)) {
+ getLogger().debug ("VALIDATOR: and it is not");
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ }
+ } catch ( NumberFormatException nfe ) {
+ getLogger().debug("VALIDATOR: long parameter "+ name +":
"+eqp+" is no long", nfe);
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ }
+ }
+
+ // Validate wheter param is at least min
+ if (min != null) {
+ getLogger().debug ("VALIDATOR: long parameter "
+ + name + " should be at least " + min);
+
+ if (min.compareTo(value)>0) {
+ getLogger().debug ("VALIDATOR: and it is not");
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOSMALL);
+ }
+ }
+
+ // Validate wheter param is at most max
+ if (max != null) {
+ getLogger().debug ("VALIDATOR: long parameter "
+ + name + " should be at most " + max);
+ if (max.compareTo(value)<0) {
+ getLogger().debug ("VALIDATOR: and it is not");
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOLARGE);
+ }
+ }
}
return new ValidatorActionHelper(value);
}
@@ -365,13 +371,13 @@
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);
Double value = null;
- Double dflt = null;
- {
- String tmp = getDefault(conf);
- if ( tmp!=null ) dflt = Double.valueOf(tmp);
- }
+ Double dflt = null;
+ {
+ String tmp = getDefault(conf);
+ if ( tmp!=null ) dflt = Double.valueOf(tmp);
+ }
getLogger().debug ("VALIDATOR: validating double parameter "
+ name + " (encoded in a string: " + is_string + ")");
@@ -379,30 +385,33 @@
if (value == null) {
getLogger().debug ("VALIDATOR: double parameter "
+ name + " is null");
- if (!nullable)
- return new ValidatorActionHelper ( value,
ValidatorActionResult.ISNULL);
- else
- value = dflt;
+ if (!nullable) {
+ return new ValidatorActionHelper ( value,
+ ValidatorActionResult.ISNULL);
+ } else {
+ value = dflt;
+ return new ValidatorActionHelper (value);
+ }
}
if (constraints != null) {
Double eq = getAttributeAsDouble (constraints, "equals-to", null);
String eqp = constraints.getAttribute ("equals-to-param", "");
- Double min = getAttributeAsDouble (conf, "min", null);
- min = getAttributeAsDouble ( constraints, "min", min);
+ Double min = getAttributeAsDouble (conf, "min", null);
+ min = getAttributeAsDouble ( constraints, "min", min);
- Double max = getAttributeAsDouble (conf, "max", null);
- max = getAttributeAsDouble (constraints, "max", max);
+ Double max = getAttributeAsDouble (conf, "max", null);
+ max = getAttributeAsDouble (constraints, "max", max);
// Validate whether param is equal to constant
if (eq != null) {
getLogger().debug ("VALIDATOR: Double parameter "
+ name + " should be equal to " + eq);
- if (!value.equals (eq)) {
- getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
- }
+ if (!value.equals (eq)) {
+ getLogger().debug ("VALIDATOR: and it is not");
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ }
}
// Validate whether param is equal to another param
@@ -411,39 +420,39 @@
if (!"".equals (eqp)) {
getLogger().debug ("VALIDATOR: Double parameter "
+ name + " should be equal to " + params.get (eqp));
- // Request parameter is stored as string.
- // Need to convert it beforehand.
- try {
- Double _eqp = new Double ( Double.parseDouble((String)
params.get(eqp)));
- if (!value.equals (_eqp)) {
- getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
- }
- } catch ( NumberFormatException nfe ) {
- getLogger().debug("VALIDATOR: Double parameter "+ name +": "+eqp+"
is no double", nfe);
- return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
- }
- }
-
- // Validate wheter param is at least min
- if (min != null) {
- getLogger().debug ("VALIDATOR: Double parameter "
- + name + " should be at least " + min);
- if (0>value.compareTo(min)) {
- getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOSMALL);
- }
- }
-
- // Validate wheter param is at most max
- if (max != null) {
- getLogger().debug ("VALIDATOR: Double parameter "
- + name + " should be at most " + max);
- if (0<value.compareTo(max)) {
- getLogger().debug ("VALIDATOR: and it is not");
- return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOLARGE);
- }
- }
+ // Request parameter is stored as string.
+ // Need to convert it beforehand.
+ try {
+ Double _eqp = new Double ( Double.parseDouble((String)
params.get(eqp)));
+ if (!value.equals (_eqp)) {
+ getLogger().debug ("VALIDATOR: and it is not");
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ }
+ } catch ( NumberFormatException nfe ) {
+ getLogger().debug("VALIDATOR: Double parameter "+ name +":
"+eqp+" is no double", nfe);
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.NOMATCH);
+ }
+ }
+
+ // Validate wheter param is at least min
+ if (min != null) {
+ getLogger().debug ("VALIDATOR: Double parameter "
+ + name + " should be at least " + min);
+ if (0>value.compareTo(min)) {
+ getLogger().debug ("VALIDATOR: and it is not");
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOSMALL);
+ }
+ }
+
+ // Validate wheter param is at most max
+ if (max != null) {
+ getLogger().debug ("VALIDATOR: Double parameter "
+ + name + " should be at most " + max);
+ if (0<value.compareTo(max)) {
+ getLogger().debug ("VALIDATOR: and it is not");
+ return new ValidatorActionHelper ( value,
ValidatorActionResult.TOOLARGE);
+ }
+ }
}
return new ValidatorActionHelper(value);
}
@@ -475,7 +484,7 @@
value = null;
}
}
- return value;
+ return value;
}
/**
@@ -505,7 +514,7 @@
value = null;
}
}
- return value;
+ return value;
}
/**
@@ -519,7 +528,7 @@
private String getStringValue (String name,
Configuration conf, Object param, boolean is_string) {
String value = null;
-
+
/* convert param to string */
try {
value = (String)param;
@@ -529,7 +538,7 @@
} catch (Exception e) {
value = null;
}
- return value;
+ return value;
}
/**
@@ -551,7 +560,7 @@
* Returns the default value from given configuration.
*/
private String getDefault (Configuration conf) {
- String dflt = null;
+ String dflt = null;
try {
dflt = conf.getAttribute ("default", "");
if ("".equals (dflt.trim ())) {
@@ -560,7 +569,7 @@
} catch (Exception e) {
return null;
}
- return dflt;
+ return dflt;
}
/**
@@ -578,13 +587,13 @@
* @see org.apache.avalon.Configuration.getParameterAsLong */
private Long getAttributeAsLong (Configuration conf, String name, Long dflt) {
- Long value = null;
- try {
- value = new Long(conf.getAttributeAsLong(name));
- } catch (ConfigurationException e) {
- value = dflt;
- }
- return value;
+ Long value = null;
+ try {
+ value = new Long(conf.getAttributeAsLong(name));
+ } catch (ConfigurationException e) {
+ value = dflt;
+ }
+ return value;
}
/**
@@ -601,22 +610,22 @@
*/
private Double getAttributeAsDouble (Configuration conf, String name, Double
dflt) {
- Double value = null;
- String tmp = null;
- try {
- tmp = conf.getAttribute(name);
- try {
- value = new Double ( Double.parseDouble(tmp) );
- } catch ( NumberFormatException nfe ) {
- value = null;
- }
- } catch (ConfigurationException e) {
- value = dflt;
- }
- return value;
+ Double value = null;
+ String tmp = null;
+ try {
+ tmp = conf.getAttribute(name);
+ try {
+ value = new Double ( Double.parseDouble(tmp) );
+ } catch ( NumberFormatException nfe ) {
+ value = null;
+ }
+ } catch (ConfigurationException e) {
+ value = dflt;
+ }
+ return value;
}
}
-// $Id: AbstractValidatorAction.java,v 1.7 2001/08/20 13:55:09 dims Exp $
+// $Id: AbstractValidatorAction.java,v 1.8 2001/08/28 18:14:30 mman Exp $
// vim: set et ts=4 sw=4:
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]