Update of /var/cvs/src/org/mmbase/util
In directory james.mmbase.org:/tmp/cvs-serv19556
Modified Files:
Casting.java
Log Message:
MMB-1761. Needed to use 'itemDatatype' property of List datatypes
See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util
See also: http://www.mmbase.org/jira/browse/MMB-1761
Index: Casting.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/Casting.java,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -b -r1.122 -r1.123
--- Casting.java 8 Dec 2008 10:56:11 -0000 1.122
+++ Casting.java 29 Dec 2008 16:52:18 -0000 1.123
@@ -16,7 +16,7 @@
*
* @author Michiel Meeuwissen
* @since MMBase-1.6
- * @version $Id: Casting.java,v 1.122 2008/12/08 10:56:11 michiel Exp $
+ * @version $Id: Casting.java,v 1.123 2008/12/29 16:52:18 michiel Exp $
*/
import java.util.*;
@@ -29,6 +29,8 @@
import org.mmbase.bridge.util.NodeWrapper;
import org.mmbase.bridge.util.NodeMap;
import org.mmbase.bridge.util.MapNode;
+import org.mmbase.datatypes.DataType;
+import org.mmbase.datatypes.DataTypes;
import org.mmbase.util.transformers.CharTransformer;
import org.mmbase.util.logging.*;
import org.mmbase.util.xml.XMLWriter;
@@ -224,8 +226,10 @@
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
+ } else if (type.equals(org.mmbase.datatypes.DataType.class)) {
+ return (C) toDataType(value);
} else {
- log.error("Don't know how to convert to " + type);
+ log.error("Don't know how to convert to " + type, new
Exception());
if (value == null || "".equals(value)) {
// just to avoid the error
return null;
@@ -936,7 +940,7 @@
*/
static public BigDecimal toDecimal(Object i) {
if (i instanceof BigDecimal) {
- return ((BigDecimal) i).plus().stripTrailingZeros();
+ return (BigDecimal) i;
} else if (i instanceof CharSequence) {
try {
return new BigDecimal("" + i).stripTrailingZeros();
@@ -964,6 +968,18 @@
}
}
+ /**
+ * @since MMBase-1.9.1
+ */
+ static public DataType toDataType(Object o) {
+ if (o instanceof DataType) {
+ return (DataType) o;
+ } else {
+ return DataTypes.getDataType(toString(o));
+ }
+
+ }
+
/**
* Convert an object to a <code>Date</code>.
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs