Author: michiel
Date: 2010-02-15 23:07:50 +0100 (Mon, 15 Feb 2010)
New Revision: 41033

Added:
   mmbase/trunk/core/src/main/java/org/mmbase/util/BasicCaster.java
   mmbase/trunk/core/src/main/java/org/mmbase/util/BridgeCaster.java
   mmbase/trunk/core/src/main/java/org/mmbase/util/Caster.java
Modified:
   mmbase/trunk/core/src/main/java/org/mmbase/util/Casting.java
Log:
  MMB-1917. Factoring out bridge dependencies from Casting

Added: mmbase/trunk/core/src/main/java/org/mmbase/util/BasicCaster.java
===================================================================
--- mmbase/trunk/core/src/main/java/org/mmbase/util/BasicCaster.java            
                (rev 0)
+++ mmbase/trunk/core/src/main/java/org/mmbase/util/BasicCaster.java    
2010-02-15 22:07:50 UTC (rev 41033)
@@ -0,0 +1,35 @@
+package org.mmbase.util;
+import org.mmbase.util.transformers.CharTransformer;
+import java.util.*;
+
+/**
+ * @since MMBase-2.0
+ */
+public class BasicCaster implements Caster {
+
+    public <C> C toType(Class<C> type, Object cloud, Object value) throws 
NotRecognized {
+        throw NotRecognized.INSTANCE;
+    }
+    public Object wrap(final Object o, final CharTransformer escaper) throws 
NotRecognized {
+        throw NotRecognized.INSTANCE;
+    }
+    public Object unWrap(final Object o) throws NotRecognized {
+        throw NotRecognized.INSTANCE;
+    }
+    public Map toMap(Object o) throws NotRecognized {
+        throw NotRecognized.INSTANCE;
+    }
+    public int toInt(Object i) throws NotRecognized {
+        throw NotRecognized.INSTANCE;
+    }
+    public long toLong(Object i) throws NotRecognized {
+        throw NotRecognized.INSTANCE;
+    }
+    public float toFloat(Object i) throws NotRecognized {
+        throw NotRecognized.INSTANCE;
+    }
+    public double toDouble(Object i) throws NotRecognized {
+        throw NotRecognized.INSTANCE;
+    }
+
+}
\ No newline at end of file

Added: mmbase/trunk/core/src/main/java/org/mmbase/util/BridgeCaster.java
===================================================================
--- mmbase/trunk/core/src/main/java/org/mmbase/util/BridgeCaster.java           
                (rev 0)
