1 23 24 25 package com.sun.enterprise.admin.common; 26 27 import java.util.HashMap ; 28 29 55 56 public class ParamInfo 57 { 58 59 protected String mOperationName = null; 60 protected String [] mSignature = null; 61 protected Object [] mParams = null; 62 protected boolean mForcePrimitives = false; 63 64 private static final HashMap mPrimitives = createPrimitivesMap(); 65 private static final HashMap mPrimitiveClasses = createPrimitiveClassesMap(); 66 67 71 72 74 private static HashMap createPrimitivesMap() 75 { 76 HashMap primitives = new HashMap (); 77 primitives.put(Integer .class, "int"); 78 primitives.put(Boolean .class, "boolean"); 79 primitives.put(Float .class, "float"); 80 primitives.put(Double .class, "double"); 81 primitives.put(Byte .class, "byte"); 82 primitives.put(Character .class, "char"); 83 primitives.put(Short .class, "short"); 84 primitives.put(Long .class, "long"); 85 86 return primitives; 87 } 88 89 private static HashMap createPrimitiveClassesMap() 90 { 91 HashMap primitiveClassMap = new HashMap (); 92 primitiveClassMap.put("int", Integer.TYPE); 93 primitiveClassMap.put("boolean", Boolean.TYPE); 94 primitiveClassMap.put("float", Float.TYPE); 95 primitiveClassMap.put("double", Double.TYPE); 96 primitiveClassMap.put("byte", Byte.TYPE); 97 primitiveClassMap.put("char", Character.TYPE); 98 primitiveClassMap.put("short", Short.TYPE); 99 primitiveClassMap.put("long", Long.TYPE); 100 101 return primitiveClassMap; 102 } 103 104 public static Class getPrimitiveClass(String type) 105 { 106 return ( (Class ) mPrimitiveClasses.get(type) ); 107 } 108 109 113 114 public void initCoercionOptions() 115 { 116 mForcePrimitives = false; 117 } 118 119 124 125 public ParamInfo( String operationName, Object [] params ) 126 { 127 mOperationName = operationName; 128 mParams = params; 129 130 initCoercionOptions(); 131 mSignature = paramsToClassNames( params ); 132 } 133 134 public ParamInfo(String operationName) 135 { 136 this(operationName, new Object [0]); 137 } 138 139 140 147 148 public ParamInfo( String operationName, Object param ) 149 { 150 this(operationName, new Object []{param} ); 151 } 152 153 154 163 164 public ParamInfo( String operationName, Object param1, Object param2 ) 165 { 166 this(operationName, new Object []{param1, param2}); 167 } 168 169 170 180 181 182 public ParamInfo( String operationName, Object param1, 183 Object param2, Object param3 ) 184 { 185 this(operationName, new Object []{param1, param2, param3}); 186 } 187 188 189 200 201 public ParamInfo( String operationName, 202 Object param1, 203 Object param2, 204 Object param3, 205 Object param4 ) 206 { 207 this(operationName, new Object []{param1, param2, param3, param4}); 208 } 209 210 211 215 216 public String getOperationName() 217 { 218 return mOperationName; 219 } 220 221 222 226 227 public Object [] getParams() 228 { 229 return mParams; 230 } 231 232 233 237 238 public String [] getSignature() 239 { 240 return mSignature; 241 } 242 243 244 248 249 public String [] paramsToClassNames(Object [] params) 250 { 251 String [] signature = new String [params.length]; 252 253 for(int ctr = 0; ctr < params.length; ctr++) 254 { 255 Object primitive = null; 256 257 if(mForcePrimitives) { 259 primitive = mPrimitives.get(params[ctr].getClass()); 260 } 261 266 if (primitive != null) 267 { 268 signature[ctr] = (String ) primitive; 269 } 270 else 271 { 272 signature[ctr] = params[ctr].getClass().getName(); 273 } 274 } 275 return signature; 276 } 277 } | Popular Tags |