1 29 30 package com.caucho.config.types; 31 32 import com.caucho.config.NodeBuilder; 33 import com.caucho.config.TypeStrategy; 34 import com.caucho.util.L10N; 35 36 import org.w3c.dom.Node ; 37 38 import java.util.HashMap ; 39 40 public class ClassTypeStrategy extends TypeStrategy { 41 protected static final L10N L = new L10N(ClassTypeStrategy.class); 42 43 private static final HashMap <String ,Class > _primitiveTypes = 44 new HashMap <String ,Class >(); 45 46 47 54 public Object configure(NodeBuilder builder, Node node, Object parent) 55 throws Exception 56 { 57 String className = builder.configureString(node); 58 59 Class cl = _primitiveTypes.get(className); 60 61 if (cl != null) 62 return cl; 63 Thread thread = Thread.currentThread(); 64 ClassLoader loader = thread.getContextClassLoader(); 65 66 if (className != null && ! className.equals("")) 67 return Class.forName(className, false, loader); 68 else 69 return null; 70 } 71 72 static { 73 _primitiveTypes.put("void", void.class); 74 _primitiveTypes.put("boolean", boolean.class); 75 _primitiveTypes.put("char", char.class); 76 _primitiveTypes.put("byte", byte.class); 77 _primitiveTypes.put("short", short.class); 78 _primitiveTypes.put("int", int.class); 79 _primitiveTypes.put("long", long.class); 80 _primitiveTypes.put("float", float.class); 81 _primitiveTypes.put("double", double.class); 82 83 _primitiveTypes.put("Boolean", Boolean .class); 84 _primitiveTypes.put("Character", Character .class); 85 _primitiveTypes.put("Byte", Byte .class); 86 _primitiveTypes.put("Short", Short .class); 87 _primitiveTypes.put("Integer", Integer .class); 88 _primitiveTypes.put("Long", Long .class); 89 _primitiveTypes.put("Float", Float .class); 90 _primitiveTypes.put("Double", Double .class); 91 _primitiveTypes.put("String", String .class); 92 _primitiveTypes.put("Date", java.util.Date .class); 93 } 94 } 95 | Popular Tags |