+++ mmbase/trunk/core/src/main/java/org/mmbase/util/BridgeCaster.java   
2010-02-15 22:07:50 UTC (rev 41033)
@@ -0,0 +1,218 @@
+package org.mmbase.util;
+import org.mmbase.bridge.*;
+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 java.util.*;
+import org.mmbase.util.logging.*;
+
+
+/**
+ * @since MMBase-2.0
+ */
+public class BridgeCaster implements Caster {
+
+    private static final Logger log = Logging.getLoggerInstance(Casting.class);
+
+    private static Cloud anonymousCloud;
+
+    public <C> C toType(Class<C> type, Object cloud, Object value) throws 
NotRecognized {
+        if (type.equals(Node.class)) {
+            try {
+                if (cloud == null) {
+                    if (anonymousCloud == null || ! 
anonymousCloud.getUser().isValid()) {
+                        anonymousCloud = 
ContextProvider.getDefaultCloudContext().getCloud("mmbase");
+                    }
+                    cloud = anonymousCloud;
+                }
+                return (C) toNode(value, (Cloud) cloud);
+            } catch (Exception e) {
+                // suppose that that was because mmbase not running
+                return (C) (value instanceof Node ? value : null);
+            }
+        } else if (type.equals(org.mmbase.datatypes.DataType.class)) {
+            return (C) toDataType(value);
+        } else if (type.equals(org.mmbase.security.Operation.class)) {
+            return (C) 
org.mmbase.security.Operation.getOperation(Casting.toString(value));
+        } else {
+            throw NotRecognized.INSTANCE;
+        }
+    }
+
+    public Object wrap(final Object o, final CharTransformer escaper) throws 
NotRecognized {
+        if (o instanceof Node) {
+            return new NodeMap((Node)o) {
+
+                @Override
+                public Object getValue(String fieldName) {
+                    NodeManager nm = getNodeManager();
+                    if (nm.hasField(fieldName)) {
+                        switch (nm.getField(fieldName).getType()) {
+                        case org.mmbase.bridge.Field.TYPE_NODE:
+                            // I don't understand why, but the 'number' field 
is of type NODE,
+                            // which makes no sense whatsoever.
+                            if (!"number".equals(fieldName)) {
+                                return Casting.wrap(getNodeValue(fieldName), 
escaper);
+                            } else {
+                                return super.getStringValue(fieldName);
+                            }
+                        case org.mmbase.bridge.Field.TYPE_DATETIME:
+                            return Casting.wrap(getDateValue(fieldName), 
escaper);
+                        case org.mmbase.bridge.Field.TYPE_XML:
+                            return Casting.wrap(getXMLValue(fieldName), 
escaper);
+                        case org.mmbase.bridge.Field.TYPE_UNKNOWN:
+                            log.debug("NodeManager " + nm + " has field " + 
fieldName + " but it is of unknown type.");
+                            return 
Casting.wrap(super.getValueWithoutProcess(fieldName), escaper);
+                        default:
+                            return Casting.escape(escaper, 
Casting.toString(super.getValue(fieldName)));
+                        }
+                    } else {
+                        return Casting.escape(escaper, 
Casting.toString(super.getValue(fieldName)));
+                    }
+                }
+                @Override
+                public String toString() {
+                    int number = node.getNumber();
+                    if (number != -1) {
+                        return Casting.escape(escaper, "" + number);
+                    } else {
+                        return Casting.escape(escaper, 
node.getStringValue("_number"));
+                    }
+                }
+            };
+        } else if (o instanceof org.mmbase.bridge.NodeList) {
+            return new NodeListWrapper((org.mmbase.bridge.NodeList) o, 
escaper);
+        } else {
+            throw NotRecognized.INSTANCE;
+        }
+    }
+
+    public Object unWrap(final Object o) throws NotRecognized {
+        if (o instanceof NodeWrapper) {
+            return ((NodeWrapper)o).getNode();
+        } else if (o instanceof NodeListWrapper) {
+            return ((NodeListWrapper)o).getCollection();
+        } else {
+            throw NotRecognized.INSTANCE;
+        }
+    }
+
+    public Map toMap(Object o) throws NotRecognized {
+        if (o instanceof Node) {
+            return new NodeMap((Node)o);
+        } else {
+            throw NotRecognized.INSTANCE;
+        }
+    }
+    public int toInt(Object i) throws NotRecognized {
+        if (i instanceof Node) {
+            return ((Node)i).getNumber();
+        } else {
+            throw NotRecognized.INSTANCE;
+        }
+    }
+
+    public long toLong(Object i) throws NotRecognized {
+        if (i instanceof Node) {
+            return ((Node)i).getNumber();
+        } else {
+            throw NotRecognized.INSTANCE;
+        }
+    }
+    public float toFloat(Object i) throws NotRecognized {
+        if (i instanceof Node) {
+            return ((Node)i).getNumber();
+        } else {
+            throw NotRecognized.INSTANCE;
+        }
+    }
+    public double toDouble(Object i) throws NotRecognized {
+        if (i instanceof Node) {
+            return ((Node)i).getNumber();
+        } else {
+            throw NotRecognized.INSTANCE;
+        }
+    }
+
+
+    /**
+     * Convert an object to an Node.
+     * If the value is Numeric, the method
+     * tries to obtain the mmbase object with that number.
+     * A <code>Map</code> returns a virtual <code>Node</code> representing the 
map, (a
+     * {...@link MapNode}).
+     * All remaining situations return the node with the alias 
<code>i.toString()</code>, which can
+     * be <code>null</code> if no node which such an alias.
+     * @param i the object to convert
+     * @param cloud the Cloud to use for loading a node
+     * @return the value as a <code>Node</code>
+     * @since MMBase-1.7
+     */
+    public static Node toNode(Object i, Cloud cloud) {
+        Node res = null;
+        if (i instanceof Node) {
+            res = (Node)i;
+        } else if (i instanceof Number) {
+            int nodenumber = ((Number)i).intValue();
+            if (nodenumber != -1 && cloud.hasNode(nodenumber)) {
+                res = cloud.getNode(nodenumber);
+            }
+        } else if (i instanceof Map<?, ?>) {
+            res = new MapNode((Map)i, cloud);
+        } else if (i != null && !i.equals("")) {
+            res = cloud.getNode(Casting.toString(i));
+        }
+        return res;
+    }
+
+
+    /**
+     * @since MMBase-1.9.1
+     */
+    static public DataType<?> toDataType(Object o) {
+        if (o instanceof DataType<?>) {
+            return (DataType<?>) o;
+        } else {
+            return DataTypes.getDataType(Casting.toString(o));
+        }
+
+    }
+
+    /**
+     * @since MMBase-1.9
+     */
+    public static class NodeListWrapper extends 
org.mmbase.bridge.util.CollectionNodeList implements Unwrappable {
+        private final CharTransformer escaper;
+        NodeListWrapper(org.mmbase.bridge.NodeList list, CharTransformer e) {
+            super(list);
+            for (Map.Entry<Object, Object> entry : 
list.getProperties().entrySet()) {
+                setProperty(entry.getKey(), entry.getValue());
+            }
+            escaper = e;
+        }
+        public Node get(int index) {
+            return (Node) Casting.wrap(super.get(index), escaper);
+        }
+        public String toString() {
+            StringBuilder buf = new StringBuilder();
+            Iterator<Node> i = iterator();
+            boolean hasNext = i.hasNext();
+            while (hasNext) {
+                Casting.toStringBuilder(buf, i.next());
+                hasNext = i.hasNext();
+                if (hasNext) {
+                    buf.append(',');
+                }
+            }
+            return buf.toString();
+        }
+
+    }
+
+
+
+
+}
\ No newline at end of file

