1 10 11 package org.mmbase.bridge.util; 12 13 import java.util.*; 14 import org.mmbase.util.LocalizedString; 15 import org.mmbase.bridge.*; 16 import org.mmbase.datatypes.DataType; 17 18 19 27 28 public class DataTypeField extends org.mmbase.core.AbstractField { 29 protected final NodeManager nodeManager; 30 public DataTypeField(final Cloud cloud, final DataType dataType) { 31 super(dataType.getName(), dataType.getBaseType(), TYPE_UNKNOWN, Field.STATE_VIRTUAL, dataType); 32 nodeManager = new AbstractNodeManager(cloud) { 33 private final Map fieldTypes = new HashMap(); 34 { 35 fieldTypes.put(dataType.getName(), DataTypeField.this); 36 } 37 protected Map getFieldTypes() { 38 return Collections.unmodifiableMap(fieldTypes); 39 } 40 }; 41 } 42 public NodeManager getNodeManager() { 43 return nodeManager; 44 } 45 46 public int getSearchPosition() { 47 return -1; } 49 50 public int getListPosition() { 51 return -1; } 53 54 public int getEditPosition() { 55 return 1; 56 } 57 58 public int getStoragePosition() { 59 return -1; } 61 62 public int getMaxLength() { 63 return Integer.MAX_VALUE; } 65 66 public String getGUIType() { 67 return dataType.getName(); 68 } 69 public Collection validate(Object value) { 70 Collection errors = dataType.validate(value, null, this); 71 return LocalizedString.toStrings(errors, nodeManager.getCloud().getLocale()); 72 } 73 74 75 } 76 | Popular Tags |