Update of /var/cvs/src/org/mmbase/datatypes
In directory james.mmbase.org:/tmp/cvs-serv6077

Modified Files:
        BasicDataType.java DataType.java NodeDataType.java 
        XmlDataType.java 
Log Message:
here and there some hackery occured because 'searching' sometimes needs another 
cast. Added it to the interface to fix it


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/datatypes


Index: BasicDataType.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/BasicDataType.java,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -b -r1.109 -r1.110
--- BasicDataType.java  28 Apr 2009 08:44:00 -0000      1.109
+++ BasicDataType.java  30 Apr 2009 10:15:46 -0000      1.110
@@ -40,7 +40,7 @@
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
  * @since  MMBase-1.8
- * @version $Id: BasicDataType.java,v 1.109 2009/04/28 08:44:00 michiel Exp $
+ * @version $Id: BasicDataType.java,v 1.110 2009/04/30 10:15:46 michiel Exp $
  */
 
 public class BasicDataType<C> extends AbstractDescriptor implements 
DataType<C>, Comparable<DataType<C>>, Descriptor {
@@ -592,6 +592,13 @@
         return requiredRestriction.validate(errors, value, node, field);
     }
 
+    /**
+     * @since MMBase-1.9.1
+     */
+    public Object castForSearch(final Object value, final Node node, final 
Field field) {
+        return cast(value, node, field);
+    }
+
     protected StringBuilder toStringBuilder() {
         StringBuilder buf = new StringBuilder();
         buf.append(getName() + " (" + getTypeAsClass() + (defaultValue != null 
? ":" + defaultValue : "") + ")");
@@ -1248,7 +1255,9 @@
                     }
                 }
 
+                if (log.isDebugEnabled()) {
                 log.debug("Checking '" + value + "'");
+                }
                 NodeManager nodeManager = field.getNodeManager();
                 Cloud cloud = nodeManager.getCloud();
                 if (cloud.getUser().getRank().getInt() < Rank.ADMIN_INT) {


Index: DataType.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/DataType.java,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- DataType.java       30 Apr 2009 09:33:00 -0000      1.75
+++ DataType.java       30 Apr 2009 10:15:46 -0000      1.76
@@ -33,7 +33,7 @@
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
  * @since  MMBase-1.8
- * @version $Id: DataType.java,v 1.75 2009/04/30 09:33:00 michiel Exp $
+ * @version $Id: DataType.java,v 1.76 2009/04/30 10:15:46 michiel Exp $
  * @param <C> Class this DataType
  */
 
@@ -164,6 +164,15 @@
     public <D> D preCast(D value, Node node, Field field);
     //public Object preCast(Object value, Node node, Field field);
 
+
+    /**
+     * Sometimes the the representation of the value is a bit different in the 
database, or has a
+     * different type. So when constraining a search on the value, casting is 
done by this. This may
+     * default to {...@link cast(Object, Node, Field}.
+     * @since MMBase-1.9.1
+     */
+    public Object castForSearch(Object value, Node node, Field field);
+
     /**
      * Returns the default value of this data type.
      * @return the default value


Index: NodeDataType.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/NodeDataType.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- NodeDataType.java   7 Jan 2009 17:54:19 -0000       1.34
+++ NodeDataType.java   30 Apr 2009 10:15:46 -0000      1.35
@@ -21,7 +21,7 @@
  *
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
- * @version $Id: NodeDataType.java,v 1.34 2009/01/07 17:54:19 michiel Exp $
+ * @version $Id: NodeDataType.java,v 1.35 2009/04/30 10:15:46 michiel Exp $
  * @since MMBase-1.8
  */
 public class NodeDataType extends BasicDataType<Node> {
@@ -70,6 +70,12 @@
         }
     }
 
+    @Override
+    public Integer castForSearch(final Object value, final Node node, final 
Field field) {
+        if (value == null) return -1;
+        return org.mmbase.util.Casting.toInteger(value);
+    }
+
     /**
      * Whether the Node of the value must exist
      *


Index: XmlDataType.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/XmlDataType.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- XmlDataType.java    7 Apr 2007 17:11:56 -0000       1.6
+++ XmlDataType.java    30 Apr 2009 10:15:46 -0000      1.7
@@ -8,13 +8,14 @@
 
 */
 package org.mmbase.datatypes;
+import org.mmbase.bridge.*;
 
 /**
  * The data associated with 'XML' values ({...@link org.w3c.dom.Document}). At 
the moment this class is
  * empty, but of course we forsee the possibility for  restrictions on 
doc-type.
  *
  * @author Michiel Meeuwissen
- * @version $Id: XmlDataType.java,v 1.6 2007/04/07 17:11:56 nklasens Exp $
+ * @version $Id: XmlDataType.java,v 1.7 2009/04/30 10:15:46 michiel Exp $
  * @since MMBase-1.8
  */
 public class XmlDataType extends AbstractLengthDataType<org.w3c.dom.Document> {
@@ -22,7 +23,9 @@
     private static final long serialVersionUID = 1L; // increase this if 
object serialization changes (which we shouldn't do!)
 
 
+    @Override
     public long getLength(Object value) {
+        // TODO, depends on storage layer
         // this is how Storage would serialize it:
         return org.mmbase.util.xml.XMLWriter.write((org.w3c.dom.Document) 
value, false, true).length();
     }
@@ -35,4 +38,10 @@
         super(name, org.w3c.dom.Document.class);
     }
 
+    @Override
+    public String castForSearch(final Object value, final Node node, final 
Field field) {
+        // TODO, depends on storage layer
+        return org.mmbase.util.Casting.toString(value);
+    }
+
 }
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to