Added: mmbase/trunk/core/src/main/java/org/mmbase/util/Caster.java
===================================================================
--- mmbase/trunk/core/src/main/java/org/mmbase/util/Caster.java                 
        (rev 0)
+++ mmbase/trunk/core/src/main/java/org/mmbase/util/Caster.java 2010-02-15 
22:07:50 UTC (rev 41033)
@@ -0,0 +1,33 @@
+package org.mmbase.util;
+import org.mmbase.util.transformers.CharTransformer;
+import java.util.*;
+
+/**
+ * @since MMBase-2.0
+ */
+public interface Caster {
+
+    <C> C toType(Class<C> type, Object cloud, Object value) throws 
NotRecognized;
+    Object wrap(final Object o, final CharTransformer escaper) throws 
NotRecognized;
+    Object unWrap(final Object o) throws NotRecognized;
+    Map toMap(Object o) throws NotRecognized;
+    int toInt(Object i) throws NotRecognized;
+    long toLong(Object i) throws NotRecognized;
+    float toFloat(Object i) throws NotRecognized;
+    double toDouble(Object i) throws NotRecognized;
+
+    public static class NotRecognized extends Exception {
+        static NotRecognized INSTANCE = new NotRecognized();
+        protected NotRecognized() {
+        }
+
+    }
+
+    /**
+     * Clases implementing this will not be wrapped by {...@link #wrap}, even 
if the e.g. are CharSequence.
+     * @since MMBase-1.9
+     */
+    public static interface Unwrappable {
+    }
+
+}
\ No newline at end of file

Modified: mmbase/trunk/core/src/main/java/org/mmbase/util/Casting.java
===================================================================
--- mmbase/trunk/core/src/main/java/org/mmbase/util/Casting.java        
2010-02-15 20:03:09 UTC (rev 41032)
+++ mmbase/trunk/core/src/main/java/org/mmbase/util/Casting.java        
2010-02-15 22:07:50 UTC (rev 41033)
@@ -15,13 +15,10 @@
 import java.io.*;
 import javax.xml.parsers.*;
 import java.math.BigDecimal;
+/*
 import org.mmbase.bridge.*;
 import org.mmbase.bridge.Node;
-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;
@@ -142,9 +139,8 @@
     public static <C> C toType(Class<C> type, Object value) {
         return toType(type, null, value);
     }
+    private static Caster helper = new BasicCaster();
 
-    private static Cloud anonymousCloud = null;
-
     /**
      * Tries to 'cast' an object for use with the provided class. E.g. if 
value is a String, but the
      * type passed is Integer, then the string is act to an Integer.
@@ -157,10 +153,15 @@
      * @since MMBase-1.8
      */
     @SuppressWarnings("unchecked")
