1 28 29 package com.caucho.es.parser; 30 31 import com.caucho.es.ESException; 32 import com.caucho.es.ESId; 33 import com.caucho.server.util.CauchoSystem; 34 35 38 class JavaTypeExpr extends TypeExpr { 39 JavaTypeExpr(Block block, String className) 40 { 41 super(block, null); 42 43 this.type = TYPE_JAVA; 44 _typeName = className; 45 try { 46 this.javaType = CauchoSystem.loadClass(className, false, 47 block.getClassLoader()); 48 } catch (Exception e) { 49 this.type = TYPE_ES; 50 } 51 } 52 53 JavaTypeExpr(Block block, Class javaClass) 54 { 55 super(block, null); 56 57 this.type = TYPE_JAVA; 58 this.javaType = javaClass; 59 60 _typeName = getTypeName(javaClass); 61 } 62 63 private String getTypeName(Class cl) 64 { 65 if (cl.isArray()) 66 return getTypeName(cl.getComponentType()) + "[]"; 67 else 68 return cl.getName(); 69 } 70 71 Expr fieldReference(ESId id) 72 throws ESException 73 { 74 if (_typeName.equals("")) 75 return new JavaTypeExpr(block, id.toString()); 76 else 77 return new JavaTypeExpr(block, _typeName + "." + id); 78 } 79 80 public String toString() 81 { 82 return "[JavaTypeExpr " + javaType + " " + type + "]"; 83 } 84 } 85 | Popular Tags |