Source code: com/sun/facelets/el/LegacyValueBinding.java
1 /**
2 * Licensed under the Common Development and Distribution License,
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.sun.com/cddl/
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11 * implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14
15 package com.sun.facelets.el;
16
17 import java.io.Externalizable;
18 import java.io.IOException;
19 import java.io.ObjectInput;
20 import java.io.ObjectOutput;
21
22 import javax.el.ELContext;
23 import javax.el.ELException;
24 import javax.el.PropertyNotWritableException;
25 import javax.el.ValueExpression;
26 import javax.faces.context.FacesContext;
27 import javax.faces.el.EvaluationException;
28 import javax.faces.el.PropertyNotFoundException;
29 import javax.faces.el.ValueBinding;
30
31 /**
32 *
33 *
34 * @author Jacob Hookom
35 * @version $Id: LegacyValueBinding.java,v 1.5 2005/08/24 04:38:57 jhook Exp $
36 * @deprecated
37 */
38 public final class LegacyValueBinding extends ValueBinding implements Externalizable {
39
40 private static final long serialVersionUID = 1L;
41
42 private ValueExpression delegate;
43
44 public LegacyValueBinding() {
45 super();
46 }
47
48 public LegacyValueBinding(ValueExpression ve) {
49 this.delegate = ve;
50 }
51
52 public Object getValue(FacesContext context) throws EvaluationException,
53 PropertyNotFoundException {
54 ELContext ctx = ELAdaptor.getELContext(context);
55 try {
56 return this.delegate.getValue(ctx);
57 } catch (javax.el.PropertyNotFoundException e) {
58 throw new PropertyNotFoundException(e.getMessage(), e.getCause());
59 } catch (ELException e) {
60 throw new EvaluationException(e.getMessage(), e.getCause());
61 }
62 }
63
64 public void setValue(FacesContext context, Object value)
65 throws EvaluationException, PropertyNotFoundException {
66 ELContext ctx = ELAdaptor.getELContext(context);
67 try {
68 this.delegate.setValue(ctx, value);
69 } catch (PropertyNotWritableException e) {
70 throw new PropertyNotFoundException(e.getMessage(), e.getCause());
71 } catch (javax.el.PropertyNotFoundException e) {
72 throw new PropertyNotFoundException(e.getMessage(), e.getCause());
73 } catch (ELException e) {
74 throw new EvaluationException(e.getMessage(), e.getCause());
75 }
76 }
77
78 public boolean isReadOnly(FacesContext context) throws EvaluationException,
79 PropertyNotFoundException {
80 ELContext ctx = ELAdaptor.getELContext(context);
81 try {
82 return this.delegate.isReadOnly(ctx);
83 } catch (javax.el.PropertyNotFoundException e) {
84 throw new PropertyNotFoundException(e.getMessage(), e.getCause());
85 } catch (ELException e) {
86 throw new EvaluationException(e.getMessage(), e.getCause());
87 }
88 }
89
90 public Class getType(FacesContext context) throws EvaluationException,
91 PropertyNotFoundException {
92 ELContext ctx = ELAdaptor.getELContext(context);
93 try {
94 return this.delegate.getType(ctx);
95 } catch (javax.el.PropertyNotFoundException e) {
96 throw new PropertyNotFoundException(e.getMessage(), e.getCause());
97 } catch (ELException e) {
98 throw new EvaluationException(e.getMessage(), e.getCause());
99 }
100 }
101
102 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
103 this.delegate = (ValueExpression) in.readObject();
104 }
105
106 public void writeExternal(ObjectOutput out) throws IOException {
107 out.writeObject(this.delegate);
108 }
109
110 public String getExpressionString() {
111 return this.delegate.getExpressionString();
112 }
113 }