1 23 package com.sun.enterprise.tools.jsfext.event.handlers; 24 25 import java.util.HashMap ; 26 import java.util.Map ; 27 28 29 34 public class IODescriptor implements java.io.Serializable { 35 36 42 public IODescriptor(String name, String type) { 43 setName(name); 44 setType(type); 45 } 46 47 48 51 public String getName() { 52 if (_name == null) { 53 throw new NullPointerException ("Name cannot be null!"); 54 } 55 return _name; 56 } 57 58 59 63 protected void setName(String name) { 64 _name = name; 65 } 66 67 68 71 public String getDescription() { 72 return _description; 73 } 74 75 76 79 public void setDescription(String desc) { 80 _description = desc; 81 } 82 83 84 87 public Class getType() { 88 return _type; 89 } 90 91 92 95 public void setType(Class type) { 96 _type = type; 97 } 98 99 100 103 public void setType(String type) { 104 if ((type == null) || (type.trim().length() == 0)) { 105 return; 106 } 107 Class cls = (Class ) _typeMap.get(type); 108 if (cls == null) { 109 try { 110 cls = Class.forName(type); 111 } catch (Exception ex) { 112 throw new RuntimeException ( 113 "Unable to determine parameter type '" + type + 114 "' for parameter named '" + getName() + "'.", ex); 115 } 116 } 117 _type = cls; 118 } 119 120 121 125 public Object getDefault() { 126 return _default; 127 } 128 129 130 134 public void setDefault(Object def) { 135 _default = def; 136 } 137 138 142 public boolean isRequired() { 143 return _required; 144 } 145 146 149 public void setRequired(boolean required) { 150 _required = required; 151 } 152 153 private static Map _typeMap = new HashMap (); 155 static { 156 _typeMap.put("boolean", Boolean .class); 157 _typeMap.put("Boolean", Boolean .class); 158 _typeMap.put("byte", Byte .class); 159 _typeMap.put("Byte", Byte .class); 160 _typeMap.put("char", Character .class); 161 _typeMap.put("Character", Character .class); 162 _typeMap.put("double", Double .class); 163 _typeMap.put("Double", Double .class); 164 _typeMap.put("float", Float .class); 165 _typeMap.put("Float", Float .class); 166 _typeMap.put("int", Integer .class); 167 _typeMap.put("Integer", Integer .class); 168 _typeMap.put("long", Long .class); 169 _typeMap.put("Long", Long .class); 170 _typeMap.put("short", Short .class); 171 _typeMap.put("Short", Short .class); 172 _typeMap.put("char[]", String .class); 173 _typeMap.put("String", String .class); 174 _typeMap.put("Object", Object .class); 175 } 176 177 private String _name = null; 178 private String _description = null; 179 private Object _default = null; private Class _type = Object .class; 181 private boolean _required = false; 183 private static final long serialVersionUID = 0xA9B8C7D6E5F40312L; 184 } 185 | Popular Tags |