You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by se...@apache.org on 2003/10/01 06:35:11 UTC
cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model BooleanField.java DoubleField.java LongField.java FloatField.java ShortField.java IntegerField.java Field.java
seade 2003/09/30 21:35:11
Modified: src/java/org/apache/turbine/services/intake/model Tag:
TURBINE_2_3_BRANCH BooleanField.java
DoubleField.java LongField.java FloatField.java
ShortField.java IntegerField.java Field.java
Log:
Ensure an NPE does not occur when emptyValue is used to set an object's primitive properties.
Revision Changes Path
No revision
No revision
1.12.2.1 +16 -1 jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/BooleanField.java
Index: BooleanField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/BooleanField.java,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -r1.12 -r1.12.2.1
--- BooleanField.java 28 Jul 2003 16:47:50 -0000 1.12
+++ BooleanField.java 1 Oct 2003 04:35:10 -0000 1.12.2.1
@@ -116,6 +116,21 @@
}
/**
+ * Provides access to emptyValue such that the value returned will be
+ * acceptable as an argument parameter to Method.invoke. Subclasses
+ * that deal with primitive types should ensure that they return an
+ * appropriate value wrapped in the object wrapper class for the
+ * primitive type.
+ *
+ * @return the value to use when the field is empty or an Object that
+ * wraps the empty value for primitive types.
+ */
+ Object getSafeEmptyValue()
+ {
+ return (null == getEmptyValue()) ? Boolean.FALSE : getEmptyValue();
+ }
+
+ /**
* A suitable validator.
*
* @return class name of the validator
1.7.2.1 +16 -1 jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/DoubleField.java
Index: DoubleField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/DoubleField.java,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- DoubleField.java 18 Jul 2003 08:32:30 -0000 1.7
+++ DoubleField.java 1 Oct 2003 04:35:10 -0000 1.7.2.1
@@ -120,6 +120,21 @@
}
/**
+ * Provides access to emptyValue such that the value returned will be
+ * acceptable as an argument parameter to Method.invoke. Subclasses
+ * that deal with primitive types should ensure that they return an
+ * appropriate value wrapped in the object wrapper class for the
+ * primitive type.
+ *
+ * @return the value to use when the field is empty or an Object that
+ * wraps the empty value for primitive types.
+ */
+ Object getSafeEmptyValue()
+ {
+ return (null == getEmptyValue()) ? new Double(0.0) : getEmptyValue();
+ }
+
+ /**
* A suitable validator.
*
* @return A suitable validator
1.3.2.1 +16 -1 jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/LongField.java
Index: LongField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/LongField.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- LongField.java 18 Jul 2003 08:32:30 -0000 1.3
+++ LongField.java 1 Oct 2003 04:35:10 -0000 1.3.2.1
@@ -122,6 +122,21 @@
}
/**
+ * Provides access to emptyValue such that the value returned will be
+ * acceptable as an argument parameter to Method.invoke. Subclasses
+ * that deal with primitive types should ensure that they return an
+ * appropriate value wrapped in the object wrapper class for the
+ * primitive type.
+ *
+ * @return the value to use when the field is empty or an Object that
+ * wraps the empty value for primitive types.
+ */
+ Object getSafeEmptyValue()
+ {
+ return (null == getEmptyValue()) ? new Long(0l) : getEmptyValue();
+ }
+
+ /**
* A suitable validator.
*
* @return A suitable validator
1.9.2.1 +16 -1 jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/FloatField.java
Index: FloatField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/FloatField.java,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- FloatField.java 18 Jul 2003 08:32:30 -0000 1.9
+++ FloatField.java 1 Oct 2003 04:35:10 -0000 1.9.2.1
@@ -124,6 +124,21 @@
}
/**
+ * Provides access to emptyValue such that the value returned will be
+ * acceptable as an argument parameter to Method.invoke. Subclasses
+ * that deal with primitive types should ensure that they return an
+ * appropriate value wrapped in the object wrapper class for the
+ * primitive type.
+ *
+ * @return the value to use when the field is empty or an Object that
+ * wraps the empty value for primitive types.
+ */
+ Object getSafeEmptyValue()
+ {
+ return (null == getEmptyValue()) ? new Float(0.0) : getEmptyValue();
+ }
+
+ /**
* A suitable validator.
*
* @return A suitable validator
1.3.2.1 +17 -1 jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/ShortField.java
Index: ShortField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/ShortField.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- ShortField.java 18 Jul 2003 08:32:30 -0000 1.3
+++ ShortField.java 1 Oct 2003 04:35:10 -0000 1.3.2.1
@@ -122,6 +122,22 @@
}
/**
+ * Provides access to emptyValue such that the value returned will be
+ * acceptable as an argument parameter to Method.invoke. Subclasses
+ * that deal with primitive types should ensure that they return an
+ * appropriate value wrapped in the object wrapper class for the
+ * primitive type.
+ *
+ * @return the value to use when the field is empty or an Object that
+ * wraps the empty value for primitive types.
+ */
+ Object getSafeEmptyValue()
+ {
+ return (null == getEmptyValue())
+ ? new Short((short) 0) : getEmptyValue();
+ }
+
+ /**
* A suitable validator.
*
* @return A suitable validator
1.10.2.1 +16 -1 jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/IntegerField.java
Index: IntegerField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/IntegerField.java,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- IntegerField.java 18 Jul 2003 08:32:30 -0000 1.10
+++ IntegerField.java 1 Oct 2003 04:35:10 -0000 1.10.2.1
@@ -121,6 +121,21 @@
}
/**
+ * Provides access to emptyValue such that the value returned will be
+ * acceptable as an argument parameter to Method.invoke. Subclasses
+ * that deal with primitive types should ensure that they return an
+ * appropriate value wrapped in the object wrapper class for the
+ * primitive type.
+ *
+ * @return the value to use when the field is empty or an Object that
+ * wraps the empty value for primitive types.
+ */
+ Object getSafeEmptyValue()
+ {
+ return (null == getEmptyValue()) ? new Integer(0) : getEmptyValue();
+ }
+
+ /**
* A suitable validator.
*
* @return A suitable validator
1.15.2.5 +17 -2 jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/Field.java
Index: Field.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/intake/model/Field.java,v
retrieving revision 1.15.2.4
retrieving revision 1.15.2.5
diff -u -r1.15.2.4 -r1.15.2.5
--- Field.java 1 Oct 2003 00:25:19 -0000 1.15.2.4
+++ Field.java 1 Oct 2003 04:35:10 -0000 1.15.2.5
@@ -899,7 +899,7 @@
}
else
{
- valArray[0] = getEmptyValue();
+ valArray[0] = getSafeEmptyValue();
if (isDebugEnabled)
{
log.debug(name + ": Property is not set, using emptyValue " + valArray[0]);
@@ -966,6 +966,21 @@
public Object getEmptyValue()
{
return emptyValue;
+ }
+
+ /**
+ * Provides access to emptyValue such that the value returned will be
+ * acceptable as an argument parameter to Method.invoke. Subclasses
+ * that deal with primitive types should ensure that they return an
+ * appropriate value wrapped in the object wrapper class for the
+ * primitive type.
+ *
+ * @return the value to use when the field is empty or an Object that
+ * wraps the empty value for primitive types.
+ */
+ Object getSafeEmptyValue()
+ {
+ return getEmptyValue();
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org