1 21 22 package com.sun.enterprise.tools.guiframework.event.descriptors; 23 24 import com.iplanet.jato.RequestContext; 25 import com.iplanet.jato.view.View; 26 27 import com.sun.enterprise.tools.guiframework.FrameworkDescriptor; 28 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 29 import com.sun.enterprise.tools.guiframework.util.Util; 30 31 import java.util.HashMap ; 32 import java.util.Map ; 33 34 35 38 public class IODescriptor implements FrameworkDescriptor { 39 40 46 public IODescriptor(String name, String type) { 47 setName(name); 48 setType(type); 49 } 50 51 52 55 public String getName() { 56 if (_name == null) { 57 throw new FrameworkException("Name cannot be null!"); 58 } 59 return _name; 60 } 61 62 63 66 protected void setName(String name) { 67 _name = name; 68 } 69 70 71 74 public String getDescription() { 75 return _description; 76 } 77 78 79 82 public void setDescription(String desc) { 83 _description = desc; 84 } 85 86 87 90 public Class getType() { 91 return _type; 92 } 93 94 95 98 public void setType(Class type) { 99 _type = type; 100 } 101 102 103 106 public void setType(String type) { 107 if ((type == null) || (type.trim().length() == 0)) { 108 return; 109 } 110 Class cls = (Class )_typeMap.get(type); 111 if (cls == null) { 112 try { 113 cls = Class.forName(type); 114 } catch (Exception ex) { 115 throw new FrameworkException( 116 "Unable to determine parameter type '"+type+ 117 "' for parameter named '"+getName()+"'.", ex); 118 } 119 } 120 _type = cls; 121 } 122 123 124 128 public Object getDefault() { 129 return _default; 130 } 131 132 133 136 public void setDefault(Object def) { 137 _default = def; 138 } 139 140 141 private static Map _typeMap = new HashMap (); 143 static { 144 _typeMap.put("boolean", Boolean .class); 145 _typeMap.put("Boolean", Boolean .class); 146 _typeMap.put("byte", Byte .class); 147 _typeMap.put("Byte", Byte .class); 148 _typeMap.put("char", Character .class); 149 _typeMap.put("Character", Character .class); 150 _typeMap.put("double", Double .class); 151 _typeMap.put("Double", Double .class); 152 _typeMap.put("float", Float .class); 153 _typeMap.put("Float", Float .class); 154 _typeMap.put("int", Integer .class); 155 _typeMap.put("Integer", Integer .class); 156 _typeMap.put("long", Long .class); 157 _typeMap.put("Long", Long .class); 158 _typeMap.put("short", Short .class); 159 _typeMap.put("Short", Short .class); 160 _typeMap.put("char[]", String .class); 161 _typeMap.put("String", String .class); 162 _typeMap.put("Object", Object .class); 163 } 164 165 private String _name = null; 166 private String _description = null; 167 private Class _type = Object .class; 168 private Object _default = null; 169 } 170 | Popular Tags |