1 29 30 package com.caucho.el; 31 32 import com.caucho.vfs.WriteStream; 33 34 import javax.el.ELContext; 35 import javax.el.ELException; 36 import javax.el.ValueExpression; 37 import java.io.IOException ; 38 39 42 public class ValueExpr extends Expr { 43 private final String _name; 45 46 private final ValueExpression _valExpr; 47 48 51 public ValueExpr(String name, ValueExpression valExpr) 52 { 53 _name = name; 54 _valExpr = valExpr; 55 } 56 57 62 @Override 63 public Expr createField(String field) 64 { 65 Expr arrayExpr = createField(new StringLiteral(field)); 66 67 return new PathExpr(arrayExpr, _name + '.' + field); 68 } 69 70 77 @Override 78 public Object getValue(ELContext env) 79 throws ELException 80 { 81 return _valExpr.getValue(env); 82 } 83 84 87 @Override 88 public void printCreate(WriteStream os) 89 throws IOException 90 { 91 os.print("new com.caucho.el.ValueExpr(\""); 92 printEscapedString(os, _name); 93 os.print("\")"); 94 } 95 96 public boolean equals(Object o) 97 { 98 if (o == null || ! o.getClass().equals(ValueExpr.class)) 99 return false; 100 101 ValueExpr expr = (ValueExpr) o; 102 103 return _valExpr.equals(expr._valExpr); 104 } 105 106 public String toString() 107 { 108 return _name; 109 } 110 } 111 | Popular Tags |