From b1e4095d8614ddb1cafe87bd32f31451102708a3 Mon Sep 17 00:00:00 2001 From: Dmytro Maidaniuk Date: Sat, 17 Sep 2022 18:29:54 +0300 Subject: [PATCH 1/3] Upgraded to Jakarta EL 4 --- .gitignore | 1 + modules/api/pom.xml | 49 -- .../main/java/javax/el/ArrayELResolver.java | 307 -------- .../main/java/javax/el/BeanELResolver.java | 666 ------------------ .../java/javax/el/CompositeELResolver.java | 404 ----------- .../api/src/main/java/javax/el/ELContext.java | 174 ----- .../main/java/javax/el/ELContextEvent.java | 46 -- .../main/java/javax/el/ELContextListener.java | 29 - .../src/main/java/javax/el/ELException.java | 62 -- .../src/main/java/javax/el/ELResolver.java | 293 -------- .../src/main/java/javax/el/Expression.java | 84 --- .../main/java/javax/el/ExpressionFactory.java | 326 --------- .../main/java/javax/el/FunctionMapper.java | 37 - .../main/java/javax/el/ListELResolver.java | 321 --------- .../src/main/java/javax/el/MapELResolver.java | 303 -------- .../main/java/javax/el/MethodExpression.java | 112 --- .../src/main/java/javax/el/MethodInfo.java | 68 -- .../javax/el/MethodNotFoundException.java | 62 -- .../javax/el/PropertyNotFoundException.java | 65 -- .../el/PropertyNotWritableException.java | 64 -- .../javax/el/ResourceBundleELResolver.java | 238 ------- .../main/java/javax/el/ValueExpression.java | 180 ----- .../main/java/javax/el/ValueReference.java | 43 -- .../main/java/javax/el/VariableMapper.java | 44 -- .../api/src/test/java/javax/el/AllTests.java | 40 -- .../java/javax/el/ArrayELResolverTest.java | 259 ------- .../java/javax/el/BeanELResolverTest.java | 308 -------- .../javax/el/CompositeELResolverTest.java | 166 ----- .../src/test/java/javax/el/ELContextTest.java | 46 -- .../java/javax/el/ExpressionFactoryTest.java | 55 -- .../java/javax/el/ListELResolverTest.java | 262 ------- .../test/java/javax/el/MapELResolverTest.java | 218 ------ .../test/java/javax/el/MethodInfoTest.java | 33 - .../el/ResourceBundleELResolverTest.java | 209 ------ .../src/test/java/javax/el/TestContext.java | 33 - .../src/test/java/javax/el/TestFactory.java | 75 -- .../java/javax/el/ValueReferenceTest.java | 15 - .../test/java/javax/el/test/TestClass.java | 35 - .../java/javax/el/test/TestInterface.java | 5 - .../services/javax.el.ExpressionFactory | 1 - modules/impl/pom.xml | 23 +- .../de/odysseus/el/ExpressionFactoryImpl.java | 69 +- .../de/odysseus/el/ObjectValueExpression.java | 7 +- .../de/odysseus/el/TreeMethodExpression.java | 17 +- .../de/odysseus/el/TreeValueExpression.java | 8 +- .../odysseus/el/misc/BooleanOperations.java | 2 +- .../de/odysseus/el/misc/NumberOperations.java | 2 +- .../de/odysseus/el/misc/TypeConverter.java | 2 +- .../odysseus/el/misc/TypeConverterImpl.java | 2 +- .../java/de/odysseus/el/tree/Bindings.java | 4 +- .../de/odysseus/el/tree/ExpressionNode.java | 8 +- .../main/java/de/odysseus/el/tree/Tree.java | 8 +- .../java/de/odysseus/el/tree/TreeBuilder.java | 2 +- .../el/tree/TreeBuilderException.java | 2 +- .../de/odysseus/el/tree/impl/Builder.java | 16 +- .../odysseus/el/tree/impl/ast/AstBinary.java | 2 +- .../odysseus/el/tree/impl/ast/AstBoolean.java | 2 +- .../odysseus/el/tree/impl/ast/AstBracket.java | 4 +- .../odysseus/el/tree/impl/ast/AstChoice.java | 4 +- .../el/tree/impl/ast/AstComposite.java | 2 +- .../de/odysseus/el/tree/impl/ast/AstDot.java | 4 +- .../de/odysseus/el/tree/impl/ast/AstEval.java | 6 +- .../el/tree/impl/ast/AstFunction.java | 4 +- .../el/tree/impl/ast/AstIdentifier.java | 16 +- .../odysseus/el/tree/impl/ast/AstMethod.java | 12 +- .../odysseus/el/tree/impl/ast/AstNested.java | 2 +- .../de/odysseus/el/tree/impl/ast/AstNode.java | 2 +- .../de/odysseus/el/tree/impl/ast/AstNull.java | 2 +- .../odysseus/el/tree/impl/ast/AstNumber.java | 2 +- .../el/tree/impl/ast/AstParameters.java | 2 +- .../el/tree/impl/ast/AstProperty.java | 12 +- .../el/tree/impl/ast/AstRightValue.java | 8 +- .../odysseus/el/tree/impl/ast/AstString.java | 2 +- .../de/odysseus/el/tree/impl/ast/AstText.java | 8 +- .../odysseus/el/tree/impl/ast/AstUnary.java | 4 +- .../el/util/RootPropertyResolver.java | 8 +- .../de/odysseus/el/util/SimpleContext.java | 10 +- .../de/odysseus/el/util/SimpleResolver.java | 16 +- .../services/jakarta.el.ExpressionFactory} | 2 +- .../src/main/resources/OSGI-INF/services.xml | 2 +- .../el/ObjectValueExpressionTest.java | 2 +- .../odysseus/el/TreeMethodExpressionTest.java | 4 +- .../odysseus/el/TreeValueExpressionTest.java | 4 +- .../el/misc/TypeConverterImplTest.java | 2 +- .../de/odysseus/el/tree/BindingsTest.java | 2 +- .../el/tree/impl/ast/AstBinaryTest.java | 2 +- .../el/tree/impl/ast/AstBooleanTest.java | 2 +- .../el/tree/impl/ast/AstBracketTest.java | 8 +- .../el/tree/impl/ast/AstChoiceTest.java | 2 +- .../el/tree/impl/ast/AstCompositeTest.java | 2 +- .../odysseus/el/tree/impl/ast/AstDotTest.java | 10 +- .../el/tree/impl/ast/AstFunctionTest.java | 2 +- .../el/tree/impl/ast/AstIdentifierTest.java | 8 +- .../el/tree/impl/ast/AstMethodTest.java | 10 +- .../el/tree/impl/ast/AstNullTest.java | 2 +- .../el/tree/impl/ast/AstNumberTest.java | 2 +- .../el/tree/impl/ast/AstStringTest.java | 2 +- .../el/tree/impl/ast/AstTextTest.java | 2 +- .../el/tree/impl/ast/AstUnaryTest.java | 2 +- modules/spi/.gitignore | 4 - modules/spi/pom.xml | 43 -- pom.xml | 36 +- project/doc/xdocs/guide/start.xml | 2 +- project/doc/xdocs/guide/util/context.xml | 2 +- project/doc/xdocs/guide/util/resolver.xml | 2 +- {modules/api => samples}/.gitignore | 0 samples/pom.xml | 56 ++ .../el/samples/calculator/Calculator.java | 6 +- .../samples/experimental/SyntaxExtension.java | 4 +- .../samples/extensions/MethodInvocations.java | 10 +- .../el/samples/extensions/NullProperties.java | 6 +- .../el/samples/extensions/VarArgs.java | 4 +- .../el/samples/xml/sax/AbstractFilter.java | 6 +- .../el/samples/xml/sax/AttributesFilter.java | 4 +- .../el/samples/xml/sax/TextFilter.java | 2 +- .../el/samples/xml/sax/XMELFilter.java | 2 +- 116 files changed, 284 insertions(+), 6023 deletions(-) delete mode 100644 modules/api/pom.xml delete mode 100644 modules/api/src/main/java/javax/el/ArrayELResolver.java delete mode 100644 modules/api/src/main/java/javax/el/BeanELResolver.java delete mode 100644 modules/api/src/main/java/javax/el/CompositeELResolver.java delete mode 100644 modules/api/src/main/java/javax/el/ELContext.java delete mode 100644 modules/api/src/main/java/javax/el/ELContextEvent.java delete mode 100644 modules/api/src/main/java/javax/el/ELContextListener.java delete mode 100644 modules/api/src/main/java/javax/el/ELException.java delete mode 100644 modules/api/src/main/java/javax/el/ELResolver.java delete mode 100644 modules/api/src/main/java/javax/el/Expression.java delete mode 100644 modules/api/src/main/java/javax/el/ExpressionFactory.java delete mode 100644 modules/api/src/main/java/javax/el/FunctionMapper.java delete mode 100644 modules/api/src/main/java/javax/el/ListELResolver.java delete mode 100644 modules/api/src/main/java/javax/el/MapELResolver.java delete mode 100644 modules/api/src/main/java/javax/el/MethodExpression.java delete mode 100644 modules/api/src/main/java/javax/el/MethodInfo.java delete mode 100644 modules/api/src/main/java/javax/el/MethodNotFoundException.java delete mode 100644 modules/api/src/main/java/javax/el/PropertyNotFoundException.java delete mode 100644 modules/api/src/main/java/javax/el/PropertyNotWritableException.java delete mode 100644 modules/api/src/main/java/javax/el/ResourceBundleELResolver.java delete mode 100644 modules/api/src/main/java/javax/el/ValueExpression.java delete mode 100644 modules/api/src/main/java/javax/el/ValueReference.java delete mode 100644 modules/api/src/main/java/javax/el/VariableMapper.java delete mode 100644 modules/api/src/test/java/javax/el/AllTests.java delete mode 100644 modules/api/src/test/java/javax/el/ArrayELResolverTest.java delete mode 100644 modules/api/src/test/java/javax/el/BeanELResolverTest.java delete mode 100644 modules/api/src/test/java/javax/el/CompositeELResolverTest.java delete mode 100644 modules/api/src/test/java/javax/el/ELContextTest.java delete mode 100644 modules/api/src/test/java/javax/el/ExpressionFactoryTest.java delete mode 100644 modules/api/src/test/java/javax/el/ListELResolverTest.java delete mode 100644 modules/api/src/test/java/javax/el/MapELResolverTest.java delete mode 100644 modules/api/src/test/java/javax/el/MethodInfoTest.java delete mode 100644 modules/api/src/test/java/javax/el/ResourceBundleELResolverTest.java delete mode 100644 modules/api/src/test/java/javax/el/TestContext.java delete mode 100644 modules/api/src/test/java/javax/el/TestFactory.java delete mode 100644 modules/api/src/test/java/javax/el/ValueReferenceTest.java delete mode 100644 modules/api/src/test/java/javax/el/test/TestClass.java delete mode 100644 modules/api/src/test/java/javax/el/test/TestInterface.java delete mode 100644 modules/api/src/test/resources/META-INF/services/javax.el.ExpressionFactory rename modules/{spi/src/main/resources/META-INF/services/javax.el.ExpressionFactory => impl/src/main/resources/META-INF/services/jakarta.el.ExpressionFactory} (97%) delete mode 100644 modules/spi/.gitignore delete mode 100644 modules/spi/pom.xml rename {modules/api => samples}/.gitignore (100%) create mode 100644 samples/pom.xml diff --git a/.gitignore b/.gitignore index a97bb1b..e130fe3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.settings /bin /target +.idea diff --git a/modules/api/pom.xml b/modules/api/pom.xml deleted file mode 100644 index d0fca00..0000000 --- a/modules/api/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - 4.0.0 - - - de.odysseus.juel - juel-parent - 2.2.8-SNAPSHOT - ../../pom.xml - - - de.odysseus.juel - juel-api - jar - - Java Unified Expression Language API - 2.2.8-SNAPSHOT - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - false - - Expression Language - 2.2 - Sun Microsystems Inc. - JUEL - ${project.version} - Odysseus Software GmbH - de.odysseus - javax.el - Odysseus.de - ${project.version} - Expression Language API - 2 - de.odysseus.juel-api - - - - - - - diff --git a/modules/api/src/main/java/javax/el/ArrayELResolver.java b/modules/api/src/main/java/javax/el/ArrayELResolver.java deleted file mode 100644 index 525cd7d..0000000 --- a/modules/api/src/main/java/javax/el/ArrayELResolver.java +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Iterator; - -/** - * Defines property resolution behavior on arrays. This resolver handles base objects that are Java - * language arrays. It accepts any object as a property and coerces that object into an integer - * index into the array. The resulting value is the value in the array at that index. This resolver - * can be constructed in read-only mode, which means that isReadOnly will always return true and - * {@link #setValue(ELContext, Object, Object, Object)} will always throw - * PropertyNotWritableException. ELResolvers are combined together using {@link CompositeELResolver} - * s, to define rich semantics for evaluating an expression. See the javadocs for {@link ELResolver} - * for details. - */ -public class ArrayELResolver extends ELResolver { - private final boolean readOnly; - - /** - * Creates a new read/write ArrayELResolver. - */ - public ArrayELResolver() { - this(false); - } - - /** - * Creates a new ArrayELResolver whose read-only status is determined by the given parameter. - * - * @param readOnly - * true if this resolver cannot modify arrays; false otherwise. - */ - public ArrayELResolver(boolean readOnly) { - this.readOnly = readOnly; - } - - /** - * If the base object is a Java language array, returns the most general type that this resolver - * accepts for the property argument. Otherwise, returns null. Assuming the base is an array, - * this method will always return Integer.class. This is because arrays accept integers for - * their index. - * - * @param context - * The context of this evaluation. - * @param base - * The array to analyze. Only bases that are a Java language array are handled by - * this resolver. - * @return null if base is not a Java language array; otherwise Integer.class. - */ - @Override - public Class getCommonPropertyType(ELContext context, Object base) { - return isResolvable(base) ? Integer.class : null; - } - - /** - * Always returns null, since there is no reason to iterate through set set of all integers. The - * getCommonPropertyType(ELContext, Object)8 method returns sufficient information about what - * properties this resolver accepts. - * - * @param context - * The context of this evaluation. - * @param base - * The array to analyze. Only bases that are a Java language array are handled by - * this resolver. - * @return null. - */ - @Override - public Iterator getFeatureDescriptors(ELContext context, Object base) { - return null; - } - - /** - * If the base object is an array, returns the most general acceptable type for a value in this - * array. If the base is a array, the propertyResolved property of the ELContext object must be - * set to true by this resolver, before returning. If this property is not true after this - * method is called, the caller should ignore the return value. Assuming the base is an array, - * this method will always return base.getClass().getComponentType(), which is the most general - * type of component that can be stored at any given index in the array. - * - * @param context - * The context of this evaluation. - * @param base - * The array to analyze. Only bases that are a Java language array are handled by - * this resolver. - * @param property - * The index of the element in the array to return the acceptable type for. Will be - * coerced into an integer, but otherwise ignored by this resolver. - * @return If the propertyResolved property of ELContext was set to true, then the most general - * acceptable type; otherwise undefined. - * @throws PropertyNotFoundException - * if the given index is out of bounds for this array. - * @throws NullPointerException - * if context is null - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Class getType(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - Class result = null; - if (isResolvable(base)) { - toIndex(base, property); - result = base.getClass().getComponentType(); - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is a Java language array, returns the value at the given index. The index - * is specified by the property argument, and coerced into an integer. If the coercion could not - * be performed, an IllegalArgumentException is thrown. If the index is out of bounds, null is - * returned. If the base is a Java language array, the propertyResolved property of the - * ELContext object must be set to true by this resolver, before returning. If this property is - * not true after this method is called, the caller should ignore the return value. - * - * @param context - * The context of this evaluation. - * @param base - * The array to analyze. Only bases that are a Java language array are handled by - * this resolver. - * @param property - * The index of the element in the array to return the acceptable type for. Will be - * coerced into an integer, but otherwise ignored by this resolver. - * @return If the propertyResolved property of ELContext was set to true, then the value at the - * given index or null if the index was out of bounds. Otherwise, undefined. - * @throws PropertyNotFoundException - * if the given index is out of bounds for this array. - * @throws NullPointerException - * if context is null - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Object getValue(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - Object result = null; - if (isResolvable(base)) { - int index = toIndex(null, property); - result = index < 0 || index >= Array.getLength(base) ? null : Array.get(base, index); - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is a Java language array, returns whether a call to - * {@link #setValue(ELContext, Object, Object, Object)} will always fail. If the base is a Java - * language array, the propertyResolved property of the ELContext object must be set to true by - * this resolver, before returning. If this property is not true after this method is called, - * the caller should ignore the return value. If this resolver was constructed in read-only - * mode, this method will always return true. Otherwise, it returns false. - * - * @param context - * The context of this evaluation. - * @param base - * The array to analyze. Only bases that are a Java language array are handled by - * this resolver. - * @param property - * The index of the element in the array to return the acceptable type for. Will be - * coerced into an integer, but otherwise ignored by this resolver. - * @return If the propertyResolved property of ELContext was set to true, then true if calling - * the setValue method will always fail or false if it is possible that such a call may - * succeed; otherwise undefined. - * @throws PropertyNotFoundException - * if the given index is out of bounds for this array. - * @throws NullPointerException - * if context is null - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public boolean isReadOnly(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - if (isResolvable(base)) { - toIndex(base, property); - context.setPropertyResolved(true); - } - return readOnly; - } - - /** - * If the base object is a Java language array, attempts to set the value at the given index - * with the given value. The index is specified by the property argument, and coerced into an - * integer. If the coercion could not be performed, an IllegalArgumentException is thrown. If - * the index is out of bounds, a PropertyNotFoundException is thrown. If the base is a Java - * language array, the propertyResolved property of the ELContext object must be set to true by - * this resolver, before returning. If this property is not true after this method is called, - * the caller can safely assume no value was set. If this resolver was constructed in read-only - * mode, this method will always throw PropertyNotWritableException. - * - * @param context - * The context of this evaluation. - * @param base - * The array to analyze. Only bases that are a Java language array are handled by - * this resolver. - * @param property - * The index of the element in the array to return the acceptable type for. Will be - * coerced into an integer, but otherwise ignored by this resolver. - * @param value - * The value to be set at the given index. - * @throws PropertyNotFoundException - * if the given index is out of bounds for this array. - * @throws ClassCastException - * if the class of the specified element prevents it from being added to this array. - * @throws NullPointerException - * if context is null - * @throws IllegalArgumentException - * if the property could not be coerced into an integer, or if some aspect of the - * specified element prevents it from being added to this array. - * @throws PropertyNotWritableException - * if this resolver was constructed in read-only mode. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public void setValue(ELContext context, Object base, Object property, Object value) { - if (context == null) { - throw new NullPointerException("context is null"); - } - if (isResolvable(base)) { - if (readOnly) { - throw new PropertyNotWritableException("resolver is read-only"); - } - Array.set(base, toIndex(base, property), value); - context.setPropertyResolved(true); - } - } - - /** - * Test whether the given base should be resolved by this ELResolver. - * - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return base != null && base.getClass().isArray() - */ - private final boolean isResolvable(Object base) { - return base != null && base.getClass().isArray(); - } - - /** - * Convert the given property to an index in (array) base. - * - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return The index of property in base. - * @throws IllegalArgumentException - * if base property cannot be coerced to an integer or base is not an array. - * @throws PropertyNotFoundException - * if the computed index is out of bounds for base. - */ - private final int toIndex(Object base, Object property) { - int index = 0; - if (property instanceof Number) { - index = ((Number) property).intValue(); - } else if (property instanceof String) { - try { - index = Integer.valueOf((String) property); - } catch (NumberFormatException e) { - throw new IllegalArgumentException("Cannot parse array index: " + property); - } - } else if (property instanceof Character) { - index = ((Character) property).charValue(); - } else if (property instanceof Boolean) { - index = ((Boolean) property).booleanValue() ? 1 : 0; - } else { - throw new IllegalArgumentException("Cannot coerce property to array index: " + property); - } - if (base != null && (index < 0 || index >= Array.getLength(base))) { - throw new PropertyNotFoundException("Array index out of bounds: " + index); - } - return index; - } -} diff --git a/modules/api/src/main/java/javax/el/BeanELResolver.java b/modules/api/src/main/java/javax/el/BeanELResolver.java deleted file mode 100644 index 02f1111..0000000 --- a/modules/api/src/main/java/javax/el/BeanELResolver.java +++ /dev/null @@ -1,666 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Defines property resolution behavior on objects using the JavaBeans component architecture. This - * resolver handles base objects of any type, as long as the base is not null. It accepts any object - * as a property, and coerces it to a string. That string is then used to find a JavaBeans compliant - * property on the base object. The value is accessed using JavaBeans getters and setters. This - * resolver can be constructed in read-only mode, which means that isReadOnly will always return - * true and {@link #setValue(ELContext, Object, Object, Object)} will always throw - * PropertyNotWritableException. ELResolvers are combined together using {@link CompositeELResolver} - * s, to define rich semantics for evaluating an expression. See the javadocs for {@link ELResolver} - * for details. Because this resolver handles base objects of any type, it should be placed near the - * end of a composite resolver. Otherwise, it will claim to have resolved a property before any - * resolvers that come after it get a chance to test if they can do so as well. - * - * @see CompositeELResolver - * @see ELResolver - */ -public class BeanELResolver extends ELResolver { - protected static final class BeanProperties { - private final Map map = new HashMap(); - - public BeanProperties(Class baseClass) { - PropertyDescriptor[] descriptors; - try { - descriptors = Introspector.getBeanInfo(baseClass).getPropertyDescriptors(); - } catch (IntrospectionException e) { - throw new ELException(e); - } - for (PropertyDescriptor descriptor : descriptors) { - map.put(descriptor.getName(), new BeanProperty(descriptor)); - } - } - - public BeanProperty getBeanProperty(String property) { - return map.get(property); - } - } - - protected static final class BeanProperty { - private final PropertyDescriptor descriptor; - - private Method readMethod; - private Method writedMethod; - - public BeanProperty(PropertyDescriptor descriptor) { - this.descriptor = descriptor; - } - - public Class getPropertyType() { - return descriptor.getPropertyType(); - } - - public Method getReadMethod() { - if (readMethod == null) { - readMethod = findAccessibleMethod(descriptor.getReadMethod()); - } - return readMethod; - } - - public Method getWriteMethod() { - if (writedMethod == null) { - writedMethod = findAccessibleMethod(descriptor.getWriteMethod()); - } - return writedMethod; - } - - public boolean isReadOnly() { - return getWriteMethod() == null; - } - } - - private static Method findPublicAccessibleMethod(Method method) { - if (method == null || !Modifier.isPublic(method.getModifiers())) { - return null; - } - if (method.isAccessible() || Modifier.isPublic(method.getDeclaringClass().getModifiers())) { - return method; - } - for (Class cls : method.getDeclaringClass().getInterfaces()) { - Method mth = null; - try { - mth = findPublicAccessibleMethod(cls.getMethod(method.getName(), method.getParameterTypes())); - if (mth != null) { - return mth; - } - } catch (NoSuchMethodException ignore) { - // do nothing - } - } - Class cls = method.getDeclaringClass().getSuperclass(); - if (cls != null) { - Method mth = null; - try { - mth = findPublicAccessibleMethod(cls.getMethod(method.getName(), method.getParameterTypes())); - if (mth != null) { - return mth; - } - } catch (NoSuchMethodException ignore) { - // do nothing - } - } - return null; - } - - private static Method findAccessibleMethod(Method method) { - Method result = findPublicAccessibleMethod(method); - if (result == null && method != null && Modifier.isPublic(method.getModifiers())) { - result = method; - try { - method.setAccessible(true); - } catch (SecurityException e) { - result = null; - } - } - return result; - } - - private final boolean readOnly; - private final ConcurrentHashMap, BeanProperties> cache; - - private ExpressionFactory defaultFactory; - - /** - * Creates a new read/write BeanELResolver. - */ - public BeanELResolver() { - this(false); - } - - /** - * Creates a new BeanELResolver whose read-only status is determined by the given parameter. - */ - public BeanELResolver(boolean readOnly) { - this.readOnly = readOnly; - this.cache = new ConcurrentHashMap, BeanProperties>(); - } - - /** - * If the base object is not null, returns the most general type that this resolver accepts for - * the property argument. Otherwise, returns null. Assuming the base is not null, this method - * will always return Object.class. This is because any object is accepted as a key and is - * coerced into a string. - * - * @param context - * The context of this evaluation. - * @param base - * The bean to analyze. - * @return null if base is null; otherwise Object.class. - */ - @Override - public Class getCommonPropertyType(ELContext context, Object base) { - return isResolvable(base) ? Object.class : null; - } - - /** - * If the base object is not null, returns an Iterator containing the set of JavaBeans - * properties available on the given object. Otherwise, returns null. The Iterator returned must - * contain zero or more instances of java.beans.FeatureDescriptor. Each info object contains - * information about a property in the bean, as obtained by calling the - * BeanInfo.getPropertyDescriptors method. The FeatureDescriptor is initialized using the same - * fields as are present in the PropertyDescriptor, with the additional required named - * attributes "type" and "resolvableAtDesignTime" set as follows: - *
    - *
  • {@link ELResolver#TYPE} - The runtime type of the property, from - * PropertyDescriptor.getPropertyType().
  • - *
  • {@link ELResolver#RESOLVABLE_AT_DESIGN_TIME} - true.
  • - *
- * - * @param context - * The context of this evaluation. - * @param base - * The bean to analyze. - * @return An Iterator containing zero or more FeatureDescriptor objects, each representing a - * property on this bean, or null if the base object is null. - */ - @Override - public Iterator getFeatureDescriptors(ELContext context, Object base) { - if (isResolvable(base)) { - final PropertyDescriptor[] properties; - try { - properties = Introspector.getBeanInfo(base.getClass()).getPropertyDescriptors(); - } catch (IntrospectionException e) { - return Collections. emptyList().iterator(); - } - return new Iterator() { - int next = 0; - - public boolean hasNext() { - return properties != null && next < properties.length; - } - - public FeatureDescriptor next() { - PropertyDescriptor property = properties[next++]; - FeatureDescriptor feature = new FeatureDescriptor(); - feature.setDisplayName(property.getDisplayName()); - feature.setName(property.getName()); - feature.setShortDescription(property.getShortDescription()); - feature.setExpert(property.isExpert()); - feature.setHidden(property.isHidden()); - feature.setPreferred(property.isPreferred()); - feature.setValue(TYPE, property.getPropertyType()); - feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true); - return feature; - } - - public void remove() { - throw new UnsupportedOperationException("cannot remove"); - } - }; - } - return null; - } - - /** - * If the base object is not null, returns the most general acceptable type that can be set on - * this bean property. If the base is not null, the propertyResolved property of the ELContext - * object must be set to true by this resolver, before returning. If this property is not true - * after this method is called, the caller should ignore the return value. The provided property - * will first be coerced to a String. If there is a BeanInfoProperty for this property and there - * were no errors retrieving it, the propertyType of the propertyDescriptor is returned. - * Otherwise, a PropertyNotFoundException is thrown. - * - * @param context - * The context of this evaluation. - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return If the propertyResolved property of ELContext was set to true, then the most general - * acceptable type; otherwise undefined. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if base is not null and the specified property does not exist or is not readable. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Class getType(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException(); - } - Class result = null; - if (isResolvable(base)) { - result = toBeanProperty(base, property).getPropertyType(); - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is not null, returns the current value of the given property on this bean. - * If the base is not null, the propertyResolved property of the ELContext object must be set to - * true by this resolver, before returning. If this property is not true after this method is - * called, the caller should ignore the return value. The provided property name will first be - * coerced to a String. If the property is a readable property of the base object, as per the - * JavaBeans specification, then return the result of the getter call. If the getter throws an - * exception, it is propagated to the caller. If the property is not found or is not readable, a - * PropertyNotFoundException is thrown. - * - * @param context - * The context of this evaluation. - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return If the propertyResolved property of ELContext was set to true, then the value of the - * given property. Otherwise, undefined. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if base is not null and the specified property does not exist or is not readable. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Object getValue(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException(); - } - Object result = null; - if (isResolvable(base)) { - Method method = toBeanProperty(base, property).getReadMethod(); - if (method == null) { - throw new PropertyNotFoundException("Cannot read property " + property); - } - try { - result = method.invoke(base); - } catch (InvocationTargetException e) { - throw new ELException(e.getCause()); - } catch (Exception e) { - throw new ELException(e); - } - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is not null, returns whether a call to - * {@link #setValue(ELContext, Object, Object, Object)} will always fail. If the base is not - * null, the propertyResolved property of the ELContext object must be set to true by this - * resolver, before returning. If this property is not true after this method is called, the - * caller can safely assume no value was set. - * - * @param context - * The context of this evaluation. - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return If the propertyResolved property of ELContext was set to true, then true if calling - * the setValue method will always fail or false if it is possible that such a call may - * succeed; otherwise undefined. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if base is not null and the specified property does not exist or is not readable. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public boolean isReadOnly(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException(); - } - boolean result = readOnly; - if (isResolvable(base)) { - result |= toBeanProperty(base, property).isReadOnly(); - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is not null, attempts to set the value of the given property on this bean. - * If the base is not null, the propertyResolved property of the ELContext object must be set to - * true by this resolver, before returning. If this property is not true after this method is - * called, the caller can safely assume no value was set. If this resolver was constructed in - * read-only mode, this method will always throw PropertyNotWritableException. The provided - * property name will first be coerced to a String. If property is a writable property of base - * (as per the JavaBeans Specification), the setter method is called (passing value). If the - * property exists but does not have a setter, then a PropertyNotFoundException is thrown. If - * the property does not exist, a PropertyNotFoundException is thrown. - * - * @param context - * The context of this evaluation. - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @param value - * The value to be associated with the specified key. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if base is not null and the specified property does not exist or is not readable. - * @throws PropertyNotWritableException - * if this resolver was constructed in read-only mode, or if there is no setter for - * the property - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public void setValue(ELContext context, Object base, Object property, Object value) { - if (context == null) { - throw new NullPointerException(); - } - if (isResolvable(base)) { - if (readOnly) { - throw new PropertyNotWritableException("resolver is read-only"); - } - Method method = toBeanProperty(base, property).getWriteMethod(); - if (method == null) { - throw new PropertyNotWritableException("Cannot write property: " + property); - } - try { - method.invoke(base, value); - } catch (InvocationTargetException e) { - throw new ELException("Cannot write property: " + property, e.getCause()); - } catch (IllegalArgumentException e) { - throw new ELException("Cannot write property: " + property, e); - } catch (IllegalAccessException e) { - throw new PropertyNotWritableException("Cannot write property: " + property, e); - } - context.setPropertyResolved(true); - } - } - - /** - * If the base object is not null, invoke the method, with the given parameters on - * this bean. The return value from the method is returned. - * - *

- * If the base is not null, the propertyResolved property of the - * ELContext object must be set to true by this resolver, before - * returning. If this property is not true after this method is called, the caller - * should ignore the return value. - *

- * - *

- * The provided method object will first be coerced to a String. The methods in the - * bean is then examined and an attempt will be made to select one for invocation. If no - * suitable can be found, a MethodNotFoundException is thrown. - * - * If the given paramTypes is not null, select the method with the given name and - * parameter types. - * - * Else select the method with the given name that has the same number of parameters. If there - * are more than one such method, the method selection process is undefined. - * - * Else select the method with the given name that takes a variable number of arguments. - * - * Note the resolution for overloaded methods will likely be clarified in a future version of - * the spec. - * - * The provided parameters are coerced to the corresponding parameter types of the method, and - * the method is then invoked. - * - * @param context - * The context of this evaluation. - * @param base - * The bean on which to invoke the method - * @param method - * The simple name of the method to invoke. Will be coerced to a String. - * If method is "<init>"or "<clinit>" a MethodNotFoundException is - * thrown. - * @param paramTypes - * An array of Class objects identifying the method's formal parameter types, in - * declared order. Use an empty array if the method has no parameters. Can be - * null, in which case the method's formal parameter types are assumed - * to be unknown. - * @param params - * The parameters to pass to the method, or null if no parameters. - * @return The result of the method invocation (null if the method has a - * void return type). - * @throws MethodNotFoundException - * if no suitable method can be found. - * @throws ELException - * if an exception was thrown while performing (base, method) resolution. The thrown - * exception must be included as the cause property of this exception, if available. - * If the exception thrown is an InvocationTargetException, extract its - * cause and pass it to the ELException constructor. - * @since 2.2 - */ - @Override - public Object invoke(ELContext context, Object base, Object method, Class[] paramTypes, Object[] params) { - if (context == null) { - throw new NullPointerException(); - } - Object result = null; - if (isResolvable(base)) { - if (params == null) { - params = new Object[0]; - } - String name = method.toString(); - Method target = findMethod(base, name, paramTypes, params.length); - if (target == null) { - throw new MethodNotFoundException("Cannot find method " + name + " with " + params.length + " parameters in " + base.getClass()); - } - try { - result = target.invoke(base, coerceParams(getExpressionFactory(context), target, params)); - } catch (InvocationTargetException e) { - throw new ELException(e.getCause()); - } catch (IllegalAccessException e) { - throw new ELException(e); - } - context.setPropertyResolved(true); - } - return result; - }; - - private Method findMethod(Object base, String name, Class[] types, int paramCount) { - if (types != null) { - try { - return findAccessibleMethod(base.getClass().getMethod(name, types)); - } catch (NoSuchMethodException e) { - return null; - } - } - Method varArgsMethod = null; - for (Method method : base.getClass().getMethods()) { - if (method.getName().equals(name)) { - int formalParamCount = method.getParameterTypes().length; - if (method.isVarArgs() && paramCount >= formalParamCount - 1) { - varArgsMethod = method; - } else if (paramCount == formalParamCount) { - return findAccessibleMethod(method); - } - } - } - return varArgsMethod == null ? null : findAccessibleMethod(varArgsMethod); - } - - /** - * Lookup an expression factory used to coerce method parameters in context under key - * "javax.el.ExpressionFactory". - * If no expression factory can be found under that key, use a default instance created with - * {@link ExpressionFactory#newInstance()}. - * @param context - * The context of this evaluation. - * @return expression factory instance - */ - private ExpressionFactory getExpressionFactory(ELContext context) { - Object obj = context.getContext(ExpressionFactory.class); - if (obj instanceof ExpressionFactory) { - return (ExpressionFactory)obj; - } - if (defaultFactory == null) { - defaultFactory = ExpressionFactory.newInstance(); - } - return defaultFactory; - } - - private Object[] coerceParams(ExpressionFactory factory, Method method, Object[] params) { - Class[] types = method.getParameterTypes(); - Object[] args = new Object[types.length]; - if (method.isVarArgs()) { - int varargIndex = types.length - 1; - if (params.length < varargIndex) { - throw new ELException("Bad argument count"); - } - for (int i = 0; i < varargIndex; i++) { - coerceValue(args, i, factory, params[i], types[i]); - } - Class varargType = types[varargIndex].getComponentType(); - int length = params.length - varargIndex; - Object array = null; - if (length == 1) { - Object source = params[varargIndex]; - if (source != null && source.getClass().isArray()) { - if (types[varargIndex].isInstance(source)) { // use source array as is - array = source; - } else { // coerce array elements - length = Array.getLength(source); - array = Array.newInstance(varargType, length); - for (int i = 0; i < length; i++) { - coerceValue(array, i, factory, Array.get(source, i), varargType); - } - } - } else { // single element array - array = Array.newInstance(varargType, 1); - coerceValue(array, 0, factory, source, varargType); - } - } else { - array = Array.newInstance(varargType, length); - for (int i = 0; i < length; i++) { - coerceValue(array, i, factory, params[varargIndex + i], varargType); - } - } - args[varargIndex] = array; - } else { - if (params.length != args.length) { - throw new ELException("Bad argument count"); - } - for (int i = 0; i < args.length; i++) { - coerceValue(args, i, factory, params[i], types[i]); - } - } - return args; - } - - private void coerceValue(Object array, int index, ExpressionFactory factory, Object value, Class type) { - if (value != null || type.isPrimitive()) { - Array.set(array, index, factory.coerceToType(value, type)); - } - } - - /** - * Test whether the given base should be resolved by this ELResolver. - * - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return base != null - */ - private final boolean isResolvable(Object base) { - return base != null; - } - - /** - * Lookup BeanProperty for the given (base, property) pair. - * - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return The BeanProperty representing (base, property). - * @throws PropertyNotFoundException - * if no BeanProperty can be found. - */ - private final BeanProperty toBeanProperty(Object base, Object property) { - BeanProperties beanProperties = cache.get(base.getClass()); - if (beanProperties == null) { - BeanProperties newBeanProperties = new BeanProperties(base.getClass()); - beanProperties = cache.putIfAbsent(base.getClass(), newBeanProperties); - if (beanProperties == null) { // put succeeded, use new value - beanProperties = newBeanProperties; - } - } - BeanProperty beanProperty = property == null ? null : beanProperties.getBeanProperty(property.toString()); - if (beanProperty == null) { - throw new PropertyNotFoundException("Could not find property " + property + " in " + base.getClass()); - } - return beanProperty; - } - - /** - * This method is not part of the API, though it can be used (reflectively) by clients of this - * class to remove entries from the cache when the beans are being unloaded. - * - * Note: this method is present in the reference implementation, so we're adding it here to ease - * migration. - * - * @param classloader - * The classLoader used to load the beans. - */ - @SuppressWarnings("unused") - private final void purgeBeanClasses(ClassLoader loader) { - Iterator> classes = cache.keySet().iterator(); - while (classes.hasNext()) { - if (loader == classes.next().getClassLoader()) { - classes.remove(); - } - } - } -} diff --git a/modules/api/src/main/java/javax/el/CompositeELResolver.java b/modules/api/src/main/java/javax/el/CompositeELResolver.java deleted file mode 100644 index 0cd8d91..0000000 --- a/modules/api/src/main/java/javax/el/CompositeELResolver.java +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Iterator; -import java.util.List; - -/** - * Maintains an ordered composite list of child ELResolvers. Though only a single ELResolver is - * associated with an ELContext, there are usually multiple resolvers considered for any given - * variable or property resolution. ELResolvers are combined together using a CompositeELResolver, - * to define rich semantics for evaluating an expression. For the - * {@link #getValue(ELContext, Object, Object)}, {@link #getType(ELContext, Object, Object)}, - * {@link #setValue(ELContext, Object, Object, Object)} and - * {@link #isReadOnly(ELContext, Object, Object)} methods, an ELResolver is not responsible for - * resolving all possible (base, property) pairs. In fact, most resolvers will only handle a base of - * a single type. To indicate that a resolver has successfully resolved a particular (base, - * property) pair, it must set the propertyResolved property of the ELContext to true. If it could - * not handle the given pair, it must leave this property alone. The caller must ignore the return - * value of the method if propertyResolved is false. The CompositeELResolver initializes the - * ELContext.propertyResolved flag to false, and uses it as a stop condition for iterating through - * its component resolvers. The ELContext.propertyResolved flag is not used for the design-time - * methods {@link #getFeatureDescriptors(ELContext, Object)} and - * {@link #getCommonPropertyType(ELContext, Object)}. Instead, results are collected and combined - * from all child ELResolvers for these methods. - */ -public class CompositeELResolver extends ELResolver { - private final List resolvers = new ArrayList(); - - /** - * Adds the given resolver to the list of component resolvers. Resolvers are consulted in the - * order in which they are added. - * - * @param elResolver - * The component resolver to add. - * @throws NullPointerException - * If the provided resolver is null. - */ - public void add(ELResolver elResolver) { - if (elResolver == null) { - throw new NullPointerException("resolver must not be null"); - } - resolvers.add(elResolver); - } - - /** - * Returns the most general type that this resolver accepts for the property argument, given a - * base object. One use for this method is to assist tools in auto-completion. The result is - * obtained by querying all component resolvers. The Class returned is the most specific class - * that is a common superclass of all the classes returned by each component resolver's - * getCommonPropertyType method. If null is returned by a resolver, it is skipped. - * - * @param context - * The context of this evaluation. - * @param base - * The base object to return the most general property type for, or null to enumerate - * the set of top-level variables that this resolver can evaluate. - * @return null if this ELResolver does not know how to handle the given base object; otherwise - * Object.class if any type of property is accepted; otherwise the most general property - * type accepted for the given base. - */ - @Override - public Class getCommonPropertyType(ELContext context, Object base) { - Class result = null; - for (int i = 0, l = resolvers.size(); i < l; i++) { - Class type = resolvers.get(i).getCommonPropertyType(context, base); - if (type != null) { - if (result == null || type.isAssignableFrom(result)) { - result = type; - } else if (!result.isAssignableFrom(type)) { - result = Object.class; - } - } - } - return result; - } - - /** - * Returns information about the set of variables or properties that can be resolved for the - * given base object. One use for this method is to assist tools in auto-completion. The results - * are collected from all component resolvers. The propertyResolved property of the ELContext is - * not relevant to this method. The results of all ELResolvers are concatenated. The Iterator - * returned is an iterator over the collection of FeatureDescriptor objects returned by the - * iterators returned by each component resolver's getFeatureDescriptors method. If null is - * returned by a resolver, it is skipped. - * - * @param context - * The context of this evaluation. - * @param base - * The base object to return the most general property type for, or null to enumerate - * the set of top-level variables that this resolver can evaluate. - * @return An Iterator containing zero or more (possibly infinitely more) FeatureDescriptor - * objects, or null if this resolver does not handle the given base object or that the - * results are too complex to represent with this method - */ - @Override - public Iterator getFeatureDescriptors(final ELContext context, final Object base) { - return new Iterator() { - Iterator empty = Collections. emptyList().iterator(); - Iterator resolvers = CompositeELResolver.this.resolvers.iterator(); - Iterator features = empty; - - Iterator features() { - while (!features.hasNext() && resolvers.hasNext()) { - features = resolvers.next().getFeatureDescriptors(context, base); - if (features == null) { - features = empty; - } - } - return features; - } - - public boolean hasNext() { - return features().hasNext(); - } - - public FeatureDescriptor next() { - return features().next(); - } - - public void remove() { - features().remove(); - } - }; - } - - /** - * For a given base and property, attempts to identify the most general type that is acceptable - * for an object to be passed as the value parameter in a future call to the - * {@link #setValue(ELContext, Object, Object, Object)} method. The result is obtained by - * querying all component resolvers. If this resolver handles the given (base, property) pair, - * the propertyResolved property of the ELContext object must be set to true by the resolver, - * before returning. If this property is not true after this method is called, the caller should - * ignore the return value. First, propertyResolved is set to false on the provided ELContext. - * Next, for each component resolver in this composite: - *

    - *
  1. The getType() method is called, passing in the provided context, base and property.
  2. - *
  3. If the ELContext's propertyResolved flag is false then iteration continues.
  4. - *
  5. Otherwise, iteration stops and no more component resolvers are considered. The value - * returned by getType() is returned by this method.
  6. - *
- * If none of the component resolvers were able to perform this operation, the value null is - * returned and the propertyResolved flag remains set to false. Any exception thrown by - * component resolvers during the iteration is propagated to the caller of this method. - * - * @param context - * The context of this evaluation. - * @param base - * The base object to return the most general property type for, or null to enumerate - * the set of top-level variables that this resolver can evaluate. - * @param property - * The property or variable to return the acceptable type for. - * @return If the propertyResolved property of ELContext was set to true, then the most general - * acceptable type; otherwise undefined. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if base is not null and the specified property does not exist or is not readable. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Class getType(ELContext context, Object base, Object property) { - context.setPropertyResolved(false); - for (int i = 0, l = resolvers.size(); i < l; i++) { - Class type = resolvers.get(i).getType(context, base, property); - if (context.isPropertyResolved()) { - return type; - } - } - return null; - } - - /** - * Attempts to resolve the given property object on the given base object by querying all - * component resolvers. If this resolver handles the given (base, property) pair, the - * propertyResolved property of the ELContext object must be set to true by the resolver, before - * returning. If this property is not true after this method is called, the caller should ignore - * the return value. First, propertyResolved is set to false on the provided ELContext. Next, - * for each component resolver in this composite: - *
    - *
  1. The getValue() method is called, passing in the provided context, base and property.
  2. - *
  3. If the ELContext's propertyResolved flag is false then iteration continues.
  4. - *
  5. Otherwise, iteration stops and no more component resolvers are considered. The value - * returned by getValue() is returned by this method.
  6. - *
- * If none of the component resolvers were able to perform this operation, the value null is - * returned and the propertyResolved flag remains set to false. Any exception thrown by - * component resolvers during the iteration is propagated to the caller of this method. - * - * @param context - * The context of this evaluation. - * @param base - * The base object to return the most general property type for, or null to enumerate - * the set of top-level variables that this resolver can evaluate. - * @param property - * The property or variable to return the acceptable type for. - * @return If the propertyResolved property of ELContext was set to true, then the result of the - * variable or property resolution; otherwise undefined. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if base is not null and the specified property does not exist or is not readable. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Object getValue(ELContext context, Object base, Object property) { - context.setPropertyResolved(false); - for (int i = 0, l = resolvers.size(); i < l; i++) { - Object value = resolvers.get(i).getValue(context, base, property); - if (context.isPropertyResolved()) { - return value; - } - } - return null; - } - - /** - * For a given base and property, attempts to determine whether a call to - * {@link #setValue(ELContext, Object, Object, Object)} will always fail. The result is obtained - * by querying all component resolvers. If this resolver handles the given (base, property) - * pair, the propertyResolved property of the ELContext object must be set to true by the - * resolver, before returning. If this property is not true after this method is called, the - * caller should ignore the return value. First, propertyResolved is set to false on the - * provided ELContext. Next, for each component resolver in this composite: - *
    - *
  1. The isReadOnly() method is called, passing in the provided context, base and property.
  2. - *
  3. If the ELContext's propertyResolved flag is false then iteration continues.
  4. - *
  5. Otherwise, iteration stops and no more component resolvers are considered. The value - * returned by isReadOnly() is returned by this method.
  6. - *
- * If none of the component resolvers were able to perform this operation, the value false is - * returned and the propertyResolved flag remains set to false. Any exception thrown by - * component resolvers during the iteration is propagated to the caller of this method. - * - * @param context - * The context of this evaluation. - * @param base - * The base object to return the most general property type for, or null to enumerate - * the set of top-level variables that this resolver can evaluate. - * @param property - * The property or variable to return the acceptable type for. - * @return If the propertyResolved property of ELContext was set to true, then true if the - * property is read-only or false if not; otherwise undefined. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if base is not null and the specified property does not exist or is not readable. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public boolean isReadOnly(ELContext context, Object base, Object property) { - context.setPropertyResolved(false); - for (int i = 0, l = resolvers.size(); i < l; i++) { - boolean readOnly = resolvers.get(i).isReadOnly(context, base, property); - if (context.isPropertyResolved()) { - return readOnly; - } - } - return false; - } - - /** - * Attempts to set the value of the given property object on the given base object. All - * component resolvers are asked to attempt to set the value. If this resolver handles the given - * (base, property) pair, the propertyResolved property of the ELContext object must be set to - * true by the resolver, before returning. If this property is not true after this method is - * called, the caller can safely assume no value has been set. First, propertyResolved is set to - * false on the provided ELContext. Next, for each component resolver in this composite: - *
    - *
  1. The setValue() method is called, passing in the provided context, base, property and - * value.
  2. - *
  3. If the ELContext's propertyResolved flag is false then iteration continues.
  4. - *
  5. Otherwise, iteration stops and no more component resolvers are considered.
  6. - *
- * If none of the component resolvers were able to perform this operation, the propertyResolved - * flag remains set to false. Any exception thrown by component resolvers during the iteration - * is propagated to the caller of this method. - * - * @param context - * The context of this evaluation. - * @param base - * The base object to return the most general property type for, or null to enumerate - * the set of top-level variables that this resolver can evaluate. - * @param property - * The property or variable to return the acceptable type for. - * @param value - * The value to set the property or variable to. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if base is not null and the specified property does not exist or is not readable. - * @throws PropertyNotWritableException - * if the given (base, property) pair is handled by this ELResolver but the - * specified variable or property is not writable. - * @throws ELException - * if an exception was thrown while attempting to set the property or variable. The - * thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public void setValue(ELContext context, Object base, Object property, Object value) { - context.setPropertyResolved(false); - for (int i = 0, l = resolvers.size(); i < l; i++) { - resolvers.get(i).setValue(context, base, property, value); - if (context.isPropertyResolved()) { - return; - } - } - } - - /** - * Attempts to resolve and invoke the given method on the given base - * object by querying all component resolvers. - * - *

- * If this resolver handles the given (base, method) pair, the propertyResolved - * property of the ELContext object must be set to true by the - * resolver, before returning. If this property is not true after this method is - * called, the caller should ignore the return value. - *

- * - *

- * First, propertyResolved is set to false on the provided - * ELContext. - *

- * - *

- * Next, for each component resolver in this composite: - *

    - *
  1. The invoke() method is called, passing in the provided context, - * base, method, paramTypes, and params.
  2. - *
  3. If the ELContext's propertyResolved flag is false - * then iteration continues.
  4. - *
  5. Otherwise, iteration stops and no more component resolvers are considered. The value - * returned by getValue() is returned by this method.
  6. - *
- *

- * - *

- * If none of the component resolvers were able to perform this operation, the value - * null is returned and the propertyResolved flag remains set to - * false - *

- * - *

- * Any exception thrown by component resolvers during the iteration is propagated to the caller - * of this method. - *

- * - * @param context - * The context of this evaluation. - * @param base - * The bean on which to invoke the method - * @param method - * The simple name of the method to invoke. Will be coerced to a String. - * If method is "<init>"or "<clinit>" a NoSuchMethodException is raised. - * @param paramTypes - * An array of Class objects identifying the method's formal parameter types, in - * declared order. Use an empty array if the method has no parameters. Can be - * null, in which case the method's formal parameter types are assumed - * to be unknown. - * @param params - * The parameters to pass to the method, or null if no parameters. - * @return The result of the method invocation (null if the method has a - * void return type). - * @since 2.2 - */ - @Override - public Object invoke(ELContext context, Object base, Object method, Class[] paramTypes, Object[] params) { - context.setPropertyResolved(false); - for (int i = 0, l = resolvers.size(); i < l; i++) { - Object result = resolvers.get(i).invoke(context, base, method, paramTypes, params); - if (context.isPropertyResolved()) { - return result; - } - } - return null; - } -} diff --git a/modules/api/src/main/java/javax/el/ELContext.java b/modules/api/src/main/java/javax/el/ELContext.java deleted file mode 100644 index 6303b92..0000000 --- a/modules/api/src/main/java/javax/el/ELContext.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * Context information for expression evaluation. To evaluate an {@link Expression}, an ELContext - * must be provided. The ELContext holds: - *
    - *
  • a reference to the base {@link ELResolver} that will be consulted to resolve model objects - * and their properties
  • - *
  • a reference to {@link FunctionMapper} that will be used to resolve EL Functions.
  • - *
  • a reference to {@link VariableMapper} that will be used to resolve EL Variables.
  • - *
  • a collection of all the relevant context objects for use by ELResolvers
  • - *
  • state information during the evaluation of an expression, such as whether a property has been - * resolved yet
  • - *
- * The collection of context objects is necessary because each ELResolver may need access to a - * different context object. For example, JSP and Faces resolvers need access to a - * javax.servlet.jsp.JspContext and a javax.faces.context.FacesContext, respectively. Creation of - * ELContext objects is controlled through the underlying technology. For example, in JSP the - * JspContext.getELContext() factory method is used. Some technologies provide the ability to add an - * {@link ELContextListener} so that applications and frameworks can ensure their own context - * objects are attached to any newly created ELContext. Because it stores state during expression - * evaluation, an ELContext object is not thread-safe. Care should be taken to never share an - * ELContext instance between two or more threads. - */ -public abstract class ELContext { - private Map, Object> context; - private Locale locale; - private boolean resolved; - - /** - * Returns the context object associated with the given key. The ELContext maintains a - * collection of context objects relevant to the evaluation of an expression. These context - * objects are used by ELResolvers. This method is used to retrieve the context with the given - * key from the collection. By convention, the object returned will be of the type specified by - * the key. However, this is not required and the key is used strictly as a unique identifier. - * - * @param key - * The unique identifier that was used to associate the context object with this - * ELContext. - * @return The context object associated with the given key, or null if no such context was - * found. - * @throws NullPointerException - * if key is null. - */ - public Object getContext(Class key) { - if (key == null) { - throw new NullPointerException("key is null"); - } - if (context == null) { - return null; - } - return context.get(key); - } - - /** - * Retrieves the ELResolver associated with this context. The ELContext maintains a reference to - * the ELResolver that will be consulted to resolve variables and properties during an - * expression evaluation. This method retrieves the reference to the resolver. Once an ELContext - * is constructed, the reference to the ELResolver associated with the context cannot be - * changed. - * - * @return The resolver to be consulted for variable and property resolution during expression - * evaluation. - */ - public abstract ELResolver getELResolver(); - - /** - * Retrieves the FunctionMapper associated with this ELContext. - * - * @return The function mapper to be consulted for the resolution of EL functions. - */ - public abstract FunctionMapper getFunctionMapper(); - - /** - * Get the Locale stored by a previous invocation to {@link #setLocale(Locale)}. If this method - * returns non null, this Locale must be used for all localization needs in the implementation. - * The Locale must not be cached to allow for applications that change Locale dynamically. - * - * @return The Locale in which this instance is operating. Used primarily for message - * localization. - */ - public Locale getLocale() { - return locale; - } - - /** - * Retrieves the VariableMapper associated with this ELContext. - * - * @return The variable mapper to be consulted for the resolution of EL variables. - */ - public abstract VariableMapper getVariableMapper(); - - /** - * Returns whether an {@link ELResolver} has successfully resolved a given (base, property) - * pair. The {@link CompositeELResolver} checks this property to determine whether it should - * consider or skip other component resolvers. - * - * @return The variable mapper to be consulted for the resolution of EL variables. - * @see CompositeELResolver - */ - public boolean isPropertyResolved() { - return resolved; - } - - /** - * Associates a context object with this ELContext. The ELContext maintains a collection of - * context objects relevant to the evaluation of an expression. These context objects are used - * by ELResolvers. This method is used to add a context object to that collection. By - * convention, the contextObject will be of the type specified by the key. However, this is not - * required and the key is used strictly as a unique identifier. - * - * @param key - * The key used by an {@link ELResolver} to identify this context object. - * @param contextObject - * The context object to add to the collection. - * @throws NullPointerException - * if key is null or contextObject is null. - */ - public void putContext(Class key, Object contextObject) { - if (key == null) { - throw new NullPointerException("key is null"); - } - if (context == null) { - context = new HashMap, Object>(); - } - context.put(key, contextObject); - } - - /** - * Set the Locale for this instance. This method may be called by the party creating the - * instance, such as JavaServer Faces or JSP, to enable the EL implementation to provide - * localized messages to the user. If no Locale is set, the implementation must use the locale - * returned by Locale.getDefault( ). - * - * @param locale - * The Locale in which this instance is operating. Used primarily for message - * localization. - */ - public void setLocale(Locale locale) { - this.locale = locale; - } - - /** - * Called to indicate that a ELResolver has successfully resolved a given (base, property) pair. - * The {@link CompositeELResolver} checks this property to determine whether it should consider - * or skip other component resolvers. - * - * @param resolved - * true if the property has been resolved, or false if not. - * @see CompositeELResolver - */ - public void setPropertyResolved(boolean resolved) { - this.resolved = resolved; - } -} diff --git a/modules/api/src/main/java/javax/el/ELContextEvent.java b/modules/api/src/main/java/javax/el/ELContextEvent.java deleted file mode 100644 index a60e105..0000000 --- a/modules/api/src/main/java/javax/el/ELContextEvent.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * An event which indicates that an {@link ELContext} has been created. The source object is the - * ELContext that was created. - */ -public class ELContextEvent extends EventObject { - private static final long serialVersionUID = 1L; - - /** - * Constructs an ELContextEvent object to indicate that an ELContext has been created. - * - * @param source - * the ELContext that was created. - */ - public ELContextEvent(ELContext source) { - super(source); - } - - /** - * Returns the ELContext that was created. This is a type-safe equivalent of the - * java.util.EventObject.getSource() method. - * - * @return the ELContext that was created. - */ - public ELContext getELContext() { - return (ELContext) getSource(); - } -} diff --git a/modules/api/src/main/java/javax/el/ELContextListener.java b/modules/api/src/main/java/javax/el/ELContextListener.java deleted file mode 100644 index 65b6412..0000000 --- a/modules/api/src/main/java/javax/el/ELContextListener.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * The listener interface for receiving notification when an {@link ELContext} is created. - */ -public interface ELContextListener extends java.util.EventListener { - /** - * Invoked when a new ELContext has been created. - * - * @param ece - * the notification event. - */ - public void contextCreated(ELContextEvent ece); -} diff --git a/modules/api/src/main/java/javax/el/ELException.java b/modules/api/src/main/java/javax/el/ELException.java deleted file mode 100644 index 71ade54..0000000 --- a/modules/api/src/main/java/javax/el/ELException.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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. - */ -public class ELException extends RuntimeException { - private static final long serialVersionUID = 1L; - - /** - * 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 cause. - * - * @param cause - * the originating cause of this exception - */ - public ELException(Throwable cause) { - super(cause); - } - - /** - * 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); - } -} diff --git a/modules/api/src/main/java/javax/el/ELResolver.java b/modules/api/src/main/java/javax/el/ELResolver.java deleted file mode 100644 index 14b19e7..0000000 --- a/modules/api/src/main/java/javax/el/ELResolver.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Iterator; - -/** - * Enables customization of variable and property resolution behavior for EL expression evaluation. - * - * While evaluating an expression, the ELResolver associated with the ELContext is consulted to do - * the initial resolution of the first variable of an expression. It is also consulted when a . or - * [] operator is encountered, except for the last such operator in a method expression, in which - * case the resolution rules are hard coded. - * - * For example, in the EL expression ${employee.lastName}, the ELResolver determines what object - * employee refers to, and what it means to get the lastName property on that object. - * - * Most methods in this class accept a base and property parameter. In the case of variable - * resolution (e.g. determining what employee refers to in ${employee.lastName}), the base parameter - * will be null and the property parameter will always be of type String. In this case, if the - * property is not a String, the behavior of the ELResolver is undefined. - * - * In the case of property resolution, the base parameter identifies the base object and the - * property object identifies the property on that base. For example, in the expression - * ${employee.lastName}, base is the result of the variable resolution for employee and property is - * the string "lastName". In the expression ${y[x]}, base is the result of the variable resolution - * for y and property is the result of the variable resolution for x. - * - * Though only a single ELResolver is associated with an ELContext, there are usually multiple - * resolvers considered for any given variable or property resolution. ELResolvers are combined - * together using {@link CompositeELResolver}s, to define rich semantics for evaluating an - * expression. For the {@link #getValue(ELContext, Object, Object)}, - * {@link #getType(ELContext, Object, Object)}, {@link #setValue(ELContext, Object, Object, Object)} - * and {@link #isReadOnly(ELContext, Object, Object)} methods, an ELResolver is not responsible for - * resolving all possible (base, property) pairs. In fact, most resolvers will only handle a base of - * a single type. To indicate that a resolver has successfully resolved a particular (base, - * property) pair, it must set the propertyResolved property of the ELContext to true. If it could - * not handle the given pair, it must leave this property alone. The caller must ignore the return - * value of the method if propertyResolved is false. - * - * The {@link #getFeatureDescriptors(ELContext, Object)} and - * {@link #getCommonPropertyType(ELContext, Object)} methods are primarily designed for design-time - * tool support, but must handle invocation at runtime as well. The java.beans.Beans.isDesignTime() - * method can be used to determine if the resolver is being consulted at design-time or runtime. - */ -public abstract class ELResolver { - /** - * The attribute name of the named attribute in the FeatureDescriptor that specifies whether the - * variable or property can be resolved at runtime. - */ - public static final String RESOLVABLE_AT_DESIGN_TIME = "resolvableAtDesignTime"; - - /** - * The attribute name of the named attribute in the FeatureDescriptor that specifies the runtime - * type of the variable or property. - */ - public static final String TYPE = "type"; - - /** - * Returns the most general type that this resolver accepts for the property argument, given a - * base object. One use for this method is to assist tools in auto-completion. This assists - * tools in auto-completion and also provides a way to express that the resolver accepts a - * primitive value, such as an integer index into an array. For example, the - * {@link ArrayELResolver} will accept any int as a property, so the return value would be - * Integer.class. - * - * @param context - * The context of this evaluation. - * @param base - * The base object to return the most general property type for, or null to enumerate - * the set of top-level variables that this resolver can evaluate. - * @return null if this ELResolver does not know how to handle the given base object; otherwise - * Object.class if any type of property is accepted; otherwise the most general property - * type accepted for the given base. - */ - public abstract Class getCommonPropertyType(ELContext context, Object base); - - /** - * Returns information about the set of variables or properties that can be resolved for the - * given base object. One use for this method is to assist tools in auto-completion. If the base - * parameter is null, the resolver must enumerate the list of top-level variables it can - * resolve. The Iterator returned must contain zero or more instances of - * java.beans.FeatureDescriptor, in no guaranteed order. In the case of primitive types such as - * int, the value null must be returned. This is to prevent the useless iteration through all - * possible primitive values. A return value of null indicates that this resolver does not - * handle the given base object or that the results are too complex to represent with this - * method and the {@link #getCommonPropertyType(ELContext, Object)} method should be used - * instead. Each FeatureDescriptor will contain information about a single variable or property. - * In addition to the standard properties, the FeatureDescriptor must have two named attributes - * (as set by the setValue method): - *
    - *
  • {@link #TYPE} - The value of this named attribute must be an instance of java.lang.Class - * and specify the runtime type of the variable or property.
  • - *
  • {@link #RESOLVABLE_AT_DESIGN_TIME} - The value of this named attribute must be an - * instance of java.lang.Boolean and indicates whether it is safe to attempt to resolve this - * property at designtime. For instance, it may be unsafe to attempt a resolution at design time - * if the ELResolver needs access to a resource that is only available at runtime and no - * acceptable simulated value can be provided.
  • - *
- * The caller should be aware that the Iterator returned might iterate through a very large or - * even infinitely large set of properties. Care should be taken by the caller to not get stuck - * in an infinite loop. This is a "best-effort" list. Not all ELResolvers will return completely - * accurate results, but all must be callable at both design-time and runtime (i.e. whether or - * not Beans.isDesignTime() returns true), without causing errors. The propertyResolved property - * of the ELContext is not relevant to this method. The results of all ELResolvers are - * concatenated in the case of composite resolvers. - * - * @param context - * The context of this evaluation. - * @param base - * The base object whose set of valid properties is to be enumerated, or null to - * enumerate the set of top-level variables that this resolver can evaluate. - * @return An Iterator containing zero or more (possibly infinitely more) FeatureDescriptor - * objects, or null if this resolver does not handle the given base object or that the - * results are too complex to represent with this method - */ - public abstract Iterator getFeatureDescriptors(ELContext context, Object base); - - /** - * For a given base and property, attempts to identify the most general type that is acceptable - * for an object to be passed as the value parameter in a future call to the - * {@link #setValue(ELContext, Object, Object, Object)} method. If this resolver handles the - * given (base, property) pair, the propertyResolved property of the ELContext object must be - * set to true by the resolver, before returning. If this property is not true after this method - * is called, the caller should ignore the return value. This is not always the same as - * getValue().getClass(). For example, in the case of an {@link ArrayELResolver}, the getType - * method will return the element type of the array, which might be a superclass of the type of - * the actual element that is currently in the specified array element. - * - * @param context - * The context of this evaluation. - * @param base - * The base object whose property value is to be analyzed, or null to analyze a - * top-level variable. - * @param property - * The property or variable to return the acceptable type for. - * @return If the propertyResolved property of ELContext was set to true, then the most general - * acceptable type; otherwise undefined. - * @throws java.lang.NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if the given (base, property) pair is handled by this ELResolver but the - * specified variable or property does not exist or is not readable. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - public abstract Class getType(ELContext context, Object base, Object property); - - /** - * Attempts to resolve the given property object on the given base object. If this resolver - * handles the given (base, property) pair, the propertyResolved property of the ELContext - * object must be set to true by the resolver, before returning. If this property is not true - * after this method is called, the caller should ignore the return value. - * - * @param context - * The context of this evaluation. - * @param base - * The base object whose property value is to be returned, or null to resolve a - * top-level variable. - * @param property - * The property or variable to be resolved. - * @return If the propertyResolved property of ELContext was set to true, then the result of the - * variable or property resolution; otherwise undefined. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if the given (base, property) pair is handled by this ELResolver but the - * specified variable or property does not exist or is not readable. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - public abstract Object getValue(ELContext context, Object base, Object property); - - /** - * For a given base and property, attempts to determine whether a call to - * {@link #setValue(ELContext, Object, Object, Object)} will always fail. If this resolver - * handles the given (base, property) pair, the propertyResolved property of the ELContext - * object must be set to true by the resolver, before returning. If this property is not true - * after this method is called, the caller should ignore the return value. - * - * @param context - * The context of this evaluation. - * @param base - * The base object whose property value is to be analyzed, or null to analyze a - * top-level variable. - * @param property - * The property or variable to return the read-only status for. - * @return If the propertyResolved property of ELContext was set to true, then true if the - * property is read-only or false if not; otherwise undefined. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if the given (base, property) pair is handled by this ELResolver but the - * specified variable or property does not exist. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - public abstract boolean isReadOnly(ELContext context, Object base, Object property); - - /** - * Attempts to set the value of the given property object on the given base object. If this - * resolver handles the given (base, property) pair, the propertyResolved property of the - * ELContext object must be set to true by the resolver, before returning. If this property is - * not true after this method is called, the caller can safely assume no value has been set. - * - * @param context - * The context of this evaluation. - * @param base - * The base object whose property value is to be set, or null to set a top-level - * variable. - * @param property - * The property or variable to be set. - * @param value - * The value to set the property or variable to. - * @throws NullPointerException - * if context is null - * @throws PropertyNotFoundException - * if the given (base, property) pair is handled by this ELResolver but the - * specified variable or property does not exist. - * @throws PropertyNotWritableException - * if the given (base, property) pair is handled by this ELResolver but the - * specified variable or property is not writable. - * @throws ELException - * if an exception was thrown while attempting to set the property or variable. The - * thrown exception must be included as the cause property of this exception, if - * available. - */ - public abstract void setValue(ELContext context, Object base, Object property, Object value); - - /** - * Attempts to resolve and invoke the given method on the given base - * object. - * - *

- * If this resolver handles the given (base, method) pair, the propertyResolved - * property of the ELContext object must be set to true by the - * resolver, before returning. If this property is not true after this method is - * called, the caller should ignore the return value. - *

- * - *

- * A default implementation is provided that returns null so that existing classes that extend - * ELResolver can continue to function. - *

- * - * @param context - * The context of this evaluation. - * @param base - * The bean on which to invoke the method - * @param method - * The simple name of the method to invoke. Will be coerced to a String. - * @param paramTypes - * An array of Class objects identifying the method's formal parameter types, in - * declared order. Use an empty array if the method has no parameters. Can be - * null, in which case the method's formal parameter types are assumed - * to be unknown. - * @param params - * The parameters to pass to the method, or null if no parameters. - * @return The result of the method invocation (null if the method has a - * void return type). - * @throws MethodNotFoundException - * if no suitable method can be found. - * @throws ELException - * if an exception was thrown while performing (base, method) resolution. The thrown - * exception must be included as the cause property of this exception, if available. - * If the exception thrown is an InvocationTargetException, extract its - * cause and pass it to the ELException constructor. - * @since 2.2 - */ - public Object invoke(ELContext context, Object base, Object method, Class[] paramTypes, Object[] params) { - return null; - } -} diff --git a/modules/api/src/main/java/javax/el/Expression.java b/modules/api/src/main/java/javax/el/Expression.java deleted file mode 100644 index ffcbf5c..0000000 --- a/modules/api/src/main/java/javax/el/Expression.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; -import java.util.Hashtable; - -/** - * Base class for the expression subclasses {@link ValueExpression} and {@link MethodExpression}, - * implementing characterstics common to both. All expressions must implement the equals() and - * hashCode() methods so that two expressions can be compared for equality. They are redefined - * abstract in this class to force their implementation in subclasses. All expressions must also be - * Serializable so that they can be saved and restored. Expressions are also designed to be - * immutable so that only one instance needs to be created for any given expression String / - * {@link FunctionMapper}. This allows a container to pre-create expressions and not have to reparse - * them each time they are evaluated. - */ -public abstract class Expression implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * Determines whether the specified object is equal to this Expression. The result is true if - * and only if the argument is not null, is an Expression object that is the of the same type - * (ValueExpression or MethodExpression), and has an identical parsed representation. Note that - * two expressions can be equal if their expression Strings are different. For example, - * ${fn1:foo()} and ${fn2:foo()} are equal if their corresponding FunctionMappers mapped fn1:foo - * and fn2:foo to the same method. - * - * @param obj - * the Object to test for equality. - * @return true if obj equals this Expression; false otherwise. - */ - @Override - public abstract boolean equals(Object obj); - - /** - * Returns the original String used to create this Expression, unmodified. 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). 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 Expression. - * - * @return The original expression String. - */ - public abstract String getExpressionString(); - - /** - * Returns the hash code for this Expression. See the note in the {@link #equals(Object)} method - * on how two expressions can be equal if their expression Strings are different. Recall that if - * two objects are equal according to the equals(Object) method, then calling the hashCode - * method on each of the two objects must produce the same integer result. Implementations must - * take special note and implement hashCode correctly. - * - * @return The hash code for this Expression. - * @see #equals(Object) - * @see Hashtable - * @see Object#hashCode() - */ - @Override - public abstract int hashCode(); - - /** - * Returns whether this expression was created from only literal text. This method must return - * true if and only if the expression string this expression was created from contained no - * unescaped EL delimeters (${...} or #{...}). - * - * @return true if this expression was created from only literal text; false otherwise. - */ - public abstract boolean isLiteralText(); -} diff --git a/modules/api/src/main/java/javax/el/ExpressionFactory.java b/modules/api/src/main/java/javax/el/ExpressionFactory.java deleted file mode 100644 index f42742f..0000000 --- a/modules/api/src/main/java/javax/el/ExpressionFactory.java +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Constructor; -import java.util.Properties; - -/** - * Parses a String into a {@link ValueExpression} or {@link MethodExpression} instance for later - * evaluation. Classes that implement the EL expression language expose their functionality via this - * abstract class. There is no concrete implementation of this API available in this package. - * Technologies such as JavaServer Pages and JavaServer Faces provide access to an implementation - * via factory methods. The {@link #createValueExpression(ELContext, String, Class)} method is used - * to parse expressions that evaluate to values (both l-values and r-values are supported). The - * {@link #createMethodExpression(ELContext, String, Class, Class[])} method is used to parse - * expressions that evaluate to a reference to a method on an object. Unlike previous incarnations - * of this API, there is no way to parse and evaluate an expression in one single step. The - * expression needs to first be parsed, and then evaluated. Resolution of model objects is performed - * at evaluation time, via the {@link ELResolver} associated with the {@link ELContext} passed to - * the ValueExpression or MethodExpression. The ELContext object also provides access to the - * {@link FunctionMapper} and {@link VariableMapper} to be used when parsing the expression. EL - * function and variable mapping is performed at parse-time, and the results are bound to the - * expression. Therefore, the {@link ELContext}, {@link FunctionMapper}, and {@link VariableMapper} - * are not stored for future use and do not have to be Serializable. The createValueExpression and - * createMethodExpression methods must be thread-safe. That is, multiple threads may call these - * methods on the same ExpressionFactory object simultaneously. Implementations should synchronize - * access if they depend on transient state. Implementations should not, however, assume that only - * one object of each ExpressionFactory type will be instantiated; global caching should therefore - * be static. The ExpressionFactory must be able to handle the following types of input for the - * expression parameter: - *
    - *
  • Single expressions using the ${} delimiter (e.g. "${employee.lastName}").
  • - *
  • Single expressions using the #{} delimiter (e.g. "#{employee.lastName}").
  • - *
  • Literal text containing no ${} or #{} delimiters (e.g. "John Doe").
  • - *
  • Multiple expressions using the same delimiter (e.g.
  • - * "${employee.firstName}${employee.lastName}" or "#{employee.firstName}#{employee.lastName}"). - *
  • Mixed literal text and expressions using the same delimiter (e.g. "Name: - * ${employee.firstName} ${employee.lastName}").
  • - *
- * The following types of input are illegal and must cause an {@link ELException} to be thrown: - *
    - *
  • Multiple expressions using different delimiters (e.g. - * "${employee.firstName}#{employee.lastName}").
  • - *
  • Mixed literal text and expressions using different delimiters(e.g. "Name: - * ${employee.firstName} #{employee.lastName}").
  • - *
- */ -public abstract class ExpressionFactory { - /** - * Creates a new instance of a ExpressionFactory. This method uses the following ordered lookup - * procedure to determine the ExpressionFactory implementation class to load: - *
    - *
  • Use the Services API (as detailed in the JAR specification). If a resource with the name - * of META-INF/services/javax.el.ExpressionFactory exists, then its first line, if present, is - * used as the UTF-8 encoded name of the implementation class.
  • - *
  • Use the properties file "lib/el.properties" in the JRE directory. If this file exists and - * it is readable by the java.util.Properties.load(InputStream) method, and it contains an entry - * whose key is "javax.el.ExpressionFactory", then the value of that entry is used as the name - * of the implementation class.
  • - *
  • Use the javax.el.ExpressionFactory system property. If a system property with this name - * is defined, then its value is used as the name of the implementation class.
  • - *
  • Use a platform default implementation.
  • - *
- * - * @return An instance of ExpressionFactory. - * @throws ELException - * if a factory class cannot be found or instantiation fails. - */ - public static ExpressionFactory newInstance() { - return newInstance(null); - } - - /** - * Create a new instance of a ExpressionFactory, with optional properties. This method uses the - * same lookup procedure as the one used in newInstance(). If the argument properties is not - * null, and if the implementation contains a constructor with a single parameter of type - * java.util.Properties, then the constructor is used to create the instance. Properties are - * optional and can be ignored by an implementation. The name of a property should start with - * "javax.el." The following are some suggested names for properties. - *
    - *
  • javax.el.cacheSize
  • - *
- * - * @param properties - * Properties passed to the constructor of the implementation. - * @return An instance of ExpressionFactory. - * @throws ELException - * if a factory class cannot be found or instantiation fails. - */ - public static ExpressionFactory newInstance(Properties properties) { - ClassLoader classLoader; - try { - classLoader = Thread.currentThread().getContextClassLoader(); - } catch (SecurityException e) { - classLoader = ExpressionFactory.class.getClassLoader(); - } - - String className = null; - - String serviceId = "META-INF/services/" + ExpressionFactory.class.getName(); - InputStream input = classLoader.getResourceAsStream(serviceId); - try { - if (input != null) { - BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); - className = reader.readLine(); - reader.close(); - } - } catch (IOException e) { - // do nothing - } finally { - if (input != null) { - try { - input.close(); - } catch (Exception io) { - // do nothing - } finally { - input = null; - } - } - } - - if (className == null || className.trim().length() == 0) { - try { - String home = System.getProperty("java.home"); - if (home != null) { - String path = home + File.separator + "lib" + File.separator + "el.properties"; - File file = new File(path); - if (file.exists()) { - input = new FileInputStream(file); - Properties props = new Properties(); - props.load(input); - className = props.getProperty(ExpressionFactory.class.getName()); - } - } - } catch (IOException e) { - // do nothing - } catch (SecurityException e) { - // do nothing - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException io) { - // do nothing - } finally { - input = null; - } - } - } - } - - if (className == null || className.trim().length() == 0) { - try { - className = System.getProperty(ExpressionFactory.class.getName()); - } catch (Exception se) { - // do nothing - } - } - - if (className == null || className.trim().length() == 0) { - className = "de.odysseus.el.ExpressionFactoryImpl"; - } - - return newInstance(properties, className, classLoader); - } - - /** - * Create an ExpressionFactory instance. - * - * @param properties - * Properties passed to the constructor of the implementation. - * @return an instance of ExpressionFactory - * @param className - * The name of the ExpressionFactory class. - * @param classLoader - * The class loader to be used to load the class. - * @return An instance of ExpressionFactory. - * @throws ELException - * if the class could not be found or if it is not a subclass of ExpressionFactory - * or if the class could not be instantiated. - */ - private static ExpressionFactory newInstance(Properties properties, String className, ClassLoader classLoader) { - Class clazz = null; - try { - clazz = classLoader.loadClass(className.trim()); - if (!ExpressionFactory.class.isAssignableFrom(clazz)) { - throw new ELException("Invalid expression factory class: " + clazz.getName()); - } - } catch (ClassNotFoundException e) { - throw new ELException("Could not find expression factory class", e); - } - try { - if (properties != null) { - Constructor constructor = null; - try { - constructor = clazz.getConstructor(Properties.class); - } catch (Exception e) { - // do nothing - } - if (constructor != null) { - return (ExpressionFactory) constructor.newInstance(properties); - } - } - return (ExpressionFactory) clazz.newInstance(); - } catch (Exception e) { - throw new ELException("Could not create expression factory instance", e); - } - } - - /** - * Coerces an object to a specific type according to the EL type conversion rules. An - * {@link ELException} is thrown if an error results from applying the conversion rules. - * - * @param obj - * The object to coerce. - * @param targetType - * The target type for the coercion. - * @return the coerced object - * @throws ELException - * if an error results from applying the conversion rules. - */ - public abstract Object coerceToType(Object obj, Class targetType); - - /** - * Parses an expression into a {@link MethodExpression} for later evaluation. Use this method - * for expressions that refer to methods. If the expression is a String literal, a - * MethodExpression is created, which when invoked, returns the String literal, coerced to - * expectedReturnType. An ELException is thrown if expectedReturnType is void or if the coercion - * of the String literal to the expectedReturnType yields an error (see Section "1.16 Type - * Conversion"). This method should perform syntactic validation of the expression. If in doing - * so it detects errors, it should raise an ELException. - * - * @param context - * The EL context used to parse the expression. The FunctionMapper and VariableMapper - * stored in the ELContext are used to resolve functions and variables found in the - * expression. They can be null, in which case functions or variables are not - * supported for this expression. The object returned must invoke the same functions - * and access the same variable mappings regardless of whether the mappings in the - * provided FunctionMapper and VariableMapper instances change between calling - * ExpressionFactory.createMethodExpression() and any method on MethodExpression. - * Note that within the EL, the ${} and #{} syntaxes are treated identically. This - * includes the use of VariableMapper and FunctionMapper at expression creation time. - * Each is invoked if not null, independent of whether the #{} or ${} syntax is used - * for the expression. - * @param expression - * The expression to parse - * @param expectedReturnType - * The expected return type for the method to be found. After evaluating the - * expression, the MethodExpression must check that the return type of the actual - * method matches this type. Passing in a value of null indicates the caller does not - * care what the return type is, and the check is disabled. - * @param expectedParamTypes - * The expected parameter types for the method to be found. Must be an array with no - * elements if there are no parameters expected. It is illegal to pass null, unless - * the method is specified with arguments in the EL expression. - * @return The parsed expression - * @throws ELException - * Thrown if there are syntactical errors in the provided expression. - * @throws NullPointerException - * if paramTypes is null. - */ - public abstract MethodExpression createMethodExpression(ELContext context, String expression, - Class expectedReturnType, Class[] expectedParamTypes); - - /** - * Parses an expression into a {@link ValueExpression} for later evaluation. Use this method for - * expressions that refer to values. This method should perform syntactic validation of the - * expression. If in doing so it detects errors, it should raise an ELException. - * - * @param context - * The EL context used to parse the expression. The FunctionMapper and VariableMapper - * stored in the ELContext are used to resolve functions and variables found in the - * expression. They can be null, in which case functions or variables are not - * supported for this expression. The object returned must invoke the same functions - * and access the same variable mappings regardless of whether the mappings in the - * provided FunctionMapper and VariableMapper instances change between calling - * ExpressionFactory.createValueExpression() and any method on ValueExpression. Note - * that within the EL, the ${} and #{} syntaxes are treated identically. This - * includes the use of VariableMapper and FunctionMapper at expression creation time. - * Each is invoked if not null, independent of whether the #{} or ${} syntax is used - * for the expression. - * @param expression - * The expression to parse - * @param expectedType - * The type the result of the expression will be coerced to after evaluation. - * @return The parsed expression - * @throws ELException - * Thrown if there are syntactical errors in the provided expression. - * @throws NullPointerException - * if paramTypes is null. - */ - public abstract ValueExpression createValueExpression(ELContext context, String expression, Class expectedType); - - /** - * Creates a ValueExpression that wraps an object instance. This method can be used to pass any - * object as a ValueExpression. The wrapper ValueExpression is read only, and returns the - * wrapped object via its getValue() method, optionally coerced. - * - * @param instance - * The object instance to be wrapped. - * @param expectedType - * The type the result of the expression will be coerced to after evaluation. There - * will be no coercion if it is Object.class, - * @return a ValueExpression that wraps the given object instance. - */ - public abstract ValueExpression createValueExpression(Object instance, Class expectedType); -} diff --git a/modules/api/src/main/java/javax/el/FunctionMapper.java b/modules/api/src/main/java/javax/el/FunctionMapper.java deleted file mode 100644 index b797cd7..0000000 --- a/modules/api/src/main/java/javax/el/FunctionMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * The interface to a map between EL function names and methods. A FunctionMapper maps - * ${prefix:name()} style functions to a static method that can execute that function. - */ -public abstract class FunctionMapper { - /** - * Resolves the specified prefix and local name into a java.lang.Method. Returns null if no - * function could be found that matches the given prefix and local name. - * - * @param prefix - * the prefix of the function, or "" if no prefix. For example, "fn" in - * ${fn:method()}, or "" in ${method()}. - * @param localName - * the short name of the function. For example, "method" in ${fn:method()}. - * @return the static method to invoke, or null if no match was found. - */ - public abstract Method resolveFunction(String prefix, String localName); -} diff --git a/modules/api/src/main/java/javax/el/ListELResolver.java b/modules/api/src/main/java/javax/el/ListELResolver.java deleted file mode 100644 index 30e8b02..0000000 --- a/modules/api/src/main/java/javax/el/ListELResolver.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Iterator; -import java.util.List; - -/** - * Defines property resolution behavior on instances of java.util.List. This resolver handles base - * objects of type java.util.List. It accepts any object as a property and coerces that object into - * an integer index into the list. The resulting value is the value in the list at that index. This - * resolver can be constructed in read-only mode, which means that isReadOnly will always return - * true and {@link #setValue(ELContext, Object, Object, Object)} will always throw - * PropertyNotWritableException. ELResolvers are combined together using {@link CompositeELResolver} - * s, to define rich semantics for evaluating an expression. See the javadocs for {@link ELResolver} - * for details. - */ -public class ListELResolver extends ELResolver { - private final boolean readOnly; - - /** - * Creates a new read/write ListELResolver. - */ - public ListELResolver() { - this(false); - } - - /** - * Creates a new ListELResolver whose read-only status is determined by the given parameter. - * - * @param readOnly - * true if this resolver cannot modify lists; false otherwise. - */ - public ListELResolver(boolean readOnly) { - this.readOnly = readOnly; - } - - /** - * If the base object is a list, returns the most general type that this resolver accepts for - * the property argument. Otherwise, returns null. Assuming the base is a List, this method will - * always return Integer.class. This is because Lists accept integers as their index. - * - * @param context - * The context of this evaluation. - * @param base - * The list to analyze. Only bases of type List are handled by this resolver. - * @return null if base is not a List; otherwise Integer.class. - */ - @Override - public Class getCommonPropertyType(ELContext context, Object base) { - return isResolvable(base) ? Integer.class : null; - } - - /** - * Always returns null, since there is no reason to iterate through set set of all integers. - * - * @param context - * The context of this evaluation. - * @param base - * The list to analyze. Only bases of type List are handled by this resolver. - * @return null. - */ - @Override - public Iterator getFeatureDescriptors(ELContext context, Object base) { - return null; - } - - /** - * If the base object is a list, returns the most general acceptable type for a value in this - * list. If the base is a List, the propertyResolved property of the ELContext object must be - * set to true by this resolver, before returning. If this property is not true after this - * method is called, the caller should ignore the return value. Assuming the base is a List, - * this method will always return Object.class. This is because Lists accept any object as an - * element. - * - * @param context - * The context of this evaluation. - * @param base - * The list to analyze. Only bases of type List are handled by this resolver. - * @param property - * The index of the element in the list to return the acceptable type for. Will be - * coerced into an integer, but otherwise ignored by this resolver. - * @return If the propertyResolved property of ELContext was set to true, then the most general - * acceptable type; otherwise undefined. - * @throws PropertyNotFoundException - * if the given index is out of bounds for this list. - * @throws IllegalArgumentException - * if the property could not be coerced into an integer. - * @throws NullPointerException - * if context is null - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Class getType(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - Class result = null; - if (isResolvable(base)) { - toIndex((List) base, property); - result = Object.class; - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is a list, returns the value at the given index. The index is specified by - * the property argument, and coerced into an integer. If the coercion could not be performed, - * an IllegalArgumentException is thrown. If the index is out of bounds, null is returned. If - * the base is a List, the propertyResolved property of the ELContext object must be set to true - * by this resolver, before returning. If this property is not true after this method is called, - * the caller should ignore the return value. - * - * @param context - * The context of this evaluation. - * @param base - * The list to analyze. Only bases of type List are handled by this resolver. - * @param property - * The index of the element in the list to return the acceptable type for. Will be - * coerced into an integer, but otherwise ignored by this resolver. - * @return If the propertyResolved property of ELContext was set to true, then the value at the - * given index or null if the index was out of bounds. Otherwise, undefined. - * @throws PropertyNotFoundException - * if the given index is out of bounds for this list. - * @throws IllegalArgumentException - * if the property could not be coerced into an integer. - * @throws NullPointerException - * if context is null - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Object getValue(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - Object result = null; - if (isResolvable(base)) { - int index = toIndex(null, property); - List list = (List) base; - result = index < 0 || index >= list.size() ? null : list.get(index); - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is a list, returns whether a call to - * {@link #setValue(ELContext, Object, Object, Object)} will always fail. If the base is a List, - * the propertyResolved property of the ELContext object must be set to true by this resolver, - * before returning. If this property is not true after this method is called, the caller should - * ignore the return value. If this resolver was constructed in read-only mode, this method will - * always return true. If a List was created using java.util.Collections.unmodifiableList(List), - * this method must return true. Unfortunately, there is no Collections API method to detect - * this. However, an implementation can create a prototype unmodifiable List and query its - * runtime type to see if it matches the runtime type of the base object as a workaround. - * - * @param context - * The context of this evaluation. - * @param base - * The list to analyze. Only bases of type List are handled by this resolver. - * @param property - * The index of the element in the list to return the acceptable type for. Will be - * coerced into an integer, but otherwise ignored by this resolver. - * @return If the propertyResolved property of ELContext was set to true, then true if calling - * the setValue method will always fail or false if it is possible that such a call may - * succeed; otherwise undefined. - * @throws PropertyNotFoundException - * if the given index is out of bounds for this list. - * @throws IllegalArgumentException - * if the property could not be coerced into an integer. - * @throws NullPointerException - * if context is null - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public boolean isReadOnly(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - if (isResolvable(base)) { - toIndex((List) base, property); - context.setPropertyResolved(true); - } - return readOnly; - } - - /** - * If the base object is a list, attempts to set the value at the given index with the given - * value. The index is specified by the property argument, and coerced into an integer. If the - * coercion could not be performed, an IllegalArgumentException is thrown. If the index is out - * of bounds, a PropertyNotFoundException is thrown. If the base is a List, the propertyResolved - * property of the ELContext object must be set to true by this resolver, before returning. If - * this property is not true after this method is called, the caller can safely assume no value - * was set. If this resolver was constructed in read-only mode, this method will always throw - * PropertyNotWritableException. If a List was created using - * java.util.Collections.unmodifiableList(List), this method must throw - * PropertyNotWritableException. Unfortunately, there is no Collections API method to detect - * this. However, an implementation can create a prototype unmodifiable List and query its - * runtime type to see if it matches the runtime type of the base object as a workaround. - * - * @param context - * The context of this evaluation. - * @param base - * The list to analyze. Only bases of type List are handled by this resolver. - * @param property - * The index of the element in the list to return the acceptable type for. Will be - * coerced into an integer, but otherwise ignored by this resolver. - * @param value - * The value to be set at the given index. - * @throws ClassCastException - * if the class of the specified element prevents it from being added to this list. - * @throws PropertyNotFoundException - * if the given index is out of bounds for this list. - * @throws PropertyNotWritableException - * if this resolver was constructed in read-only mode, or if the set operation is - * not supported by the underlying list. - * @throws IllegalArgumentException - * if the property could not be coerced into an integer. - * @throws NullPointerException - * if context is null - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - @SuppressWarnings("unchecked") - public void setValue(ELContext context, Object base, Object property, Object value) { - if (context == null) { - throw new NullPointerException("context is null"); - } - if (isResolvable(base)) { - if (readOnly) { - throw new PropertyNotWritableException("resolver is read-only"); - } - List list = (List) base; - int index = toIndex(list, property); - try { - list.set(index, value); - } catch (UnsupportedOperationException e) { - throw new PropertyNotWritableException(e); - } catch (ArrayStoreException e) { - throw new IllegalArgumentException(e); - } - context.setPropertyResolved(true); - } - } - - /** - * Test whether the given base should be resolved by this ELResolver. - * - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return base instanceof List - */ - private static final boolean isResolvable(Object base) { - return base instanceof List; - } - - /** - * Convert the given property to an index in (list) base. - * - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return The index of property in base. - * @throws IllegalArgumentException - * if base property cannot be coerced to an integer. - * @throws PropertyNotFoundException - * if base is not null and the computed index is out of bounds for base. - */ - private static final int toIndex(List base, Object property) { - int index = 0; - if (property instanceof Number) { - index = ((Number) property).intValue(); - } else if (property instanceof String) { - try { - index = Integer.valueOf((String) property); - } catch (NumberFormatException e) { - throw new IllegalArgumentException("Cannot parse list index: " + property); - } - } else if (property instanceof Character) { - index = ((Character) property).charValue(); - } else if (property instanceof Boolean) { - index = ((Boolean) property).booleanValue() ? 1 : 0; - } else { - throw new IllegalArgumentException("Cannot coerce property to list index: " + property); - } - if (base != null && (index < 0 || index >= base.size())) { - throw new PropertyNotFoundException("List index out of bounds: " + index); - } - return index; - } -} diff --git a/modules/api/src/main/java/javax/el/MapELResolver.java b/modules/api/src/main/java/javax/el/MapELResolver.java deleted file mode 100644 index 50a0742..0000000 --- a/modules/api/src/main/java/javax/el/MapELResolver.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Iterator; -import java.util.Map; - -/** - * Defines property resolution behavior on instances of java.util.Map. This resolver handles base - * objects of type java.util.Map. It accepts any object as a property and uses that object as a key - * in the map. The resulting value is the value in the map that is associated with that key. This - * resolver can be constructed in read-only mode, which means that isReadOnly will always return - * true and {@link #setValue(ELContext, Object, Object, Object)} will always throw - * PropertyNotWritableException. ELResolvers are combined together using {@link CompositeELResolver} - * s, to define rich semantics for evaluating an expression. See the javadocs for {@link ELResolver} - * for details. - */ -public class MapELResolver extends ELResolver { - private final boolean readOnly; - - /** - * Creates a new read/write MapELResolver. - */ - public MapELResolver() { - this(false); - } - - /** - * Creates a new MapELResolver whose read-only status is determined by the given parameter. - */ - public MapELResolver(boolean readOnly) { - this.readOnly = readOnly; - } - - /** - * If the base object is a map, returns the most general type that this resolver accepts for the - * property argument. Otherwise, returns null. Assuming the base is a Map, this method will - * always return Object.class. This is because Maps accept any object as a key. - * - * @param context - * The context of this evaluation. - * @param base - * The map to analyze. Only bases of type Map are handled by this resolver. - * @return null if base is not a Map; otherwise Object.class. - */ - @Override - public Class getCommonPropertyType(ELContext context, Object base) { - return isResolvable(base) ? Object.class : null; - } - - /** - * If the base object is a map, returns an Iterator containing the set of keys available in the - * Map. Otherwise, returns null. The Iterator returned must contain zero or more instances of - * java.beans.FeatureDescriptor. Each info object contains information about a key in the Map, - * and is initialized as follows: - *
    - *
  • displayName - The return value of calling the toString method on this key, or "null" if - * the key is null
  • - *
  • name - Same as displayName property
  • - *
  • shortDescription - Empty string
  • - *
  • expert - false
  • - *
  • hidden - false
  • - *
  • preferred - true
  • - *
- * In addition, the following named attributes must be set in the returned FeatureDescriptors: - *
    - *
  • {@link ELResolver#TYPE} - The return value of calling the getClass() method on this key, - * or null if the key is null.
  • - *
  • {@link ELResolver#RESOLVABLE_AT_DESIGN_TIME} - true
  • - *
- * - * @param context - * The context of this evaluation. - * @param base - * The map to analyze. Only bases of type Map are handled by this resolver. - * @return An Iterator containing zero or more (possibly infinitely more) FeatureDescriptor - * objects, each representing a key in this map, or null if the base object is not a - * map. - */ - @Override - public Iterator getFeatureDescriptors(ELContext context, Object base) { - if (isResolvable(base)) { - Map map = (Map) base; - final Iterator keys = map.keySet().iterator(); - return new Iterator() { - public boolean hasNext() { - return keys.hasNext(); - } - public FeatureDescriptor next() { - Object key = keys.next(); - FeatureDescriptor feature = new FeatureDescriptor(); - feature.setDisplayName(key == null ? "null" : key.toString()); - feature.setName(feature.getDisplayName()); - feature.setShortDescription(""); - feature.setExpert(true); - feature.setHidden(false); - feature.setPreferred(true); - feature.setValue(TYPE, key == null ? null : key.getClass()); - feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true); - return feature; - - } - public void remove() { - throw new UnsupportedOperationException("cannot remove"); - } - }; - } - return null; - } - - /** - * If the base object is a map, returns the most general acceptable type for a value in this - * map. If the base is a Map, the propertyResolved property of the ELContext object must be set - * to true by this resolver, before returning. If this property is not true after this method is - * called, the caller should ignore the return value. Assuming the base is a Map, this method - * will always return Object.class. This is because Maps accept any object as the value for a - * given key. - * - * @param context - * The context of this evaluation. - * @param base - * The map to analyze. Only bases of type Map are handled by this resolver. - * @param property - * The key to return the acceptable type for. Ignored by this resolver. - * @return If the propertyResolved property of ELContext was set to true, then the most general - * acceptable type; otherwise undefined. - * @throws NullPointerException - * if context is null - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Class getType(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - Class result = null; - if (isResolvable(base)) { - result = Object.class; - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is a map, returns the value associated with the given key, as specified by - * the property argument. If the key was not found, null is returned. If the base is a Map, the - * propertyResolved property of the ELContext object must be set to true by this resolver, - * before returning. If this property is not true after this method is called, the caller should - * ignore the return value. Just as in java.util.Map.get(Object), just because null is returned - * doesn't mean there is no mapping for the key; it's also possible that the Map explicitly maps - * the key to null. - * - * @param context - * The context of this evaluation. - * @param base - * The map to analyze. Only bases of type Map are handled by this resolver. - * @param property - * The key to return the acceptable type for. Ignored by this resolver. - * @return If the propertyResolved property of ELContext was set to true, then the value - * associated with the given key or null if the key was not found. Otherwise, undefined. - * @throws ClassCastException - * if the key is of an inappropriate type for this map (optionally thrown by the - * underlying Map). - * @throws NullPointerException - * if context is null, or if the key is null and this map does not permit null keys - * (the latter is optionally thrown by the underlying Map). - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Object getValue(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - Object result = null; - if (isResolvable(base)) { - result = ((Map) base).get(property); - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is a map, returns whether a call to - * {@link #setValue(ELContext, Object, Object, Object)} will always fail. If the base is a Map, - * the propertyResolved property of the ELContext object must be set to true by this resolver, - * before returning. If this property is not true after this method is called, the caller should - * ignore the return value. If this resolver was constructed in read-only mode, this method will - * always return true. If a Map was created using java.util.Collections.unmodifiableMap(Map), - * this method must return true. Unfortunately, there is no Collections API method to detect - * this. However, an implementation can create a prototype unmodifiable Map and query its - * runtime type to see if it matches the runtime type of the base object as a workaround. - * - * @param context - * The context of this evaluation. - * @param base - * The map to analyze. Only bases of type Map are handled by this resolver. - * @param property - * The key to return the acceptable type for. Ignored by this resolver. - * @return If the propertyResolved property of ELContext was set to true, then true if calling - * the setValue method will always fail or false if it is possible that such a call may - * succeed; otherwise undefined. - * @throws NullPointerException - * if context is null. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public boolean isReadOnly(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - if (isResolvable(base)) { - context.setPropertyResolved(true); - } - return readOnly; - } - - /** - * If the base object is a map, attempts to set the value associated with the given key, as - * specified by the property argument. If the base is a Map, the propertyResolved property of - * the ELContext object must be set to true by this resolver, before returning. If this property - * is not true after this method is called, the caller can safely assume no value was set. If - * this resolver was constructed in read-only mode, this method will always throw - * PropertyNotWritableException. If a Map was created using - * java.util.Collections.unmodifiableMap(Map), this method must throw - * PropertyNotWritableException. Unfortunately, there is no Collections API method to detect - * this. However, an implementation can create a prototype unmodifiable Map and query its - * runtime type to see if it matches the runtime type of the base object as a workaround. - * - * @param context - * The context of this evaluation. - * @param base - * The map to analyze. Only bases of type Map are handled by this resolver. - * @param property - * The key to return the acceptable type for. Ignored by this resolver. - * @param value - * The value to be associated with the specified key. - * @throws ClassCastException - * if the class of the specified key or value prevents it from being stored in this - * map. - * @throws NullPointerException - * if context is null, or if this map does not permit null keys or values, and the - * specified key or value is null. - * @throws IllegalArgumentException - * if some aspect of this key or value prevents it from being stored in this map. - * @throws PropertyNotWritableException - * if this resolver was constructed in read-only mode, or if the put operation is - * not supported by the underlying map. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - @SuppressWarnings("unchecked") - public void setValue(ELContext context, Object base, Object property, Object value) { - if (context == null) { - throw new NullPointerException("context is null"); - } - if (isResolvable(base)) { - if (readOnly) { - throw new PropertyNotWritableException("resolver is read-only"); - } - ((Map) base).put(property, value); - context.setPropertyResolved(true); - } - } - - /** - * Test whether the given base should be resolved by this ELResolver. - * - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return base instanceof Map - */ - private final boolean isResolvable(Object base) { - return base instanceof Map; - } -} diff --git a/modules/api/src/main/java/javax/el/MethodExpression.java b/modules/api/src/main/java/javax/el/MethodExpression.java deleted file mode 100644 index 751bc0f..0000000 --- a/modules/api/src/main/java/javax/el/MethodExpression.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * An Expression that refers to a method on an object. The - * {@link ExpressionFactory#createMethodExpression(ELContext, String, Class, Class[])} method can be - * used to parse an expression string and return a concrete instance of MethodExpression 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. The {@link #getMethodInfo(ELContext)} and - * {@link #invoke(ELContext, Object[])} methods will evaluate the expression each time they are - * called. The {@link ELResolver} in the ELContext is used to resolve the top-level variables and to - * determine the behavior of the . and [] operators. For any of the two methods, the - * {@link ELResolver#getValue(ELContext, Object, Object)} method is used to resolve all properties - * up to but excluding the last one. This provides the base object on which the method appears. If - * the base object is null, a PropertyNotFoundException must be thrown. At the last resolution, the - * final property is then coerced to a String, 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 MethodExpression). See the notes about - * comparison, serialization and immutability in the {@link Expression} javadocs. - * - * @see ELResolver - * @see Expression - * @see ExpressionFactory - */ -public abstract class MethodExpression extends Expression { - private static final long serialVersionUID = 1L; - - /** - * Evaluates the expression relative to the provided context, and returns information about the - * actual referenced method. - * - * @param context - * The context of this evaluation. - * @return The context of this evaluation - * @throws NullPointerException - * if context is null - * @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. - */ - public abstract MethodInfo getMethodInfo(ELContext context); - - /** - * If a String literal is specified as the expression, returns the String literal coerced to the - * expected return type of the method signature. An ELException is thrown if expectedReturnType - * is void or if the coercion of the String literal to the expectedReturnType yields an error - * (see Section "1.16 Type Conversion" of the EL specification). If not a String literal, - * 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. Any - * parameters passed to this method is ignored if isLiteralText() is true. - * - * @param context - * The context of this evaluation. - * @param params - * The parameters to pass to the method, or null if no parameters. - * @return the result of the method invocation (null if the method has a void return type). - * @throws NullPointerException - * if context is null - * @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 a String literal is specified and expectedReturnType of the MethodExpression - * is void or if the coercion of the String literal to the expectedReturnType yields - * an error (see Section "1.16 Type Conversion"). - * @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 InvocationTargetException, extract its - * cause and pass it to the ELException constructor. - */ - public abstract Object invoke(ELContext context, Object[] params); - - /** - * Return whether this MethodExpression was created with parameters. - * - *

- * This method must return true if and only if parameters are specified in the EL, - * using the expr-a.expr-b(...) syntax. - *

- * - * @return true if the MethodExpression was created with parameters, - * false otherwise. - * @since 2.2 - */ - public boolean isParmetersProvided() { - return false; - } -} diff --git a/modules/api/src/main/java/javax/el/MethodInfo.java b/modules/api/src/main/java/javax/el/MethodInfo.java deleted file mode 100644 index 566e52d..0000000 --- a/modules/api/src/main/java/javax/el/MethodInfo.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * Holds information about a method that a {@link MethodExpression} evaluated to. - */ -public class MethodInfo { - private final String name; - private final Class returnType; - private final Class[] paramTypes; - - /** - * Creates a new instance of MethodInfo with the given information. - * - * @param name - * The name of the method - * @param returnType - * The return type of the method - * @param paramTypes - * The types of each of the method's parameters - */ - public MethodInfo(String name, Class returnType, Class[] paramTypes) { - this.name = name; - this.returnType = returnType; - this.paramTypes = paramTypes; - } - - /** - * Returns the name of the method - * - * @return the name of the method - */ - public String getName() { - return name; - } - - /** - * Returns the parameter types of the method - * - * @return the parameter types of the method - */ - public Class[] getParamTypes() { - return paramTypes; - } - - /** - * Returns the return type of the method - * - * @return the return type of the method - */ - public Class getReturnType() { - return returnType; - } -} diff --git a/modules/api/src/main/java/javax/el/MethodNotFoundException.java b/modules/api/src/main/java/javax/el/MethodNotFoundException.java deleted file mode 100644 index ed8e77f..0000000 --- a/modules/api/src/main/java/javax/el/MethodNotFoundException.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * Thrown when a method could not be found while evaluating a {@link MethodExpression}. - */ -public class MethodNotFoundException extends ELException { - private static final long serialVersionUID = 1L; - - /** - * Creates a MethodNotFoundException with no detail message. - */ - public MethodNotFoundException() { - super(); - } - - /** - * Creates a MethodNotFoundException with the provided detail message. - * - * @param message - * the detail message - */ - public MethodNotFoundException(String message) { - super(message); - } - - /** - * Creates a MethodNotFoundException with the given root cause. - * - * @param cause - * the originating cause of this exception - */ - public MethodNotFoundException(Throwable cause) { - super(cause); - } - - /** - * Creates a MethodNotFoundException with the given detail message and root cause. - * - * @param message - * the detail message - * @param cause - * the originating cause of this exception - */ - public MethodNotFoundException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/modules/api/src/main/java/javax/el/PropertyNotFoundException.java b/modules/api/src/main/java/javax/el/PropertyNotFoundException.java deleted file mode 100644 index ef33076..0000000 --- a/modules/api/src/main/java/javax/el/PropertyNotFoundException.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * Thrown when a property could not be found while evaluating a {@link ValueExpression} or - * {@link MethodExpression}. For example, this could be triggered by an index out of bounds while - * setting an array value, or by an unreadable property while getting the value of a JavaBeans - * property. - */ -public class PropertyNotFoundException extends ELException { - private static final long serialVersionUID = 1L; - - /** - * Creates a PropertyNotFoundException with no detail message. - */ - public PropertyNotFoundException() { - super(); - } - - /** - * Creates a PropertyNotFoundException with the provided detail message. - * - * @param message - * the detail message - */ - public PropertyNotFoundException(String message) { - super(message); - } - - /** - * Creates a PropertyNotFoundException with the given root cause. - * - * @param cause - * the originating cause of this exception - */ - public PropertyNotFoundException(Throwable cause) { - super(cause); - } - - /** - * Creates a PropertyNotFoundException with the given detail message and root cause. - * - * @param message - * the detail message - * @param cause - * the originating cause of this exception - */ - public PropertyNotFoundException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/modules/api/src/main/java/javax/el/PropertyNotWritableException.java b/modules/api/src/main/java/javax/el/PropertyNotWritableException.java deleted file mode 100644 index fd326d8..0000000 --- a/modules/api/src/main/java/javax/el/PropertyNotWritableException.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * Thrown when a property could not be written to while setting the value on a - * {@link ValueExpression}. For example, this could be triggered by trying to set a map value on an - * unmodifiable map. - */ -public class PropertyNotWritableException extends ELException { - private static final long serialVersionUID = 1L; - - /** - * Creates a PropertyNotWritableException with no detail message. - */ - public PropertyNotWritableException() { - super(); - } - - /** - * Creates a PropertyNotWritableException with the provided detail message. - * - * @param message - * the detail message - */ - public PropertyNotWritableException(String message) { - super(message); - } - - /** - * Creates a PropertyNotWritableException with the given root cause. - * - * @param cause - * the originating cause of this exception - */ - public PropertyNotWritableException(Throwable cause) { - super(cause); - } - - /** - * Creates a PropertyNotWritableException with the given detail message and root cause. - * - * @param message - * the detail message - * @param cause - * the originating cause of this exception - */ - public PropertyNotWritableException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/modules/api/src/main/java/javax/el/ResourceBundleELResolver.java b/modules/api/src/main/java/javax/el/ResourceBundleELResolver.java deleted file mode 100644 index f794de8..0000000 --- a/modules/api/src/main/java/javax/el/ResourceBundleELResolver.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Enumeration; -import java.util.Iterator; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * Defines property resolution behavior on instances of java.util.ResourceBundle. This resolver - * handles base objects of type java.util.ResourceBundle. It accepts any object as a property and - * coerces it to a java.lang.String for invoking java.util.ResourceBundle.getObject(String). This - * resolver is read only and will throw a {@link PropertyNotWritableException} if setValue is - * called. ELResolvers are combined together using {@link CompositeELResolver}s, to define rich - * semantics for evaluating an expression. See the javadocs for {@link ELResolver} for details. - */ -public class ResourceBundleELResolver extends ELResolver { - /** - * If the base object is a ResourceBundle, returns the most general type that this resolver - * accepts for the property argument. Otherwise, returns null. Assuming the base is a - * ResourceBundle, this method will always return String.class. - * - * @param context - * The context of this evaluation. - * @param base - * The bundle to analyze. Only bases of type ResourceBundle are handled by this - * resolver. - * @return null if base is not a ResourceBundle; otherwise String.class. - */ - @Override - public Class getCommonPropertyType(ELContext context, Object base) { - return isResolvable(base) ? String.class : null; - } - - /** - * If the base object is a ResourceBundle, returns an Iterator containing the set of keys - * available in the ResourceBundle. Otherwise, returns null. The Iterator returned must contain - * zero or more instances of java.beans.FeatureDescriptor. Each info object contains information - * about a key in the ResourceBundle, and is initialized as follows: - *
    - *
  • displayName - The String key name
  • - *
  • name - Same as displayName property
  • - *
  • shortDescription - Empty string
  • - *
  • expert - false
  • - *
  • hidden - false
  • - *
  • preferred - true
  • - *
- * In addition, the following named attributes must be set in the returned FeatureDescriptors: - *
    - *
  • {@link ELResolver#TYPE} - String.class.
  • - *
  • {@link ELResolver#RESOLVABLE_AT_DESIGN_TIME} - true
  • - *
- * - * @param context - * The context of this evaluation. - * @param base - * The bundle to analyze. Only bases of type ResourceBundle are handled by this - * resolver. - * @return An Iterator containing zero or more (possibly infinitely more) FeatureDescriptor - * objects, each representing a key in this bundle, or null if the base object is not a - * ResourceBundle. - */ - @Override - public Iterator getFeatureDescriptors(ELContext context, Object base) { - if (isResolvable(base)) { - final Enumeration keys = ((ResourceBundle) base).getKeys(); - return new Iterator() { - public boolean hasNext() { - return keys.hasMoreElements(); - } - public FeatureDescriptor next() { - FeatureDescriptor feature = new FeatureDescriptor(); - feature.setDisplayName(keys.nextElement()); - feature.setName(feature.getDisplayName()); - feature.setShortDescription(""); - feature.setExpert(true); - feature.setHidden(false); - feature.setPreferred(true); - feature.setValue(TYPE, String.class); - feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true); - return feature; - } - public void remove() { - throw new UnsupportedOperationException("Cannot remove"); - - } - }; - } - return null; - } - - /** - * If the base object is an instance of ResourceBundle, return null, since the resolver is read - * only. If the base is ResourceBundle, the propertyResolved property of the ELContext object - * must be set to true by this resolver, before returning. If this property is not true after - * this method is called, the caller should ignore the return value. - * - * @param context - * The context of this evaluation. - * @param base - * The bundle to analyze. Only bases of type ResourceBundle are handled by this - * resolver. - * @param property - * The name of the property to analyze. - * @return If the propertyResolved property of ELContext was set to true, then null; otherwise - * undefined. - * @throws NullPointerException - * if context is null - */ - @Override - public Class getType(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - if (isResolvable(base)) { - context.setPropertyResolved(true); - } - return null; - } - - /** - * If the base object is an instance of ResourceBundle, the provided property will first be - * coerced to a String. The Object returned by getObject on the base ResourceBundle will be - * returned. If the base is ResourceBundle, the propertyResolved property of the ELContext - * object must be set to true by this resolver, before returning. If this property is not true - * after this method is called, the caller should ignore the return value. - * - * @param context - * The context of this evaluation. - * @param base - * The bundle to analyze. Only bases of type ResourceBundle are handled by this - * resolver. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return If the propertyResolved property of ELContext was set to true, then null if property - * is null; otherwise the Object for the given key (property coerced to String) from the - * ResourceBundle. If no object for the given key can be found, then the String "???" + - * key + "???". - * @throws NullPointerException - * if context is null. - * @throws ELException - * if an exception was thrown while performing the property or variable resolution. - * The thrown exception must be included as the cause property of this exception, if - * available. - */ - @Override - public Object getValue(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - Object result = null; - if (isResolvable(base)) { - if (property != null) { - try { - result = ((ResourceBundle) base).getObject(property.toString()); - } catch (MissingResourceException e) { - result = "???" + property + "???"; - } - } - context.setPropertyResolved(true); - } - return result; - } - - /** - * If the base object is not null and an instanceof java.util.ResourceBundle, return true. - * - * @return If the propertyResolved property of ELContext was set to true, then true; otherwise - * undefined. - * @throws NullPointerException - * if context is null. - */ - @Override - public boolean isReadOnly(ELContext context, Object base, Object property) { - if (context == null) { - throw new NullPointerException("context is null"); - } - if (isResolvable(base)) { - context.setPropertyResolved(true); - } - return true; - } - - /** - * If the base object is a ResourceBundle, throw a {@link PropertyNotWritableException}. - * - * @param context - * The context of this evaluation. - * @param base - * The bundle to analyze. Only bases of type ResourceBundle are handled by this - * resolver. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @param value - * The value to be set. - * @throws NullPointerException - * if context is null. - * @throws PropertyNotWritableException - * Always thrown if base is an instance of ResourceBundle. - */ - @Override - public void setValue(ELContext context, Object base, Object property, Object value) { - if (context == null) { - throw new NullPointerException("context is null"); - } - if (isResolvable(base)) { - throw new PropertyNotWritableException("resolver is read-only"); - } - } - - /** - * Test whether the given base should be resolved by this ELResolver. - * - * @param base - * The bean to analyze. - * @param property - * The name of the property to analyze. Will be coerced to a String. - * @return base instanceof ResourceBundle - */ - private final boolean isResolvable(Object base) { - return base instanceof ResourceBundle; - } -} diff --git a/modules/api/src/main/java/javax/el/ValueExpression.java b/modules/api/src/main/java/javax/el/ValueExpression.java deleted file mode 100644 index a01ec59..0000000 --- a/modules/api/src/main/java/javax/el/ValueExpression.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * An Expression that can get or set a value. - *

- * In previous incarnations of this API, expressions could only be read. ValueExpression objects can - * now be used both to retrieve a value and to set a value. Expressions that can have a value set on - * them are referred to as l-value expressions. Those that cannot are referred to as r-value - * expressions. Not all r-value expressions can be used as l-value expressions (e.g. "${1+1}" or - * "${firstName} ${lastName}"). See the EL Specification for details. Expressions that cannot be - * used as l-values must always return true from isReadOnly(). - *

- *

- * The {@link ExpressionFactory#createValueExpression(ELContext, String, Class)} method can be used - * to parse an expression string and return a concrete instance of ValueExpression 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. - *

- *

- * The {@link #getValue(ELContext)}, {@link #setValue(ELContext, Object)}, - * {@link #isReadOnly(ELContext)}, {@link #getType(ELContext)} and - * {@link #getValueReference(ELContext)} methods will evaluate the expression each time they are - * called. The {@link ELResolver} in the ELContext is used to resolve the top-level variables and to - * determine the behavior of the . and [] operators. For any of the five methods, the - * {@link ELResolver#getValue(ELContext, Object, Object)} method is used to resolve all properties - * up to but excluding the last one. This provides the base object. For all methods other than the - * {@link #getValueReference(ELContext)} method, at the last resolution, the ValueExpression will - * call the corresponding {@link ELResolver#getValue(ELContext, Object, Object)}, - * {@link ELResolver#setValue(ELContext, Object, Object, Object)}, - * {@link ELResolver#isReadOnly(ELContext, Object, Object)} or - * {@link ELResolver#getType(ELContext, Object, Object)} method, depending on which was called on - * the ValueExpression. For the {@link #getValueReference(ELContext)} method, the (base, property) - * is not resolved by the ELResolver, but an instance of {@link ValueReference} is created to - * encapsulate this (base, property), and returned. - *

- *

- * See the notes about comparison, serialization and immutability in the {@link Expression} - * javadocs. - *

- * - * @see ELResolver - * @see Expression - * @see ExpressionFactory - */ -public abstract class ValueExpression extends Expression { - private static final long serialVersionUID = 1L; - - /** - * Returns the type the result of the expression will be coerced to after evaluation. - * - * @return the expectedType passed to the ExpressionFactory.createValueExpression method that - * created this ValueExpression. - */ - public abstract Class getExpectedType(); - - /** - * Evaluates the expression relative to the provided context, and returns the most general type - * that is acceptable for an object to be passed as the value parameter in a future call to the - * {@link #setValue(ELContext, Object)} method. This is not always the same as - * getValue().getClass(). For example, in the case of an expression that references an array - * element, the getType method will return the element type of the array, which might be a - * superclass of the type of the actual element that is currently in the specified array - * element. - * - * @param context - * The context of this evaluation. - * @return the most general acceptable type; otherwise undefined. - * @throws NullPointerException - * if context is null. - * @throws PropertyNotFoundException - * if one of the property resolutions failed because a specified variable or - * property does not exist or is not readable. - * @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. - */ - public abstract Class getType(ELContext context); - - /** - * Evaluates the expression relative to the provided context, and returns the resulting value. - * The resulting value is automatically coerced to the type returned by getExpectedType(), which - * was provided to the ExpressionFactory when this expression was created. - * - * @param context - * The context of this evaluation. - * @return The result of the expression evaluation. - * @throws NullPointerException - * if context is null. - * @throws PropertyNotFoundException - * if one of the property resolutions failed because a specified variable or - * property does not exist or is not readable. - * @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. - */ - public abstract Object getValue(ELContext context); - - /** - * Evaluates the expression relative to the provided context, and returns true if a call to - * {@link #setValue(ELContext, Object)} will always fail. - * - * @param context - * The context of this evaluation. - * @return true if the expression is read-only or false if not. - * @throws NullPointerException - * if context is null. - * @throws PropertyNotFoundException - * if one of the property resolutions failed because a specified variable or - * property does not exist or is not readable. - * @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. - */ - public abstract boolean isReadOnly(ELContext context); - - /** - * Evaluates the expression relative to the provided context, and sets the result to the - * provided value. - * - * @param context - * The context of this evaluation. - * @param value - * The new value to be set. - * @throws NullPointerException - * if context is null. - * @throws PropertyNotFoundException - * if one of the property resolutions failed because a specified variable or - * property does not exist or is not readable. - * @throws PropertyNotWritableException - * if the final variable or property resolution failed because the specified - * variable or property is not writable. - * @throws ELException - * if an exception was thrown while attempting to set the property or variable. The - * thrown exception must be included as the cause property of this exception, if - * available. - */ - public abstract void setValue(ELContext context, Object value); - - /** - * Returns a {@link ValueReference} for this expression instance. - * - * @param context - * the context of this evaluation - * @return the ValueReference for this ValueExpression, or - * null if this ValueExpression is not a reference to a base - * (null or non-null) and a property. If the base is null, and the property is a EL - * variable, return the ValueReference for the ValueExpression - * associated with this EL variable. - * @throws PropertyNotFoundException - * if one of the property resolutions failed because a specified variable or - * property does not exist or is not readable. - * @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. - * @since 2.2 - */ - public ValueReference getValueReference(ELContext context) { - return null; - } -} diff --git a/modules/api/src/main/java/javax/el/ValueReference.java b/modules/api/src/main/java/javax/el/ValueReference.java deleted file mode 100644 index 53905e7..0000000 --- a/modules/api/src/main/java/javax/el/ValueReference.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * This class encapsulates a base model object and one of its properties. - * - * @since 2.2 - */ -public class ValueReference implements Serializable { - private static final long serialVersionUID = 1L; - - private Object base; - private Object property; - - public ValueReference(Object base, Object property) { - this.base = base; - this.property = property; - } - - public Object getBase() { - return base; - } - - public Object getProperty() { - return property; - } -} \ No newline at end of file diff --git a/modules/api/src/main/java/javax/el/VariableMapper.java b/modules/api/src/main/java/javax/el/VariableMapper.java deleted file mode 100644 index db2a07c..0000000 --- a/modules/api/src/main/java/javax/el/VariableMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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; - -/** - * The interface to a map between EL variables and the EL expressions they are associated with. - */ -public abstract class VariableMapper { - /** - * Resolves the specified variable name to a ValueExpression. - * - * @param variable - * The variable name - * @return the ValueExpression assigned to the variable, null if there is no previous assignment - * to this variable. - */ - public abstract ValueExpression resolveVariable(String variable); - - /** - * Assign a ValueExpression to an EL variable, replacing any previously assignment to the same - * variable. The assignment for the variable is removed if the expression is null. - * - * @param variable - * The variable name - * @param expression - * The ValueExpression to be assigned to the variable. - * @return The previous ValueExpression assigned to this variable, null if there is no previous - * assignment to this variable. - */ - public abstract ValueExpression setVariable(String variable, ValueExpression expression); -} diff --git a/modules/api/src/test/java/javax/el/AllTests.java b/modules/api/src/test/java/javax/el/AllTests.java deleted file mode 100644 index 3fec357..0000000 --- a/modules/api/src/test/java/javax/el/AllTests.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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 junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for javax.el"); - //$JUnit-BEGIN$ - suite.addTestSuite(ArrayELResolverTest.class); - suite.addTestSuite(BeanELResolverTest.class); - suite.addTestSuite(CompositeELResolverTest.class); - suite.addTestSuite(ListELResolverTest.class); - suite.addTestSuite(MapELResolverTest.class); - suite.addTestSuite(ResourceBundleELResolverTest.class); - suite.addTestSuite(ELContextTest.class); - suite.addTestSuite(MethodInfoTest.class); - suite.addTestSuite(ExpressionFactoryTest.class); - suite.addTestSuite(ValueReferenceTest.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/modules/api/src/test/java/javax/el/ArrayELResolverTest.java b/modules/api/src/test/java/javax/el/ArrayELResolverTest.java deleted file mode 100644 index bbf492a..0000000 --- a/modules/api/src/test/java/javax/el/ArrayELResolverTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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 junit.framework.TestCase; -import javax.el.TestContext; - -public class ArrayELResolverTest extends TestCase { - ELContext context = new TestContext(); - - public void testGetCommonPropertyType() { - int scalar = 0; - int[] array = { 1, 2, 3 }; - ArrayELResolver resolver = new ArrayELResolver(); - - // base is array --> int.class - assertSame(Integer.class, resolver.getCommonPropertyType(context, array)); - - // base is scalar --> null - assertNull(resolver.getCommonPropertyType(context, scalar)); - - // base == null --> null - assertNull(resolver.getCommonPropertyType(context, null)); - } - - public void testGetFeatureDescriptors() { - int scalar = 0; - int[] array = { 1, 2, 3 }; - ArrayELResolver resolver = new ArrayELResolver(); - - // any --> null - assertNull(resolver.getFeatureDescriptors(context, scalar)); - assertNull(resolver.getFeatureDescriptors(context, array)); - assertNull(resolver.getFeatureDescriptors(context, null)); - } - - public void testGetType() { - int scalar = 0; - int[] array = { 1, 2, 3 }; - ArrayELResolver resolver = new ArrayELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is array, property == 1 --> int.class - context.setPropertyResolved(false); - assertSame(int.class, resolver.getType(context, array, 1)); - assertTrue(context.isPropertyResolved()); - - // base is array, bad property --> exception - try { - resolver.getType(context, array, null); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.getType(context, array, "foo"); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.getType(context, array, -1); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - try { - resolver.getType(context, array, array.length); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - } - - public void testGetValue() { - int scalar = 0; - int[] array = { 1, 2, 3 }; - ArrayELResolver resolver = new ArrayELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is array, property == 1 --> 2 - context.setPropertyResolved(false); - assertEquals(2, resolver.getValue(context, array, 1)); - assertTrue(context.isPropertyResolved()); - - // base is array, bad property --> exception - try { - resolver.getValue(context, array, null); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.getValue(context, array, "foo"); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - assertNull(resolver.getValue(context, array, -1)); - assertNull(resolver.getValue(context, array, array.length)); - } - - public void testIsReadOnly() { - int scalar = 0; - int[] array = { 1, 2, 3 }; - ArrayELResolver resolver = new ArrayELResolver(); - ArrayELResolver resolverReadOnly = new ArrayELResolver(true); - - // base is null --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is array, property == 1 --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, array, 1)); - assertTrue(context.isPropertyResolved()); - - // base is array, property == 1 --> true (use read-only resolver) - context.setPropertyResolved(false); - assertTrue(resolverReadOnly.isReadOnly(context, array, 1)); - assertTrue(context.isPropertyResolved()); - - // base is array, bad property --> exception - try { - resolver.isReadOnly(context, array, null); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.isReadOnly(context, array, "foo"); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.isReadOnly(context, array, -1); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - try { - resolver.isReadOnly(context, array, array.length); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - } - - public void testSetValue() { - int scalar = 0; - int[] array = { 1, 2, 3 }; - ArrayELResolver resolver = new ArrayELResolver(); - ArrayELResolver resolverReadOnly = new ArrayELResolver(true); - - // base == null --> unresolved - context.setPropertyResolved(false); - resolver.setValue(context, null, "foo", -1); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> unresolved - context.setPropertyResolved(false); - resolver.setValue(context, scalar, "foo", -1); - assertFalse(context.isPropertyResolved()); - - // base is array, property == 1 --> ok - context.setPropertyResolved(false); - resolver.setValue(context, array, 1, 999); - assertEquals(999, array[1]); - assertTrue(context.isPropertyResolved()); - - // base is array, bad property --> exception - try { - resolver.setValue(context, array, null, 999); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.setValue(context, array, "foo", 999); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.setValue(context, array, -1, 999); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - try { - resolver.setValue(context, array, array.length, 999); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - - // base is array, property == 1, bad value --> exception - try { - resolver.setValue(context, array, 1, null); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.setValue(context, array, 1, "foo"); - fail(); - } catch (ClassCastException e) { - // fine, according to the spec... - } catch (IllegalArgumentException e) { - // violates the spec, but we'll accept this... - } - - // read-only resolver - try { - resolverReadOnly.setValue(context, array, 1, 999); - fail(); - } catch (PropertyNotWritableException e) { - // fine - } - } -} diff --git a/modules/api/src/test/java/javax/el/BeanELResolverTest.java b/modules/api/src/test/java/javax/el/BeanELResolverTest.java deleted file mode 100644 index 16bbbbc..0000000 --- a/modules/api/src/test/java/javax/el/BeanELResolverTest.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Iterator; -import java.util.List; -import java.util.Properties; - -import javax.el.test.TestClass; - -import junit.framework.TestCase; - -public class BeanELResolverTest extends TestCase { - public static class TestBean { - int readOnly = 123; - int readWrite = 456; - int writeOnly = 789; - public int getReadOnly() { - return readOnly; - } - protected void setReadOnly(int readOnly) { - this.readOnly = readOnly; - } - public int getReadWrite() { - return readWrite; - } - public void setReadWrite(int readWrite) { - this.readWrite = readWrite; - } - int getWriteOnly() { - return writeOnly; - } - public void setWriteOnly(int writeOnly) { - this.writeOnly = writeOnly; - } - public int add(int n, int... rest) { - for (int x : rest) { - n += x; - } - return n; - } - public String cat(String... strings) { - StringBuilder b = new StringBuilder(); - for (String s : strings) { - b.append(s); - } - return b.toString(); - } - int secret() { - return 42; - } - } - - ELContext context = new TestContext(); - - public void testGetCommonPropertyType() { - BeanELResolver resolver = new BeanELResolver(); - - // base is bean --> Object.class - assertSame(Object.class, resolver.getCommonPropertyType(context, new TestBean())); - - // base == null --> null - assertNull(resolver.getCommonPropertyType(context, null)); - } - - public void testGetFeatureDescriptors() { - BeanELResolver resolver = new BeanELResolver(); - - // base == null --> null - assertNull(resolver.getCommonPropertyType(context, null)); - - // base is bean --> features... - Iterator iterator = resolver.getFeatureDescriptors(context, new TestBean()); - List names = new ArrayList(); - while (iterator.hasNext()) { - FeatureDescriptor feature = iterator.next(); - names.add(feature.getName()); - Class type = "class".equals(feature.getName()) ? Class.class : int.class; - assertSame(type, feature.getValue(ELResolver.TYPE)); - assertSame(Boolean.TRUE, feature.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); - } - assertTrue(names.contains("class")); - assertTrue(names.contains("readOnly")); - assertTrue(names.contains("readWrite")); - assertTrue(names.contains("writeOnly")); - assertEquals(4, names.size()); - } - - public void testGetType() { - BeanELResolver resolver = new BeanELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is bean, property == "readWrite" --> int.class - context.setPropertyResolved(false); - assertSame(int.class, resolver.getType(context, new TestBean(), "readWrite")); - assertTrue(context.isPropertyResolved()); - - // base is bean, property == null --> exception - try { - resolver.getType(context, new TestBean(), null); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - - // base is bean, property != null, but doesn't exist --> exception - try { - resolver.getType(context, new TestBean(), "doesntExist"); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - } - - public void testGetValue() { - Properties properties = new Properties(); - properties.setProperty(ExpressionFactory.class.getName(), TestFactory.class.getName()); - BeanELResolver resolver = new BeanELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is bean, property == "readWrite" --> 123 - context.setPropertyResolved(false); - assertEquals(456, resolver.getValue(context, new TestBean(), "readWrite")); - assertTrue(context.isPropertyResolved()); - - // base is bean, property == "writeOnly" --> exception - try { - resolver.getValue(context, new TestBean(), "writeOnly"); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - - // base is bean, property != null, but doesn't exist --> exception - try { - resolver.getValue(context, new TestBean(), "doesntExist"); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - } - - public void testGetValue2() { - Properties properties = new Properties(); - properties.setProperty(ExpressionFactory.class.getName(), TestFactory.class.getName()); - BeanELResolver resolver = new BeanELResolver(); - - context.setPropertyResolved(false); - assertEquals(42, resolver.getValue(context, new TestClass().getAnonymousTestInterface(), "fourtyTwo")); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertEquals(42, resolver.getValue(context, new TestClass().getNestedTestInterface(), "fourtyTwo")); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertEquals(42, resolver.getValue(context, new TestClass().getNestedTestInterface2(), "fourtyTwo")); - assertTrue(context.isPropertyResolved()); - } - - public void testIsReadOnly() { - BeanELResolver resolver = new BeanELResolver(); - BeanELResolver resolverReadOnly = new BeanELResolver(true); - - // base == null --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is bean, property == "readOnly" --> true - context.setPropertyResolved(false); - assertTrue(resolver.isReadOnly(context, new TestBean(), "readOnly")); - assertTrue(context.isPropertyResolved()); - - // base is bean, property == "readWrite" --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, new TestBean(), "readWrite")); - assertTrue(context.isPropertyResolved()); - - // base is bean, property == "writeOnly" --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, new TestBean(), "writeOnly")); - assertTrue(context.isPropertyResolved()); - - // base is bean, property == 1 --> true (use read-only resolver) - context.setPropertyResolved(false); - assertTrue(resolverReadOnly.isReadOnly(context, new TestBean(), "readWrite")); - assertTrue(context.isPropertyResolved()); - - // is bean, property != null, but doesn't exist --> exception - try { - resolver.isReadOnly(context, new TestBean(), "doesntExist"); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - } - - public void testSetValue() { - BeanELResolver resolver = new BeanELResolver(); - BeanELResolver resolverReadOnly = new BeanELResolver(true); - - // base == null --> unresolved - context.setPropertyResolved(false); - resolver.setValue(context, null, "foo", -1); - assertFalse(context.isPropertyResolved()); - - // base is bean, property == "readWrite" --> ok - context.setPropertyResolved(false); - TestBean bean = new TestBean(); - resolver.setValue(context, bean, "readWrite", 999); - assertEquals(999, bean.getReadWrite()); - assertTrue(context.isPropertyResolved()); - - // base is bean, property == "readOnly" --> exception - try { - resolver.setValue(context, new TestBean(), "readOnly", 1); - fail(); - } catch (PropertyNotWritableException e) { - // fine - } - - // base is bean, property != null, but doesn't exist --> exception - try { - resolver.setValue(context, new TestBean(), "doesntExist", 1); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - - // base is bean, property == "readWrite", invalid value --> exception - try { - resolver.setValue(context, new TestBean(), "readWrite", "invalid"); - fail(); - } catch (ELException e) { - // fine, according to the spec... - } catch (IllegalArgumentException e) { - // violates the spec, but we'll accept this... - } - - // read-only resolver - try { - resolverReadOnly.setValue(context, bean, "readWrite", 999); - fail(); - } catch (PropertyNotWritableException e) { - // fine - } - } - - public void testInvoke() { - BeanELResolver resolver = new BeanELResolver(); - - assertEquals(1, resolver.invoke(context, new TestBean(), "add", null, new Integer[]{1})); - assertEquals(6, resolver.invoke(context, new TestBean(), "add", null, new Integer[]{1, 2, 3})); - assertEquals(6, resolver.invoke(context, new TestBean(), "add", null, new String[]{"1", "2", "3"})); - assertEquals(6, resolver.invoke(context, new TestBean(), "add", null, new Object[]{1, new int[]{2, 3}})); - assertEquals(6, resolver.invoke(context, new TestBean(), "add", null, new Object[]{1, new Double[]{2.0, 3.0}})); - - assertEquals("", resolver.invoke(context, new TestBean(), "cat", null, new Object[0])); - assertEquals("", resolver.invoke(context, new TestBean(), "cat", null, null)); - assertEquals("123", resolver.invoke(context, new TestBean(), "cat", null, new Object[]{123})); - assertEquals("123", resolver.invoke(context, new TestBean(), "cat", null, new Integer[]{1, 2, 3})); - assertEquals("123", resolver.invoke(context, new TestBean(), "cat", null, new Object[]{new String[]{"1", "2", "3"}})); - - TestBean bean = new TestBean(); - bean.setReadWrite(1); - assertNull(resolver.invoke(context, bean, "setReadWrite", null, new Object[]{null})); - assertEquals(0, bean.getReadWrite()); - assertNull(resolver.invoke(context, bean, "setReadWrite", null, new Object[]{5})); - assertEquals(5, bean.getReadWrite()); - try { - resolver.invoke(context, new TestBean(), "secret", null, null); - fail(); - } catch (MethodNotFoundException e) { - // fine - } - } - - public void testInvoke2() { - BeanELResolver resolver = new BeanELResolver(); - assertEquals(42, resolver.invoke(context, new TestClass().getAnonymousTestInterface(), "getFourtyTwo", null, new Class[]{})); - assertEquals(42, resolver.invoke(context, new TestClass().getNestedTestInterface(), "getFourtyTwo", null, new Class[]{})); - assertEquals(42, resolver.invoke(context, new TestClass().getNestedTestInterface2(), "getFourtyTwo", null, new Class[]{})); - } -} diff --git a/modules/api/src/test/java/javax/el/CompositeELResolverTest.java b/modules/api/src/test/java/javax/el/CompositeELResolverTest.java deleted file mode 100644 index ac9db94..0000000 --- a/modules/api/src/test/java/javax/el/CompositeELResolverTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.HashMap; -import java.util.Iterator; -import java.util.Map; - -import junit.framework.TestCase; -import javax.el.TestContext; - -public class CompositeELResolverTest extends TestCase { - ELContext context = new TestContext(); - - Map sampleMap() { - Map map = new HashMap(); - for (int i = 0; i < 3; i++) { - map.put(i, i+1); - } - return map; - } - - public void testGetCommonPropertyType() { - CompositeELResolver resolver = new CompositeELResolver(); - assertNull(resolver.getCommonPropertyType(context, null)); - assertNull(resolver.getCommonPropertyType(context, "foo")); - - resolver.add(new ArrayELResolver()); - assertNull(resolver.getCommonPropertyType(context, null)); - assertNull(resolver.getCommonPropertyType(context, "foo")); - assertSame(Integer.class, resolver.getCommonPropertyType(context, new int[0])); - - resolver.add(new ListELResolver()); - assertNull(resolver.getCommonPropertyType(context, null)); - assertNull(resolver.getCommonPropertyType(context, "foo")); - assertSame(Integer.class, resolver.getCommonPropertyType(context, new ArrayList())); - - resolver.add(new MapELResolver()); - assertNull(resolver.getCommonPropertyType(context, null)); - assertNull(resolver.getCommonPropertyType(context, "foo")); - assertSame(Object.class, resolver.getCommonPropertyType(context, new HashMap())); - } - - private int count(Iterator iterator) { - int count = 0; - while (iterator.hasNext()) { - iterator.next(); - count++; - } - return count; - } - - public void testGetFeatureDescriptors() { - CompositeELResolver resolver = new CompositeELResolver(); - assertFalse(resolver.getFeatureDescriptors(context, null).hasNext()); - assertFalse(resolver.getFeatureDescriptors(context, "foo").hasNext()); - assertFalse(resolver.getFeatureDescriptors(context, sampleMap()).hasNext()); - - resolver.add(new MapELResolver()); - assertEquals(3, count(resolver.getFeatureDescriptors(context, sampleMap()))); // 0, 1, 2 - - resolver.add(new ArrayELResolver()); - resolver.add(new BeanELResolver()); - resolver.add(new ListELResolver()); - assertEquals(5, count(resolver.getFeatureDescriptors(context, sampleMap()))); // 0, 1, 2, class, empty - } - - public void testGetType() { - CompositeELResolver resolver = new CompositeELResolver(); - assertNull(resolver.getType(context, null, "foo")); - assertNull(resolver.getType(context, "foo", "class")); - - resolver.add(new MapELResolver()); - assertNull(resolver.getType(context, null, "foo")); - assertNull(resolver.getType(context, "foo", "class")); - assertEquals(Object.class, resolver.getType(context, sampleMap(), "foo")); - assertEquals(Object.class, resolver.getType(context, sampleMap(), 0)); - - resolver.add(new BeanELResolver()); - assertNull(resolver.getType(context, null, "foo")); - assertEquals(Class.class, resolver.getType(context, "foo", "class")); - assertEquals(Object.class, resolver.getType(context, sampleMap(), "foo")); - assertEquals(Object.class, resolver.getType(context, sampleMap(), 0)); - } - - public void testGetValue() { - CompositeELResolver resolver = new CompositeELResolver(); - assertNull(resolver.getValue(context, null, "foo")); - assertNull(resolver.getValue(context, "foo", "class")); - - resolver.add(new MapELResolver()); - assertNull(resolver.getValue(context, null, "foo")); - assertNull(resolver.getValue(context, "foo", "class")); - assertNull(resolver.getValue(context, sampleMap(), "foo")); - assertEquals(1, resolver.getValue(context, sampleMap(), 0)); - - resolver.add(new BeanELResolver()); - assertNull(resolver.getValue(context, null, "foo")); - assertEquals(String.class, resolver.getValue(context, "foo", "class")); - assertNull(resolver.getValue(context, sampleMap(), "foo")); - assertEquals(1, resolver.getValue(context, sampleMap(), 0)); - } - - public void testIsReadOnly() { - CompositeELResolver resolver = new CompositeELResolver(); - assertFalse(resolver.isReadOnly(context, null, "foo")); - assertFalse(resolver.isReadOnly(context, "foo", "class")); - - resolver.add(new MapELResolver()); - assertFalse(resolver.isReadOnly(context, null, "foo")); - assertFalse(resolver.isReadOnly(context, "foo", "class")); - assertFalse(resolver.isReadOnly(context, sampleMap(), "foo")); - assertFalse(resolver.isReadOnly(context, sampleMap(), 0)); - - resolver.add(new BeanELResolver()); - assertFalse(resolver.isReadOnly(context, null, "foo")); - assertTrue(resolver.isReadOnly(context, "foo", "class")); - assertFalse(resolver.isReadOnly(context, sampleMap(), "foo")); - assertFalse(resolver.isReadOnly(context, sampleMap(), 0)); - } - - public void testSetValue() { - CompositeELResolver resolver = new CompositeELResolver(); - resolver.setValue(context, null, "foo", "bar"); - resolver.setValue(context, "foo", "class", Integer.class); - - resolver.add(new MapELResolver()); - resolver.setValue(context, null, "foo", "bar"); - resolver.setValue(context, "foo", "class", Integer.class); - Map map = sampleMap(); - resolver.setValue(context, map, "foo", "bar"); - assertEquals("bar", map.get("foo")); - resolver.setValue(context, map, 0, 999); - assertEquals(999, map.get(0)); - - resolver.add(new BeanELResolver()); - resolver.setValue(context, null, "foo", "bar"); - try { - resolver.setValue(context, "foo", "class", Integer.class); - fail(); - } catch (PropertyNotWritableException e) { - // fine - } - map = sampleMap(); - resolver.setValue(context, map, "foo", "bar"); - assertEquals("bar", map.get("foo")); - resolver.setValue(context, map, 0, 999); - assertEquals(999, map.get(0)); - } - -} diff --git a/modules/api/src/test/java/javax/el/ELContextTest.java b/modules/api/src/test/java/javax/el/ELContextTest.java deleted file mode 100644 index c207d31..0000000 --- a/modules/api/src/test/java/javax/el/ELContextTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Locale; - -import junit.framework.TestCase; - -import javax.el.TestContext; - -public class ELContextTest extends TestCase { - - public void testContext() { - ELContext context = new TestContext(); - assertNull(context.getContext(Integer.class)); - context.putContext(Integer.class, "foo"); - assertEquals("foo", context.getContext(Integer.class)); - } - - public void testLocale() { - ELContext context = new TestContext(); - assertNull(context.getLocale()); - context.setLocale(Locale.ENGLISH); - assertEquals(Locale.ENGLISH, context.getLocale()); - } - - public void testPropertyResolved() { - ELContext context = new TestContext(); - assertFalse(context.isPropertyResolved()); - context.setPropertyResolved(true); - assertTrue(context.isPropertyResolved()); - } -} diff --git a/modules/api/src/test/java/javax/el/ExpressionFactoryTest.java b/modules/api/src/test/java/javax/el/ExpressionFactoryTest.java deleted file mode 100644 index a6fd114..0000000 --- a/modules/api/src/test/java/javax/el/ExpressionFactoryTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Properties; - -import junit.framework.TestCase; - -public class ExpressionFactoryTest extends TestCase { - private String getFactoryClassName() throws IOException { - String className = null; - String serviceId = "META-INF/services/" + ExpressionFactory.class.getName(); - InputStream input = getClass().getClassLoader().getResourceAsStream(serviceId); - if (input != null) { - BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8")); - className = reader.readLine(); - reader.close(); - } - return className; - } - - public void testNewInstance() throws IOException { - ExpressionFactory factory = ExpressionFactory.newInstance(); - assertNotNull(factory); - assertEquals(factory.getClass().getName(), getFactoryClassName()); - } - - public void testNewInstanceProperties() throws IOException { - Properties properties = new Properties(); - - ExpressionFactory factory = ExpressionFactory.newInstance(properties); - assertNotNull(factory); - assertEquals(factory.getClass().getName(), getFactoryClassName()); - if (TestFactory.class.getName().equals(getFactoryClassName())) { - assertSame(properties, ((TestFactory)factory).properties); - } - } -} diff --git a/modules/api/src/test/java/javax/el/ListELResolverTest.java b/modules/api/src/test/java/javax/el/ListELResolverTest.java deleted file mode 100644 index 1742a82..0000000 --- a/modules/api/src/test/java/javax/el/ListELResolverTest.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Arrays; -import java.util.List; - -import junit.framework.TestCase; -import javax.el.TestContext; - -public class ListELResolverTest extends TestCase { - ELContext context = new TestContext(); - - public void testGetCommonPropertyType() { - Integer scalar = 0; - List list = Arrays.asList(1, 2, 3); - ListELResolver resolver = new ListELResolver(); - - // base is array --> int.class - assertSame(Integer.class, resolver.getCommonPropertyType(context, list)); - - // base is scalar --> null - assertNull(resolver.getCommonPropertyType(context, scalar)); - - // base == null --> null - assertNull(resolver.getCommonPropertyType(context, null)); - } - - public void testGetFeatureDescriptors() { - Integer scalar = 0; - List list = Arrays.asList(1, 2, 3); - ListELResolver resolver = new ListELResolver(); - - // any --> null - assertNull(resolver.getFeatureDescriptors(context, scalar)); - assertNull(resolver.getFeatureDescriptors(context, list)); - assertNull(resolver.getFeatureDescriptors(context, null)); - } - - public void testGetType() { - Integer scalar = 0; - List list = Arrays.asList(1, 2, 3); - ListELResolver resolver = new ListELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is array, property == 1 --> Object.class - context.setPropertyResolved(false); - assertSame(Object.class, resolver.getType(context, list, 1)); - assertTrue(context.isPropertyResolved()); - - // base is array, bad property --> exception - try { - resolver.getType(context, list, null); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.getType(context, list, "foo"); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.getType(context, list, -1); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - try { - resolver.getType(context, list, list.size()); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - } - - public void testGetValue() { - Integer scalar = 0; - List list = Arrays.asList(1, 2, 3); - ListELResolver resolver = new ListELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is array, property == 1 --> 2 - context.setPropertyResolved(false); - assertEquals(2, resolver.getValue(context, list, 1)); - assertTrue(context.isPropertyResolved()); - - // base is array, bad property --> exception - try { - resolver.getValue(context, list, null); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.getValue(context, list, "foo"); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - assertNull(resolver.getValue(context, list, -1)); - assertNull(resolver.getValue(context, list, list.size())); - } - - public void testIsReadOnly() { - Integer scalar = 0; - List list = Arrays.asList(1, 2, 3); - ListELResolver resolver = new ListELResolver(); - ListELResolver resolverReadOnly = new ListELResolver(true); - - // base is null --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is array, property == 1 --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, list, 1)); - assertTrue(context.isPropertyResolved()); - - // base is array, property == 1 --> true (use read-only resolver) - context.setPropertyResolved(false); - assertTrue(resolverReadOnly.isReadOnly(context, list, 1)); - assertTrue(context.isPropertyResolved()); - - // base is array, bad property --> exception - try { - resolver.isReadOnly(context, list, null); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.isReadOnly(context, list, "foo"); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.isReadOnly(context, list, -1); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - try { - resolver.isReadOnly(context, list, list.size()); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - } - - public void testSetValue() { - Integer scalar = 0; - List list = Arrays.asList(1, 2, 3); - ListELResolver resolver = new ListELResolver(); - ListELResolver resolverReadOnly = new ListELResolver(true); - - // base == null --> unresolved - context.setPropertyResolved(false); - resolver.setValue(context, null, "foo", -1); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> unresolved - context.setPropertyResolved(false); - resolver.setValue(context, scalar, "foo", -1); - assertFalse(context.isPropertyResolved()); - - // base is array, property == 1 --> ok - context.setPropertyResolved(false); - resolver.setValue(context, list, 1, 999); - assertEquals(999, list.get(1).intValue()); - assertTrue(context.isPropertyResolved()); - - // base is array, bad property --> exception - try { - resolver.setValue(context, list, null, 999); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.setValue(context, list, "foo", 999); - fail(); - } catch (IllegalArgumentException e) { - // fine - } - try { - resolver.setValue(context, list, -1, 999); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - try { - resolver.setValue(context, list, list.size(), 999); - fail(); - } catch (PropertyNotFoundException e) { - // fine - } - - // base is array, property == 1, value == null --> ok - context.setPropertyResolved(false); - resolver.setValue(context, list, 1, null); - assertNull(list.get(1)); - assertTrue(context.isPropertyResolved()); - - // base is array, property == 1, bad value --> exception - try { - resolver.setValue(context, list, 1, "foo"); - fail(); - } catch (ClassCastException e) { - // fine, according to the spec... - } catch (IllegalArgumentException e) { - // violates the spec, but we'll accept this... - } - - // read-only resolver - try { - resolverReadOnly.setValue(context, list, 1, 999); - fail(); - } catch (PropertyNotWritableException e) { - // fine - } - } -} diff --git a/modules/api/src/test/java/javax/el/MapELResolverTest.java b/modules/api/src/test/java/javax/el/MapELResolverTest.java deleted file mode 100644 index 8857275..0000000 --- a/modules/api/src/test/java/javax/el/MapELResolverTest.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import junit.framework.TestCase; -import javax.el.TestContext; - -public class MapELResolverTest extends TestCase { - ELContext context = new TestContext(); - - Map sampleMap() { - Map map = new HashMap(); - for (int i = 0; i < 3; i++) { - map.put(i, i+1); - } - return map; - } - - public void testGetCommonPropertyType() { - Integer scalar = 0; - Map map = sampleMap(); - MapELResolver resolver = new MapELResolver(); - - // base is map --> Object.class - assertSame(Object.class, resolver.getCommonPropertyType(context, map)); - - // base is scalar --> null - assertNull(resolver.getCommonPropertyType(context, scalar)); - - // base == null --> null - assertNull(resolver.getCommonPropertyType(context, null)); - } - - public void testGetFeatureDescriptors() { - Integer scalar = 0; - Map map = sampleMap(); - MapELResolver resolver = new MapELResolver(); - - // base is scalar or null --> null - assertNull(resolver.getFeatureDescriptors(context, scalar)); - assertNull(resolver.getFeatureDescriptors(context, null)); - - // base == null --> null - assertNull(resolver.getCommonPropertyType(context, null)); - - // base is map --> features... - Iterator iterator = resolver.getFeatureDescriptors(context, map); - List names = new ArrayList(); - while (iterator.hasNext()) { - FeatureDescriptor feature = iterator.next(); - names.add(feature.getName()); - assertSame(Integer.class, feature.getValue(ELResolver.TYPE)); - assertSame(Boolean.TRUE, feature.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); - } - assertTrue(names.contains("0")); - assertTrue(names.contains("1")); - assertTrue(names.contains("2")); - assertEquals(3, names.size()); - } - - public void testGetType() { - Integer scalar = 0; - Map map = sampleMap(); - MapELResolver resolver = new MapELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is map, any property --> Object.class - context.setPropertyResolved(false); - assertSame(Object.class, resolver.getType(context, map, 1)); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertSame(Object.class, resolver.getType(context, map, null)); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertSame(Object.class, resolver.getType(context, map, "foo")); - assertTrue(context.isPropertyResolved()); - } - - public void testGetValue() { - Integer scalar = 0; - Map map = sampleMap(); - MapELResolver resolver = new MapELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is map, property == 1 --> 2 - context.setPropertyResolved(false); - assertEquals(2, resolver.getValue(context, map, 1)); - assertTrue(context.isPropertyResolved()); - - // base is map, any property which is not a key in the map --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, map, "foo")); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, map, null)); - assertTrue(context.isPropertyResolved()); - } - - public void testIsReadOnly() { - Integer scalar = 0; - Map map = sampleMap(); - MapELResolver resolver = new MapELResolver(); - MapELResolver resolverReadOnly = new MapELResolver(true); - - // base is null --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is map, property == 1 --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, map, 1)); - assertTrue(context.isPropertyResolved()); - - // base is map, property == 1 --> true (use read-only resolver) - context.setPropertyResolved(false); - assertTrue(resolverReadOnly.isReadOnly(context, map, 1)); - assertTrue(context.isPropertyResolved()); - - // base is map, any property which is not a key in the map --> false - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, map, "foo")); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertFalse(resolver.isReadOnly(context, map, null)); - assertTrue(context.isPropertyResolved()); - } - - public void testSetValue() { - Integer scalar = 0; - Map map = sampleMap(); - MapELResolver resolver = new MapELResolver(); - MapELResolver resolverReadOnly = new MapELResolver(true); - - // base == null --> unresolved - context.setPropertyResolved(false); - resolver.setValue(context, null, "foo", -1); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> unresolved - context.setPropertyResolved(false); - resolver.setValue(context, scalar, "foo", -1); - assertFalse(context.isPropertyResolved()); - - // base is map, property == 1 --> ok - context.setPropertyResolved(false); - resolver.setValue(context, map, 1, 999); - assertEquals(999, map.get(1).intValue()); - assertTrue(context.isPropertyResolved()); - - // base is map, any property which is not a key in the map --> false - context.setPropertyResolved(false); - resolver.setValue(context, map, 999, "foo"); - assertEquals(map.get(999), "foo"); - assertTrue(context.isPropertyResolved()); - - // base is map, property == 1, value == null --> ok - context.setPropertyResolved(false); - resolver.setValue(context, map, 1, null); - assertNull(map.get(1)); - assertTrue(context.isPropertyResolved()); - - // read-only resolver - try { - resolverReadOnly.setValue(context, map, 1, 999); - fail(); - } catch (PropertyNotWritableException e) { - // fine - } - } -} diff --git a/modules/api/src/test/java/javax/el/MethodInfoTest.java b/modules/api/src/test/java/javax/el/MethodInfoTest.java deleted file mode 100644 index b7b66ae..0000000 --- a/modules/api/src/test/java/javax/el/MethodInfoTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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 junit.framework.TestCase; - -public class MethodInfoTest extends TestCase { - - public void testGetName() { - assertEquals("foo", new MethodInfo("foo", Integer.class, new Class[]{String.class}).getName()); - } - - public void testGetParamTypes() { - assertEquals(String.class, new MethodInfo("foo", Integer.class, new Class[]{String.class}).getParamTypes()[0]); - } - - public void testGetReturnType() { - assertEquals(Integer.class, new MethodInfo("foo", Integer.class, new Class[]{String.class}).getReturnType()); - } -} diff --git a/modules/api/src/test/java/javax/el/ResourceBundleELResolverTest.java b/modules/api/src/test/java/javax/el/ResourceBundleELResolverTest.java deleted file mode 100644 index f94a412..0000000 --- a/modules/api/src/test/java/javax/el/ResourceBundleELResolverTest.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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.Iterator; -import java.util.List; -import java.util.ListResourceBundle; -import java.util.ResourceBundle; - -import junit.framework.TestCase; -import javax.el.TestContext; - -public class ResourceBundleELResolverTest extends TestCase { - ELContext context = new TestContext(); - - ResourceBundle sampleBundle() { - return new ListResourceBundle() { - @Override - protected Object[][] getContents() { - return new Object[][]{ - {"0", 1}, - {"1", 2}, - {"2", 3}, - }; - } - }; - } - - public void testGetCommonPropertyType() { - Integer scalar = 0; - ResourceBundle bundle = sampleBundle(); - ResourceBundleELResolver resolver = new ResourceBundleELResolver(); - - // base is bundle --> String.class - assertSame(String.class, resolver.getCommonPropertyType(context, bundle)); - - // base is scalar --> null - assertNull(resolver.getCommonPropertyType(context, scalar)); - - // base == null --> null - assertNull(resolver.getCommonPropertyType(context, null)); - } - - public void testGetFeatureDescriptors() { - Integer scalar = 0; - ResourceBundle bundle = sampleBundle(); - ResourceBundleELResolver resolver = new ResourceBundleELResolver(); - - // base is scalar or null --> null - assertNull(resolver.getFeatureDescriptors(context, scalar)); - assertNull(resolver.getFeatureDescriptors(context, null)); - - // base == null --> null - assertNull(resolver.getCommonPropertyType(context, null)); - - // base is bean --> features... - Iterator iterator = resolver.getFeatureDescriptors(context, bundle); - List names = new ArrayList(); - while (iterator.hasNext()) { - FeatureDescriptor feature = iterator.next(); - names.add(feature.getName()); - assertSame(String.class, feature.getValue(ELResolver.TYPE)); - assertSame(Boolean.TRUE, feature.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); - } - assertTrue(names.contains("0")); - assertTrue(names.contains("1")); - assertTrue(names.contains("2")); - assertEquals(3, names.size()); - } - - public void testGetType() { - Integer scalar = 0; - ResourceBundle bundle = sampleBundle(); - ResourceBundleELResolver resolver = new ResourceBundleELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is bundle, any property --> null - context.setPropertyResolved(false); - assertNull(resolver.getType(context, bundle, 1)); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertNull(resolver.getType(context, bundle, null)); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertNull(resolver.getType(context, bundle, "foo")); - assertTrue(context.isPropertyResolved()); - } - - public void testGetValue() { - Integer scalar = 0; - ResourceBundle bundle = sampleBundle(); - ResourceBundleELResolver resolver = new ResourceBundleELResolver(); - - // base == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is bundle, property == 1 --> 2 - context.setPropertyResolved(false); - assertEquals(2, resolver.getValue(context, bundle, 1)); - assertTrue(context.isPropertyResolved()); - - // base is bundle, any non-null property which is not a key in the bundle --> '???' + property + '???' - context.setPropertyResolved(false); - assertEquals("???foo???", resolver.getValue(context, bundle, "foo")); - assertTrue(context.isPropertyResolved()); - - // base is bundle, property == null --> null - context.setPropertyResolved(false); - assertNull(resolver.getValue(context, bundle, null)); - assertTrue(context.isPropertyResolved()); - } - - public void testIsReadOnly() { - Integer scalar = 0; - ResourceBundle bundle = sampleBundle(); - ResourceBundleELResolver resolver = new ResourceBundleELResolver(); - - // base is null --> false - context.setPropertyResolved(false); - assertTrue(resolver.isReadOnly(context, null, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> false - context.setPropertyResolved(false); - assertTrue(resolver.isReadOnly(context, scalar, "foo")); - assertFalse(context.isPropertyResolved()); - - // base is bundle, any property --> true - context.setPropertyResolved(false); - assertTrue(resolver.isReadOnly(context, bundle, 1)); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertTrue(resolver.isReadOnly(context, bundle, "foo")); - assertTrue(context.isPropertyResolved()); - - context.setPropertyResolved(false); - assertTrue(resolver.isReadOnly(context, bundle, null)); - assertTrue(context.isPropertyResolved()); - } - - public void testSetValue() { - Integer scalar = 0; - ResourceBundle bundle = sampleBundle(); - ResourceBundleELResolver resolver = new ResourceBundleELResolver(); - - // base == null --> unresolved - context.setPropertyResolved(false); - resolver.setValue(context, null, "foo", -1); - assertFalse(context.isPropertyResolved()); - - // base is scalar --> unresolved - context.setPropertyResolved(false); - resolver.setValue(context, scalar, "foo", -1); - assertFalse(context.isPropertyResolved()); - - try { - resolver.setValue(context, bundle, "1", 999); - fail(); - } catch (PropertyNotWritableException e) { - // fine - } - try { - resolver.setValue(context, bundle, "1", null); - fail(); - } catch (PropertyNotWritableException e) { - // fine - } - try { - resolver.setValue(context, bundle, "1", "foo"); - fail(); - } catch (PropertyNotWritableException e) { - // fine - } - } -} diff --git a/modules/api/src/test/java/javax/el/TestContext.java b/modules/api/src/test/java/javax/el/TestContext.java deleted file mode 100644 index cadec3d..0000000 --- a/modules/api/src/test/java/javax/el/TestContext.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * 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 TestContext extends ELContext { - @Override - public FunctionMapper getFunctionMapper() { - return null; - } - - @Override - public VariableMapper getVariableMapper() { - return null; - } - - @Override - public ELResolver getELResolver() { - return null; - } -} diff --git a/modules/api/src/test/java/javax/el/TestFactory.java b/modules/api/src/test/java/javax/el/TestFactory.java deleted file mode 100644 index 0d87967..0000000 --- a/modules/api/src/test/java/javax/el/TestFactory.java +++ /dev/null @@ -1,75 +0,0 @@ -package javax.el; - -import java.util.Properties; - -public class TestFactory extends ExpressionFactory { - final Properties properties; - public TestFactory() { - this.properties = null; - } - public TestFactory(Properties properties) { - this.properties = properties; - } - @Override - public Object coerceToType(Object obj, Class targetType) { - if (targetType.isPrimitive()) { - if (targetType == boolean.class) { - if (obj == null) { - return false; - } - targetType = Boolean.class; - } - if (targetType == int.class) { - if (obj == null) { - return 0; - } - targetType = Integer.class; - } - if (targetType == long.class) { - if (obj == null) { - return 0; - } - targetType = Long.class; - } - } - if (targetType.isInstance(obj)) { - return obj; - } - if (targetType == String.class) { - return obj == null ? "" : obj.toString(); - } - if (obj.getClass() == String.class) { - if (targetType == Boolean.class) { - return Boolean.valueOf(obj.toString()); - } - if (targetType == Integer.class) { - return Integer.valueOf(obj.toString()); - } - } - if (obj instanceof Number) { - if (targetType == Integer.class) { - return ((Number)obj).intValue(); - } - if (targetType == Long.class) { - return ((Number)obj).longValue(); - } - if (targetType == Double.class) { - return ((Number)obj).doubleValue(); - } - } - throw new ELException("Test conversion failed: " + obj.getClass() + " --> " + targetType); - } - @Override - public MethodExpression createMethodExpression(ELContext context, String expression, - Class expectedReturnType, Class[] expectedParamTypes) { - throw new UnsupportedOperationException(); - }; - @Override - public ValueExpression createValueExpression(ELContext context, String expression, Class expectedType) { - throw new UnsupportedOperationException(); - } - @Override - public ValueExpression createValueExpression(Object instance, Class expectedType) { - throw new UnsupportedOperationException(); - } -} diff --git a/modules/api/src/test/java/javax/el/ValueReferenceTest.java b/modules/api/src/test/java/javax/el/ValueReferenceTest.java deleted file mode 100644 index 3ddc3c1..0000000 --- a/modules/api/src/test/java/javax/el/ValueReferenceTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package javax.el; - -import junit.framework.TestCase; - -public class ValueReferenceTest extends TestCase { - - public void testGetBase() { - assertEquals("foo", new ValueReference("foo", "bar").getBase()); - } - - public void testGetProperty() { - assertEquals("bar", new ValueReference("foo", "bar").getProperty()); - } - -} diff --git a/modules/api/src/test/java/javax/el/test/TestClass.java b/modules/api/src/test/java/javax/el/test/TestClass.java deleted file mode 100644 index db0da52..0000000 --- a/modules/api/src/test/java/javax/el/test/TestClass.java +++ /dev/null @@ -1,35 +0,0 @@ -package javax.el.test; - -public class TestClass { - private static class TestInterfaceImpl implements TestInterface { - public int getFourtyTwo() { - return 42; - } - } - - private static class NestedClass { - public static class TestInterfaceImpl2 implements TestInterface { - public int getFourtyTwo() { - return 42; - } - } - } - - private TestInterface anonymousTestInterface = new TestInterface() { - public int getFourtyTwo() { - return 42; - } - }; - - public TestInterface getNestedTestInterface() { - return new TestInterfaceImpl(); - } - - public TestInterface getNestedTestInterface2() { - return new NestedClass.TestInterfaceImpl2(); - } - - public TestInterface getAnonymousTestInterface() { - return anonymousTestInterface; - } -} diff --git a/modules/api/src/test/java/javax/el/test/TestInterface.java b/modules/api/src/test/java/javax/el/test/TestInterface.java deleted file mode 100644 index d229aa7..0000000 --- a/modules/api/src/test/java/javax/el/test/TestInterface.java +++ /dev/null @@ -1,5 +0,0 @@ -package javax.el.test; - -public interface TestInterface { - public int getFourtyTwo(); -} diff --git a/modules/api/src/test/resources/META-INF/services/javax.el.ExpressionFactory b/modules/api/src/test/resources/META-INF/services/javax.el.ExpressionFactory deleted file mode 100644 index a821dac..0000000 --- a/modules/api/src/test/resources/META-INF/services/javax.el.ExpressionFactory +++ /dev/null @@ -1 +0,0 @@ -javax.el.TestFactory diff --git a/modules/impl/pom.xml b/modules/impl/pom.xml index 176add4..022ba3a 100644 --- a/modules/impl/pom.xml +++ b/modules/impl/pom.xml @@ -6,36 +6,35 @@ de.odysseus.juel juel-parent - 2.2.8-SNAPSHOT + 4.0.0-SNAPSHOT ../../pom.xml - de.odysseus.juel juel-impl + 4.0.0-SNAPSHOT jar - Java Unified Expression Language Implementation - 2.2.8-SNAPSHOT + Jakarta Expression Language Implementation org.apache.maven.plugins maven-jar-plugin - 2.4 + 3.3.0 false - Expression Language - 2.2 - Sun Microsystems Inc. + Jakarta Expression Language + 4.0.0 + Eclipse Foundation JUEL ${project.version} Odysseus Software GmbH de.odysseus de.odysseus.el.tree.impl.Builder - javax.el + jakarta.el de.odysseus.el,de.odysseus.el.util Odysseus.de ${project.version} @@ -52,9 +51,9 @@ - ${project.groupId} - juel-api - ${project.version} + jakarta.el + jakarta.el-api + 4.0.0 provided diff --git a/modules/impl/src/main/java/de/odysseus/el/ExpressionFactoryImpl.java b/modules/impl/src/main/java/de/odysseus/el/ExpressionFactoryImpl.java index 2321847..514c395 100644 --- a/modules/impl/src/main/java/de/odysseus/el/ExpressionFactoryImpl.java +++ b/modules/impl/src/main/java/de/odysseus/el/ExpressionFactoryImpl.java @@ -23,9 +23,9 @@ import java.util.EnumSet; import java.util.Properties; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.ExpressionFactory; +import jakarta.el.ELContext; +import jakarta.el.ELException; +import jakarta.el.ExpressionFactory; import de.odysseus.el.misc.TypeConverter; import de.odysseus.el.tree.TreeBuilder; @@ -39,7 +39,7 @@ * * This class is also used as an EL "service provider". The juel-spi jar file specifies this * class as el expression factory implementation in - * META-INF/services/javax.el.ExpressionFactory. Calling + * META-INF/services/jakarta.el.ExpressionFactory. Calling * {@link ExpressionFactory#newInstance()} will then return an instance of this class, configured as * described below. * @@ -47,9 +47,9 @@ *
    *
  1. * If the file JAVA_HOME/lib/el.properties exists and if it contains property - * javax.el.ExpressionFactory whose value is the name of this class, these properties + * jakarta.el.ExpressionFactory whose value is the name of this class, these properties * are taken as default properties.
  2. - *
  3. Otherwise, if system property javax.el.ExpressionFactory is set to the name of + *
  4. Otherwise, if system property jakarta.el.ExpressionFactory is set to the name of * this class, the system properties {@link System#getProperties()} are taken as default properties. *
  5. *
  6. @@ -57,39 +57,38 @@ * JAVA_HOME/lib/el.properties or {@link System#getProperties()}.
  7. *
* There are also constructors to explicitly pass in an instance of {@link Properties}. - * * Having this, the following properties are read: *
    *
  • - * javax.el.cacheSize - cache size (int, default is 1000)
  • + * jakarta.el.cacheSize - cache size (int, default is 1000) *
  • - * javax.el.methodInvocations - allow method invocations as in + * jakarta.el.methodInvocations - allow method invocations as in * ${foo.bar(baz)} (boolean, default is false).
  • *
  • - * javax.el.nullProperties - resolve null properties as in + * jakarta.el.nullProperties - resolve null properties as in * ${foo[null]} (boolean, default is false).
  • *
  • - * javax.el.varArgs - support function/method calls using varargs (boolean, default is + * jakarta.el.varArgs - support function/method calls using varargs (boolean, default is * false).
  • *
* * @author Christoph Beck */ -public class ExpressionFactoryImpl extends javax.el.ExpressionFactory { +public class ExpressionFactoryImpl extends jakarta.el.ExpressionFactory { /** * A profile provides a default set of language features that will define the builder's - * behavior. A profile can be adjusted using the javax.el.methodInvocations, - * javax.el.varArgs and javax.el.nullProperties properties. + * behavior. A profile can be adjusted using the jakarta.el.methodInvocations, + * jakarta.el.varArgs and jakarta.el.nullProperties properties. * * @since 2.2 */ - public static enum Profile { + public enum Profile { /** * JEE5: none */ JEE5(EnumSet.noneOf(Feature.class)), /** - * JEE6: javax.el.methodInvocations, javax.el.varArgs. This is the + * JEE6: jakarta.el.methodInvocations, jakarta.el.varArgs. This is the * default profile. */ JEE6(EnumSet.of(Feature.METHOD_INVOCATIONS, Feature.VARARGS)); @@ -110,29 +109,29 @@ boolean contains(Feature feature) { } /** - * javax.el.methodInvocations + * jakarta.el.methodInvocations */ - public static final String PROP_METHOD_INVOCATIONS = "javax.el.methodInvocations"; + public static final String PROP_METHOD_INVOCATIONS = "jakarta.el.methodInvocations"; /** - * javax.el.varArgs + * jakarta.el.varArgs */ - public static final String PROP_VAR_ARGS = "javax.el.varArgs"; + public static final String PROP_VAR_ARGS = "jakarta.el.varArgs"; /** - * javax.el.nullProperties + * jakarta.el.nullProperties */ - public static final String PROP_NULL_PROPERTIES = "javax.el.nullProperties"; + public static final String PROP_NULL_PROPERTIES = "jakarta.el.nullProperties"; /** - * javax.el.ignoreReturnType + * jakarta.el.ignoreReturnType */ - public static final String PROP_IGNORE_RETURN_TYPE = "javax.el.ignoreReturnType"; + public static final String PROP_IGNORE_RETURN_TYPE = "jakarta.el.ignoreReturnType"; /** - * javax.el.cacheSize + * jakarta.el.cacheSize */ - public static final String PROP_CACHE_SIZE = "javax.el.cacheSize"; + public static final String PROP_CACHE_SIZE = "jakarta.el.cacheSize"; private final TreeStore store; private final TypeConverter converter; @@ -167,7 +166,7 @@ public ExpressionFactoryImpl(Profile profile) { /** * Create a new expression factory using the default builder and cache implementations. The * builder and cache are configured using the specified properties. The maximum cache size will - * be 1000 unless overridden by property javax.el.cacheSize. The builder profile is + * be 1000 unless overridden by property jakarta.el.cacheSize. The builder profile is * {@link Profile#JEE6} (features may be overridden in properties). * * @param properties @@ -180,7 +179,7 @@ public ExpressionFactoryImpl(Properties properties) { /** * Create a new expression factory using the default builder and cache implementations. The * builder and cache are configured using the specified profile and properties. The maximum - * cache size will be 1000 unless overridden by property javax.el.cacheSize. + * cache size will be 1000 unless overridden by property jakarta.el.cacheSize. * * @param profile * builder profile (individual features may be overridden in properties) @@ -197,7 +196,7 @@ public ExpressionFactoryImpl(Profile profile, Properties properties) { /** * Create a new expression factory using the default builder and cache implementations. The * builder and cache are configured using the specified properties. The maximum cache size will - * be 1000 unless overridden by property javax.el.cacheSize. The builder profile is + * be 1000 unless overridden by property jakarta.el.cacheSize. The builder profile is * {@link Profile#JEE6} (individual features may be overridden in properties). * * @param properties @@ -212,7 +211,7 @@ public ExpressionFactoryImpl(Properties properties, TypeConverter converter) { /** * Create a new expression factory using the default builder and cache implementations. The * builder and cache are configured using the specified profile and properties. The maximum - * cache size will be 1000 unless overridden by property javax.el.cacheSize. + * cache size will be 1000 unless overridden by property jakarta.el.cacheSize. * * @param profile * builder profile (individual features may be overridden in properties) @@ -270,14 +269,14 @@ private Properties loadDefaultProperties() { // ignore... } } - if (getClass().getName().equals(properties.getProperty("javax.el.ExpressionFactory"))) { + if (getClass().getName().equals(properties.getProperty("jakarta.el.ExpressionFactory"))) { return properties; } } } catch (SecurityException e) { // ignore... } - if (getClass().getName().equals(System.getProperty("javax.el.ExpressionFactory"))) { + if (getClass().getName().equals(System.getProperty("jakarta.el.ExpressionFactory"))) { return System.getProperties(); } return null; @@ -318,7 +317,7 @@ private boolean getFeatureProperty(Profile profile, Properties properties, Featu * Create the factory's tree store. This implementation creates a new tree store using the * default builder and cache implementations. The builder and cache are configured using the * specified properties. The maximum cache size will be as specified unless overridden by - * property javax.el.cacheSize. + * property jakarta.el.cacheSize. */ protected TreeStore createTreeStore(int defaultCacheSize, Profile profile, Properties properties) { // create builder @@ -393,7 +392,7 @@ protected TreeBuilder createTreeBuilder(Properties properties, Feature... featur Constructor constructor = clazz.getConstructor(Feature[].class); if (constructor == null) { if (features == null || features.length == 0) { - return TreeBuilder.class.cast(clazz.newInstance()); + return (TreeBuilder) clazz.newInstance(); } else { throw new ELException("Builder " + clazz + " is missing constructor (can't pass features)"); } @@ -431,7 +430,7 @@ private Class load(Class clazz, Properties properties) { } @Override - public final Object coerceToType(Object obj, Class targetType) { + public Object coerceToType(Object obj, Class targetType) { return converter.convert(obj, targetType); } diff --git a/modules/impl/src/main/java/de/odysseus/el/ObjectValueExpression.java b/modules/impl/src/main/java/de/odysseus/el/ObjectValueExpression.java index 9b64c75..bca49b1 100644 --- a/modules/impl/src/main/java/de/odysseus/el/ObjectValueExpression.java +++ b/modules/impl/src/main/java/de/odysseus/el/ObjectValueExpression.java @@ -15,18 +15,19 @@ */ package de.odysseus.el; -import javax.el.ELContext; -import javax.el.ELException; +import jakarta.el.ELContext; +import jakarta.el.ELException; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.misc.TypeConverter; +import jakarta.el.ValueExpression; /** * Object wrapper expression. * * @author Christoph Beck */ -public final class ObjectValueExpression extends javax.el.ValueExpression { +public final class ObjectValueExpression extends ValueExpression { private static final long serialVersionUID = 1L; private final TypeConverter converter; diff --git a/modules/impl/src/main/java/de/odysseus/el/TreeMethodExpression.java b/modules/impl/src/main/java/de/odysseus/el/TreeMethodExpression.java index 26f3888..7a1d9ea 100644 --- a/modules/impl/src/main/java/de/odysseus/el/TreeMethodExpression.java +++ b/modules/impl/src/main/java/de/odysseus/el/TreeMethodExpression.java @@ -20,11 +20,7 @@ import java.io.PrintWriter; import java.util.Arrays; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.FunctionMapper; -import javax.el.MethodInfo; -import javax.el.VariableMapper; +import jakarta.el.*; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.misc.TypeConverter; @@ -38,12 +34,11 @@ /** * A method expression is ready to be evaluated (by calling either * {@link #invoke(ELContext, Object[])} or {@link #getMethodInfo(ELContext)}). - * * Instances of this class are usually created using an {@link ExpressionFactoryImpl}. * * @author Christoph Beck */ -public final class TreeMethodExpression extends javax.el.MethodExpression { +public final class TreeMethodExpression extends MethodExpression { private static final long serialVersionUID = 1L; private final TreeBuilder builder; @@ -140,14 +135,6 @@ public boolean isLiteralText() { return node.isLiteralText(); } - /** - * @return true if this is a method invocation expression - */ - @Override - public boolean isParmetersProvided() { - return node.isMethodInvocation(); - } - /** * Answer true if this is a deferred expression (starting with #{) */ diff --git a/modules/impl/src/main/java/de/odysseus/el/TreeValueExpression.java b/modules/impl/src/main/java/de/odysseus/el/TreeValueExpression.java index 268ec54..12f5fff 100644 --- a/modules/impl/src/main/java/de/odysseus/el/TreeValueExpression.java +++ b/modules/impl/src/main/java/de/odysseus/el/TreeValueExpression.java @@ -19,11 +19,7 @@ import java.io.ObjectInputStream; import java.io.PrintWriter; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.FunctionMapper; -import javax.el.ValueReference; -import javax.el.VariableMapper; +import jakarta.el.*; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.misc.TypeConverter; @@ -43,7 +39,7 @@ * * @author Christoph Beck */ -public final class TreeValueExpression extends javax.el.ValueExpression { +public final class TreeValueExpression extends ValueExpression { private static final long serialVersionUID = 1L; private final TreeBuilder builder; diff --git a/modules/impl/src/main/java/de/odysseus/el/misc/BooleanOperations.java b/modules/impl/src/main/java/de/odysseus/el/misc/BooleanOperations.java index 47ea004..1aeac6b 100644 --- a/modules/impl/src/main/java/de/odysseus/el/misc/BooleanOperations.java +++ b/modules/impl/src/main/java/de/odysseus/el/misc/BooleanOperations.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.Set; -import javax.el.ELException; +import jakarta.el.ELException; public class BooleanOperations { private final static Set> SIMPLE_INTEGER_TYPES = new HashSet>(); diff --git a/modules/impl/src/main/java/de/odysseus/el/misc/NumberOperations.java b/modules/impl/src/main/java/de/odysseus/el/misc/NumberOperations.java index e619695..e0ba749 100644 --- a/modules/impl/src/main/java/de/odysseus/el/misc/NumberOperations.java +++ b/modules/impl/src/main/java/de/odysseus/el/misc/NumberOperations.java @@ -18,7 +18,7 @@ import java.math.BigDecimal; import java.math.BigInteger; -import javax.el.ELException; +import jakarta.el.ELException; /** * Arithmetic Operations as specified in chapter 1.7. diff --git a/modules/impl/src/main/java/de/odysseus/el/misc/TypeConverter.java b/modules/impl/src/main/java/de/odysseus/el/misc/TypeConverter.java index a8ea490..f2ae322 100644 --- a/modules/impl/src/main/java/de/odysseus/el/misc/TypeConverter.java +++ b/modules/impl/src/main/java/de/odysseus/el/misc/TypeConverter.java @@ -17,7 +17,7 @@ import java.io.Serializable; -import javax.el.ELException; +import jakarta.el.ELException; public interface TypeConverter extends Serializable { /** diff --git a/modules/impl/src/main/java/de/odysseus/el/misc/TypeConverterImpl.java b/modules/impl/src/main/java/de/odysseus/el/misc/TypeConverterImpl.java index 1bd77da..6f7e4d9 100644 --- a/modules/impl/src/main/java/de/odysseus/el/misc/TypeConverterImpl.java +++ b/modules/impl/src/main/java/de/odysseus/el/misc/TypeConverterImpl.java @@ -20,7 +20,7 @@ import java.math.BigDecimal; import java.math.BigInteger; -import javax.el.ELException; +import jakarta.el.ELException; /** * Type Conversions as described in EL 2.1 specification (section 1.17). diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/Bindings.java b/modules/impl/src/main/java/de/odysseus/el/tree/Bindings.java index 37a6b3d..d0e14c8 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/Bindings.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/Bindings.java @@ -22,8 +22,8 @@ import java.lang.reflect.Method; import java.util.Arrays; -import javax.el.ELException; -import javax.el.ValueExpression; +import jakarta.el.ELException; +import jakarta.el.ValueExpression; import de.odysseus.el.misc.TypeConverter; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/ExpressionNode.java b/modules/impl/src/main/java/de/odysseus/el/tree/ExpressionNode.java index fa7d34a..8e98f80 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/ExpressionNode.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/ExpressionNode.java @@ -15,9 +15,9 @@ */ package de.odysseus.el.tree; -import javax.el.ELContext; -import javax.el.MethodInfo; -import javax.el.ValueReference; +import jakarta.el.ELContext; +import jakarta.el.MethodInfo; +import jakarta.el.ValueReference; /** * Expression node interface. This interface provides all the methods needed for value expressions @@ -78,7 +78,7 @@ public interface ExpressionNode extends Node { /** * Determine whether {@link #setValue(Bindings, ELContext, Object)} will throw a - * {@link javax.el.PropertyNotWritableException}. + * {@link jakarta.el.PropertyNotWritableException}. * * @param bindings * bindings containing variables and functions diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/Tree.java b/modules/impl/src/main/java/de/odysseus/el/tree/Tree.java index ea681d5..71b9d62 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/Tree.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/Tree.java @@ -18,10 +18,10 @@ import java.lang.reflect.Method; import java.util.List; -import javax.el.ELException; -import javax.el.FunctionMapper; -import javax.el.ValueExpression; -import javax.el.VariableMapper; +import jakarta.el.ELException; +import jakarta.el.FunctionMapper; +import jakarta.el.ValueExpression; +import jakarta.el.VariableMapper; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.misc.TypeConverter; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/TreeBuilder.java b/modules/impl/src/main/java/de/odysseus/el/tree/TreeBuilder.java index f5cdafd..85e3c2d 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/TreeBuilder.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/TreeBuilder.java @@ -17,7 +17,7 @@ import java.io.Serializable; -import javax.el.ELException; +import jakarta.el.ELException; /** * Tree builder interface. diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/TreeBuilderException.java b/modules/impl/src/main/java/de/odysseus/el/tree/TreeBuilderException.java index 6807bac..a80d3ef 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/TreeBuilderException.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/TreeBuilderException.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.misc.LocalMessages; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/Builder.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/Builder.java index 8ce0c38..dad38e3 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/Builder.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/Builder.java @@ -18,12 +18,12 @@ import java.io.PrintWriter; import java.util.EnumSet; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.ELResolver; -import javax.el.ExpressionFactory; -import javax.el.FunctionMapper; -import javax.el.VariableMapper; +import jakarta.el.ELContext; +import jakarta.el.ELException; +import jakarta.el.ELResolver; +import jakarta.el.ExpressionFactory; +import jakarta.el.FunctionMapper; +import jakarta.el.VariableMapper; import de.odysseus.el.tree.Bindings; import de.odysseus.el.tree.NodePrinter; @@ -44,12 +44,12 @@ public class Builder implements TreeBuilder { /** * Feature enumeration type. */ - public static enum Feature { + public enum Feature { /** * Method invocations as in ${foo.bar(1)} as specified in JSR 245, * maintenance release 2. * The method to be invoked is resolved at evaluation time by calling - * {@link ELResolver#invoke(javax.el.ELContext, Object, Object, Class[], Object[])}. + * {@link ELResolver#invoke(jakarta.el.ELContext, Object, Object, Class[], Object[])}. */ METHOD_INVOCATIONS, /** diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBinary.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBinary.java index fbc63fe..6821904 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBinary.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBinary.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; +import jakarta.el.ELContext; import de.odysseus.el.misc.BooleanOperations; import de.odysseus.el.misc.NumberOperations; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBoolean.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBoolean.java index 8f25c92..0d0783c 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBoolean.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBoolean.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; +import jakarta.el.ELContext; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBracket.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBracket.java index 066746d..f8c1b2d 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBracket.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstBracket.java @@ -15,8 +15,8 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; -import javax.el.ELException; +import jakarta.el.ELContext; +import jakarta.el.ELException; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstChoice.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstChoice.java index 08cedeb..bd6ae43 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstChoice.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstChoice.java @@ -15,8 +15,8 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; -import javax.el.ELException; +import jakarta.el.ELContext; +import jakarta.el.ELException; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstComposite.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstComposite.java index 1f4a5ee..b5d2481 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstComposite.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstComposite.java @@ -17,7 +17,7 @@ import java.util.List; -import javax.el.ELContext; +import jakarta.el.ELContext; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstDot.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstDot.java index 3cfaa69..0f86e33 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstDot.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstDot.java @@ -15,8 +15,8 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; -import javax.el.ELException; +import jakarta.el.ELContext; +import jakarta.el.ELException; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstEval.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstEval.java index f5071cd..7384b02 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstEval.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstEval.java @@ -15,9 +15,9 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; -import javax.el.MethodInfo; -import javax.el.ValueReference; +import jakarta.el.ELContext; +import jakarta.el.MethodInfo; +import jakarta.el.ValueReference; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstFunction.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstFunction.java index fcdbec0..1f68251 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstFunction.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstFunction.java @@ -19,8 +19,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import javax.el.ELContext; -import javax.el.ELException; +import jakarta.el.ELContext; +import jakarta.el.ELException; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstIdentifier.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstIdentifier.java index d9b026a..0479b8a 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstIdentifier.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstIdentifier.java @@ -19,14 +19,14 @@ import java.lang.reflect.Method; import java.util.Arrays; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.MethodExpression; -import javax.el.MethodInfo; -import javax.el.MethodNotFoundException; -import javax.el.PropertyNotFoundException; -import javax.el.ValueExpression; -import javax.el.ValueReference; +import jakarta.el.ELContext; +import jakarta.el.ELException; +import jakarta.el.MethodExpression; +import jakarta.el.MethodInfo; +import jakarta.el.MethodNotFoundException; +import jakarta.el.PropertyNotFoundException; +import jakarta.el.ValueExpression; +import jakarta.el.ValueReference; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstMethod.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstMethod.java index 9ffdaaf..7657414 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstMethod.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstMethod.java @@ -15,12 +15,12 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.MethodInfo; -import javax.el.MethodNotFoundException; -import javax.el.PropertyNotFoundException; -import javax.el.ValueReference; +import jakarta.el.ELContext; +import jakarta.el.ELException; +import jakarta.el.MethodInfo; +import jakarta.el.MethodNotFoundException; +import jakarta.el.PropertyNotFoundException; +import jakarta.el.ValueReference; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNested.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNested.java index 891463a..7011d91 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNested.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNested.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; +import jakarta.el.ELContext; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNode.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNode.java index d71fb56..9191c1c 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNode.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNode.java @@ -18,7 +18,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import javax.el.ELContext; +import jakarta.el.ELContext; import de.odysseus.el.tree.Bindings; import de.odysseus.el.tree.ExpressionNode; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNull.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNull.java index 769c5a4..d65224e 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNull.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNull.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; +import jakarta.el.ELContext; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNumber.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNumber.java index bed0c83..087cd39 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNumber.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstNumber.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; +import jakarta.el.ELContext; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstParameters.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstParameters.java index f42507c..aa375cb 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstParameters.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstParameters.java @@ -17,7 +17,7 @@ import java.util.List; -import javax.el.ELContext; +import jakarta.el.ELContext; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstProperty.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstProperty.java index c3cc78b..5f4bd86 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstProperty.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstProperty.java @@ -18,12 +18,12 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.MethodInfo; -import javax.el.MethodNotFoundException; -import javax.el.PropertyNotFoundException; -import javax.el.ValueReference; +import jakarta.el.ELContext; +import jakarta.el.ELException; +import jakarta.el.MethodInfo; +import jakarta.el.MethodNotFoundException; +import jakarta.el.PropertyNotFoundException; +import jakarta.el.ValueReference; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstRightValue.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstRightValue.java index 36cbdda..84fe71a 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstRightValue.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstRightValue.java @@ -15,10 +15,10 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.MethodInfo; -import javax.el.ValueReference; +import jakarta.el.ELContext; +import jakarta.el.ELException; +import jakarta.el.MethodInfo; +import jakarta.el.ValueReference; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstString.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstString.java index ba3b2cc..893bc47 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstString.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstString.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; +import jakarta.el.ELContext; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstText.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstText.java index e12b494..896467a 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstText.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstText.java @@ -15,10 +15,10 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.MethodInfo; -import javax.el.ValueReference; +import jakarta.el.ELContext; +import jakarta.el.ELException; +import jakarta.el.MethodInfo; +import jakarta.el.ValueReference; import de.odysseus.el.misc.LocalMessages; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstUnary.java b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstUnary.java index bb04659..a50a79b 100644 --- a/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstUnary.java +++ b/modules/impl/src/main/java/de/odysseus/el/tree/impl/ast/AstUnary.java @@ -15,8 +15,8 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELContext; -import javax.el.ELException; +import jakarta.el.ELContext; +import jakarta.el.ELException; import de.odysseus.el.misc.BooleanOperations; import de.odysseus.el.misc.NumberOperations; diff --git a/modules/impl/src/main/java/de/odysseus/el/util/RootPropertyResolver.java b/modules/impl/src/main/java/de/odysseus/el/util/RootPropertyResolver.java index bee5337..2d43e34 100644 --- a/modules/impl/src/main/java/de/odysseus/el/util/RootPropertyResolver.java +++ b/modules/impl/src/main/java/de/odysseus/el/util/RootPropertyResolver.java @@ -21,10 +21,10 @@ import java.util.Iterator; import java.util.Map; -import javax.el.ELContext; -import javax.el.ELResolver; -import javax.el.PropertyNotFoundException; -import javax.el.PropertyNotWritableException; +import jakarta.el.ELContext; +import jakarta.el.ELResolver; +import jakarta.el.PropertyNotFoundException; +import jakarta.el.PropertyNotWritableException; /** * Simple root property resolver implementation. This resolver handles root properties (i.e. diff --git a/modules/impl/src/main/java/de/odysseus/el/util/SimpleContext.java b/modules/impl/src/main/java/de/odysseus/el/util/SimpleContext.java index 1c56a9f..ef4983c 100644 --- a/modules/impl/src/main/java/de/odysseus/el/util/SimpleContext.java +++ b/modules/impl/src/main/java/de/odysseus/el/util/SimpleContext.java @@ -20,11 +20,11 @@ import java.util.HashMap; import java.util.Map; -import javax.el.ELContext; -import javax.el.ELResolver; -import javax.el.FunctionMapper; -import javax.el.ValueExpression; -import javax.el.VariableMapper; +import jakarta.el.ELContext; +import jakarta.el.ELResolver; +import jakarta.el.FunctionMapper; +import jakarta.el.ValueExpression; +import jakarta.el.VariableMapper; /** * Simple context implementation. diff --git a/modules/impl/src/main/java/de/odysseus/el/util/SimpleResolver.java b/modules/impl/src/main/java/de/odysseus/el/util/SimpleResolver.java index 874588d..ce080e7 100644 --- a/modules/impl/src/main/java/de/odysseus/el/util/SimpleResolver.java +++ b/modules/impl/src/main/java/de/odysseus/el/util/SimpleResolver.java @@ -18,14 +18,14 @@ import java.beans.FeatureDescriptor; import java.util.Iterator; -import javax.el.ArrayELResolver; -import javax.el.BeanELResolver; -import javax.el.CompositeELResolver; -import javax.el.ELContext; -import javax.el.ELResolver; -import javax.el.ListELResolver; -import javax.el.MapELResolver; -import javax.el.ResourceBundleELResolver; +import jakarta.el.ArrayELResolver; +import jakarta.el.BeanELResolver; +import jakarta.el.CompositeELResolver; +import jakarta.el.ELContext; +import jakarta.el.ELResolver; +import jakarta.el.ListELResolver; +import jakarta.el.MapELResolver; +import jakarta.el.ResourceBundleELResolver; /** * Simple resolver implementation. This resolver handles root properties (top-level identifiers). diff --git a/modules/spi/src/main/resources/META-INF/services/javax.el.ExpressionFactory b/modules/impl/src/main/resources/META-INF/services/jakarta.el.ExpressionFactory similarity index 97% rename from modules/spi/src/main/resources/META-INF/services/javax.el.ExpressionFactory rename to modules/impl/src/main/resources/META-INF/services/jakarta.el.ExpressionFactory index dac1d51..d30f907 100644 --- a/modules/spi/src/main/resources/META-INF/services/javax.el.ExpressionFactory +++ b/modules/impl/src/main/resources/META-INF/services/jakarta.el.ExpressionFactory @@ -1 +1 @@ -de.odysseus.el.ExpressionFactoryImpl +de.odysseus.el.ExpressionFactoryImpl diff --git a/modules/impl/src/main/resources/OSGI-INF/services.xml b/modules/impl/src/main/resources/OSGI-INF/services.xml index 185123e..3c2a3b9 100644 --- a/modules/impl/src/main/resources/OSGI-INF/services.xml +++ b/modules/impl/src/main/resources/OSGI-INF/services.xml @@ -3,7 +3,7 @@ - + diff --git a/modules/impl/src/test/java/de/odysseus/el/ObjectValueExpressionTest.java b/modules/impl/src/test/java/de/odysseus/el/ObjectValueExpressionTest.java index 87eeb6a..af18da4 100644 --- a/modules/impl/src/test/java/de/odysseus/el/ObjectValueExpressionTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/ObjectValueExpressionTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.misc.TypeConverter; diff --git a/modules/impl/src/test/java/de/odysseus/el/TreeMethodExpressionTest.java b/modules/impl/src/test/java/de/odysseus/el/TreeMethodExpressionTest.java index 3b49478..45dec01 100644 --- a/modules/impl/src/test/java/de/odysseus/el/TreeMethodExpressionTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/TreeMethodExpressionTest.java @@ -15,8 +15,8 @@ */ package de.odysseus.el; -import javax.el.BeanELResolver; -import javax.el.MethodInfo; +import jakarta.el.BeanELResolver; +import jakarta.el.MethodInfo; import de.odysseus.el.tree.TreeStore; import de.odysseus.el.tree.impl.Builder; diff --git a/modules/impl/src/test/java/de/odysseus/el/TreeValueExpressionTest.java b/modules/impl/src/test/java/de/odysseus/el/TreeValueExpressionTest.java index a35d4d3..504008d 100644 --- a/modules/impl/src/test/java/de/odysseus/el/TreeValueExpressionTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/TreeValueExpressionTest.java @@ -15,8 +15,8 @@ */ package de.odysseus.el; -import javax.el.BeanELResolver; -import javax.el.PropertyNotFoundException; +import jakarta.el.BeanELResolver; +import jakarta.el.PropertyNotFoundException; import de.odysseus.el.tree.TreeStore; import de.odysseus.el.tree.impl.Builder; diff --git a/modules/impl/src/test/java/de/odysseus/el/misc/TypeConverterImplTest.java b/modules/impl/src/test/java/de/odysseus/el/misc/TypeConverterImplTest.java index 9ef2fbb..0bb0540 100644 --- a/modules/impl/src/test/java/de/odysseus/el/misc/TypeConverterImplTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/misc/TypeConverterImplTest.java @@ -25,7 +25,7 @@ import java.math.BigInteger; import java.util.Date; -import javax.el.ELException; +import jakarta.el.ELException; import junit.framework.TestCase; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/BindingsTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/BindingsTest.java index 7d7c4d5..225e28a 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/BindingsTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/BindingsTest.java @@ -17,7 +17,7 @@ import java.lang.reflect.Method; -import javax.el.ValueExpression; +import jakarta.el.ValueExpression; import de.odysseus.el.ObjectValueExpression; import de.odysseus.el.TestCase; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBinaryTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBinaryTest.java index 74201a7..86b5e55 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBinaryTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBinaryTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBooleanTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBooleanTest.java index 2bcdda5..3e7586d 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBooleanTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBooleanTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBracketTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBracketTest.java index 31ef59b..21f7138 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBracketTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBracketTest.java @@ -18,10 +18,10 @@ import java.util.Arrays; import java.util.HashMap; -import javax.el.ELException; -import javax.el.MethodInfo; -import javax.el.PropertyNotFoundException; -import javax.el.ValueExpression; +import jakarta.el.ELException; +import jakarta.el.MethodInfo; +import jakarta.el.PropertyNotFoundException; +import jakarta.el.ValueExpression; import de.odysseus.el.TestCase; import de.odysseus.el.test.TestClass; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstChoiceTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstChoiceTest.java index caadf63..9313a3c 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstChoiceTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstChoiceTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstCompositeTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstCompositeTest.java index 687ca37..59273c2 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstCompositeTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstCompositeTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstDotTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstDotTest.java index 1631ca6..b691e32 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstDotTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstDotTest.java @@ -17,11 +17,11 @@ import java.util.Arrays; -import javax.el.BeanELResolver; -import javax.el.ELException; -import javax.el.MethodInfo; -import javax.el.PropertyNotFoundException; -import javax.el.ValueExpression; +import jakarta.el.BeanELResolver; +import jakarta.el.ELException; +import jakarta.el.MethodInfo; +import jakarta.el.PropertyNotFoundException; +import jakarta.el.ValueExpression; import de.odysseus.el.TestCase; import de.odysseus.el.test.TestClass; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstFunctionTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstFunctionTest.java index 6fdbffd..ee9f8a7 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstFunctionTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstFunctionTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstIdentifierTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstIdentifierTest.java index ad6e58b..fe294c5 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstIdentifierTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstIdentifierTest.java @@ -18,10 +18,10 @@ import java.lang.reflect.Method; import java.util.Arrays; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.MethodExpression; -import javax.el.MethodInfo; +import jakarta.el.ELContext; +import jakarta.el.ELException; +import jakarta.el.MethodExpression; +import jakarta.el.MethodInfo; import de.odysseus.el.ObjectValueExpression; import de.odysseus.el.TestCase; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstMethodTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstMethodTest.java index bc86710..9020c0b 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstMethodTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstMethodTest.java @@ -15,11 +15,11 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.BeanELResolver; -import javax.el.ELException; -import javax.el.MethodNotFoundException; -import javax.el.PropertyNotFoundException; -import javax.el.ValueExpression; +import jakarta.el.BeanELResolver; +import jakarta.el.ELException; +import jakarta.el.MethodNotFoundException; +import jakarta.el.PropertyNotFoundException; +import jakarta.el.ValueExpression; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNullTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNullTest.java index 3624773..29e60e1 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNullTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNullTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNumberTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNumberTest.java index 9897aa0..16a4291 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNumberTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNumberTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstStringTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstStringTest.java index 5581789..c64ef81 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstStringTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstStringTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstTextTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstTextTest.java index bfd0a1b..9c0bf4f 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstTextTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstTextTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstUnaryTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstUnaryTest.java index e0e4473..1aba57a 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstUnaryTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstUnaryTest.java @@ -15,7 +15,7 @@ */ package de.odysseus.el.tree.impl.ast; -import javax.el.ELException; +import jakarta.el.ELException; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; diff --git a/modules/spi/.gitignore b/modules/spi/.gitignore deleted file mode 100644 index c708c36..0000000 --- a/modules/spi/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target -/.settings -/.classpath -/.project diff --git a/modules/spi/pom.xml b/modules/spi/pom.xml deleted file mode 100644 index 6aebbf6..0000000 --- a/modules/spi/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - 4.0.0 - - - de.odysseus.juel - juel-parent - 2.2.8-SNAPSHOT - ../../pom.xml - - - de.odysseus.juel - juel-spi - jar - - Java Unified Expression Language Service Provider - 2.2.8-SNAPSHOT - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - false - - Expression Language - 2.2 - Sun Microsystems Inc. - JUEL - ${project.version} - Odysseus Software GmbH - de.odysseus - - - - - - - diff --git a/pom.xml b/pom.xml index 8c11173..2882530 100644 --- a/pom.xml +++ b/pom.xml @@ -5,28 +5,27 @@ org.sonatype.oss oss-parent - 7 + 9 de.odysseus.juel juel-parent pom - Java Unified Expression Language - 2.2.8-SNAPSHOT + Jakarta Expression Language + 4.0.0-SNAPSHOT - Implementation of the Java Unified Expression Language as specified - by the Expression Language Specification, Version 2.1 (JEE5, part of - the JSP 2.1 standard [JSR-245]), plus maintenance release 2.2 (JEE6). + Implementation of the Jakarta Expression Language as specified + by the Expression Language Specification, Version 4.0.0 (Jakarta EE 8). - http://juel.sourceforge.net/ + https://github.com/beckchr/juel 2006 The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt repo @@ -45,6 +44,13 @@ developer + + Dmytro Maidaniuk + dmytro.maidaniuk@gmail.com + + developer + + @@ -55,13 +61,14 @@ UTF-8 + UTF-8 junit junit - 3.8.1 + 4.13.2 test @@ -71,10 +78,10 @@ org.apache.maven.plugins maven-compiler-plugin - 2.5.1 + 3.10.1 - 1.5 - 1.5 + 1.8 + 1.8 true @@ -82,7 +89,7 @@ org.apache.maven.plugins maven-source-plugin - 2.1.2 + 3.2.1 true @@ -105,8 +112,7 @@ - modules/api modules/impl - modules/spi + samples diff --git a/project/doc/xdocs/guide/start.xml b/project/doc/xdocs/guide/start.xml index 3fef08f..ab67756 100644 --- a/project/doc/xdocs/guide/start.xml +++ b/project/doc/xdocs/guide/start.xml @@ -26,7 +26,7 @@

Here's all you need to use the EL in your application (assuming you added - the JUEL JAR files to your classpath and did import javax.el.*): + the JUEL JAR files to your classpath and did import jakarta.el.*):

  1. diff --git a/project/doc/xdocs/guide/util/context.xml b/project/doc/xdocs/guide/util/context.xml index 35e69c4..cd6699d 100644 --- a/project/doc/xdocs/guide/util/context.xml +++ b/project/doc/xdocs/guide/util/context.xml @@ -29,7 +29,7 @@ The following example defines function math:sin and variable pi and uses them in an expression.

    - import javax.el.*; + import jakarta.el.*; import de.odysseus.el.util.SimpleContext; import de.odysseus.el.ExpressionFactoryImpl; ... diff --git a/project/doc/xdocs/guide/util/resolver.xml b/project/doc/xdocs/guide/util/resolver.xml index 57d8cd2..e8221df 100644 --- a/project/doc/xdocs/guide/util/resolver.xml +++ b/project/doc/xdocs/guide/util/resolver.xml @@ -26,7 +26,7 @@ method will throw an exception.

    import java.util.Date; -import javax.el.*; +import jakarta.el.*; import de.odysseus.el.util.SimpleContext; import de.odysseus.el.util.SimpleResolver; import de.odysseus.el.ExpressionFactoryImpl; diff --git a/modules/api/.gitignore b/samples/.gitignore similarity index 100% rename from modules/api/.gitignore rename to samples/.gitignore diff --git a/samples/pom.xml b/samples/pom.xml new file mode 100644 index 0000000..3c4e5ee --- /dev/null +++ b/samples/pom.xml @@ -0,0 +1,56 @@ + + + + 4.0.0 + + + de.odysseus.juel + juel-parent + 4.0.0-SNAPSHOT + ../pom.xml + + + samples + 4.0.0-SNAPSHOT + jar + + Jakarta Expression Language samples + + + + jakarta.el + jakarta.el-api + 4.0.0 + provided + + + + de.odysseus.juel + juel-impl + ${project.version} + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.3.0 + + + generate-sources + + add-source + + + + src + + + + + + + + diff --git a/samples/src/de/odysseus/el/samples/calculator/Calculator.java b/samples/src/de/odysseus/el/samples/calculator/Calculator.java index 52fe1b5..bff5df0 100644 --- a/samples/src/de/odysseus/el/samples/calculator/Calculator.java +++ b/samples/src/de/odysseus/el/samples/calculator/Calculator.java @@ -3,9 +3,9 @@ import java.io.IOException; import java.io.InputStreamReader; -import javax.el.ELException; -import javax.el.ExpressionFactory; -import javax.el.ValueExpression; +import jakarta.el.ELException; +import jakarta.el.ExpressionFactory; +import jakarta.el.ValueExpression; import de.odysseus.el.ExpressionFactoryImpl; import de.odysseus.el.tree.TreeBuilderException; diff --git a/samples/src/de/odysseus/el/samples/experimental/SyntaxExtension.java b/samples/src/de/odysseus/el/samples/experimental/SyntaxExtension.java index 9aa0dd4..5596089 100644 --- a/samples/src/de/odysseus/el/samples/experimental/SyntaxExtension.java +++ b/samples/src/de/odysseus/el/samples/experimental/SyntaxExtension.java @@ -15,8 +15,8 @@ */ package de.odysseus.el.samples.experimental; -import javax.el.ExpressionFactory; -import javax.el.ValueExpression; +import jakarta.el.ExpressionFactory; +import jakarta.el.ValueExpression; import de.odysseus.el.ExpressionFactoryImpl; import de.odysseus.el.misc.TypeConverter; diff --git a/samples/src/de/odysseus/el/samples/extensions/MethodInvocations.java b/samples/src/de/odysseus/el/samples/extensions/MethodInvocations.java index f69c225..de64789 100644 --- a/samples/src/de/odysseus/el/samples/extensions/MethodInvocations.java +++ b/samples/src/de/odysseus/el/samples/extensions/MethodInvocations.java @@ -15,11 +15,11 @@ */ package de.odysseus.el.samples.extensions; -import javax.el.BeanELResolver; -import javax.el.CompositeELResolver; -import javax.el.ELContext; -import javax.el.ExpressionFactory; -import javax.el.ValueExpression; +import jakarta.el.BeanELResolver; +import jakarta.el.CompositeELResolver; +import jakarta.el.ELContext; +import jakarta.el.ExpressionFactory; +import jakarta.el.ValueExpression; import de.odysseus.el.ExpressionFactoryImpl; import de.odysseus.el.util.SimpleContext; diff --git a/samples/src/de/odysseus/el/samples/extensions/NullProperties.java b/samples/src/de/odysseus/el/samples/extensions/NullProperties.java index 571cf57..260de67 100644 --- a/samples/src/de/odysseus/el/samples/extensions/NullProperties.java +++ b/samples/src/de/odysseus/el/samples/extensions/NullProperties.java @@ -18,9 +18,9 @@ import java.util.HashMap; import java.util.Map; -import javax.el.ELContext; -import javax.el.ExpressionFactory; -import javax.el.ValueExpression; +import jakarta.el.ELContext; +import jakarta.el.ExpressionFactory; +import jakarta.el.ValueExpression; import de.odysseus.el.ExpressionFactoryImpl; import de.odysseus.el.util.SimpleContext; diff --git a/samples/src/de/odysseus/el/samples/extensions/VarArgs.java b/samples/src/de/odysseus/el/samples/extensions/VarArgs.java index 0d4ea66..311cb42 100644 --- a/samples/src/de/odysseus/el/samples/extensions/VarArgs.java +++ b/samples/src/de/odysseus/el/samples/extensions/VarArgs.java @@ -17,8 +17,8 @@ import java.lang.reflect.Method; -import javax.el.ExpressionFactory; -import javax.el.ValueExpression; +import jakarta.el.ExpressionFactory; +import jakarta.el.ValueExpression; import de.odysseus.el.ExpressionFactoryImpl; import de.odysseus.el.util.SimpleContext; diff --git a/samples/src/de/odysseus/el/samples/xml/sax/AbstractFilter.java b/samples/src/de/odysseus/el/samples/xml/sax/AbstractFilter.java index 643167a..d379395 100644 --- a/samples/src/de/odysseus/el/samples/xml/sax/AbstractFilter.java +++ b/samples/src/de/odysseus/el/samples/xml/sax/AbstractFilter.java @@ -15,9 +15,9 @@ */ package de.odysseus.el.samples.xml.sax; -import javax.el.ELContext; -import javax.el.ELException; -import javax.el.ExpressionFactory; +import jakarta.el.ELContext; +import jakarta.el.ELException; +import jakarta.el.ExpressionFactory; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLFilterImpl; diff --git a/samples/src/de/odysseus/el/samples/xml/sax/AttributesFilter.java b/samples/src/de/odysseus/el/samples/xml/sax/AttributesFilter.java index 91e6360..d45992e 100644 --- a/samples/src/de/odysseus/el/samples/xml/sax/AttributesFilter.java +++ b/samples/src/de/odysseus/el/samples/xml/sax/AttributesFilter.java @@ -18,8 +18,8 @@ import java.io.IOException; import java.io.StringReader; -import javax.el.ELContext; -import javax.el.ELException; +import jakarta.el.ELContext; +import jakarta.el.ELException; import org.xml.sax.Attributes; import org.xml.sax.InputSource; diff --git a/samples/src/de/odysseus/el/samples/xml/sax/TextFilter.java b/samples/src/de/odysseus/el/samples/xml/sax/TextFilter.java index 105f735..637067c 100644 --- a/samples/src/de/odysseus/el/samples/xml/sax/TextFilter.java +++ b/samples/src/de/odysseus/el/samples/xml/sax/TextFilter.java @@ -18,7 +18,7 @@ import java.io.IOException; import java.io.StringReader; -import javax.el.ELContext; +import jakarta.el.ELContext; import org.xml.sax.Attributes; import org.xml.sax.InputSource; diff --git a/samples/src/de/odysseus/el/samples/xml/sax/XMELFilter.java b/samples/src/de/odysseus/el/samples/xml/sax/XMELFilter.java index 86c9548..a2bbccd 100644 --- a/samples/src/de/odysseus/el/samples/xml/sax/XMELFilter.java +++ b/samples/src/de/odysseus/el/samples/xml/sax/XMELFilter.java @@ -18,7 +18,7 @@ import java.io.IOException; import java.io.StringReader; -import javax.el.ELContext; +import jakarta.el.ELContext; import org.xml.sax.Attributes; import org.xml.sax.InputSource; From 351296f85ffcbc967e8adccd1e8a935cb78c5d53 Mon Sep 17 00:00:00 2001 From: Dmytro Maidaniuk Date: Sun, 18 Sep 2022 10:55:18 +0300 Subject: [PATCH 2/3] Added GitHub actions --- .github/workflows/main.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..78be5bf --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,26 @@ +name: Java CI with Maven + +on: + push: + branches: + - master + - develop + - feature/* + - bugfix/* + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + - name: Build with Maven + run: mvn clean package From 46a05e9f3c606693594606c1ce96bd6fb648ca8b Mon Sep 17 00:00:00 2001 From: Dmytro Maidaniuk Date: Sun, 18 Sep 2022 11:13:29 +0300 Subject: [PATCH 3/3] Corrected GitHub action's label --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 78be5bf..c067cdc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 8 uses: actions/setup-java@v2 with: java-version: '8'