01: /*
02: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
03: *
04: * This file is part of Resin(R) Open Source
05: *
06: * Each copy or derived work must preserve the copyright notice and this
07: * notice unmodified.
08: *
09: * Resin Open Source is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU General Public License version 2
11: * as published by the Free Software Foundation.
12: *
13: * Resin Open Source is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
16: * of NON-INFRINGEMENT. See the GNU General Public License for more
17: * details.
18: *
19: * You should have received a copy of the GNU General Public License
20: * along with Resin Open Source; if not, write to the
21: *
22: * Free Software Foundation, Inc.
23: * 59 Temple Place, Suite 330
24: * Boston, MA 02111-1307 USA
25: *
26: * @author Scott Ferguson
27: */
28:
29: package com.caucho.jsf.el;
30:
31: import javax.el.*;
32: import javax.faces.context.*;
33: import javax.faces.el.*;
34:
35: public class ValueExpressionAdapter extends ValueExpression {
36: private final ValueBinding _expr;
37: private final Class _type;
38:
39: public ValueExpressionAdapter(ValueBinding expr, Class type) {
40: _expr = expr;
41: _type = type;
42: }
43:
44: public ValueBinding getBinding() {
45: return _expr;
46: }
47:
48: public String getExpressionString() {
49: return _expr.getExpressionString();
50: }
51:
52: public Object getValue(ELContext elContext) {
53: FacesContext facesContext = (FacesContext) elContext
54: .getContext(FacesContext.class);
55:
56: return _expr.getValue(facesContext);
57: }
58:
59: public void setValue(ELContext elContext, Object value) {
60: FacesContext facesContext = (FacesContext) elContext
61: .getContext(FacesContext.class);
62:
63: _expr.setValue(facesContext, value);
64: }
65:
66: public boolean isReadOnly(ELContext elContext) {
67: FacesContext facesContext = (FacesContext) elContext
68: .getContext(FacesContext.class);
69:
70: return _expr.isReadOnly(facesContext);
71: }
72:
73: public Class getType(ELContext elContext) {
74: return _type;
75: }
76:
77: public Class getExpectedType() {
78: return _type;
79: }
80:
81: public boolean isLiteralText() {
82: return false;
83: }
84:
85: public int hashCode() {
86: return _expr.getExpressionString().hashCode();
87: }
88:
89: public boolean equals(Object o) {
90: return this == o;
91: }
92:
93: public String toString() {
94: return "ValueExpressionAdapter[" + _expr.getExpressionString()
95: + "]";
96: }
97: }
|