You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2006/01/25 15:37:45 UTC
svn commit: r372228 [1/6] - in /tomcat/jasper/tc6.0.x/src/share: javax/
javax/el/ org/apache/el/ org/apache/el/lang/ org/apache/el/parser/
org/apache/el/util/
Author: remm
Date: Wed Jan 25 06:37:16 2006
New Revision: 372228
URL: http://svn.apache.org/viewcvs?rev=372228&view=rev
Log:
- Add the JSP 2.1 implementation for the expression language.
- Right now, I'm putting all the code in one place.
- Code contributed by Jacob Hookom (iCLA is on file).
Added:
tomcat/jasper/tc6.0.x/src/share/javax/
tomcat/jasper/tc6.0.x/src/share/javax/el/
tomcat/jasper/tc6.0.x/src/share/javax/el/ArrayELResolver.java
tomcat/jasper/tc6.0.x/src/share/javax/el/BeanELResolver.java
tomcat/jasper/tc6.0.x/src/share/javax/el/CompositeELResolver.java
tomcat/jasper/tc6.0.x/src/share/javax/el/ELContext.java
tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextEvent.java
tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextListener.java
tomcat/jasper/tc6.0.x/src/share/javax/el/ELException.java
tomcat/jasper/tc6.0.x/src/share/javax/el/ELResolver.java
tomcat/jasper/tc6.0.x/src/share/javax/el/Expression.java
tomcat/jasper/tc6.0.x/src/share/javax/el/ExpressionFactory.java
tomcat/jasper/tc6.0.x/src/share/javax/el/FunctionMapper.java
tomcat/jasper/tc6.0.x/src/share/javax/el/ListELResolver.java
tomcat/jasper/tc6.0.x/src/share/javax/el/LocalStrings.properties
tomcat/jasper/tc6.0.x/src/share/javax/el/MapELResolver.java
tomcat/jasper/tc6.0.x/src/share/javax/el/MethodExpression.java
tomcat/jasper/tc6.0.x/src/share/javax/el/MethodInfo.java
tomcat/jasper/tc6.0.x/src/share/javax/el/MethodNotFoundException.java
tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotFoundException.java
tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotWritableException.java
tomcat/jasper/tc6.0.x/src/share/javax/el/ResourceBundleELResolver.java
tomcat/jasper/tc6.0.x/src/share/javax/el/ValueExpression.java
tomcat/jasper/tc6.0.x/src/share/javax/el/VariableMapper.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/
tomcat/jasper/tc6.0.x/src/share/org/apache/el/ExpressionFactoryImpl.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/Messages.properties
tomcat/jasper/tc6.0.x/src/share/org/apache/el/MethodExpressionImpl.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/MethodExpressionLiteral.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/ValueExpressionImpl.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/ValueExpressionLiteral.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/lang/
tomcat/jasper/tc6.0.x/src/share/org/apache/el/lang/ELArithmetic.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/lang/ELSupport.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/lang/EvaluationContext.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/lang/ExpressionBuilder.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/lang/FunctionMapperFactory.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/lang/FunctionMapperImpl.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/lang/VariableMapperFactory.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/lang/VariableMapperImpl.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/ArithmeticNode.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstAnd.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstBracketSuffix.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstChoice.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstCompositeExpression.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstDeferredExpression.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstDiv.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstDotSuffix.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstDynamicExpression.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstEmpty.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstEqual.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstFalse.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstFloatingPoint.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstFunction.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstGreaterThan.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstGreaterThanEqual.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstIdentifier.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstInteger.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstLessThan.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstLessThanEqual.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstLiteralExpression.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstMinus.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstMod.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstMult.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstNegative.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstNot.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstNotEqual.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstNull.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstOr.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstPlus.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstString.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstTrue.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/AstValue.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/BooleanNode.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/ELParser.html
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/ELParser.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/ELParser.jjt
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/ELParserConstants.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/ELParserTokenManager.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/ELParserTreeConstants.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/JJTELParserState.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/Node.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/NodeVisitor.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/ParseException.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/SimpleCharStream.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/SimpleNode.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/Token.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/parser/TokenMgrError.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/util/
tomcat/jasper/tc6.0.x/src/share/org/apache/el/util/ConcurrentCache.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/util/MessageFactory.java
tomcat/jasper/tc6.0.x/src/share/org/apache/el/util/ReflectionUtil.java
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ArrayELResolver.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ArrayELResolver.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ArrayELResolver.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ArrayELResolver.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.beans.FeatureDescriptor;
+import java.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class ArrayELResolver extends ELResolver {
+
+ private final boolean readOnly;
+
+ public ArrayELResolver() {
+ this.readOnly = false;
+ }
+
+ public ArrayELResolver(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base != null && base.getClass().isArray()) {
+ context.setPropertyResolved(true);
+ int idx = coerce(property);
+ checkBounds(base, idx);
+ return Array.get(base, idx);
+ }
+
+ return null;
+ }
+
+ public Class<?> getType(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base != null && base.getClass().isArray()) {
+ context.setPropertyResolved(true);
+ int idx = coerce(property);
+ checkBounds(base, idx);
+ return base.getClass().getComponentType();
+ }
+
+ return null;
+ }
+
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException,
+ ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base != null && base.getClass().isArray()) {
+ context.setPropertyResolved(true);
+
+ if (this.readOnly) {
+ throw new PropertyNotWritableException(message(context,
+ "resolverNotWriteable", new Object[] { base.getClass()
+ .getName() }));
+ }
+
+ int idx = coerce(property);
+ checkBounds(base, idx);
+ Array.set(base, idx, value);
+ }
+ }
+
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base != null && base.getClass().isArray()) {
+ context.setPropertyResolved(true);
+ int idx = coerce(property);
+ checkBounds(base, idx);
+ }
+
+ return this.readOnly;
+ }
+
+ public Iterator getFeatureDescriptors(ELContext context, Object base) {
+ if (base != null && base.getClass().isArray()) {
+ FeatureDescriptor[] descs = new FeatureDescriptor[Array.getLength(base)];
+ for (int i = 0; i < descs.length; i++) {
+ descs[i] = new FeatureDescriptor();
+ descs[i].setDisplayName("["+i+"]");
+ descs[i].setExpert(false);
+ descs[i].setHidden(false);
+ descs[i].setName(""+i);
+ descs[i].setPreferred(true);
+ descs[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.FALSE);
+ descs[i].setValue(TYPE, Integer.class);
+ }
+ return Arrays.asList(descs).iterator();
+ }
+ return null;
+ }
+
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ if (base != null && base.getClass().isArray()) {
+ return Integer.class;
+ }
+ return null;
+ }
+
+ private final static void checkBounds(Object base, int idx) {
+ if (idx < 0 || idx >= Array.getLength(base)) {
+ throw new PropertyNotFoundException(
+ new ArrayIndexOutOfBoundsException(idx).getMessage());
+ }
+ }
+
+ private final static int coerce(Object property) {
+ if (property instanceof Number) {
+ return ((Number) property).intValue();
+ }
+ if (property instanceof Character) {
+ return ((Character) property).charValue();
+ }
+ if (property instanceof Boolean) {
+ return (((Boolean) property).booleanValue() ? 1 : 0);
+ }
+ throw new IllegalArgumentException(property != null ? property
+ .toString() : "null");
+ }
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/BeanELResolver.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/BeanELResolver.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/BeanELResolver.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/BeanELResolver.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,326 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class BeanELResolver extends ELResolver {
+
+ private final boolean readOnly;
+
+ private final ConcurrentCache<String, BeanProperties> cache = new ConcurrentCache<String, BeanProperties>(
+ 1000);
+
+ public BeanELResolver() {
+ this.readOnly = false;
+ }
+
+ public BeanELResolver(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (base == null || property == null) {
+ return null;
+ }
+
+ context.setPropertyResolved(true);
+ Method m = this.property(context, base, property).read(context);
+ try {
+ return m.invoke(base, (Object[]) null);
+ } catch (IllegalAccessException e) {
+ throw new ELException(e);
+ } catch (InvocationTargetException e) {
+ throw new ELException(message(context, "propertyReadError",
+ new Object[] { base.getClass().getName(),
+ property.toString() }), e.getCause());
+ } catch (Exception e) {
+ throw new ELException(e);
+ }
+ }
+
+ public Class<?> getType(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (base == null || property == null) {
+ return null;
+ }
+
+ context.setPropertyResolved(true);
+ return this.property(context, base, property).getType();
+ }
+
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException,
+ ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (base == null || property == null) {
+ return;
+ }
+
+ context.setPropertyResolved(true);
+
+ if (this.readOnly) {
+ throw new PropertyNotWritableException(message(context,
+ "resolverNotWriteable", new Object[] { base.getClass()
+ .getName() }));
+ }
+
+ Method m = this.property(context, base, property).write(context);
+ try {
+ m.invoke(base, new Object[] { value });
+ } catch (IllegalAccessException e) {
+ throw new ELException(e);
+ } catch (InvocationTargetException e) {
+ throw new ELException(message(context, "propertyWriteError",
+ new Object[] { base.getClass().getName(),
+ property.toString() }), e.getCause());
+ } catch (Exception e) {
+ throw new ELException(e);
+ }
+ }
+
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (base == null || property == null) {
+ return false;
+ }
+
+ context.setPropertyResolved(true);
+ return this.readOnly
+ || this.property(context, base, property).isReadOnly();
+ }
+
+ public Iterator getFeatureDescriptors(ELContext context, Object base) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base == null) {
+ return null;
+ }
+
+ try {
+ BeanInfo info = Introspector.getBeanInfo(base.getClass());
+ PropertyDescriptor[] pds = info.getPropertyDescriptors();
+ for (int i = 0; i < pds.length; i++) {
+ pds[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
+ pds[i].setValue(TYPE, pds[i].getPropertyType());
+ }
+ return Arrays.asList(pds).iterator();
+ } catch (IntrospectionException e) {
+ //
+ }
+
+ return null;
+ }
+
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base != null) {
+ return Object.class;
+ }
+
+ return null;
+ }
+
+ private final static class BeanProperties {
+ private final Map<String, BeanProperty> properties;
+
+ private final Class<?> type;
+
+ public BeanProperties(Class<?> type) throws ELException {
+ this.type = type;
+ this.properties = new HashMap<String, BeanProperty>();
+ try {
+ BeanInfo info = Introspector.getBeanInfo(this.type);
+ PropertyDescriptor[] pds = info.getPropertyDescriptors();
+ for (int i = 0; i < pds.length; i++) {
+ this.properties.put(pds[i].getName(), new BeanProperty(
+ type, pds[i]));
+ }
+ } catch (IntrospectionException ie) {
+ throw new ELException(ie);
+ }
+ }
+
+ public BeanProperty get(ELContext ctx, String name) {
+ BeanProperty property = this.properties.get(name);
+ if (property == null) {
+ throw new PropertyNotFoundException(message(ctx,
+ "propertyNotFound",
+ new Object[] { type.getName(), name }));
+ }
+ return property;
+ }
+ }
+
+ private final static class BeanProperty {
+ private final Class type;
+
+ private final Class owner;
+
+ private final PropertyDescriptor descriptor;
+
+ private Method read;
+
+ private Method write;
+
+ public BeanProperty(Class owner, PropertyDescriptor descriptor) {
+ this.owner = owner;
+ this.descriptor = descriptor;
+ this.type = descriptor.getPropertyType();
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ public boolean isReadOnly() {
+ return this.write != null
+ || null == getMethod(type, descriptor.getWriteMethod());
+ }
+
+ public Method write(ELContext ctx) {
+ if (this.write == null) {
+ this.write = getMethod(this.owner, descriptor.getWriteMethod());
+ if (this.write == null) {
+ throw new PropertyNotFoundException(message(ctx,
+ "propertyNotWritable", new Object[] {
+ type.getName(), descriptor.getName() }));
+ }
+ }
+ return this.write;
+ }
+
+ public Method read(ELContext ctx) {
+ if (this.read == null) {
+ this.read = getMethod(this.owner, descriptor.getWriteMethod());
+ if (this.read == null) {
+ throw new PropertyNotFoundException(message(ctx,
+ "propertyNotReadable", new Object[] {
+ type.getName(), descriptor.getName() }));
+ }
+ }
+ return this.read;
+ }
+ }
+
+ private final BeanProperty property(ELContext ctx, Object base,
+ Object property) {
+ Class<?> type = base.getClass();
+ String prop = property.toString();
+
+ BeanProperties props = this.cache.get(type.getName());
+ if (props == null) {
+ props = new BeanProperties(type);
+ this.cache.put(type.getName(), props);
+ }
+
+ return props.get(ctx, prop);
+ }
+
+ private final static Method getMethod(Class type, Method m) {
+ if (m == null || Modifier.isPublic(type.getModifiers())) {
+ return m;
+ }
+ Class[] inf = type.getInterfaces();
+ Method mp = null;
+ for (int i = 0; i < inf.length; i++) {
+ try {
+ mp = inf[i].getMethod(m.getName(), (Class[]) m.getParameterTypes());
+ mp = getMethod(mp.getDeclaringClass(), mp);
+ if (mp != null) {
+ return mp;
+ }
+ } catch (NoSuchMethodException e) {
+ }
+ }
+ Class sup = type.getSuperclass();
+ if (sup != null) {
+ try {
+ mp = sup.getMethod(m.getName(), (Class[]) m.getParameterTypes());
+ mp = getMethod(mp.getDeclaringClass(), mp);
+ if (mp != null) {
+ return mp;
+ }
+ } catch (NoSuchMethodException e) {
+ }
+ }
+ return null;
+ }
+
+ private final static class ConcurrentCache<K,V> {
+
+ private final int size;
+ private final Map<K,V> eden;
+ private final Map<K,V> longterm;
+
+ public ConcurrentCache(int size) {
+ this.size = size;
+ this.eden = new ConcurrentHashMap<K,V>(size);
+ this.longterm = new WeakHashMap<K,V>(size);
+ }
+
+ public V get(K key) {
+ V value = this.eden.get(key);
+ if (value == null) {
+ value = this.longterm.get(key);
+ if (value != null) {
+ this.eden.put(key, value);
+ }
+ }
+ return value;
+ }
+
+ public void put(K key, V value) {
+ if (this.eden.size() >= this.size) {
+ this.longterm.putAll(this.eden);
+ this.eden.clear();
+ }
+ this.eden.put(key, value);
+ }
+
+ }
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/CompositeELResolver.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/CompositeELResolver.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/CompositeELResolver.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/CompositeELResolver.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.util.Iterator;
+
+public class CompositeELResolver extends ELResolver {
+
+ private int size;
+
+ private ELResolver[] resolvers;
+
+ public CompositeELResolver() {
+ this.size = 0;
+ this.resolvers = new ELResolver[2];
+ }
+
+ public void add(ELResolver elResolver) {
+ if (elResolver == null) {
+ throw new NullPointerException();
+ }
+
+ if (this.size >= this.resolvers.length) {
+ ELResolver[] nr = new ELResolver[this.size * 2];
+ System.arraycopy(this.resolvers, 0, nr, 0, this.size);
+ this.resolvers = nr;
+ }
+ this.resolvers[this.size++] = elResolver;
+ }
+
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ context.setPropertyResolved(false);
+ int sz = this.size;
+ Object result = null;
+ for (int i = 0; i < sz; i++) {
+ result = this.resolvers[i].getValue(context, base, property);
+ if (context.isPropertyResolved()) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException,
+ ELException {
+ context.setPropertyResolved(false);
+ int sz = this.size;
+ for (int i = 0; i < sz; i++) {
+ this.resolvers[i].setValue(context, base, property, value);
+ if (context.isPropertyResolved()) {
+ return;
+ }
+ }
+ }
+
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ context.setPropertyResolved(false);
+ int sz = this.size;
+ boolean readOnly = false;
+ for (int i = 0; i < sz; i++) {
+ readOnly = this.resolvers[i].isReadOnly(context, base, property);
+ if (context.isPropertyResolved()) {
+ return readOnly;
+ }
+ }
+ return false;
+ }
+
+ public Iterator getFeatureDescriptors(ELContext context, Object base) {
+ return new FeatureIterator(context, base, this.resolvers, this.size);
+ }
+
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ int sz = this.size;
+ Class<?> commonType = null, type = null;
+ for (int i = 0; i < sz; i++) {
+ type = this.resolvers[i].getCommonPropertyType(context, base);
+ if (type != null
+ && (commonType == null || commonType.isAssignableFrom(type))) {
+ commonType = type;
+ }
+ }
+ return commonType;
+ }
+
+ public Class<?> getType(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ context.setPropertyResolved(false);
+ int sz = this.size;
+ Class<?> type;
+ for (int i = 0; i < sz; i++) {
+ type = this.resolvers[i].getType(context, base, property);
+ if (context.isPropertyResolved()) {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ private final static class FeatureIterator implements Iterator {
+
+ private final ELContext context;
+
+ private final Object base;
+
+ private final ELResolver[] resolvers;
+
+ private final int size;
+
+ private Iterator itr;
+
+ private int idx;
+
+ public FeatureIterator(ELContext context, Object base,
+ ELResolver[] resolvers, int size) {
+ this.context = context;
+ this.base = base;
+ this.resolvers = resolvers;
+ this.size = size;
+
+ this.idx = 0;
+ this.guaranteeIterator();
+ }
+
+ private void guaranteeIterator() {
+ while (this.itr == null && this.idx < this.size) {
+ this.itr = this.resolvers[this.idx].getFeatureDescriptors(
+ this.context, this.base);
+ this.idx++;
+ }
+ }
+
+ public boolean hasNext() {
+ return this.itr != null;
+ }
+
+ public Object next() {
+ Object result = null;
+ if (this.itr != null) {
+ if (this.itr.hasNext()) {
+ result = this.itr.next();
+ if (!this.itr.hasNext()) {
+ this.itr = null;
+ this.guaranteeIterator();
+ }
+ }
+ }
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ELContext.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ELContext.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ELContext.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ELContext.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ *
+ */
+public abstract class ELContext {
+
+ private Locale locale;
+
+ private Map<Class<?>, Object> map;
+
+ private boolean resolved;
+
+ /**
+ *
+ */
+ public ELContext() {
+ this.resolved = false;
+ }
+
+ public Object getContext(Class key) {
+ if (this.map == null) {
+ return null;
+ }
+ return this.map.get(key);
+ }
+
+ public void putContext(Class key, Object contextObject) throws NullPointerException {
+ if (key == null || contextObject == null) {
+ throw new NullPointerException();
+ }
+
+ if (this.map == null) {
+ this.map = new HashMap<Class<?>, Object>();
+ }
+
+ this.map.put(key, contextObject);
+ }
+
+ public void setPropertyResolved(boolean resolved) {
+ this.resolved = resolved;
+ }
+
+ public boolean isPropertyResolved() {
+ return this.resolved;
+ }
+
+ public abstract ELResolver getELResolver();
+
+ public abstract FunctionMapper getFunctionMapper();
+
+ public abstract VariableMapper getVariableMapper();
+
+ public Locale getLocale() {
+ return this.locale;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextEvent.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextEvent.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextEvent.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextEvent.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.util.EventObject;
+
+/**
+ *
+ */
+public class ELContextEvent extends EventObject {
+
+ /**
+ * @param source
+ */
+ public ELContextEvent(ELContext source) {
+ super(source);
+ }
+
+ public ELContext getELContext() {
+ return (ELContext) this.getSource();
+ }
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextListener.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextListener.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextListener.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ELContextListener.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ * @author Jacob Hookom [jacob/hookom.net]
+ *
+ */
+public interface ELContextListener {
+
+ public void contextCreated(ELContextEvent event);
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ELException.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ELException.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ELException.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ELException.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ * Represents any of the exception conditions that can arise during expression
+ * evaluation.
+ *
+ * @since 2.1
+ */
+public class ELException extends RuntimeException {
+
+ /**
+ * Creates an ELException with no detail message
+ */
+ public ELException() {
+ super();
+ }
+
+ /**
+ * Creates an ELException with the provided detail message.
+ *
+ * @param message
+ * the detail message
+ */
+ public ELException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates an ELException with the given detail message and root cause.
+ *
+ * @param message
+ * the detail message
+ * @param cause
+ * the originating cause of this exception
+ */
+ public ELException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Creates an ELException with the given cause
+ *
+ * @param cause
+ * the originating cause of this exception
+ */
+ public ELException(Throwable cause) {
+ super(cause);
+ }
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ELResolver.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ELResolver.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ELResolver.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ELResolver.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author Jacob Hookom [jacob/hookom.net]
+ *
+ */
+public abstract class ELResolver {
+
+ static String message(ELContext context, String name, Object[] props) {
+ Locale locale = context.getLocale();
+ if (locale == null) {
+ locale = Locale.getDefault();
+ if (locale == null) {
+ return "";
+ }
+ }
+ ResourceBundle bundle = ResourceBundle.getBundle(
+ "javax.el.LocalStrings", locale);
+ try {
+ String template = bundle.getString(name);
+ if (props != null) {
+ template = MessageFormat.format(template, props);
+ }
+ return template;
+ } catch (MissingResourceException e) {
+ return "Missing Resource: '" + name + "' for Locale "
+ + locale.getDisplayName();
+ }
+ }
+
+ public final static String RESOLVABLE_AT_DESIGN_TIME = "resolvableAtDesignTime";
+
+ public final static String TYPE = "type";
+
+ public abstract Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException;
+
+ public abstract Class<?> getType(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException;
+
+ public abstract void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException;
+
+ public abstract boolean isReadOnly(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException;
+
+ public abstract Iterator getFeatureDescriptors(ELContext context, Object base);
+
+ public abstract Class<?> getCommonPropertyType(ELContext context, Object base);
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/Expression.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/Expression.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/Expression.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/Expression.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.io.Serializable;
+
+/**
+ *
+ */
+public abstract class Expression implements Serializable {
+
+ public abstract boolean equals(Object obj);
+
+ public abstract int hashCode();
+
+ public abstract String getExpressionString();
+
+ public abstract boolean isLiteralText();
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ExpressionFactory.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ExpressionFactory.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ExpressionFactory.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ExpressionFactory.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ *
+ * @since 2.1
+ */
+public abstract class ExpressionFactory {
+
+ public abstract Object coerceToType(Object obj, Class<?> expectedType)
+ throws ELException;
+
+ public abstract ValueExpression createValueExpression(ELContext context,
+ String expression, Class<?> expectedType)
+ throws NullPointerException, ELException;
+
+ public abstract ValueExpression createValueExpression(Object instance,
+ Class<?> expectedType);
+
+ public abstract MethodExpression createMethodExpression(ELContext context,
+ String expression, Class<?> expectedReturnType,
+ Class<?>[] expectedParamTypes) throws ELException,
+ NullPointerException;
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/FunctionMapper.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/FunctionMapper.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/FunctionMapper.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/FunctionMapper.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.lang.reflect.Method;
+
+/**
+ *
+ */
+public abstract class FunctionMapper {
+
+ public abstract Method resolveFunction(String prefix, String localName);
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ListELResolver.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ListELResolver.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ListELResolver.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ListELResolver.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.beans.FeatureDescriptor;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+public class ListELResolver extends ELResolver {
+
+ private final boolean readOnly;
+
+ private final static Class UNMODIFIABLE = Collections.unmodifiableList(
+ new ArrayList()).getClass();
+
+ public ListELResolver() {
+ this.readOnly = true;
+ }
+
+ public ListELResolver(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof List) {
+ context.setPropertyResolved(true);
+ List list = (List) base;
+ int idx = coerce(property);
+ if (idx < 0 || idx >= list.size()) {
+ return null;
+ }
+ return list.get(idx);
+ }
+
+ return null;
+ }
+
+ public Class<?> getType(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof List) {
+ context.setPropertyResolved(true);
+ List list = (List) base;
+ int idx = coerce(property);
+ if (idx < 0 || idx >= list.size()) {
+ return null;
+ }
+ Object obj = list.get(idx);
+ return (obj != null) ? obj.getClass() : null;
+ }
+
+ return null;
+ }
+
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException,
+ ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof List) {
+ context.setPropertyResolved(true);
+ List list = (List) base;
+
+ if (this.readOnly) {
+ throw new PropertyNotWritableException(message(context,
+ "resolverNotWriteable", new Object[] { base.getClass()
+ .getName() }));
+ }
+
+ int idx = coerce(property);
+ try {
+ list.set(idx, value);
+ } catch (UnsupportedOperationException e) {
+ throw new PropertyNotWritableException(e);
+ } catch (IndexOutOfBoundsException e) {
+ throw new PropertyNotFoundException(e);
+ }
+ }
+ }
+
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof List) {
+ context.setPropertyResolved(true);
+ List list = (List) base;
+ int idx = coerce(property);
+ if (idx < 0 || idx >= list.size()) {
+ throw new PropertyNotFoundException(
+ new ArrayIndexOutOfBoundsException(idx).getMessage());
+ }
+ return this.readOnly || UNMODIFIABLE.equals(list.getClass());
+ }
+
+ return this.readOnly;
+ }
+
+ public Iterator getFeatureDescriptors(ELContext context, Object base) {
+ if (base instanceof List) {
+ FeatureDescriptor[] descs = new FeatureDescriptor[((List) base).size()];
+ for (int i = 0; i < descs.length; i++) {
+ descs[i] = new FeatureDescriptor();
+ descs[i].setDisplayName("["+i+"]");
+ descs[i].setExpert(false);
+ descs[i].setHidden(false);
+ descs[i].setName(""+i);
+ descs[i].setPreferred(true);
+ descs[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.FALSE);
+ descs[i].setValue(TYPE, Integer.class);
+ }
+ return Arrays.asList(descs).iterator();
+ }
+ return null;
+ }
+
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ if (base != null && base instanceof List) {
+ return Integer.class;
+ }
+ return null;
+ }
+
+ private final static int coerce(Object property) {
+ if (property instanceof Number) {
+ return ((Number) property).intValue();
+ }
+ if (property instanceof Character) {
+ return ((Character) property).charValue();
+ }
+ if (property instanceof Boolean) {
+ return (((Boolean) property).booleanValue() ? 1 : 0);
+ }
+ throw new IllegalArgumentException(property != null ? property
+ .toString() : "null");
+ }
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/LocalStrings.properties
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/LocalStrings.properties?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/LocalStrings.properties (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/LocalStrings.properties Wed Jan 25 06:37:16 2006
@@ -0,0 +1,23 @@
+# Copyright 2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Default localized string information
+# Localized for Locale en_US
+
+propertyNotFound=Property '{1}' not found on type {0}
+propertyNotReadable=Property '{1}' not readable on type {0}
+propertyNotWritable=Property '{1}' not writable on type {0}
+propertyReadError=Error reading '{1}' on type {0}
+propertyWriteError=Error writing '{1}' on type {0}
+resolverNotWritable=ELResolver not writable for type {0}
\ No newline at end of file
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/MapELResolver.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/MapELResolver.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/MapELResolver.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/MapELResolver.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class MapELResolver extends ELResolver {
+
+ private final static Class UNMODIFIABLE = Collections.unmodifiableMap(
+ new HashMap()).getClass();
+
+ private final boolean readOnly;
+
+ public MapELResolver() {
+ this.readOnly = false;
+ }
+
+ public MapELResolver(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof Map) {
+ context.setPropertyResolved(true);
+ return ((Map) base).get(property);
+ }
+
+ return null;
+ }
+
+ public Class<?> getType(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof Map) {
+ context.setPropertyResolved(true);
+ Object obj = ((Map) base).get(property);
+ return (obj != null) ? obj.getClass() : null;
+ }
+
+ return null;
+ }
+
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException,
+ ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof Map) {
+ context.setPropertyResolved(true);
+
+ if (this.readOnly) {
+ throw new PropertyNotWritableException(message(context,
+ "resolverNotWriteable", new Object[] { base.getClass()
+ .getName() }));
+ }
+
+ try {
+ ((Map) base).put(property, value);
+ } catch (UnsupportedOperationException e) {
+ throw new PropertyNotWritableException(e);
+ }
+ }
+ }
+
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof Map) {
+ context.setPropertyResolved(true);
+ return this.readOnly || UNMODIFIABLE.equals(base.getClass());
+ }
+
+ return this.readOnly;
+ }
+
+ public Iterator getFeatureDescriptors(ELContext context, Object base) {
+ if (base instanceof Map) {
+ Iterator itr = ((Map) base).keySet().iterator();
+ List feats = new ArrayList();
+ Object key;
+ FeatureDescriptor desc;
+ while (itr.hasNext()) {
+ key = itr.next();
+ desc = new FeatureDescriptor();
+ desc.setDisplayName(key.toString());
+ desc.setExpert(false);
+ desc.setHidden(false);
+ desc.setName(key.toString());
+ desc.setPreferred(true);
+ desc.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.FALSE);
+ desc.setValue(TYPE, key.getClass());
+ feats.add(desc);
+ }
+ return feats.iterator();
+ }
+ return null;
+ }
+
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ if (base instanceof Map) {
+ return Object.class;
+ }
+ return null;
+ }
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/MethodExpression.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/MethodExpression.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/MethodExpression.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/MethodExpression.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ *
+ */
+public abstract class MethodExpression extends Expression {
+
+ public abstract MethodInfo getMethodInfo(ELContext context) throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException;
+
+ public abstract Object invoke(ELContext context, Object[] params) throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException;
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/MethodInfo.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/MethodInfo.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/MethodInfo.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/MethodInfo.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ *
+ */
+public class MethodInfo {
+
+ private final String name;
+
+ private final Class<?>[] paramTypes;
+
+ private final Class<?> returnType;
+
+ /**
+ *
+ */
+ public MethodInfo(String name, Class<?> returnType, Class<?>[] paramTypes) {
+ this.name = name;
+ this.returnType = returnType;
+ this.paramTypes = paramTypes;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public Class<?>[] getParamTypes() {
+ return this.paramTypes;
+ }
+
+ public Class<?> getReturnType() {
+ return this.returnType;
+ }
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/MethodNotFoundException.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/MethodNotFoundException.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/MethodNotFoundException.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/MethodNotFoundException.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ *
+ */
+public class MethodNotFoundException extends ELException {
+
+ /**
+ *
+ */
+ public MethodNotFoundException() {
+ super();
+ }
+
+ /**
+ * @param message
+ */
+ public MethodNotFoundException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public MethodNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param cause
+ */
+ public MethodNotFoundException(Throwable cause) {
+ super(cause);
+ }
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotFoundException.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotFoundException.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotFoundException.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotFoundException.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ *
+ */
+public class PropertyNotFoundException extends ELException {
+
+ /**
+ *
+ */
+ public PropertyNotFoundException() {
+ super();
+ }
+
+ /**
+ * @param message
+ */
+ public PropertyNotFoundException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public PropertyNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param cause
+ */
+ public PropertyNotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotWritableException.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotWritableException.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotWritableException.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/PropertyNotWritableException.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ *
+ */
+public class PropertyNotWritableException extends ELException {
+
+ /**
+ *
+ */
+ public PropertyNotWritableException() {
+ super();
+ }
+
+ /**
+ * @param message
+ */
+ public PropertyNotWritableException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public PropertyNotWritableException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param cause
+ */
+ public PropertyNotWritableException(Throwable cause) {
+ super(cause);
+ }
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ResourceBundleELResolver.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ResourceBundleELResolver.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ResourceBundleELResolver.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ResourceBundleELResolver.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class ResourceBundleELResolver extends ELResolver {
+
+ public ResourceBundleELResolver() {
+ super();
+ }
+
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof ResourceBundle) {
+ context.setPropertyResolved(true);
+
+ if (property != null) {
+ try {
+ return ((ResourceBundle) base).getObject(property
+ .toString());
+ } catch (MissingResourceException mre) {
+ return "???" + property.toString() + "???";
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public Class<?> getType(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof ResourceBundle) {
+ context.setPropertyResolved(true);
+ }
+
+ return null;
+ }
+
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException,
+ ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof ResourceBundle) {
+ context.setPropertyResolved(true);
+ throw new PropertyNotWritableException(message(context,
+ "resolverNotWriteable", new Object[] { base.getClass()
+ .getName() }));
+ }
+ }
+
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof ResourceBundle) {
+ context.setPropertyResolved(true);
+ }
+
+ return true;
+ }
+
+ public Iterator getFeatureDescriptors(ELContext context, Object base) {
+ if (base instanceof ResourceBundle) {
+ List feats = new ArrayList();
+ Enumeration e = ((ResourceBundle) base).getKeys();
+ FeatureDescriptor feat;
+ String key;
+ while (e.hasMoreElements()) {
+ key = (String) e.nextElement();
+ feat = new FeatureDescriptor();
+ feat.setDisplayName(key);
+ feat.setExpert(false);
+ feat.setHidden(false);
+ feat.setName(key);
+ feat.setPreferred(true);
+ feat.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
+ feat.setValue(TYPE, String.class);
+ feats.add(feat);
+ }
+ return feats.iterator();
+ }
+ return null;
+ }
+
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ if (base instanceof ResourceBundle) {
+ return String.class;
+ }
+ return null;
+ }
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/ValueExpression.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/ValueExpression.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/ValueExpression.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/ValueExpression.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ *
+ */
+public abstract class ValueExpression extends Expression {
+
+ public abstract Class<?> getExpectedType();
+
+ public abstract Class<?> getType(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException;
+
+ public abstract boolean isReadOnly(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException;
+
+ public abstract void setValue(ELContext context, Object value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException;
+
+ public abstract Object getValue(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException;
+
+}
Added: tomcat/jasper/tc6.0.x/src/share/javax/el/VariableMapper.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/javax/el/VariableMapper.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/javax/el/VariableMapper.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/javax/el/VariableMapper.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.el;
+
+/**
+ *
+ */
+public abstract class VariableMapper {
+
+ public abstract ValueExpression resolveVariable(String variable);
+
+ public abstract ValueExpression setVariable(String variable, ValueExpression expression);
+}
Added: tomcat/jasper/tc6.0.x/src/share/org/apache/el/ExpressionFactoryImpl.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/el/ExpressionFactoryImpl.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/org/apache/el/ExpressionFactoryImpl.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/org/apache/el/ExpressionFactoryImpl.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.el;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+import org.apache.el.lang.ELSupport;
+import org.apache.el.lang.ExpressionBuilder;
+import org.apache.el.util.MessageFactory;
+
+
+/**
+ * @see javax.el.ExpressionFactory
+ *
+ * @author Jacob Hookom [jacob@hookom.net]
+ * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: kchung $
+ */
+public class ExpressionFactoryImpl extends ExpressionFactory {
+
+ /**
+ *
+ */
+ public ExpressionFactoryImpl() {
+ super();
+ }
+
+ public Object coerceToType(Object obj, Class type) {
+ return ELSupport.coerceToType(obj, type);
+ }
+
+ public MethodExpression createMethodExpression(ELContext context,
+ String expression, Class<?> expectedReturnType,
+ Class<?>[] expectedParamTypes) {
+ if (expectedParamTypes == null) {
+ throw new NullPointerException(MessageFactory
+ .get("error.method.nullParms"));
+ }
+ ExpressionBuilder builder = new ExpressionBuilder(expression, context);
+ return builder.createMethodExpression(expectedReturnType,
+ expectedParamTypes);
+ }
+
+ public ValueExpression createValueExpression(ELContext context,
+ String expression, Class expectedType) {
+ if (expectedType == null) {
+ throw new NullPointerException(MessageFactory
+ .get("error.value.expectedType"));
+ }
+ ExpressionBuilder builder = new ExpressionBuilder(expression, context);
+ return builder.createValueExpression(expectedType);
+ }
+
+ public ValueExpression createValueExpression(Object instance,
+ Class expectedType) {
+ if (expectedType == null) {
+ throw new NullPointerException(MessageFactory
+ .get("error.value.expectedType"));
+ }
+ return new ValueExpressionLiteral(instance, expectedType);
+ }
+}
Added: tomcat/jasper/tc6.0.x/src/share/org/apache/el/Messages.properties
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/el/Messages.properties?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/org/apache/el/Messages.properties (added)
+++ tomcat/jasper/tc6.0.x/src/share/org/apache/el/Messages.properties Wed Jan 25 06:37:16 2006
@@ -0,0 +1,48 @@
+# General Errors
+error.convert=Cannot convert {0} of type {1} to {2}
+error.compare=Cannot compare {0} to {1}
+error.function=Problems calling function ''{0}''
+error.unreachable.base=Target Unreachable, identifier ''{0}'' resolved to null
+error.unreachable.property=Target Unreachable, ''{0}'' returned null
+error.resolver.unhandled=ELResolver did not handle type: {0} with property of ''{1}''
+error.resolver.unhandled.null=ELResolver cannot handle a null base Object with identifier ''{0}''
+
+# ValueExpressionLiteral
+error.value.literal.write=ValueExpression is a literal and not writable: {0}
+
+# ExpressionFactoryImpl
+error.null=Expression cannot be null
+error.mixed=Expression cannot contain both '#{..}' and '${..}' : {0}
+error.method=Not a valid MethodExpression : {0}
+error.method.nullParms=Parameter types cannot be null
+error.value.expectedType=Expected type cannot be null
+
+# ExpressionMediator
+error.eval=Error Evaluating {0} : {1}
+
+# ValueSetVisitor
+error.syntax.set=Illegal Syntax for Set Operation
+
+# ReflectionUtil
+error.method.notfound=Method not found: {0}.{1}({2})
+error.property.notfound=Property ''{1}'' not found on {0}
+
+# ValidatingVisitor
+error.fnMapper.null=Expression uses functions, but no FunctionMapper was provided
+error.fnMapper.method=Function ''{0}'' not found
+error.fnMapper.paramcount=Function ''{0}'' specifies {1} params, but {2} were declared
+
+# **ExpressionImpl
+error.context.null=ELContext was null
+
+# ArrayELResolver
+error.array.outofbounds=Index {0} is out of bounds for array of size {1}
+
+# ListELResolver
+error.list.outofbounds=Index {0} is out of bounds for list of size {1}
+
+# BeanELResolver
+error.property.notfound=Property ''{1}'' not found on type: {0}
+error.property.invocation=Property ''{1}'' threw an exception from type: {0}
+error.property.notreadable=Property ''{1}'' doesn't have a 'get' specified on type: {0}
+error.property.notwritable=Property ''{1}'' doesn't have a 'set' specified on type: {0}
\ No newline at end of file
Added: tomcat/jasper/tc6.0.x/src/share/org/apache/el/MethodExpressionImpl.java
URL: http://svn.apache.org/viewcvs/tomcat/jasper/tc6.0.x/src/share/org/apache/el/MethodExpressionImpl.java?rev=372228&view=auto
==============================================================================
--- tomcat/jasper/tc6.0.x/src/share/org/apache/el/MethodExpressionImpl.java (added)
+++ tomcat/jasper/tc6.0.x/src/share/org/apache/el/MethodExpressionImpl.java Wed Jan 25 06:37:16 2006
@@ -0,0 +1,319 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.el;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.Expression;
+import javax.el.ExpressionFactory;
+import javax.el.FunctionMapper;
+import javax.el.MethodExpression;
+import javax.el.MethodInfo;
+import javax.el.MethodNotFoundException;
+import javax.el.PropertyNotFoundException;
+import javax.el.VariableMapper;
+
+import org.apache.el.lang.ELSupport;
+import org.apache.el.lang.EvaluationContext;
+import org.apache.el.lang.ExpressionBuilder;
+import org.apache.el.parser.Node;
+import org.apache.el.util.ReflectionUtil;
+
+
+/**
+ * An <code>Expression</code> that refers to a method on an object.
+ *
+ * <p>
+ * <code>The {@link ExpressionFactory#createMethodExpression} method
+ * can be used to parse an expression string and return a concrete instance
+ * of <code>MethodExpression</code> that encapsulates the parsed expression.
+ * The {@link FunctionMapper} is used at parse time, not evaluation time,
+ * so one is not needed to evaluate an expression using this class.
+ * However, the {@link ELContext} is needed at evaluation time.</p>
+ *
+ * <p>The {@link #getMethodInfo} and {@link #invoke} methods will evaluate the
+ * expression each time they are called. The {@link ELResolver} in the
+ * <code>ELContext</code> is used to resolve the top-level variables and to
+ * determine the behavior of the <code>.</code> and <code>[]</code>
+ * operators. For any of the two methods, the {@link ELResolver#getValue}
+ * method is used to resolve all properties up to but excluding the last
+ * one. This provides the <code>base</code> object on which the method
+ * appears. If the <code>base</code> object is null, a
+ * <code>NullPointerException</code> must be thrown. At the last resolution,
+ * the final <code>property</code> is then coerced to a <code>String</code>,
+ * which provides the name of the method to be found. A method matching the
+ * name and expected parameters provided at parse time is found and it is
+ * either queried or invoked (depending on the method called on this
+ * <code>MethodExpression</code>).</p>
+ *
+ * <p>See the notes about comparison, serialization and immutability in
+ * the {@link Expression} javadocs.
+ *
+ * @see javax.el.ELResolver
+ * @see javax.el.Expression
+ * @see javax.el.ExpressionFactory
+ * @see javax.el.MethodExpression
+ *
+ * @author Jacob Hookom [jacob@hookom.net]
+ * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: jhook $
+ */
+public final class MethodExpressionImpl extends MethodExpression implements
+ Externalizable {
+
+ private Class expectedType;
+
+ private String expr;
+
+ private FunctionMapper fnMapper;
+
+ private VariableMapper varMapper;
+
+ private transient Node node;
+
+ private Class[] paramTypes;
+
+ /**
+ *
+ */
+ public MethodExpressionImpl() {
+ super();
+ }
+
+ /**
+ * @param expr
+ * @param node
+ * @param fnMapper
+ * @param expectedType
+ * @param paramTypes
+ */
+ public MethodExpressionImpl(String expr, Node node,
+ FunctionMapper fnMapper, VariableMapper varMapper,
+ Class expectedType, Class[] paramTypes) {
+ super();
+ this.expr = expr;
+ this.node = node;
+ this.fnMapper = fnMapper;
+ this.varMapper = varMapper;
+ this.expectedType = expectedType;
+ this.paramTypes = paramTypes;
+ }
+
+ /**
+ * Determines whether the specified object is equal to this
+ * <code>Expression</code>.
+ *
+ * <p>
+ * The result is <code>true</code> if and only if the argument is not
+ * <code>null</code>, is an <code>Expression</code> object that is the
+ * of the same type (<code>ValueExpression</code> or
+ * <code>MethodExpression</code>), and has an identical parsed
+ * representation.
+ * </p>
+ *
+ * <p>
+ * Note that two expressions can be equal if their expression Strings are
+ * different. For example, <code>${fn1:foo()}</code> and
+ * <code>${fn2:foo()}</code> are equal if their corresponding
+ * <code>FunctionMapper</code>s mapped <code>fn1:foo</code> and
+ * <code>fn2:foo</code> to the same method.
+ * </p>
+ *
+ * @param obj
+ * the <code>Object</code> to test for equality.
+ * @return <code>true</code> if <code>obj</code> equals this
+ * <code>Expression</code>; <code>false</code> otherwise.
+ * @see java.util.Hashtable
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ return (obj instanceof MethodExpressionImpl && obj.hashCode() == this
+ .hashCode());
+ }
+
+ /**
+ * Returns the original String used to create this <code>Expression</code>,
+ * unmodified.
+ *
+ * <p>
+ * This is used for debugging purposes but also for the purposes of
+ * comparison (e.g. to ensure the expression in a configuration file has not
+ * changed).
+ * </p>
+ *
+ * <p>
+ * This method does not provide sufficient information to re-create an
+ * expression. Two different expressions can have exactly the same
+ * expression string but different function mappings. Serialization should
+ * be used to save and restore the state of an <code>Expression</code>.
+ * </p>
+ *
+ * @return The original expression String.
+ *
+ * @see javax.el.Expression#getExpressionString()
+ */
+ public String getExpressionString() {
+ return this.expr;
+ }
+
+ /**
+ * Evaluates the expression relative to the provided context, and returns
+ * information about the actual referenced method.
+ *
+ * @param context
+ * The context of this evaluation
+ * @return an instance of <code>MethodInfo</code> containing information
+ * about the method the expression evaluated to.
+ * @throws NullPointerException
+ * if context is <code>null</code> or the base object is
+ * <code>null</code> on the last resolution.
+ * @throws PropertyNotFoundException
+ * if one of the property resolutions failed because a specified
+ * variable or property does not exist or is not readable.
+ * @throws MethodNotFoundException
+ * if no suitable method can be found.
+ * @throws ELException
+ * if an exception was thrown while performing property or
+ * variable resolution. The thrown exception must be included as
+ * the cause property of this exception, if available.
+ * @see javax.el.MethodExpression#getMethodInfo(javax.el.ELContext)
+ */
+ public MethodInfo getMethodInfo(ELContext context)
+ throws PropertyNotFoundException, MethodNotFoundException,
+ ELException {
+ Node n = this.getNode();
+ EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
+ this.varMapper);
+ return n.getMethodInfo(ctx, this.paramTypes);
+ }
+
+ /**
+ * @return
+ * @throws ELException
+ */
+ private Node getNode() throws ELException {
+ if (this.node == null) {
+ this.node = ExpressionBuilder.createNode(this.expr);
+ }
+ return this.node;
+ }
+
+ /**
+ * Returns the hash code for this <code>Expression</code>.
+ *
+ * <p>
+ * See the note in the {@link #equals} method on how two expressions can be
+ * equal if their expression Strings are different. Recall that if two
+ * objects are equal according to the <code>equals(Object)</code> method,
+ * then calling the <code>hashCode</code> method on each of the two
+ * objects must produce the same integer result. Implementations must take
+ * special note and implement <code>hashCode</code> correctly.
+ * </p>
+ *
+ * @return The hash code for this <code>Expression</code>.
+ * @see #equals
+ * @see java.util.Hashtable
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return this.expr.hashCode();
+ }
+
+ /**
+ * Evaluates the expression relative to the provided context, invokes the
+ * method that was found using the supplied parameters, and returns the
+ * result of the method invocation.
+ *
+ * @param context
+ * The context of this evaluation.
+ * @param params
+ * The parameters to pass to the method, or <code>null</code>
+ * if no parameters.
+ * @return the result of the method invocation (<code>null</code> if the
+ * method has a <code>void</code> return type).
+ * @throws NullPointerException
+ * if context is <code>null</code> or the base object is
+ * <code>null</code> on the last resolution.
+ * @throws PropertyNotFoundException
+ * if one of the property resolutions failed because a specified
+ * variable or property does not exist or is not readable.
+ * @throws MethodNotFoundException
+ * if no suitable method can be found.
+ * @throws ELException
+ * if an exception was thrown while performing property or
+ * variable resolution. The thrown exception must be included as
+ * the cause property of this exception, if available. If the
+ * exception thrown is an <code>InvocationTargetException</code>,
+ * extract its <code>cause</code> and pass it to the
+ * <code>ELException</code> constructor.
+ * @see javax.el.MethodExpression#invoke(javax.el.ELContext,
+ * java.lang.Object[])
+ */
+ public Object invoke(ELContext context, Object[] params)
+ throws PropertyNotFoundException, MethodNotFoundException,
+ ELException {
+ EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
+ this.varMapper);
+ Object v = this.getNode().invoke(ctx, this.paramTypes, params);
+ if (this.expectedType != null) {
+ return ELSupport.coerceToType(v, this.expectedType);
+ } else {
+ return v;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+ */
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ this.expr = in.readUTF();
+ String type = in.readUTF();
+ if (!"".equals(type)) {
+ this.expectedType = ReflectionUtil.forName(type);
+ }
+ this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in
+ .readObject()));
+ this.fnMapper = (FunctionMapper) in.readObject();
+ this.varMapper = (VariableMapper) in.readObject();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+ */
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeUTF(this.expr);
+ out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
+ : "");
+ out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
+ out.writeObject(this.fnMapper);
+ out.writeObject(this.varMapper);
+ }
+
+ public boolean isLiteralText() {
+ return false;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org