1 28 29 package com.caucho.es.parser; 30 31 import com.caucho.es.ESException; 32 33 import java.io.IOException ; 34 import java.lang.reflect.Modifier ; 35 36 39 class JavaClassExpr extends Expr { 40 private String name; 41 private Class javaClass; 42 private TypeExpr javaType; 43 44 JavaClassExpr(Block block, Class javaClass) 45 { 46 super(block); 47 48 this.javaClass = javaClass; 49 50 if (javaClass.getName().indexOf('.') < 0) 51 block.function.cl.addJavaImport(javaClass.getName()); 52 } 53 54 void setType(int type) 55 { 56 } 57 58 int getType() 59 { 60 return TYPE_ES; 61 } 62 63 Expr getTypeExpr() 64 { 65 return null; 66 } 67 68 71 Class getJavaType() 72 { 73 return Class .class; 74 } 75 76 79 Class getJavaClass() 80 { 81 return javaClass; 82 } 83 84 CallExpr startNew() 85 throws ESException 86 { 87 return new JavaNewExpr(block, javaClass); 88 } 89 90 CallExpr startCall() 91 throws ESException 92 { 93 return new JavaNewExpr(block, javaClass); 94 } 95 96 void printImpl() throws IOException 97 { 98 if (! Modifier.isPublic(javaClass.getModifiers())) 99 throw new IOException ("can't create `" + javaClass.getName() + "'"); 100 101 cl.print("_env.wrapClass(" + javaClass.getName() + ".class)"); 102 } 103 } 104 | Popular Tags |