001: /*
002: * Copyright 2006 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.myfaces.el.convert;
018:
019: import javax.el.ELContext;
020: import javax.el.ELException;
021: import javax.el.ELResolver;
022: import javax.faces.context.FacesContext;
023: import javax.faces.el.EvaluationException;
024: import javax.faces.el.PropertyNotFoundException;
025: import javax.faces.el.PropertyResolver;
026:
027: /**
028: *
029: * @author Stan Silvert
030: */
031: public class ELResolverToPropertyResolver extends PropertyResolver {
032:
033: private ELResolver elResolver;
034:
035: /**
036: * Creates a new instance of ELResolverToPropertyResolver
037: */
038: public ELResolverToPropertyResolver(ELResolver elResolver) {
039: this .elResolver = elResolver;
040: }
041:
042: public boolean isReadOnly(Object base, int index)
043: throws EvaluationException, PropertyNotFoundException {
044:
045: try {
046: return elResolver.isReadOnly(elContext(), base,
047: new Integer(index));
048: } catch (javax.el.PropertyNotFoundException e) {
049: throw new javax.faces.el.PropertyNotFoundException(e);
050: } catch (ELException e) {
051: throw new EvaluationException(e);
052: }
053:
054: }
055:
056: public boolean isReadOnly(Object base, Object property)
057: throws EvaluationException, PropertyNotFoundException {
058:
059: try {
060: return elResolver.isReadOnly(elContext(), base, property);
061: } catch (javax.el.PropertyNotFoundException e) {
062: throw new javax.faces.el.PropertyNotFoundException(e);
063: } catch (ELException e) {
064: throw new EvaluationException(e);
065: }
066:
067: }
068:
069: public Object getValue(Object base, int index)
070: throws EvaluationException, PropertyNotFoundException {
071:
072: try {
073: return elResolver.getValue(elContext(), base, new Integer(
074: index));
075: } catch (javax.el.PropertyNotFoundException e) {
076: throw new javax.faces.el.PropertyNotFoundException(e);
077: } catch (ELException e) {
078: throw new EvaluationException(e);
079: }
080:
081: }
082:
083: public Object getValue(Object base, Object property)
084: throws EvaluationException, PropertyNotFoundException {
085:
086: try {
087: return elResolver.getValue(elContext(), base, property);
088: } catch (javax.el.PropertyNotFoundException e) {
089: throw new javax.faces.el.PropertyNotFoundException(e);
090: } catch (ELException e) {
091: throw new EvaluationException(e);
092: }
093: }
094:
095: public Class getType(Object base, int index)
096: throws EvaluationException, PropertyNotFoundException {
097:
098: try {
099: return elResolver.getType(elContext(), base, new Integer(
100: index));
101: } catch (javax.el.PropertyNotFoundException e) {
102: throw new javax.faces.el.PropertyNotFoundException(e);
103: } catch (ELException e) {
104: throw new EvaluationException(e);
105: }
106: }
107:
108: public Class getType(Object base, Object property)
109: throws EvaluationException, PropertyNotFoundException {
110:
111: try {
112: return elResolver.getType(elContext(), base, property);
113: } catch (javax.el.PropertyNotFoundException e) {
114: throw new javax.faces.el.PropertyNotFoundException(e);
115: } catch (ELException e) {
116: throw new EvaluationException(e);
117: }
118: }
119:
120: public void setValue(Object base, Object property, Object value)
121: throws EvaluationException, PropertyNotFoundException {
122:
123: try {
124: elResolver.setValue(elContext(), base, property, value);
125: } catch (javax.el.PropertyNotFoundException e) {
126: throw new javax.faces.el.PropertyNotFoundException(e);
127: } catch (ELException e) {
128: throw new EvaluationException(e);
129: }
130: }
131:
132: public void setValue(Object base, int index, Object value)
133: throws EvaluationException, PropertyNotFoundException {
134:
135: try {
136: elResolver.setValue(elContext(), base, new Integer(index),
137: value);
138: } catch (javax.el.PropertyNotFoundException e) {
139: throw new javax.faces.el.PropertyNotFoundException(e);
140: } catch (ELException e) {
141: throw new EvaluationException(e);
142: }
143:
144: }
145:
146: private ELContext elContext() {
147: return FacesContext.getCurrentInstance().getELContext();
148: }
149:
150: }
|