1 29 30 package com.caucho.el; 31 32 import com.caucho.util.L10N; 33 34 import javax.el.ELContext; 35 import javax.el.ELException; 36 import javax.el.PropertyNotFoundException; 37 import javax.el.PropertyNotWritableException; 38 import javax.el.ValueExpression; 39 import java.util.logging.Logger ; 40 41 44 public class ObjectValueExpression extends ValueExpression 45 { 46 protected static final Logger log 47 = Logger.getLogger(ObjectValueExpression.class.getName()); 48 protected static final L10N L = new L10N(Expr.class); 49 50 private final Expr _expr; 51 private final String _expressionString; 52 private final Class _expectedType; 53 54 public ObjectValueExpression(Expr expr, 55 String expressionString, 56 Class <?> expectedType) 57 { 58 _expr = expr; 59 _expressionString = expressionString; 60 _expectedType = expectedType; 61 } 62 63 public ObjectValueExpression(Expr expr, String expressionString) 64 { 65 _expr = expr; 66 _expressionString = expressionString; 67 _expectedType = Object .class; 68 } 69 70 public ObjectValueExpression(Expr expr) 71 { 72 _expr = expr; 73 _expressionString = _expr.toString(); 74 _expectedType = Object .class; 75 } 76 77 public boolean isLiteralText() 78 { 79 return _expr.isLiteralText(); 80 } 81 82 public String getExpressionString() 83 { 84 return _expressionString; 85 } 86 87 public Class <?> getExpectedType() 88 { 89 return _expectedType; 90 } 91 92 public Class <?> getType(ELContext context) 93 throws PropertyNotFoundException, 94 ELException 95 { 96 Object value = getValue(context); 97 98 if (value == null) 99 return null; 100 else 101 return value.getClass(); 102 } 103 104 @Override 105 public Object getValue(ELContext context) 106 throws PropertyNotFoundException, 107 ELException 108 { 109 return _expr.getValue(context); 110 } 111 112 @Override 113 public boolean isReadOnly(ELContext context) 114 throws PropertyNotFoundException, 115 ELException 116 { 117 return _expr.isReadOnly(context); 118 } 119 120 public void setValue(ELContext context, Object value) 121 throws PropertyNotFoundException, 122 PropertyNotWritableException, 123 ELException 124 { 125 _expr.setValue(context, value); 126 } 127 128 public int hashCode() 129 { 130 return _expr.hashCode(); 131 } 132 133 public boolean equals(Object o) 134 { 135 if (this == o) 136 return true; 137 else if (! (o instanceof ObjectValueExpression)) 138 return false; 139 140 ObjectValueExpression expr = (ObjectValueExpression) o; 141 142 return _expr.equals(expr._expr); 143 } 144 145 public String toString() 146 { 147 return "ObjectValueExpression[" + getExpressionString() + "]"; 148 } 149 } 150 | Popular Tags |