KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > servlet > jsp > jstl > core > IndexedValueExpression


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  *
21  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package javax.servlet.jsp.jstl.core;
25
26 import javax.el.ELContext;
27 import javax.el.ValueExpression;
28
29 /**
30  * @author Jacob Hookom
31  * @version $Id: IndexedValueExpression.java,v 1.2 2005/12/08 01:20:43 kchung Exp $
32  */

33 public final class IndexedValueExpression extends ValueExpression {
34
35     /**
36      *
37      */

38     private static final long serialVersionUID = 1L;
39     protected final Integer JavaDoc i;
40     protected final ValueExpression orig;
41
42     /**
43      *
44      */

45     public IndexedValueExpression(ValueExpression orig, int i) {
46         this.i = new Integer JavaDoc(i);
47         this.orig = orig;
48     }
49
50     /*
51      * (non-Javadoc)
52      *
53      * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
54      */

55     public Object JavaDoc getValue(ELContext context) {
56         Object JavaDoc base = this.orig.getValue(context);
57         if (base != null) {
58             context.setPropertyResolved(false);
59             return context.getELResolver().getValue(context, base, i);
60         }
61         return null;
62     }
63
64     /*
65      * (non-Javadoc)
66      *
67      * @see javax.el.ValueExpression#setValue(javax.el.ELContext,
68      * java.lang.Object)
69      */

70     public void setValue(ELContext context, Object JavaDoc value) {
71         Object JavaDoc base = this.orig.getValue(context);
72         if (base != null) {
73             context.setPropertyResolved(false);
74             context.getELResolver().setValue(context, base, i, value);
75         }
76     }
77
78     /*
79      * (non-Javadoc)
80      *
81      * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
82      */

83     public boolean isReadOnly(ELContext context) {
84         Object JavaDoc base = this.orig.getValue(context);
85         if (base != null) {
86             context.setPropertyResolved(false);
87             return context.getELResolver().isReadOnly(context, base, i);
88         }
89         return true;
90     }
91
92     /*
93      * (non-Javadoc)
94      *
95      * @see javax.el.ValueExpression#getType(javax.el.ELContext)
96      */

97     public Class JavaDoc getType(ELContext context) {
98         Object JavaDoc base = this.orig.getValue(context);
99         if (base != null) {
100             context.setPropertyResolved(false);
101             return context.getELResolver().getType(context, base, i);
102         }
103         return null;
104     }
105
106     /*
107      * (non-Javadoc)
108      *
109      * @see javax.el.ValueExpression#getExpectedType()
110      */

111     public Class JavaDoc getExpectedType() {
112         return Object JavaDoc.class;
113     }
114
115     /*
116      * (non-Javadoc)
117      *
118      * @see javax.el.Expression#getExpressionString()
119      */

120     public String JavaDoc getExpressionString() {
121         return this.orig.getExpressionString();
122     }
123
124     /*
125      * (non-Javadoc)
126      *
127      * @see javax.el.Expression#equals(java.lang.Object)
128      */

129     public boolean equals(Object JavaDoc obj) {
130         return this.orig.equals(obj);
131     }
132
133     /*
134      * (non-Javadoc)
135      *
136      * @see javax.el.Expression#hashCode()
137      */

138     public int hashCode() {
139         return this.orig.hashCode();
140     }
141
142     /*
143      * (non-Javadoc)
144      *
145      * @see javax.el.Expression#isLiteralText()
146      */

147     public boolean isLiteralText() {
148         return false;
149     }
150
151 }
152
153
Popular Tags