1 10 11 package org.mmbase.bridge.implementation; 12 import org.mmbase.bridge.*; 13 import org.mmbase.util.Casting; 14 import org.mmbase.bridge.util.MapNode; 15 import org.mmbase.module.core.VirtualNode; 16 import org.mmbase.module.core.MMObjectNode; 17 import org.w3c.dom.Document ; 18 import org.w3c.dom.Element ; 19 import java.util.*; 20 21 29 public class BasicFunctionValue extends org.mmbase.bridge.util.AbstractFieldValue { 30 31 private final Object value; 32 33 39 BasicFunctionValue(Node node, Object value) { 40 super(node, null); 41 this.value = convert(value, null); 42 } 43 44 50 BasicFunctionValue(Cloud cloud, Object value) { 51 super(null, cloud); 52 Object v = value; 53 if (v instanceof List) { List list = (List) v; 55 if (list.size() > 0) { 56 Object first = list.get(0); 57 if (first instanceof MMObjectNode || first instanceof Node) { if (cloud == null) { 59 if (first instanceof Node) { 60 cloud = ((Node) first).getCloud(); 61 } else { 62 cloud = ContextProvider.getDefaultCloudContext().getCloud("mmbase", "class", null); 63 } 64 } 66 NodeList l = cloud.createNodeList(); 67 v = l; 68 l.addAll(list); 69 } 70 } 71 } 72 this.value = convert(v, cloud); 73 } 74 75 protected static Object convert(Object o, Cloud cloud) { 76 if (o instanceof VirtualNode) { 77 VirtualNode vn = (VirtualNode) o; 78 return new MapNode(vn.getValues(), cloud); 79 } else if (o instanceof MMObjectNode) { 80 MMObjectNode mn = (MMObjectNode) o; 81 return cloud.getNode(mn.getNumber()); 82 } 83 return o; 84 } 85 86 public Object get() { 87 return value; 88 } 89 90 } 91 | Popular Tags |