Update of /var/cvs/src/org/mmbase/bridge/util
In directory james.mmbase.org:/tmp/cvs-serv1396

Modified Files:
        AbstractNode.java 
Log Message:
test-case for 'duration' was failing because 'null' in implicitely stored as 
-1, even if the field is not required. -1 is not a valid value for duration. 
This fixes that


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/bridge/util


Index: AbstractNode.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/bridge/util/AbstractNode.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- AbstractNode.java   17 Oct 2007 12:48:14 -0000      1.22
+++ AbstractNode.java   12 Sep 2008 11:15:26 -0000      1.23
@@ -31,7 +31,7 @@
  * here, to minimalize the implementation effort of fully implemented Nodes.
  *
  * @author Michiel Meeuwissen
- * @version $Id: AbstractNode.java,v 1.22 2007/10/17 12:48:14 michiel Exp $
+ * @version $Id: AbstractNode.java,v 1.23 2008/09/12 11:15:26 michiel Exp $
  * @see org.mmbase.bridge.Node
  * @since MMBase-1.8
  */
@@ -81,17 +81,33 @@
         if (value == null) {
             setValueWithoutProcess(fieldName, value);
         } else {
-            value = field.getDataType().cast(value, this, field);
-            switch(field.getDataType().getBaseType()) {
+            DataType dt = field.getDataType();
+            value = dt.cast(value, this, field);
+            if (value == null && dt instanceof 
org.mmbase.datatypes.NumberDataType) {
+                // null would otherwise be converted to -1, which makes little 
sense.
+                // but must happen because set<Numeric>Value methods cannot 
accept null.
+                setValueWithoutProcess(fieldName, value);
+                return;
+            }
+            switch(dt.getBaseType()) {
             case Field.TYPE_STRING:  setStringValue(fieldName, (String) 
value); break;
-            case Field.TYPE_INTEGER: setIntValue(fieldName, 
Casting.toInt(value)); break;
+            case Field.TYPE_INTEGER:
+                setIntValue(fieldName, Casting.toInt(value));
+                break;
             case Field.TYPE_BINARY:    {
                 long length = getSize(fieldName);
-                setInputStreamValue(fieldName, Casting.toInputStream(value), 
length); break;
+                setInputStreamValue(fieldName, Casting.toInputStream(value), 
length);
+                break;
             }
-            case Field.TYPE_FLOAT:   setFloatValue(fieldName, 
Casting.toFloat(value)); break;
-            case Field.TYPE_DOUBLE:  setDoubleValue(fieldName, 
Casting.toDouble(value)); break;
-            case Field.TYPE_LONG:    setLongValue(fieldName, 
Casting.toLong(value)); break;
+            case Field.TYPE_FLOAT:
+                setFloatValue(fieldName, Casting.toFloat(value));
+                break;
+            case Field.TYPE_DOUBLE:
+                setDoubleValue(fieldName, Casting.toDouble(value));
+                break;
+            case Field.TYPE_LONG:
+                setLongValue(fieldName, Casting.toLong(value));
+                break;
             case Field.TYPE_XML:     setXMLValue(fieldName, (Document) value); 
break;
             case Field.TYPE_NODE:    setNodeValue(fieldName, 
Casting.toNode(value, getCloud())); break;
             case Field.TYPE_DATETIME: setDateValue(fieldName, (Date) value); 
break;
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to