-    public static <C> C toType(Class<C> type, Cloud cloud, Object value) {
+    public static <C> C toType(Class<C> type, Object cloud, Object value) {
         if (value != null && isType(type, value))  {
             return (C) value;
         } else {
+            try {
+                return helper.toType(type, cloud, value);
+            } catch (Caster.NotRecognized e) {
+                // never mind
+            }
             if (type.equals(Boolean.TYPE) || type.equals(Boolean.class)) {
                 return (C) Boolean.valueOf(toBoolean(value));
             } else if (type.equals(Byte.TYPE) || type.equals(Byte.class)) {
@@ -202,19 +203,6 @@
                 return (C) toString(value);
             } else if (type.equals(Date.class)) {
                 return (C) toDate(value);
-            } else if (type.equals(Node.class)) {
-                try {
-                    if (cloud == null) {
-                        if (anonymousCloud == null || ! 
anonymousCloud.getUser().isValid()) {
-                            anonymousCloud = 
ContextProvider.getDefaultCloudContext().getCloud("mmbase");
-                        }
-                        cloud = anonymousCloud;
-                    }
-                    return (C) toNode(value, cloud);
-                } catch (Exception e) {
-                    // suppose that that was because mmbase not running
-                    return (C) (value instanceof Node ? value : null);
-                }
             } else if (type.equals(Document.class)) {
                 return (C) toXML(value);
             } else if (type.equals(List.class)) {
@@ -239,10 +227,6 @@
                 } catch (Exception e) {
                     throw new IllegalArgumentException(e);
                 }
-           } else if (type.equals(org.mmbase.datatypes.DataType.class)) {
-                return (C) toDataType(value);
-           } else if (type.equals(org.mmbase.security.Operation.class)) {
-                return (C) 
org.mmbase.security.Operation.getOperation(toString(value));
            } else if (type.equals(Locale.class)) {
                 if (value instanceof Locale) {
                     return (C) value;
@@ -388,48 +372,15 @@
     public static Object wrap(final Object o, final CharTransformer escaper) {
         if (o == null) {
             return escape(escaper, "");
-        } else if (o instanceof Unwrappable) {
-            return o;
-        } else if (o instanceof Node) {
-            return new NodeMap((Node)o) {
+        }
+        try {
+            return helper.wrap(o, escaper);
+        } catch (Caster.NotRecognized e) {
+            // never mind
+        }
 
-                @Override
-                public Object getValue(String fieldName) {
-                    NodeManager nm = getNodeManager();
-                    if (nm.hasField(fieldName)) {
-                        switch (nm.getField(fieldName).getType()) {
-                        case org.mmbase.bridge.Field.TYPE_NODE:
-                            // I don't understand why, but the 'number' field 
is of type NODE,
-                            // which makes no sense whatsoever.
-                            if (!"number".equals(fieldName)) {
-                                return wrap(getNodeValue(fieldName), escaper);
-                            } else {
-                                return super.getStringValue(fieldName);
-                            }
-                        case org.mmbase.bridge.Field.TYPE_DATETIME:
-                            return wrap(getDateValue(fieldName), escaper);
-                        case org.mmbase.bridge.Field.TYPE_XML:
-                            return wrap(getXMLValue(fieldName), escaper);
-                        case org.mmbase.bridge.Field.TYPE_UNKNOWN:
-                            log.debug("NodeManager " + nm + " has field " + 
fieldName + " but it is of unknown type.");
-                            return 
wrap(super.getValueWithoutProcess(fieldName), escaper);
-                        default:
-                            return escape(escaper, 
Casting.toString(super.getValue(fieldName)));
-                        }
-                    } else {
-                        return escape(escaper, 
Casting.toString(super.getValue(fieldName)));
-                    }
-                }
-                @Override
-                public String toString() {
-                    int number = node.getNumber();
-                    if (number != -1) {
-                        return escape(escaper, "" + number);
-                    } else {
-                        return escape(escaper, node.getStringValue("_number"));
-                    }
-                }
-            };
+        if (o instanceof Caster.Unwrappable) {
+            return o;
         } else if (o instanceof Date) {
             return new java.util.Date(((Date)o).getTime()) {
                 private static final long serialVersionUID = 1L; // increase 
this if object chages.
@@ -443,8 +394,6 @@
         } else if (o instanceof org.w3c.dom.Node) {
             // don't know how to wrap
             return escape(escaper, XMLWriter.write((org.w3c.dom.Node) o, 
false, true));
-        } else if (o instanceof org.mmbase.bridge.NodeList) {
-            return new NodeListWrapper((org.mmbase.bridge.NodeList) o, 
escaper);
         } else if (o instanceof List) {
             return new ListWrapper((List) o, escaper);
         } else if (o instanceof byte[]) {
@@ -468,7 +417,7 @@
 
     }
 
-    private static String escape(CharTransformer escaper, CharSequence string) 
{
+    static String escape(CharTransformer escaper, CharSequence string) {
         if (escaper != null) {
             return escaper.transform(string.toString());
         } else {
@@ -480,11 +429,12 @@
      * @since MMBase-1.8
      */
     public static Object unWrap(final Object o) {
-        if (o instanceof NodeWrapper) {
-            return ((NodeWrapper)o).getNode();
-        } else if (o instanceof NodeListWrapper) {
-            return ((NodeListWrapper)o).getCollection();
-        } else if (o instanceof ListWrapper) {
+        try {
+            return helper.unWrap(o);
+        } catch(Caster.NotRecognized e) {
+            // never mind
+        }
+        if (o instanceof ListWrapper) {
             return ((ListWrapper)o).getList();
         } else if (o instanceof StringWrapper) {
             return ((StringWrapper)o).getString();
@@ -538,7 +488,13 @@
     public static Map toMap(Object o) {
         if (o == null) {
             return new HashMap();
-        } else if (o instanceof Map) {
+        }
+        try {
+            return helper.toMap(o);
+        } catch (Caster.NotRecognized e) {
+            //
+        }
+        if (o instanceof Map) {
             return (Map) o;
         } else if (o instanceof org.mmbase.util.functions.Parameters) {
             return ((org.mmbase.util.functions.Parameters) o).toMap();
@@ -555,8 +511,6 @@
                 }
             }
             return result;
-        } else if (o instanceof Node) {
-            return new NodeMap((Node)o);
         } else {
             Map m = new HashMap();
             m.put(o, o);
@@ -697,36 +651,6 @@
 
 
     /**
-     * Convert an object to an Node.
-     * If the value is Numeric, the method
-     * tries to obtain the mmbase object with that number.
-     * A <code>Map</code> returns a virtual <code>Node</code> representing the 
map, (a
-     * {...@link MapNode}).
-     * All remaining situations return the node with the alias 
<code>i.toString()</code>, which can
-     * be <code>null</code> if no node which such an alias.
-     * @param i the object to convert
-     * @param cloud the Cloud to use for loading a node
-     * @return the value as a <code>Node</code>
-     * @since MMBase-1.7
-     */
-    public static Node toNode(Object i, Cloud cloud) {
-        Node res = null;
-        if (i instanceof Node) {
-            res = (Node)i;
-        } else if (i instanceof Number) {
-            int nodenumber = ((Number)i).intValue();
-            if (nodenumber != -1 && cloud.hasNode(nodenumber)) {
-                res = cloud.getNode(nodenumber);
-            }
-        } else if (i instanceof Map<?, ?>) {
-            res = new MapNode((Map)i, cloud);
-        } else if (i != null && !i.equals("")) {
-            res = cloud.getNode(toString(i));
-        }
-        return res;
-    }
-
-    /**
      * Convert an object to an <code>int</code>.
      * Boolean values return 0 for false, 1 for true.
      * String values are parsed to a number, if possible.
@@ -741,7 +665,13 @@
         int res = def;
         if (i == null) {
             return def;
-        } else if (i instanceof Number) {
+        }
+        try {
+            return helper.toInt(i);
+        } catch (Caster.NotRecognized e) {
+            // never mind
+        }
+        if (i instanceof Number) {
             long l = ((Number)i).longValue();
             if (l > Integer.MAX_VALUE) {
                 res = Integer.MAX_VALUE;
@@ -750,8 +680,6 @@
             } else {
                 res = (int) l;
             }
-        } else if (i instanceof Node) {
-            res = ((Node)i).getNumber();
         } else if (i instanceof Boolean) {
             res = ((Boolean)i).booleanValue() ? 1 : 0;
         } else if (i instanceof Date) {
@@ -871,6 +799,11 @@
      */
     static public long toLong(Object i, long def) {
         long res = def;
+        try {
+            return helper.toLong(i);
+        } catch (Caster.NotRecognized e) {
+            // never mind
+        }
         if (i instanceof Boolean) {
             res = ((Boolean)i).booleanValue() ? 1 : 0;
         } else if (i instanceof Number) {
@@ -878,8 +811,6 @@
         } else if (i instanceof Date) {
             res = ((Date)i).getTime();
             if (res !=- 1) res /= 1000;
-        } else if (i instanceof Node) {
-            res = ((Node)i).getNumber();
         } else if (i instanceof Object[]) {
             Object[] array = (Object[]) i;
             if (array.length == 0) return 0;
@@ -931,6 +862,10 @@
      */
     static public float toFloat(Object i, float def) {
         float res = def;
+        try {
+            return helper.toFloat(i);
+        } catch (Caster.NotRecognized e) {
+        }
         if (i instanceof Boolean) {
             res = ((Boolean)i).booleanValue() ? 1 : 0;
         } else if (i instanceof Number) {
@@ -938,8 +873,6 @@
         } else if (i instanceof Date) {
             res = ((Date)i).getTime();
             if (res!=-1) res = res / 1000;
-        } else if (i instanceof Node) {
-            res = ((Node)i).getNumber();
         } else if (i != null) {
             if(i instanceof String){
                 String s = ((String)i).toLowerCase();
@@ -981,6 +914,10 @@
      */
     static public double toDouble(Object i, double def) {
         double res = def;
+        try {
+            return helper.toFloat(i);
+        } catch (Caster.NotRecognized e) {
+        }
         if (i instanceof Boolean) {
             res = ((Boolean)i).booleanValue() ? 1 : 0;
         } else if (i instanceof Number) {
@@ -988,8 +925,6 @@
         } else if (i instanceof Date) {
             res = ((Date)i).getTime();
             if (res != -1) res = res / 1000;
-        } else if (i instanceof Node) {
-            res = ((Node)i).getNumber();
         } else if (i instanceof Object[]) {
             Object[] array = (Object[]) i;
             if (array.length == 0) return 0;
@@ -1058,19 +993,7 @@
         }
     }
 
-    /**
-     * @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>.
      * String values are parsed to a date, if possible.
@@ -1232,37 +1155,6 @@
     }
 
     /**
-     * @since MMBase-1.9
-     */
-    public static class NodeListWrapper extends 
org.mmbase.bridge.util.CollectionNodeList implements Unwrappable {
-        private final CharTransformer escaper;
-        NodeListWrapper(org.mmbase.bridge.NodeList list, CharTransformer e) {
-            super(list);
-            for (Map.Entry<Object, Object> entry : 
list.getProperties().entrySet()) {
-                setProperty(entry.getKey(), entry.getValue());
-            }
-            escaper = e;
-        }
-        public Node get(int index) {
-            return (Node) Casting.wrap(super.get(index), escaper);
-        }
-        public String toString() {
-            StringBuilder buf = new StringBuilder();
-            Iterator<Node> i = iterator();
-            boolean hasNext = i.hasNext();
-            while (hasNext) {
-                Casting.toStringBuilder(buf, i.next());
-                hasNext = i.hasNext();
-                if (hasNext) {
-                    buf.append(',');
-                }
-            }
-            return buf.toString();
-        }
-
-    }
-
-    /**
      * Wraps a String with an 'Escaper'.
      * @since MMBase-1.8
      */
@@ -1300,12 +1192,6 @@
         }
     }
 
-    /**
-     * Clases implementing this will not be wrapped by {...@link #wrap}, even 
if the e.g. are CharSequence.
-     * @since MMBase-1.9
-     */
-    public static interface Unwrappable {
-    }
 
     /**
      * @since MMBase-1.9
@@ -1324,7 +1210,7 @@
      * A SerializableInputStream where the toString represents the (escaped) 
contents of the stream itself.
      * @since MMBase-1.9.2
      */
-    static class StringSerializableInputStream extends SerializableInputStream 
implements Unwrappable {
+    static class StringSerializableInputStream extends SerializableInputStream 
implements Caster.Unwrappable {
         private static final long serialVersionUID = 2L;
 
         CharTransformer escaper;
@@ -1353,6 +1239,14 @@
         }
     }
 
+    /**
+     * @since MMBase-2.0
+     */
+    public static void setHelper(Caster h) {
+        helper = h;
+        log.info("Casting helper: " + helper);
+    }
+
     private Casting() {
     }
 

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to