001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package javax.servlet.jsp.jstl.core;
038:
039: import javax.el.ELContext;
040: import javax.el.ValueExpression;
041:
042: /**
043: * @author Jacob Hookom
044: * @version $Id: IndexedValueExpression.java,v 1.4 2007/05/06 02:17:13 tcfujii Exp $
045: */
046: public final class IndexedValueExpression extends ValueExpression {
047:
048: /**
049: *
050: */
051: private static final long serialVersionUID = 1L;
052: protected final Integer i;
053: protected final ValueExpression orig;
054:
055: /**
056: *
057: */
058: public IndexedValueExpression(ValueExpression orig, int i) {
059: this .i = Integer.valueOf(i);
060: this .orig = orig;
061: }
062:
063: /*
064: * (non-Javadoc)
065: *
066: * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
067: */
068: public Object getValue(ELContext context) {
069: Object base = this .orig.getValue(context);
070: if (base != null) {
071: context.setPropertyResolved(false);
072: return context.getELResolver().getValue(context, base, i);
073: }
074: return null;
075: }
076:
077: /*
078: * (non-Javadoc)
079: *
080: * @see javax.el.ValueExpression#setValue(javax.el.ELContext,
081: * java.lang.Object)
082: */
083: public void setValue(ELContext context, Object value) {
084: Object base = this .orig.getValue(context);
085: if (base != null) {
086: context.setPropertyResolved(false);
087: context.getELResolver().setValue(context, base, i, value);
088: }
089: }
090:
091: /*
092: * (non-Javadoc)
093: *
094: * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
095: */
096: public boolean isReadOnly(ELContext context) {
097: Object base = this .orig.getValue(context);
098: if (base != null) {
099: context.setPropertyResolved(false);
100: return context.getELResolver().isReadOnly(context, base, i);
101: }
102: return true;
103: }
104:
105: /*
106: * (non-Javadoc)
107: *
108: * @see javax.el.ValueExpression#getType(javax.el.ELContext)
109: */
110: public Class getType(ELContext context) {
111: Object base = this .orig.getValue(context);
112: if (base != null) {
113: context.setPropertyResolved(false);
114: return context.getELResolver().getType(context, base, i);
115: }
116: return null;
117: }
118:
119: /*
120: * (non-Javadoc)
121: *
122: * @see javax.el.ValueExpression#getExpectedType()
123: */
124: public Class getExpectedType() {
125: return Object.class;
126: }
127:
128: /*
129: * (non-Javadoc)
130: *
131: * @see javax.el.Expression#getExpressionString()
132: */
133: public String getExpressionString() {
134: return this .orig.getExpressionString();
135: }
136:
137: /*
138: * (non-Javadoc)
139: *
140: * @see javax.el.Expression#equals(java.lang.Object)
141: */
142: public boolean equals(Object obj) {
143: return this .orig.equals(obj);
144: }
145:
146: /*
147: * (non-Javadoc)
148: *
149: * @see javax.el.Expression#hashCode()
150: */
151: public int hashCode() {
152: return this .orig.hashCode();
153: }
154:
155: /*
156: * (non-Javadoc)
157: *
158: * @see javax.el.Expression#isLiteralText()
159: */
160: public boolean isLiteralText() {
161: return false;
162: }
163:
164: }
|