This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit f0ffcb0b9b9d8328d3223ae6d8b97129c07f4a1e Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Aug 9 15:25:42 2024 +0100 Code clean-up - formatting. No functional change. --- java/org/apache/el/ExpressionFactoryImpl.java | 20 +- java/org/apache/el/MethodExpressionImpl.java | 218 +++++++++------------ java/org/apache/el/MethodExpressionLiteral.java | 12 +- java/org/apache/el/ValueExpressionImpl.java | 103 ++++------ java/org/apache/el/ValueExpressionLiteral.java | 19 +- java/org/apache/el/lang/ELArithmetic.java | 20 +- java/org/apache/el/lang/ELSupport.java | 191 ++++++++---------- java/org/apache/el/lang/EvaluationContext.java | 18 +- java/org/apache/el/lang/ExpressionBuilder.java | 65 +++--- java/org/apache/el/lang/FunctionMapperImpl.java | 13 +- .../el/lang/LambdaExpressionNestedState.java | 13 +- java/org/apache/el/lang/VariableMapperImpl.java | 10 +- java/org/apache/el/parser/ArithmeticNode.java | 3 +- java/org/apache/el/parser/AstAnd.java | 3 +- java/org/apache/el/parser/AstBracketSuffix.java | 3 +- java/org/apache/el/parser/AstChoice.java | 6 +- .../apache/el/parser/AstCompositeExpression.java | 6 +- .../apache/el/parser/AstDeferredExpression.java | 12 +- java/org/apache/el/parser/AstDiv.java | 3 +- java/org/apache/el/parser/AstDotSuffix.java | 6 +- .../org/apache/el/parser/AstDynamicExpression.java | 12 +- java/org/apache/el/parser/AstEmpty.java | 6 +- java/org/apache/el/parser/AstEqual.java | 3 +- java/org/apache/el/parser/AstFalse.java | 3 +- java/org/apache/el/parser/AstFloatingPoint.java | 6 +- java/org/apache/el/parser/AstFunction.java | 3 +- java/org/apache/el/parser/AstGreaterThan.java | 3 +- java/org/apache/el/parser/AstGreaterThanEqual.java | 3 +- java/org/apache/el/parser/AstIdentifier.java | 44 ++--- java/org/apache/el/parser/AstInteger.java | 6 +- java/org/apache/el/parser/AstLambdaExpression.java | 31 ++- java/org/apache/el/parser/AstLessThan.java | 3 +- java/org/apache/el/parser/AstLessThanEqual.java | 3 +- .../org/apache/el/parser/AstLiteralExpression.java | 2 +- java/org/apache/el/parser/AstMapEntry.java | 9 +- java/org/apache/el/parser/AstMinus.java | 3 +- java/org/apache/el/parser/AstMod.java | 3 +- java/org/apache/el/parser/AstMult.java | 3 +- java/org/apache/el/parser/AstNegative.java | 6 +- java/org/apache/el/parser/AstNot.java | 6 +- java/org/apache/el/parser/AstNotEqual.java | 3 +- java/org/apache/el/parser/AstNull.java | 6 +- java/org/apache/el/parser/AstOr.java | 3 +- java/org/apache/el/parser/AstPlus.java | 3 +- java/org/apache/el/parser/AstString.java | 6 +- java/org/apache/el/parser/AstTrue.java | 3 +- java/org/apache/el/parser/AstValue.java | 99 ++++------ java/org/apache/el/parser/BooleanNode.java | 3 +- java/org/apache/el/stream/Stream.java | 26 +-- .../org/apache/el/stream/StreamELResolverImpl.java | 9 +- java/org/apache/el/util/ConcurrentCache.java | 2 +- java/org/apache/el/util/ExceptionUtils.java | 11 +- java/org/apache/el/util/JreCompat.java | 10 +- java/org/apache/el/util/ReflectionUtil.java | 148 +++++++------- java/org/apache/el/util/Validation.java | 31 ++- 55 files changed, 494 insertions(+), 771 deletions(-) diff --git a/java/org/apache/el/ExpressionFactoryImpl.java b/java/org/apache/el/ExpressionFactoryImpl.java index 3a6690a7ab..8ac4f3fdaf 100644 --- a/java/org/apache/el/ExpressionFactoryImpl.java +++ b/java/org/apache/el/ExpressionFactoryImpl.java @@ -34,7 +34,7 @@ import org.apache.el.util.MessageFactory; * * @author Jacob Hookom [ja...@hookom.net] */ -@aQute.bnd.annotation.spi.ServiceProvider(value=ExpressionFactory.class) +@aQute.bnd.annotation.spi.ServiceProvider(value = ExpressionFactory.class) public class ExpressionFactoryImpl extends ExpressionFactory { static { @@ -47,31 +47,25 @@ public class ExpressionFactoryImpl extends ExpressionFactory { } @Override - public MethodExpression createMethodExpression(ELContext context, - String expression, Class<?> expectedReturnType, + public MethodExpression createMethodExpression(ELContext context, String expression, Class<?> expectedReturnType, Class<?>[] expectedParamTypes) { ExpressionBuilder builder = new ExpressionBuilder(expression, context); - return builder.createMethodExpression(expectedReturnType, - expectedParamTypes); + return builder.createMethodExpression(expectedReturnType, expectedParamTypes); } @Override - public ValueExpression createValueExpression(ELContext context, - String expression, Class<?> expectedType) { + public ValueExpression createValueExpression(ELContext context, String expression, Class<?> expectedType) { if (expectedType == null) { - throw new NullPointerException(MessageFactory - .get("error.value.expectedType")); + throw new NullPointerException(MessageFactory.get("error.value.expectedType")); } ExpressionBuilder builder = new ExpressionBuilder(expression, context); return builder.createValueExpression(expectedType); } @Override - public ValueExpression createValueExpression(Object instance, - Class<?> expectedType) { + public ValueExpression createValueExpression(Object instance, Class<?> expectedType) { if (expectedType == null) { - throw new NullPointerException(MessageFactory - .get("error.value.expectedType")); + throw new NullPointerException(MessageFactory.get("error.value.expectedType")); } return new ValueExpressionLiteral(instance, expectedType); } diff --git a/java/org/apache/el/MethodExpressionImpl.java b/java/org/apache/el/MethodExpressionImpl.java index fbedd4d7b1..ebb0e0bc0e 100644 --- a/java/org/apache/el/MethodExpressionImpl.java +++ b/java/org/apache/el/MethodExpressionImpl.java @@ -38,32 +38,25 @@ import org.apache.el.util.ReflectionUtil; /** * An <code>Expression</code> that refers to a method on an object. - * * <p> - * The {@link javax.el.ExpressionFactory#createMethodExpression} method - * can be used to parse an expression string and return a concrete instance - * of <code>MethodExpression</code> that encapsulates the parsed expression. - * The {@link FunctionMapper} is used at parse time, not evaluation time, - * so one is not needed to evaluate an expression using this class. - * However, the {@link ELContext} is needed at evaluation time.</p> - * - * <p>The {@link #getMethodInfo} and {@link #invoke} methods will evaluate the - * expression each time they are called. The {@link javax.el.ELResolver} in the - * <code>ELContext</code> is used to resolve the top-level variables and to - * determine the behavior of the <code>.</code> and <code>[]</code> - * operators. For any of the two methods, the - * {@link javax.el.ELResolver#getValue} method is used to resolve all properties - * up to but excluding the last one. This provides the <code>base</code> object - * on which the method appears. If the <code>base</code> object is null, a - * <code>NullPointerException</code> must be thrown. At the last resolution, - * the final <code>property</code> is then coerced to a <code>String</code>, - * which provides the name of the method to be found. A method matching the - * name and expected parameters provided at parse time is found and it is - * either queried or invoked (depending on the method called on this - * <code>MethodExpression</code>).</p> - * - * <p>See the notes about comparison, serialization and immutability in - * the {@link javax.el.Expression} javadocs. + * The {@link javax.el.ExpressionFactory#createMethodExpression} method can be used to parse an expression string and + * return a concrete instance of <code>MethodExpression</code> that encapsulates the parsed expression. The + * {@link FunctionMapper} is used at parse time, not evaluation time, so one is not needed to evaluate an expression + * using this class. However, the {@link ELContext} is needed at evaluation time. + * </p> + * <p> + * The {@link #getMethodInfo} and {@link #invoke} methods will evaluate the expression each time they are called. The + * {@link javax.el.ELResolver} in the <code>ELContext</code> is used to resolve the top-level variables and to determine + * the behavior of the <code>.</code> and <code>[]</code> operators. For any of the two methods, the + * {@link javax.el.ELResolver#getValue} method is used to resolve all properties up to but excluding the last one. This + * provides the <code>base</code> object on which the method appears. If the <code>base</code> object is null, a + * <code>NullPointerException</code> must be thrown. At the last resolution, the final <code>property</code> is then + * coerced to a <code>String</code>, which provides the name of the method to be found. A method matching the name and + * expected parameters provided at parse time is found and it is either queried or invoked (depending on the method + * called on this <code>MethodExpression</code>). + * </p> + * <p> + * See the notes about comparison, serialization and immutability in the {@link javax.el.Expression} javadocs. * * @see javax.el.ELResolver * @see javax.el.Expression @@ -72,8 +65,7 @@ import org.apache.el.util.ReflectionUtil; * * @author Jacob Hookom [ja...@hookom.net] */ -public final class MethodExpressionImpl extends MethodExpression implements - Externalizable { +public final class MethodExpressionImpl extends MethodExpression implements Externalizable { private Class<?> expectedType; @@ -91,8 +83,7 @@ public final class MethodExpressionImpl extends MethodExpression implements super(); } - public MethodExpressionImpl(String expr, Node node, - FunctionMapper fnMapper, VariableMapper varMapper, + public MethodExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType, Class<?>[] paramTypes) { super(); this.expr = expr; @@ -104,53 +95,40 @@ public final class MethodExpressionImpl extends MethodExpression implements } /** - * Determines whether the specified object is equal to this - * <code>Expression</code>. - * + * Determines whether the specified object is equal to this <code>Expression</code>. * <p> - * The result is <code>true</code> if and only if the argument is not - * <code>null</code>, is an <code>Expression</code> object that is the - * of the same type (<code>ValueExpression</code> or - * <code>MethodExpression</code>), and has an identical parsed - * representation. + * The result is <code>true</code> if and only if the argument is not <code>null</code>, is an + * <code>Expression</code> object that is the of the same type (<code>ValueExpression</code> or + * <code>MethodExpression</code>), and has an identical parsed representation. * </p> - * * <p> - * Note that two expressions can be equal if their expression Strings are - * different. For example, <code>${fn1:foo()}</code> and - * <code>${fn2:foo()}</code> are equal if their corresponding - * <code>FunctionMapper</code>s mapped <code>fn1:foo</code> and - * <code>fn2:foo</code> to the same method. + * Note that two expressions can be equal if their expression Strings are different. For example, + * <code>${fn1:foo()}</code> and <code>${fn2:foo()}</code> are equal if their corresponding + * <code>FunctionMapper</code>s mapped <code>fn1:foo</code> and <code>fn2:foo</code> to the same method. * </p> * - * @param obj - * the <code>Object</code> to test for equality. - * @return <code>true</code> if <code>obj</code> equals this - * <code>Expression</code>; <code>false</code> otherwise. + * @param obj the <code>Object</code> to test for equality. + * + * @return <code>true</code> if <code>obj</code> equals this <code>Expression</code>; <code>false</code> otherwise. + * * @see java.util.Hashtable * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { - return (obj instanceof MethodExpressionImpl && obj.hashCode() == this - .hashCode()); + return (obj instanceof MethodExpressionImpl && obj.hashCode() == this.hashCode()); } /** - * Returns the original String used to create this <code>Expression</code>, - * unmodified. - * + * Returns the original String used to create this <code>Expression</code>, unmodified. * <p> - * This is used for debugging purposes but also for the purposes of - * comparison (e.g. to ensure the expression in a configuration file has not - * changed). + * This is used for debugging purposes but also for the purposes of comparison (e.g. to ensure the expression in a + * configuration file has not changed). * </p> - * * <p> - * This method does not provide sufficient information to re-create an - * expression. Two different expressions can have exactly the same - * expression string but different function mappings. Serialization should - * be used to save and restore the state of an <code>Expression</code>. + * This method does not provide sufficient information to re-create an expression. Two different expressions can + * have exactly the same expression string but different function mappings. Serialization should be used to save and + * restore the state of an <code>Expression</code>. * </p> * * @return The original expression String. @@ -163,34 +141,30 @@ public final class MethodExpressionImpl extends MethodExpression implements } /** - * Evaluates the expression relative to the provided context, and returns - * information about the actual referenced method. + * Evaluates the expression relative to the provided context, and returns information about the actual referenced + * method. + * + * @param context The context of this evaluation + * + * @return an instance of <code>MethodInfo</code> containing information about the method the expression evaluated + * to. + * + * @throws NullPointerException if context is <code>null</code> or the base object is <code>null</code> on the + * last resolution. + * @throws PropertyNotFoundException if one of the property resolutions failed because a specified variable or + * property does not exist or is not readable. + * @throws MethodNotFoundException if no suitable method can be found. + * @throws ELException if an exception was thrown while performing property or variable resolution. + * The thrown exception must be included as the cause property of this + * exception, if available. * - * @param context - * The context of this evaluation - * @return an instance of <code>MethodInfo</code> containing information - * about the method the expression evaluated to. - * @throws NullPointerException - * if context is <code>null</code> or the base object is - * <code>null</code> on the last resolution. - * @throws PropertyNotFoundException - * if one of the property resolutions failed because a specified - * variable or property does not exist or is not readable. - * @throws MethodNotFoundException - * if no suitable method can be found. - * @throws ELException - * if an exception was thrown while performing property or - * variable resolution. The thrown exception must be included as - * the cause property of this exception, if available. * @see javax.el.MethodExpression#getMethodInfo(javax.el.ELContext) */ @Override public MethodInfo getMethodInfo(ELContext context) - throws PropertyNotFoundException, MethodNotFoundException, - ELException { + throws PropertyNotFoundException, MethodNotFoundException, ELException { Node n = this.getNode(); - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); ctx.notifyBeforeEvaluation(getExpressionString()); MethodInfo result = n.getMethodInfo(ctx, this.paramTypes); ctx.notifyAfterEvaluation(getExpressionString()); @@ -206,17 +180,15 @@ public final class MethodExpressionImpl extends MethodExpression implements /** * Returns the hash code for this <code>Expression</code>. - * * <p> - * See the note in the {@link #equals} method on how two expressions can be - * equal if their expression Strings are different. Recall that if two - * objects are equal according to the <code>equals(Object)</code> method, - * then calling the <code>hashCode</code> method on each of the two - * objects must produce the same integer result. Implementations must take - * special note and implement <code>hashCode</code> correctly. + * See the note in the {@link #equals} method on how two expressions can be equal if their expression Strings are + * different. Recall that if two objects are equal according to the <code>equals(Object)</code> method, then calling + * the <code>hashCode</code> method on each of the two objects must produce the same integer result. Implementations + * must take special note and implement <code>hashCode</code> correctly. * </p> * * @return The hash code for this <code>Expression</code>. + * * @see #equals * @see java.util.Hashtable * @see java.lang.Object#hashCode() @@ -227,41 +199,32 @@ public final class MethodExpressionImpl extends MethodExpression implements } /** - * 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. + * Evaluates the expression relative to the provided context, invokes the method that was found using the supplied + * parameters, and returns the result of the method invocation. + * + * @param context The context of this evaluation. + * @param params The parameters to pass to the method, or <code>null</code> if no parameters. + * + * @return the result of the method invocation (<code>null</code> if the method has a <code>void</code> return + * type). + * + * @throws NullPointerException if context is <code>null</code> or the base object is <code>null</code> on the + * last resolution. + * @throws PropertyNotFoundException if one of the property resolutions failed because a specified variable or + * property does not exist or is not readable. + * @throws MethodNotFoundException if no suitable method can be found. + * @throws ELException if an exception was thrown while performing property or variable resolution. + * The thrown exception must be included as the cause property of this + * exception, if available. If the exception thrown is an + * <code>InvocationTargetException</code>, extract its <code>cause</code> and + * pass it to the <code>ELException</code> constructor. * - * @param context - * The context of this evaluation. - * @param params - * The parameters to pass to the method, or <code>null</code> - * if no parameters. - * @return the result of the method invocation (<code>null</code> if the - * method has a <code>void</code> return type). - * @throws NullPointerException - * if context is <code>null</code> or the base object is - * <code>null</code> on the last resolution. - * @throws PropertyNotFoundException - * if one of the property resolutions failed because a specified - * variable or property does not exist or is not readable. - * @throws MethodNotFoundException - * if no suitable method can be found. - * @throws ELException - * if an exception was thrown while performing property or - * variable resolution. The thrown exception must be included as - * the cause property of this exception, if available. If the - * exception thrown is an <code>InvocationTargetException</code>, - * extract its <code>cause</code> and pass it to the - * <code>ELException</code> constructor. - * @see javax.el.MethodExpression#invoke(javax.el.ELContext, - * java.lang.Object[]) + * @see javax.el.MethodExpression#invoke(javax.el.ELContext, java.lang.Object[]) */ @Override public Object invoke(ELContext context, Object[] params) - throws PropertyNotFoundException, MethodNotFoundException, - ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + throws PropertyNotFoundException, MethodNotFoundException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); ctx.notifyBeforeEvaluation(getExpressionString()); Object result = this.getNode().invoke(ctx, this.paramTypes, params); ctx.notifyAfterEvaluation(getExpressionString()); @@ -269,15 +232,13 @@ public final class MethodExpressionImpl extends MethodExpression implements } @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.expr = in.readUTF(); String type = in.readUTF(); if (!type.isEmpty()) { this.expectedType = ReflectionUtil.forName(type); } - this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in - .readObject())); + this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in.readObject())); this.fnMapper = (FunctionMapper) in.readObject(); this.varMapper = (VariableMapper) in.readObject(); } @@ -285,8 +246,7 @@ public final class MethodExpressionImpl extends MethodExpression implements @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(this.expr); - out.writeUTF((this.expectedType != null) ? this.expectedType.getName() - : ""); + out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : ""); out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes)); out.writeObject(this.fnMapper); out.writeObject(this.varMapper); @@ -304,10 +264,8 @@ public final class MethodExpressionImpl extends MethodExpression implements } /** - * @since EL 2.2 - * Note: The spelling mistake is deliberate. - * isParmetersProvided() - Specification definition - * isParametersProvided() - Corrected spelling + * @since EL 2.2 Note: The spelling mistake is deliberate. isParmetersProvided() - Specification definition + * isParametersProvided() - Corrected spelling */ @Override public boolean isParmetersProvided() { diff --git a/java/org/apache/el/MethodExpressionLiteral.java b/java/org/apache/el/MethodExpressionLiteral.java index 85a7c125af..0735bad63f 100644 --- a/java/org/apache/el/MethodExpressionLiteral.java +++ b/java/org/apache/el/MethodExpressionLiteral.java @@ -41,8 +41,7 @@ public class MethodExpressionLiteral extends MethodExpression implements Externa // do nothing } - public MethodExpressionLiteral(String expr, Class<?> expectedType, - Class<?>[] paramTypes) { + public MethodExpressionLiteral(String expr, Class<?> expectedType, Class<?>[] paramTypes) { this.expr = expr; this.expectedType = expectedType; this.paramTypes = paramTypes; @@ -51,8 +50,7 @@ public class MethodExpressionLiteral extends MethodExpression implements Externa @Override public MethodInfo getMethodInfo(ELContext context) throws ELException { context.notifyBeforeEvaluation(getExpressionString()); - MethodInfo result = - new MethodInfo(this.expr, this.expectedType, this.paramTypes); + MethodInfo result = new MethodInfo(this.expr, this.expectedType, this.paramTypes); context.notifyAfterEvaluation(getExpressionString()); return result; } @@ -97,15 +95,13 @@ public class MethodExpressionLiteral extends MethodExpression implements Externa if (!type.isEmpty()) { this.expectedType = ReflectionUtil.forName(type); } - this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in - .readObject())); + this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in.readObject())); } @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(this.expr); - out.writeUTF((this.expectedType != null) ? this.expectedType.getName() - : ""); + out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : ""); out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes)); } } diff --git a/java/org/apache/el/ValueExpressionImpl.java b/java/org/apache/el/ValueExpressionImpl.java index 1f95cd805d..ff63445c52 100644 --- a/java/org/apache/el/ValueExpressionImpl.java +++ b/java/org/apache/el/ValueExpressionImpl.java @@ -39,43 +39,32 @@ import org.apache.el.util.ReflectionUtil; /** * An <code>Expression</code> that can get or set a value. - * * <p> - * In previous incarnations of this API, expressions could only be read. - * <code>ValueExpression</code> 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. <code>"${1+1}"</code> or - * <code>"${firstName} ${lastName}"</code>). See the EL Specification for - * details. Expressions that cannot be used as l-values must always return - * <code>true</code> from <code>isReadOnly()</code>. + * In previous incarnations of this API, expressions could only be read. <code>ValueExpression</code> 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. <code>"${1+1}"</code> or <code>"${firstName} ${lastName}"</code>). See the EL + * Specification for details. Expressions that cannot be used as l-values must always return <code>true</code> from + * <code>isReadOnly()</code>. * </p> - * * <p> - * The {@link javax.el.ExpressionFactory#createValueExpression} method - * can be used to parse an expression string and return a concrete instance - * of <code>ValueExpression</code> that encapsulates the parsed expression. - * The {@link FunctionMapper} is used at parse time, not evaluation time, - * so one is not needed to evaluate an expression using this class. - * However, the {@link ELContext} is needed at evaluation time.</p> - * - * <p>The {@link #getValue}, {@link #setValue}, {@link #isReadOnly} and - * {@link #getType} methods will evaluate the expression each time they are - * called. The {@link javax.el.ELResolver} in the <code>ELContext</code> is used - * to resolve the top-level variables and to determine the behavior of the - * <code>.</code> and <code>[]</code> operators. For any of the four methods, - * the {@link javax.el.ELResolver#getValue} method is used to resolve all - * properties up to but excluding the last one. This provides the - * <code>base</code> object. At the last resolution, the - * <code>ValueExpression</code> will call the corresponding - * {@link javax.el.ELResolver#getValue}, {@link javax.el.ELResolver#setValue}, - * {@link javax.el.ELResolver#isReadOnly} or {@link javax.el.ELResolver#getType} + * The {@link javax.el.ExpressionFactory#createValueExpression} method can be used to parse an expression string and + * return a concrete instance of <code>ValueExpression</code> that encapsulates the parsed expression. The + * {@link FunctionMapper} is used at parse time, not evaluation time, so one is not needed to evaluate an expression + * using this class. However, the {@link ELContext} is needed at evaluation time. + * </p> + * <p> + * The {@link #getValue}, {@link #setValue}, {@link #isReadOnly} and {@link #getType} methods will evaluate the + * expression each time they are called. The {@link javax.el.ELResolver} in the <code>ELContext</code> is used to + * resolve the top-level variables and to determine the behavior of the <code>.</code> and <code>[]</code> operators. + * For any of the four methods, the {@link javax.el.ELResolver#getValue} method is used to resolve all properties up to + * but excluding the last one. This provides the <code>base</code> object. At the last resolution, the + * <code>ValueExpression</code> will call the corresponding {@link javax.el.ELResolver#getValue}, + * {@link javax.el.ELResolver#setValue}, {@link javax.el.ELResolver#isReadOnly} or {@link javax.el.ELResolver#getType} * method, depending on which was called on the <code>ValueExpression</code>. * </p> - * - * <p>See the notes about comparison, serialization and immutability in - * the {@link javax.el.Expression} javadocs. + * <p> + * See the notes about comparison, serialization and immutability in the {@link javax.el.Expression} javadocs. * * @see javax.el.ELResolver * @see javax.el.Expression @@ -84,8 +73,7 @@ import org.apache.el.util.ReflectionUtil; * * @author Jacob Hookom [ja...@hookom.net] */ -public final class ValueExpressionImpl extends ValueExpression implements - Externalizable { +public final class ValueExpressionImpl extends ValueExpression implements Externalizable { private Class<?> expectedType; @@ -101,8 +89,8 @@ public final class ValueExpressionImpl extends ValueExpression implements super(); } - public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, - VariableMapper varMapper, Class<?> expectedType) { + public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, + Class<?> expectedType) { this.expr = expr; this.node = node; this.fnMapper = fnMapper; @@ -128,12 +116,10 @@ public final class ValueExpressionImpl extends ValueExpression implements } /** - * Returns the type the result of the expression will be coerced to after - * evaluation. + * Returns the type the result of the expression will be coerced to after evaluation. * - * @return the <code>expectedType</code> passed to the - * <code>ExpressionFactory.createValueExpression</code> method - * that created this <code>ValueExpression</code>. + * @return the <code>expectedType</code> passed to the <code>ExpressionFactory.createValueExpression</code> method + * that created this <code>ValueExpression</code>. * * @see javax.el.Expression#getExpressionString() */ @@ -150,10 +136,8 @@ public final class ValueExpressionImpl extends ValueExpression implements } @Override - public Class<?> getType(ELContext context) throws PropertyNotFoundException, - ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + public Class<?> getType(ELContext context) throws PropertyNotFoundException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); Class<?> result = this.getNode().getType(ctx); context.notifyAfterEvaluation(getExpressionString()); @@ -161,10 +145,8 @@ public final class ValueExpressionImpl extends ValueExpression implements } @Override - public Object getValue(ELContext context) throws PropertyNotFoundException, - ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + public Object getValue(ELContext context) throws PropertyNotFoundException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); Object value = this.getNode().getValue(ctx); if (this.expectedType != null) { @@ -189,10 +171,8 @@ public final class ValueExpressionImpl extends ValueExpression implements } @Override - public boolean isReadOnly(ELContext context) - throws PropertyNotFoundException, ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + public boolean isReadOnly(ELContext context) throws PropertyNotFoundException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); boolean result = this.getNode().isReadOnly(ctx); context.notifyAfterEvaluation(getExpressionString()); @@ -200,8 +180,7 @@ public final class ValueExpressionImpl extends ValueExpression implements } @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.expr = in.readUTF(); String type = in.readUTF(); if (!type.isEmpty()) { @@ -213,10 +192,8 @@ public final class ValueExpressionImpl extends ValueExpression implements @Override public void setValue(ELContext context, Object value) - throws PropertyNotFoundException, PropertyNotWritableException, - ELException { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + throws PropertyNotFoundException, PropertyNotWritableException, ELException { + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); this.getNode().setValue(ctx, value); context.notifyAfterEvaluation(getExpressionString()); @@ -225,21 +202,19 @@ public final class ValueExpressionImpl extends ValueExpression implements @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF(this.expr); - out.writeUTF((this.expectedType != null) ? this.expectedType.getName() - : ""); + out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : ""); out.writeObject(this.fnMapper); out.writeObject(this.varMapper); } @Override public String toString() { - return "ValueExpression["+this.expr+"]"; + return "ValueExpression[" + this.expr + "]"; } @Override public ValueReference getValueReference(ELContext context) { - EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, - this.varMapper); + EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper); context.notifyBeforeEvaluation(getExpressionString()); ValueReference result = this.getNode().getValueReference(ctx); context.notifyAfterEvaluation(getExpressionString()); diff --git a/java/org/apache/el/ValueExpressionLiteral.java b/java/org/apache/el/ValueExpressionLiteral.java index 8b5febfecb..f562f398e3 100644 --- a/java/org/apache/el/ValueExpressionLiteral.java +++ b/java/org/apache/el/ValueExpressionLiteral.java @@ -29,8 +29,7 @@ import org.apache.el.util.MessageFactory; import org.apache.el.util.ReflectionUtil; -public final class ValueExpressionLiteral extends ValueExpression implements - Externalizable { +public final class ValueExpressionLiteral extends ValueExpression implements Externalizable { private static final long serialVersionUID = 1L; @@ -64,8 +63,7 @@ public final class ValueExpressionLiteral extends ValueExpression implements @Override public void setValue(ELContext context, Object value) { context.notifyBeforeEvaluation(getExpressionString()); - throw new PropertyNotWritableException(MessageFactory.get( - "error.value.literal.write", this.value)); + throw new PropertyNotWritableException(MessageFactory.get("error.value.literal.write", this.value)); } @Override @@ -98,13 +96,12 @@ public final class ValueExpressionLiteral extends ValueExpression implements @Override public boolean equals(Object obj) { - return (obj instanceof ValueExpressionLiteral && this - .equals((ValueExpressionLiteral) obj)); + return (obj instanceof ValueExpressionLiteral && this.equals((ValueExpressionLiteral) obj)); } public boolean equals(ValueExpressionLiteral ve) { - return (ve != null && (this.value != null && ve.value != null && (this.value == ve.value || this.value - .equals(ve.value)))); + return (ve != null && + (this.value != null && ve.value != null && (this.value == ve.value || this.value.equals(ve.value)))); } @Override @@ -120,13 +117,11 @@ public final class ValueExpressionLiteral extends ValueExpression implements @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(this.value); - out.writeUTF((this.expectedType != null) ? this.expectedType.getName() - : ""); + out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : ""); } @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.value = in.readObject(); String type = in.readUTF(); if (!type.isEmpty()) { diff --git a/java/org/apache/el/lang/ELArithmetic.java b/java/org/apache/el/lang/ELArithmetic.java index dc746d19a3..9cf2c9cde7 100644 --- a/java/org/apache/el/lang/ELArithmetic.java +++ b/java/org/apache/el/lang/ELArithmetic.java @@ -27,6 +27,7 @@ import org.apache.el.util.MessageFactory; /** * A helper class of Arithmetic defined by the EL Specification + * * @author Jacob Hookom [ja...@hookom.net] */ public abstract class ELArithmetic { @@ -56,8 +57,7 @@ public abstract class ELArithmetic { @Override protected Number divide(Number num0, Number num1) { - return ((BigDecimal) num0).divide((BigDecimal) num1, - RoundingMode.HALF_UP); + return ((BigDecimal) num0).divide((BigDecimal) num1, RoundingMode.HALF_UP); } @Override @@ -190,13 +190,9 @@ public abstract class ELArithmetic { @Override public boolean matches(Object obj0, Object obj1) { - return (obj0 instanceof Double - || obj1 instanceof Double - || obj0 instanceof Float - || obj1 instanceof Float - || (obj0 instanceof String && ELSupport - .isStringFloat((String) obj0)) || (obj1 instanceof String && ELSupport - .isStringFloat((String) obj1))); + return (obj0 instanceof Double || obj1 instanceof Double || obj0 instanceof Float || + obj1 instanceof Float || (obj0 instanceof String && ELSupport.isStringFloat((String) obj0)) || + (obj1 instanceof String && ELSupport.isStringFloat((String) obj1))); } } @@ -359,10 +355,8 @@ public abstract class ELArithmetic { } public static final boolean isNumberType(final Class<?> type) { - return type == Long.TYPE || type == Double.TYPE || - type == Byte.TYPE || type == Short.TYPE || - type == Integer.TYPE || type == Float.TYPE || - Number.class.isAssignableFrom(type); + return type == Long.TYPE || type == Double.TYPE || type == Byte.TYPE || type == Short.TYPE || + type == Integer.TYPE || type == Float.TYPE || Number.class.isAssignableFrom(type); } protected ELArithmetic() { diff --git a/java/org/apache/el/lang/ELSupport.java b/java/org/apache/el/lang/ELSupport.java index f42034d5f1..d16d33b376 100644 --- a/java/org/apache/el/lang/ELSupport.java +++ b/java/org/apache/el/lang/ELSupport.java @@ -48,13 +48,10 @@ public class ELSupport { static { String coerceToZeroStr; if (System.getSecurityManager() != null) { - coerceToZeroStr = AccessController.doPrivileged( - (PrivilegedAction<String>) () -> System.getProperty( - "org.apache.el.parser.COERCE_TO_ZERO", "false") - ); + coerceToZeroStr = AccessController.doPrivileged((PrivilegedAction<String>) () -> System + .getProperty("org.apache.el.parser.COERCE_TO_ZERO", "false")); } else { - coerceToZeroStr = System.getProperty( - "org.apache.el.parser.COERCE_TO_ZERO", "false"); + coerceToZeroStr = System.getProperty("org.apache.el.parser.COERCE_TO_ZERO", "false"); } COERCE_TO_ZERO = Boolean.parseBoolean(coerceToZeroStr); } @@ -63,18 +60,17 @@ public class ELSupport { /** * Compare two objects, after coercing to the same type if appropriate. * <p> - * If the objects are identical, or they are equal according to - * {@link #equals(ELContext, Object, Object)} then return 0. + * If the objects are identical, or they are equal according to {@link #equals(ELContext, Object, Object)} then + * return 0. * <p> - * If either object is a BigDecimal, then coerce both to BigDecimal first. - * Similarly for Double(Float), BigInteger, and Long(Integer, Char, Short, Byte). + * If either object is a BigDecimal, then coerce both to BigDecimal first. Similarly for Double(Float), BigInteger, + * and Long(Integer, Char, Short, Byte). * <p> - * Otherwise, check that the first object is an instance of Comparable, and compare - * against the second object. If that is null, return 1, otherwise - * return the result of comparing against the second object. + * Otherwise, check that the first object is an instance of Comparable, and compare against the second object. If + * that is null, return 1, otherwise return the result of comparing against the second object. * <p> - * Similarly, if the second object is Comparable, if the first is null, return -1, - * else return the result of comparing against the first object. + * Similarly, if the second object is Comparable, if the first is null, return -1, else return the result of + * comparing against the first object. * <p> * A null object is considered as: * <ul> @@ -83,15 +79,16 @@ public class ELSupport { * <li>Otherwise null is considered to be lower than anything else.</li> * </ul> * - * @param ctx the context in which this comparison is taking place + * @param ctx the context in which this comparison is taking place * @param obj0 first object * @param obj1 second object + * * @return -1, 0, or 1 if this object is less than, equal to, or greater than val. - * @throws ELException if neither object is Comparable + * + * @throws ELException if neither object is Comparable * @throws ClassCastException if the objects are not mutually comparable */ - public static final int compare(final ELContext ctx, final Object obj0, final Object obj1) - throws ELException { + public static final int compare(final ELContext ctx, final Object obj0, final Object obj1) throws ELException { if (obj0 == obj1 || equals(ctx, obj0, obj1)) { return 0; } @@ -144,14 +141,15 @@ public class ELSupport { * <p> * Otherwise default to using Object.equals(). * - * @param ctx the context in which this equality test is taking place + * @param ctx the context in which this equality test is taking place * @param obj0 the first object * @param obj1 the second object + * * @return true if the objects are equal + * * @throws ELException if one of the coercion fails */ - public static final boolean equals(final ELContext ctx, final Object obj0, final Object obj1) - throws ELException { + public static final boolean equals(final ELContext ctx, final Object obj0, final Object obj1) throws ELException { if (obj0 == obj1) { return true; } else if (obj0 == null || obj1 == null) { @@ -168,7 +166,7 @@ public class ELSupport { BigInteger bi0 = (BigInteger) coerceToNumber(ctx, obj0, BigInteger.class); BigInteger bi1 = (BigInteger) coerceToNumber(ctx, obj1, BigInteger.class); return bi0.equals(bi1); - } else if (isLongOp(obj0, obj1)) { + } else if (isLongOp(obj0, obj1)) { Long l0 = (Long) coerceToNumber(ctx, obj0, Long.class); Long l1 = (Long) coerceToNumber(ctx, obj1, Long.class); return l0.equals(l1); @@ -187,8 +185,8 @@ public class ELSupport { } /* - * Going to have to have some casts /raw types somewhere so doing it here keeps them all in one place. There might - * be a neater / better solution but I couldn't find it. + * Going to have to have some casts /raw types somewhere so doing it here keeps them all in one place. There might + * be a neater / better solution but I couldn't find it. */ @SuppressWarnings("unchecked") public static final Enum<?> coerceToEnum(final ELContext ctx, final Object obj, @@ -214,32 +212,31 @@ public class ELSupport { } if (!(obj instanceof String)) { - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } Enum<?> result; try { - result = Enum.valueOf(type, (String) obj); + result = Enum.valueOf(type, (String) obj); } catch (IllegalArgumentException iae) { - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } return result; } /** - * Convert an object to Boolean. - * Null and empty string are false. - * @param ctx the context in which this conversion is taking place - * @param obj the object to convert - * @param primitive is the target a primitive in which case coercion to null - * is not permitted + * Convert an object to Boolean. Null and empty string are false. + * + * @param ctx the context in which this conversion is taking place + * @param obj the object to convert + * @param primitive is the target a primitive in which case coercion to null is not permitted + * * @return the Boolean value of the object + * * @throws ELException if object is not Boolean or String */ - public static final Boolean coerceToBoolean(final ELContext ctx, final Object obj, - boolean primitive) throws ELException { + public static final Boolean coerceToBoolean(final ELContext ctx, final Object obj, boolean primitive) + throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); @@ -269,12 +266,10 @@ public class ELSupport { return Boolean.valueOf((String) obj); } - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), Boolean.class)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), Boolean.class)); } - private static Character coerceToCharacter(final ELContext ctx, final Object obj) - throws ELException { + private static Character coerceToCharacter(final ELContext ctx, final Object obj) throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); @@ -302,12 +297,10 @@ public class ELSupport { return (Character) obj; } - throw new ELException(MessageFactory.get("error.convert", - obj, objType, Character.class)); + throw new ELException(MessageFactory.get("error.convert", obj, objType, Character.class)); } - protected static final Number coerceToNumber(final Number number, - final Class<?> type) throws ELException { + protected static final Number coerceToNumber(final Number number, final Class<?> type) throws ELException { if (Long.TYPE == type || Long.class.equals(type)) { return Long.valueOf(number.longValue()); } @@ -348,12 +341,11 @@ public class ELSupport { return number; } - throw new ELException(MessageFactory.get("error.convert", - number, number.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", number, number.getClass(), type)); } - public static final Number coerceToNumber(final ELContext ctx, final Object obj, - final Class<?> type) throws ELException { + public static final Number coerceToNumber(final ELContext ctx, final Object obj, final Class<?> type) + throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); @@ -384,89 +376,79 @@ public class ELSupport { } if (obj instanceof Character) { - return coerceToNumber(Short.valueOf((short) ((Character) obj) - .charValue()), type); + return coerceToNumber(Short.valueOf((short) ((Character) obj).charValue()), type); } - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } - protected static final Number coerceToNumber(final String val, - final Class<?> type) throws ELException { + protected static final Number coerceToNumber(final String val, final Class<?> type) throws ELException { if (Long.TYPE == type || Long.class.equals(type)) { try { return Long.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Integer.TYPE == type || Integer.class.equals(type)) { try { return Integer.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Double.TYPE == type || Double.class.equals(type)) { try { return Double.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (BigInteger.class.equals(type)) { try { return new BigInteger(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (BigDecimal.class.equals(type)) { try { return new BigDecimal(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Byte.TYPE == type || Byte.class.equals(type)) { try { return Byte.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Short.TYPE == type || Short.class.equals(type)) { try { return Short.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } if (Float.TYPE == type || Float.class.equals(type)) { try { return Float.valueOf(val); } catch (NumberFormatException nfe) { - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } } - throw new ELException(MessageFactory.get("error.convert", - val, String.class, type)); + throw new ELException(MessageFactory.get("error.convert", val, String.class, type)); } /** * Coerce an object to a string. + * * @param ctx the context in which this conversion is taking place * @param obj the object to convert + * * @return the String value of the object */ public static final String coerceToString(final ELContext ctx, final Object obj) { @@ -502,8 +484,8 @@ public class ELSupport { } } - public static final Object coerceToType(final ELContext ctx, final Object obj, - final Class<?> type) throws ELException { + public static final Object coerceToType(final ELContext ctx, final Object obj, final Class<?> type) + throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); @@ -517,14 +499,12 @@ public class ELSupport { } } - if (type == null || Object.class.equals(type) || - (obj != null && type.isAssignableFrom(obj.getClass()))) { + if (type == null || Object.class.equals(type) || (obj != null && type.isAssignableFrom(obj.getClass()))) { return obj; } if (!COERCE_TO_ZERO) { - if (obj == null && !type.isPrimitive() && - !String.class.isAssignableFrom(type)) { + if (obj == null && !type.isPrimitive() && !String.class.isAssignableFrom(type)) { return null; } } @@ -556,8 +536,7 @@ public class ELSupport { if (str.isEmpty()) { return null; } - throw new ELException(MessageFactory.get("error.convert", obj, - obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } else { try { editor.setAsText(str); @@ -566,16 +545,14 @@ public class ELSupport { if (str.isEmpty()) { return null; } - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type), e); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type), e); } } } // Handle special case because the syntax for the empty set is the same // for an empty map. The parser will always parse {} as an empty set. - if (obj instanceof Set && type == Map.class && - ((Set<?>) obj).isEmpty()) { + if (obj instanceof Set && type == Map.class && ((Set<?>) obj).isEmpty()) { return Collections.EMPTY_MAP; } @@ -584,12 +561,10 @@ public class ELSupport { return coerceToArray(ctx, obj, type); } - throw new ELException(MessageFactory.get("error.convert", - obj, obj.getClass(), type)); + throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } - private static Object coerceToArray(final ELContext ctx, final Object obj, - final Class<?> type) { + private static Object coerceToArray(final ELContext ctx, final Object obj, final Class<?> type) { // Note: Nested arrays will result in nested calls to this method. // Note: Calling method has checked the obj is an array. @@ -609,34 +584,22 @@ public class ELSupport { return result; } - public static final boolean isBigDecimalOp(final Object obj0, - final Object obj1) { + public static final boolean isBigDecimalOp(final Object obj0, final Object obj1) { return (obj0 instanceof BigDecimal || obj1 instanceof BigDecimal); } - public static final boolean isBigIntegerOp(final Object obj0, - final Object obj1) { + public static final boolean isBigIntegerOp(final Object obj0, final Object obj1) { return (obj0 instanceof BigInteger || obj1 instanceof BigInteger); } public static final boolean isDoubleOp(final Object obj0, final Object obj1) { - return (obj0 instanceof Double - || obj1 instanceof Double - || obj0 instanceof Float - || obj1 instanceof Float); + return (obj0 instanceof Double || obj1 instanceof Double || obj0 instanceof Float || obj1 instanceof Float); } public static final boolean isLongOp(final Object obj0, final Object obj1) { - return (obj0 instanceof Long - || obj1 instanceof Long - || obj0 instanceof Integer - || obj1 instanceof Integer - || obj0 instanceof Character - || obj1 instanceof Character - || obj0 instanceof Short - || obj1 instanceof Short - || obj0 instanceof Byte - || obj1 instanceof Byte); + return (obj0 instanceof Long || obj1 instanceof Long || obj0 instanceof Integer || obj1 instanceof Integer || + obj0 instanceof Character || obj1 instanceof Character || obj0 instanceof Short || + obj1 instanceof Short || obj0 instanceof Byte || obj1 instanceof Byte); } public static final boolean isStringFloat(final String str) { @@ -644,12 +607,12 @@ public class ELSupport { if (len > 1) { for (int i = 0; i < len; i++) { switch (str.charAt(i)) { - case 'E': - return true; - case 'e': - return true; - case '.': - return true; + case 'E': + return true; + case 'e': + return true; + case '.': + return true; } } } diff --git a/java/org/apache/el/lang/EvaluationContext.java b/java/org/apache/el/lang/EvaluationContext.java index f62080f34f..20691f1c43 100644 --- a/java/org/apache/el/lang/EvaluationContext.java +++ b/java/org/apache/el/lang/EvaluationContext.java @@ -39,8 +39,7 @@ public final class EvaluationContext extends ELContext { private LambdaExpressionNestedState lambdaExpressionNestedState; - public EvaluationContext(ELContext elContext, FunctionMapper fnMapper, - VariableMapper varMapper) { + public EvaluationContext(ELContext elContext, FunctionMapper fnMapper, VariableMapper varMapper) { this.elContext = elContext; this.fnMapper = fnMapper; this.varMapper = varMapper; @@ -78,8 +77,7 @@ public final class EvaluationContext extends ELContext { @Override // Can't use Class<?> because API needs to match specification in superclass - public void putContext(@SuppressWarnings("rawtypes") Class key, - Object contextObject) { + public void putContext(@SuppressWarnings("rawtypes") Class key, Object contextObject) { elContext.putContext(key, contextObject); } @@ -91,7 +89,7 @@ public final class EvaluationContext extends ELContext { @Override public Locale getLocale() { return elContext.getLocale(); - } + } @Override public void setLocale(Locale locale) { @@ -144,7 +142,7 @@ public final class EvaluationContext extends ELContext { } @Override - public void enterLambdaScope(Map<String, Object> arguments) { + public void enterLambdaScope(Map<String,Object> arguments) { elContext.enterLambdaScope(arguments); } @@ -181,10 +179,10 @@ public final class EvaluationContext extends ELContext { public void setLambdaExpressionNestedState(LambdaExpressionNestedState lambdaExpressionNestedState) { - if (this.lambdaExpressionNestedState != null) { - // Should never happen - throw new IllegalStateException(MessageFactory.get("error.lambda.wrongNestedState")); - } + if (this.lambdaExpressionNestedState != null) { + // Should never happen + throw new IllegalStateException(MessageFactory.get("error.lambda.wrongNestedState")); + } this.lambdaExpressionNestedState = lambdaExpressionNestedState; } diff --git a/java/org/apache/el/lang/ExpressionBuilder.java b/java/org/apache/el/lang/ExpressionBuilder.java index 69f74b4038..f9eb10be72 100644 --- a/java/org/apache/el/lang/ExpressionBuilder.java +++ b/java/org/apache/el/lang/ExpressionBuilder.java @@ -52,22 +52,20 @@ public final class ExpressionBuilder implements NodeVisitor { private static final SynchronizedStack<ELParser> parserCache = new SynchronizedStack<>(); private static final int CACHE_SIZE; - private static final String CACHE_SIZE_PROP = - "org.apache.el.ExpressionBuilder.CACHE_SIZE"; + private static final String CACHE_SIZE_PROP = "org.apache.el.ExpressionBuilder.CACHE_SIZE"; static { String cacheSizeStr; if (System.getSecurityManager() == null) { cacheSizeStr = System.getProperty(CACHE_SIZE_PROP, "5000"); } else { - cacheSizeStr = AccessController.doPrivileged( - (PrivilegedAction<String>) () -> System.getProperty(CACHE_SIZE_PROP, "5000")); + cacheSizeStr = AccessController + .doPrivileged((PrivilegedAction<String>) () -> System.getProperty(CACHE_SIZE_PROP, "5000")); } CACHE_SIZE = Integer.parseInt(cacheSizeStr); } - private static final ConcurrentCache<String, Node> expressionCache = - new ConcurrentCache<>(CACHE_SIZE); + private static final ConcurrentCache<String,Node> expressionCache = new ConcurrentCache<>(CACHE_SIZE); private FunctionMapper fnMapper; @@ -75,8 +73,7 @@ public final class ExpressionBuilder implements NodeVisitor { private final String expression; - public ExpressionBuilder(String expression, ELContext ctx) - throws ELException { + public ExpressionBuilder(String expression, ELContext ctx) throws ELException { this.expression = expression; FunctionMapper ctxFn = ctx.getFunctionMapper(); @@ -95,8 +92,7 @@ public final class ExpressionBuilder implements NodeVisitor { return n; } - private static Node createNodeInternal(String expr) - throws ELException { + private static Node createNodeInternal(String expr) throws ELException { if (expr == null) { throw new ELException(MessageFactory.get("error.null")); } @@ -128,22 +124,19 @@ public final class ExpressionBuilder implements NodeVisitor { type = child.getClass(); } else { if (!type.equals(child.getClass())) { - throw new ELException(MessageFactory.get( - "error.mixed", expr)); + throw new ELException(MessageFactory.get("error.mixed", expr)); } } } } - if (n instanceof AstDeferredExpression - || n instanceof AstDynamicExpression) { + if (n instanceof AstDeferredExpression || n instanceof AstDynamicExpression) { n = n.jjtGetChild(0); } expressionCache.put(expr, n); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); - throw new ELException( - MessageFactory.get("error.parseFail", expr), t); + throw new ELException(MessageFactory.get("error.parseFail", expr), t); } finally { if (parser != null) { parserCache.push(parser); @@ -174,8 +167,7 @@ public final class ExpressionBuilder implements NodeVisitor { private Node build() throws ELException { Node n = createNodeInternal(this.expression); this.prepare(n); - if (n instanceof AstDeferredExpression - || n instanceof AstDynamicExpression) { + if (n instanceof AstDeferredExpression || n instanceof AstDynamicExpression) { n = n.jjtGetChild(0); } return n; @@ -190,15 +182,13 @@ public final class ExpressionBuilder implements NodeVisitor { Method m = null; if (this.fnMapper != null) { - m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode - .getLocalName()); + m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode.getLocalName()); } // References to variables that refer to lambda expressions will be // parsed as functions. This is handled at runtime but at this point // need to treat it as a variable rather than a function. - if (m == null && this.varMapper != null && - funcNode.getPrefix().length() == 0) { + if (m == null && this.varMapper != null && funcNode.getPrefix().length() == 0) { this.varMapper.resolveVariable(funcNode.getLocalName()); return; } @@ -208,8 +198,7 @@ public final class ExpressionBuilder implements NodeVisitor { } if (m == null) { - throw new ELException(MessageFactory.get( - "error.fnMapper.method", funcNode.getOutputName())); + throw new ELException(MessageFactory.get("error.fnMapper.method", funcNode.getOutputName())); } int methodParameterCount = m.getParameterTypes().length; @@ -217,8 +206,7 @@ public final class ExpressionBuilder implements NodeVisitor { int inputParameterCount = node.jjtGetChild(0).jjtGetNumChildren(); if (m.isVarArgs() && inputParameterCount < methodParameterCount - 1 || !m.isVarArgs() && inputParameterCount != methodParameterCount) { - throw new ELException(MessageFactory.get( - "error.fnMapper.paramcount", funcNode.getOutputName(), + throw new ELException(MessageFactory.get("error.fnMapper.paramcount", funcNode.getOutputName(), "" + methodParameterCount, "" + node.jjtGetChild(0).jjtGetNumChildren())); } } else if (node instanceof AstIdentifier && this.varMapper != null) { @@ -229,35 +217,30 @@ public final class ExpressionBuilder implements NodeVisitor { } } - public ValueExpression createValueExpression(Class<?> expectedType) - throws ELException { + public ValueExpression createValueExpression(Class<?> expectedType) throws ELException { Node n = this.build(); - return new ValueExpressionImpl(this.expression, n, this.fnMapper, - this.varMapper, expectedType); + return new ValueExpressionImpl(this.expression, n, this.fnMapper, this.varMapper, expectedType); } - public MethodExpression createMethodExpression(Class<?> expectedReturnType, - Class<?>[] expectedParamTypes) throws ELException { + public MethodExpression createMethodExpression(Class<?> expectedReturnType, Class<?>[] expectedParamTypes) + throws ELException { Node n = this.build(); if (!n.isParametersProvided() && expectedParamTypes == null) { - throw new NullPointerException(MessageFactory - .get("error.method.nullParms")); + throw new NullPointerException(MessageFactory.get("error.method.nullParms")); } if (n instanceof AstValue || n instanceof AstIdentifier) { - return new MethodExpressionImpl(expression, n, this.fnMapper, - this.varMapper, expectedReturnType, expectedParamTypes); - } else if (n instanceof AstLiteralExpression) { - return new MethodExpressionLiteral(expression, expectedReturnType, + return new MethodExpressionImpl(expression, n, this.fnMapper, this.varMapper, expectedReturnType, expectedParamTypes); + } else if (n instanceof AstLiteralExpression) { + return new MethodExpressionLiteral(expression, expectedReturnType, expectedParamTypes); } else { throw new ELException(MessageFactory.get("error.invalidMethodExpression", expression)); } } /* - * Copied from org.apache.tomcat.util.collections.SynchronizedStack since - * we don't want the EL implementation to depend on the JAR where that - * class resides. + * Copied from org.apache.tomcat.util.collections.SynchronizedStack since we don't want the EL implementation to + * depend on the JAR where that class resides. */ private static class SynchronizedStack<T> { diff --git a/java/org/apache/el/lang/FunctionMapperImpl.java b/java/org/apache/el/lang/FunctionMapperImpl.java index 05c4d86f32..de185d9909 100644 --- a/java/org/apache/el/lang/FunctionMapperImpl.java +++ b/java/org/apache/el/lang/FunctionMapperImpl.java @@ -33,12 +33,11 @@ import org.apache.el.util.ReflectionUtil; /** * @author Jacob Hookom [ja...@hookom.net] */ -public class FunctionMapperImpl extends FunctionMapper implements - Externalizable { +public class FunctionMapperImpl extends FunctionMapper implements Externalizable { private static final long serialVersionUID = 1L; - protected ConcurrentMap<String, Function> functions = new ConcurrentHashMap<>(); + protected ConcurrentMap<String,Function> functions = new ConcurrentHashMap<>(); @Override public Method resolveFunction(String prefix, String localName) { @@ -67,9 +66,8 @@ public class FunctionMapperImpl extends FunctionMapper implements @SuppressWarnings("unchecked") @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { - this.functions = (ConcurrentMap<String, Function>) in.readObject(); + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + this.functions = (ConcurrentMap<String,Function>) in.readObject(); } public static class Function implements Externalizable { @@ -113,8 +111,7 @@ public class FunctionMapperImpl extends FunctionMapper implements } @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.prefix = in.readUTF(); if (this.prefix.isEmpty()) { diff --git a/java/org/apache/el/lang/LambdaExpressionNestedState.java b/java/org/apache/el/lang/LambdaExpressionNestedState.java index f4a4d47c70..ebadaa472f 100644 --- a/java/org/apache/el/lang/LambdaExpressionNestedState.java +++ b/java/org/apache/el/lang/LambdaExpressionNestedState.java @@ -17,16 +17,13 @@ package org.apache.el.lang; /** - * Stores the state required for correct evaluation of lambda expressions. - * Lambda expressions may be nested. Correct evaluation requires knowledge not - * just of the current lambda expression, but also of any nested and nesting + * Stores the state required for correct evaluation of lambda expressions. Lambda expressions may be nested. Correct + * evaluation requires knowledge not just of the current lambda expression, but also of any nested and nesting * expressions. * <p> - * The sets of nodes for parsed expressions are cached and, as a result, a set - * of nodes may be being used by multiple concurrent threads. This means any - * state relating to evaluation cannot be stored in the nodes. State is - * therefore stored in the {@link EvaluationContext} which is created, used for - * a single evaluation and then discarded. + * The sets of nodes for parsed expressions are cached and, as a result, a set of nodes may be being used by multiple + * concurrent threads. This means any state relating to evaluation cannot be stored in the nodes. State is therefore + * stored in the {@link EvaluationContext} which is created, used for a single evaluation and then discarded. */ public final class LambdaExpressionNestedState { diff --git a/java/org/apache/el/lang/VariableMapperImpl.java b/java/org/apache/el/lang/VariableMapperImpl.java index 63b78881cc..898c2cb0af 100644 --- a/java/org/apache/el/lang/VariableMapperImpl.java +++ b/java/org/apache/el/lang/VariableMapperImpl.java @@ -30,7 +30,7 @@ public class VariableMapperImpl extends VariableMapper implements Externalizable private static final long serialVersionUID = 1L; - private Map<String, ValueExpression> vars = new HashMap<>(); + private Map<String,ValueExpression> vars = new HashMap<>(); public VariableMapperImpl() { super(); @@ -42,8 +42,7 @@ public class VariableMapperImpl extends VariableMapper implements Externalizable } @Override - public ValueExpression setVariable(String variable, - ValueExpression expression) { + public ValueExpression setVariable(String variable, ValueExpression expression) { if (expression == null) { return vars.remove(variable); } else { @@ -53,9 +52,8 @@ public class VariableMapperImpl extends VariableMapper implements Externalizable @SuppressWarnings("unchecked") @Override - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { - this.vars = (Map<String, ValueExpression>) in.readObject(); + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + this.vars = (Map<String,ValueExpression>) in.readObject(); } @Override diff --git a/java/org/apache/el/parser/ArithmeticNode.java b/java/org/apache/el/parser/ArithmeticNode.java index b39091529a..8b628444bc 100644 --- a/java/org/apache/el/parser/ArithmeticNode.java +++ b/java/org/apache/el/parser/ArithmeticNode.java @@ -30,8 +30,7 @@ public abstract class ArithmeticNode extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Number.class; } } diff --git a/java/org/apache/el/parser/AstAnd.java b/java/org/apache/el/parser/AstAnd.java index 728c5b2d9c..f0066452f3 100644 --- a/java/org/apache/el/parser/AstAnd.java +++ b/java/org/apache/el/parser/AstAnd.java @@ -31,8 +31,7 @@ public final class AstAnd extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = children[0].getValue(ctx); Boolean b = coerceToBoolean(ctx, obj, true); if (!b.booleanValue()) { diff --git a/java/org/apache/el/parser/AstBracketSuffix.java b/java/org/apache/el/parser/AstBracketSuffix.java index 771f828525..2f616664b0 100644 --- a/java/org/apache/el/parser/AstBracketSuffix.java +++ b/java/org/apache/el/parser/AstBracketSuffix.java @@ -31,8 +31,7 @@ public final class AstBracketSuffix extends SimpleNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.children[0].getValue(ctx); } } diff --git a/java/org/apache/el/parser/AstChoice.java b/java/org/apache/el/parser/AstChoice.java index 314ff7f246..fd35632518 100644 --- a/java/org/apache/el/parser/AstChoice.java +++ b/java/org/apache/el/parser/AstChoice.java @@ -31,15 +31,13 @@ public final class AstChoice extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { Object val = this.getValue(ctx); return (val != null) ? val.getClass() : null; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Boolean b0 = coerceToBoolean(ctx, obj0, true); return this.children[((b0.booleanValue() ? 1 : 2))].getValue(ctx); diff --git a/java/org/apache/el/parser/AstCompositeExpression.java b/java/org/apache/el/parser/AstCompositeExpression.java index a3f2a6269b..0b9b5814ae 100644 --- a/java/org/apache/el/parser/AstCompositeExpression.java +++ b/java/org/apache/el/parser/AstCompositeExpression.java @@ -33,14 +33,12 @@ public final class AstCompositeExpression extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return String.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { StringBuilder sb = new StringBuilder(16); Object obj = null; if (this.children != null) { diff --git a/java/org/apache/el/parser/AstDeferredExpression.java b/java/org/apache/el/parser/AstDeferredExpression.java index 28080ccb3e..14113ec54a 100644 --- a/java/org/apache/el/parser/AstDeferredExpression.java +++ b/java/org/apache/el/parser/AstDeferredExpression.java @@ -31,26 +31,22 @@ public final class AstDeferredExpression extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return this.children[0].getType(ctx); } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.children[0].getValue(ctx); } @Override - public boolean isReadOnly(EvaluationContext ctx) - throws ELException { + public boolean isReadOnly(EvaluationContext ctx) throws ELException { return this.children[0].isReadOnly(ctx); } @Override - public void setValue(EvaluationContext ctx, Object value) - throws ELException { + public void setValue(EvaluationContext ctx, Object value) throws ELException { this.children[0].setValue(ctx, value); } } diff --git a/java/org/apache/el/parser/AstDiv.java b/java/org/apache/el/parser/AstDiv.java index 18ee263a0f..d863798649 100644 --- a/java/org/apache/el/parser/AstDiv.java +++ b/java/org/apache/el/parser/AstDiv.java @@ -32,8 +32,7 @@ public final class AstDiv extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.divide(obj0, obj1); diff --git a/java/org/apache/el/parser/AstDotSuffix.java b/java/org/apache/el/parser/AstDotSuffix.java index adb181a1e8..05b657a40f 100644 --- a/java/org/apache/el/parser/AstDotSuffix.java +++ b/java/org/apache/el/parser/AstDotSuffix.java @@ -33,16 +33,14 @@ public final class AstDotSuffix extends SimpleNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.image; } @Override public void setImage(String image) { if (!Validation.isIdentifier(image)) { - throw new ELException(MessageFactory.get("error.identifier.notjava", - image)); + throw new ELException(MessageFactory.get("error.identifier.notjava", image)); } this.image = image; } diff --git a/java/org/apache/el/parser/AstDynamicExpression.java b/java/org/apache/el/parser/AstDynamicExpression.java index 5f89b963cf..0db0df8104 100644 --- a/java/org/apache/el/parser/AstDynamicExpression.java +++ b/java/org/apache/el/parser/AstDynamicExpression.java @@ -31,26 +31,22 @@ public final class AstDynamicExpression extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return this.children[0].getType(ctx); } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.children[0].getValue(ctx); } @Override - public boolean isReadOnly(EvaluationContext ctx) - throws ELException { + public boolean isReadOnly(EvaluationContext ctx) throws ELException { return this.children[0].isReadOnly(ctx); } @Override - public void setValue(EvaluationContext ctx, Object value) - throws ELException { + public void setValue(EvaluationContext ctx, Object value) throws ELException { this.children[0].setValue(ctx, value); } } diff --git a/java/org/apache/el/parser/AstEmpty.java b/java/org/apache/el/parser/AstEmpty.java index d8a63c57a6..e8b5c4c972 100644 --- a/java/org/apache/el/parser/AstEmpty.java +++ b/java/org/apache/el/parser/AstEmpty.java @@ -34,14 +34,12 @@ public final class AstEmpty extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Boolean.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); if (obj == null) { return Boolean.TRUE; diff --git a/java/org/apache/el/parser/AstEqual.java b/java/org/apache/el/parser/AstEqual.java index 377f7f627d..8011ac0020 100644 --- a/java/org/apache/el/parser/AstEqual.java +++ b/java/org/apache/el/parser/AstEqual.java @@ -31,8 +31,7 @@ public final class AstEqual extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return Boolean.valueOf(equals(ctx, obj0, obj1)); diff --git a/java/org/apache/el/parser/AstFalse.java b/java/org/apache/el/parser/AstFalse.java index 1d37ae924a..fcda7ca3c7 100644 --- a/java/org/apache/el/parser/AstFalse.java +++ b/java/org/apache/el/parser/AstFalse.java @@ -31,8 +31,7 @@ public final class AstFalse extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return Boolean.FALSE; } } diff --git a/java/org/apache/el/parser/AstFloatingPoint.java b/java/org/apache/el/parser/AstFloatingPoint.java index 1e27047e0f..27baa19ccd 100644 --- a/java/org/apache/el/parser/AstFloatingPoint.java +++ b/java/org/apache/el/parser/AstFloatingPoint.java @@ -54,14 +54,12 @@ public final class AstFloatingPoint extends SimpleNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.getFloatingPoint(); } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return this.getFloatingPoint().getClass(); } } diff --git a/java/org/apache/el/parser/AstFunction.java b/java/org/apache/el/parser/AstFunction.java index 1e6eeacc34..5a4e6be661 100644 --- a/java/org/apache/el/parser/AstFunction.java +++ b/java/org/apache/el/parser/AstFunction.java @@ -162,7 +162,8 @@ public final class AstFunction extends SimpleNode { if (m.isVarArgs() && i == methodParameterCount - 1) { if (inputParameterCount < methodParameterCount) { params[i] = new Object[] { null }; - } else if (inputParameterCount == methodParameterCount && isArray(parameters.jjtGetChild(i).getValue(ctx))) { + } else if (inputParameterCount == methodParameterCount && + isArray(parameters.jjtGetChild(i).getValue(ctx))) { params[i] = parameters.jjtGetChild(i).getValue(ctx); } else { Object[] varargs = new Object[inputParameterCount - methodParameterCount + 1]; diff --git a/java/org/apache/el/parser/AstGreaterThan.java b/java/org/apache/el/parser/AstGreaterThan.java index 4db596d5c4..064fc0ed7b 100644 --- a/java/org/apache/el/parser/AstGreaterThan.java +++ b/java/org/apache/el/parser/AstGreaterThan.java @@ -31,8 +31,7 @@ public final class AstGreaterThan extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); if (obj0 == null) { return Boolean.FALSE; diff --git a/java/org/apache/el/parser/AstGreaterThanEqual.java b/java/org/apache/el/parser/AstGreaterThanEqual.java index 4270b3c894..9704785258 100644 --- a/java/org/apache/el/parser/AstGreaterThanEqual.java +++ b/java/org/apache/el/parser/AstGreaterThanEqual.java @@ -31,8 +31,7 @@ public final class AstGreaterThanEqual extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); if (obj0 == obj1) { diff --git a/java/org/apache/el/parser/AstIdentifier.java b/java/org/apache/el/parser/AstIdentifier.java index a48b66cba4..a4eb1ac220 100644 --- a/java/org/apache/el/parser/AstIdentifier.java +++ b/java/org/apache/el/parser/AstIdentifier.java @@ -52,8 +52,7 @@ public final class AstIdentifier extends SimpleNode { ctx.setPropertyResolved(false); Class<?> result = ctx.getELResolver().getType(ctx, null, this.image); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled.null", this.image)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image)); } return result; } @@ -77,12 +76,11 @@ public final class AstIdentifier extends SimpleNode { // EL Resolvers ctx.setPropertyResolved(false); Object result; - /* Putting the Boolean into the ELContext is part of a performance - * optimisation for ScopedAttributeELResolver. When looking up "foo", - * the resolver can't differentiate between ${ foo } and ${ foo.bar }. - * This is important because the expensive class lookup only needs to - * be performed in the later case. This flag tells the resolver if the - * lookup can be skipped. + /* + * Putting the Boolean into the ELContext is part of a performance optimisation for ScopedAttributeELResolver. + * When looking up "foo", the resolver can't differentiate between ${ foo } and ${ foo.bar }. This is important + * because the expensive class lookup only needs to be performed in the later case. This flag tells the resolver + * if the lookup can be skipped. */ if (parent instanceof AstValue) { ctx.putContext(this.getClass(), Boolean.FALSE); @@ -110,14 +108,12 @@ public final class AstIdentifier extends SimpleNode { if (result != null) { try { return ((Class<?>) result).getField(this.image).get(null); - } catch (IllegalArgumentException | IllegalAccessException - | NoSuchFieldException | SecurityException e) { + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { throw new ELException(e); } } - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled.null", this.image)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image)); } @Override @@ -132,15 +128,13 @@ public final class AstIdentifier extends SimpleNode { ctx.setPropertyResolved(false); boolean result = ctx.getELResolver().isReadOnly(ctx, null, this.image); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled.null", this.image)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image)); } return result; } @Override - public void setValue(EvaluationContext ctx, Object value) - throws ELException { + public void setValue(EvaluationContext ctx, Object value) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); @@ -152,29 +146,25 @@ public final class AstIdentifier extends SimpleNode { ctx.setPropertyResolved(false); ctx.getELResolver().setValue(ctx, null, this.image, value); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled.null", this.image)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image)); } } @Override - public Object invoke(EvaluationContext ctx, Class<?>[] paramTypes, - Object[] paramValues) throws ELException { + public Object invoke(EvaluationContext ctx, Class<?>[] paramTypes, Object[] paramValues) throws ELException { return this.getMethodExpression(ctx).invoke(ctx.getELContext(), paramValues); } @Override - public MethodInfo getMethodInfo(EvaluationContext ctx, - Class<?>[] paramTypes) throws ELException { + public MethodInfo getMethodInfo(EvaluationContext ctx, Class<?>[] paramTypes) throws ELException { return this.getMethodExpression(ctx).getMethodInfo(ctx.getELContext()); } @Override public void setImage(String image) { if (!Validation.isIdentifier(image)) { - throw new ELException(MessageFactory.get("error.identifier.notjava", - image)); + throw new ELException(MessageFactory.get("error.identifier.notjava", image)); } this.image = image; } @@ -198,8 +188,7 @@ public final class AstIdentifier extends SimpleNode { } - private MethodExpression getMethodExpression(EvaluationContext ctx) - throws ELException { + private MethodExpression getMethodExpression(EvaluationContext ctx) throws ELException { Object obj = null; // case A: ValueExpression exists, getValue which must @@ -226,7 +215,8 @@ public final class AstIdentifier extends SimpleNode { } else if (obj == null) { throw new MethodNotFoundException(MessageFactory.get("error.identifier.noMethod", this.image)); } else { - throw new ELException(MessageFactory.get("error.identifier.notMethodExpression", this.image, obj.getClass().getName())); + throw new ELException( + MessageFactory.get("error.identifier.notMethodExpression", this.image, obj.getClass().getName())); } } } diff --git a/java/org/apache/el/parser/AstInteger.java b/java/org/apache/el/parser/AstInteger.java index 597a13bad0..76b9909d41 100644 --- a/java/org/apache/el/parser/AstInteger.java +++ b/java/org/apache/el/parser/AstInteger.java @@ -55,14 +55,12 @@ public final class AstInteger extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return this.getInteger().getClass(); } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.getInteger(); } } diff --git a/java/org/apache/el/parser/AstLambdaExpression.java b/java/org/apache/el/parser/AstLambdaExpression.java index 97a059fca7..017a42f3db 100644 --- a/java/org/apache/el/parser/AstLambdaExpression.java +++ b/java/org/apache/el/parser/AstLambdaExpression.java @@ -52,18 +52,16 @@ public class AstLambdaExpression extends SimpleNode { // nested expressions. int methodParameterSetCount = jjtGetNumChildren() - 2; if (methodParameterSetCount > state.getNestingCount()) { - throw new ELException(MessageFactory.get( - "error.lambda.tooManyMethodParameterSets")); + throw new ELException(MessageFactory.get("error.lambda.tooManyMethodParameterSets")); } // First child is always parameters even if there aren't any - AstLambdaParameters formalParametersNode = - (AstLambdaParameters) children[0]; + AstLambdaParameters formalParametersNode = (AstLambdaParameters) children[0]; Node[] formalParamNodes = formalParametersNode.children; // Second child is a value expression - ValueExpressionImpl ve = new ValueExpressionImpl("", children[1], - ctx.getFunctionMapper(), ctx.getVariableMapper(), null); + ValueExpressionImpl ve = + new ValueExpressionImpl("", children[1], ctx.getFunctionMapper(), ctx.getVariableMapper(), null); // Build a LambdaExpression List<String> formalParameters = new ArrayList<>(); @@ -87,27 +85,22 @@ public class AstLambdaExpression extends SimpleNode { } /* - * This is a (possibly nested) lambda expression with one or more sets - * of parameters provided. + * This is a (possibly nested) lambda expression with one or more sets of parameters provided. * - * If there are more nested expressions than sets of parameters this may - * return a LambdaExpression. + * If there are more nested expressions than sets of parameters this may return a LambdaExpression. * - * If there are more sets of parameters than nested expressions an - * ELException will have been thrown by the check at the start of this - * method. + * If there are more sets of parameters than nested expressions an ELException will have been thrown by the + * check at the start of this method. */ // Always have to invoke the outer-most expression int methodParameterIndex = 2; - Object result = le.invoke(((AstMethodParameters) - children[methodParameterIndex]).getParameters(ctx)); + Object result = le.invoke(((AstMethodParameters) children[methodParameterIndex]).getParameters(ctx)); methodParameterIndex++; - while (result instanceof LambdaExpression && - methodParameterIndex < jjtGetNumChildren()) { - result = ((LambdaExpression) result).invoke(((AstMethodParameters) - children[methodParameterIndex]).getParameters(ctx)); + while (result instanceof LambdaExpression && methodParameterIndex < jjtGetNumChildren()) { + result = ((LambdaExpression) result) + .invoke(((AstMethodParameters) children[methodParameterIndex]).getParameters(ctx)); methodParameterIndex++; } diff --git a/java/org/apache/el/parser/AstLessThan.java b/java/org/apache/el/parser/AstLessThan.java index f5bf01b0dd..cb165b0a1b 100644 --- a/java/org/apache/el/parser/AstLessThan.java +++ b/java/org/apache/el/parser/AstLessThan.java @@ -31,8 +31,7 @@ public final class AstLessThan extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); if (obj0 == null) { return Boolean.FALSE; diff --git a/java/org/apache/el/parser/AstLessThanEqual.java b/java/org/apache/el/parser/AstLessThanEqual.java index fab476a159..1cdcb8ea24 100644 --- a/java/org/apache/el/parser/AstLessThanEqual.java +++ b/java/org/apache/el/parser/AstLessThanEqual.java @@ -31,8 +31,7 @@ public final class AstLessThanEqual extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); if (obj0 == obj1) { diff --git a/java/org/apache/el/parser/AstLiteralExpression.java b/java/org/apache/el/parser/AstLiteralExpression.java index 67a1b573a6..1f0bec8f24 100644 --- a/java/org/apache/el/parser/AstLiteralExpression.java +++ b/java/org/apache/el/parser/AstLiteralExpression.java @@ -53,7 +53,7 @@ public final class AstLiteralExpression extends SimpleNode { if (c == '\\' && i + 2 < size) { char c1 = image.charAt(i + 1); char c2 = image.charAt(i + 2); - if ((c1 == '#' || c1 == '$') && c2 == '{') { + if ((c1 == '#' || c1 == '$') && c2 == '{') { c = c1; i++; } diff --git a/java/org/apache/el/parser/AstMapEntry.java b/java/org/apache/el/parser/AstMapEntry.java index 5a897dc097..c18874d6ac 100644 --- a/java/org/apache/el/parser/AstMapEntry.java +++ b/java/org/apache/el/parser/AstMapEntry.java @@ -17,10 +17,9 @@ /* Generated By:JJTree: Do not edit this line. AstMapEntry.java Version 4.3 */ package org.apache.el.parser; -public -class AstMapEntry extends SimpleNode { - public AstMapEntry(int id) { - super(id); - } +public class AstMapEntry extends SimpleNode { + public AstMapEntry(int id) { + super(id); + } } /* JavaCC - OriginalChecksum=6a7910e58a583371769800554113a8d3 (do not edit this line) */ diff --git a/java/org/apache/el/parser/AstMinus.java b/java/org/apache/el/parser/AstMinus.java index 92218971f2..5fbdde3522 100644 --- a/java/org/apache/el/parser/AstMinus.java +++ b/java/org/apache/el/parser/AstMinus.java @@ -32,8 +32,7 @@ public final class AstMinus extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.subtract(obj0, obj1); diff --git a/java/org/apache/el/parser/AstMod.java b/java/org/apache/el/parser/AstMod.java index ba35681abf..7393392b64 100644 --- a/java/org/apache/el/parser/AstMod.java +++ b/java/org/apache/el/parser/AstMod.java @@ -32,8 +32,7 @@ public final class AstMod extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.mod(obj0, obj1); diff --git a/java/org/apache/el/parser/AstMult.java b/java/org/apache/el/parser/AstMult.java index ce761a36dc..47441e4bf9 100644 --- a/java/org/apache/el/parser/AstMult.java +++ b/java/org/apache/el/parser/AstMult.java @@ -32,8 +32,7 @@ public final class AstMult extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.multiply(obj0, obj1); diff --git a/java/org/apache/el/parser/AstNegative.java b/java/org/apache/el/parser/AstNegative.java index f4a4224dee..7014dfb03d 100644 --- a/java/org/apache/el/parser/AstNegative.java +++ b/java/org/apache/el/parser/AstNegative.java @@ -34,14 +34,12 @@ public final class AstNegative extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Number.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); if (obj == null) { diff --git a/java/org/apache/el/parser/AstNot.java b/java/org/apache/el/parser/AstNot.java index 98fe62b45d..974690c122 100644 --- a/java/org/apache/el/parser/AstNot.java +++ b/java/org/apache/el/parser/AstNot.java @@ -31,14 +31,12 @@ public final class AstNot extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Boolean.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); Boolean b = coerceToBoolean(ctx, obj, true); return Boolean.valueOf(!b.booleanValue()); diff --git a/java/org/apache/el/parser/AstNotEqual.java b/java/org/apache/el/parser/AstNotEqual.java index d37aa6f9e5..9e40d963fd 100644 --- a/java/org/apache/el/parser/AstNotEqual.java +++ b/java/org/apache/el/parser/AstNotEqual.java @@ -31,8 +31,7 @@ public final class AstNotEqual extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return Boolean.valueOf(!equals(ctx, obj0, obj1)); diff --git a/java/org/apache/el/parser/AstNull.java b/java/org/apache/el/parser/AstNull.java index 3f4d8bc928..ed6e57f54f 100644 --- a/java/org/apache/el/parser/AstNull.java +++ b/java/org/apache/el/parser/AstNull.java @@ -31,14 +31,12 @@ public final class AstNull extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return null; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return null; } } diff --git a/java/org/apache/el/parser/AstOr.java b/java/org/apache/el/parser/AstOr.java index 86acc66c5f..e3bd257917 100644 --- a/java/org/apache/el/parser/AstOr.java +++ b/java/org/apache/el/parser/AstOr.java @@ -31,8 +31,7 @@ public final class AstOr extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj = this.children[0].getValue(ctx); Boolean b = coerceToBoolean(ctx, obj, true); if (b.booleanValue()) { diff --git a/java/org/apache/el/parser/AstPlus.java b/java/org/apache/el/parser/AstPlus.java index 7f5d23f4d2..6fb57648b6 100644 --- a/java/org/apache/el/parser/AstPlus.java +++ b/java/org/apache/el/parser/AstPlus.java @@ -32,8 +32,7 @@ public final class AstPlus extends ArithmeticNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.add(obj0, obj1); diff --git a/java/org/apache/el/parser/AstString.java b/java/org/apache/el/parser/AstString.java index a50b720a1a..267e6916ec 100644 --- a/java/org/apache/el/parser/AstString.java +++ b/java/org/apache/el/parser/AstString.java @@ -40,14 +40,12 @@ public final class AstString extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return String.class; } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return this.getString(); } diff --git a/java/org/apache/el/parser/AstTrue.java b/java/org/apache/el/parser/AstTrue.java index f511797cd4..64afdc5b2c 100644 --- a/java/org/apache/el/parser/AstTrue.java +++ b/java/org/apache/el/parser/AstTrue.java @@ -31,8 +31,7 @@ public final class AstTrue extends BooleanNode { } @Override - public Object getValue(EvaluationContext ctx) - throws ELException { + public Object getValue(EvaluationContext ctx) throws ELException { return Boolean.TRUE; } } diff --git a/java/org/apache/el/parser/AstValue.java b/java/org/apache/el/parser/AstValue.java index 77996560dc..cf9dafb4d2 100644 --- a/java/org/apache/el/parser/AstValue.java +++ b/java/org/apache/el/parser/AstValue.java @@ -58,8 +58,7 @@ public final class AstValue extends SimpleNode { ctx.setPropertyResolved(false); Class<?> result = ctx.getELResolver().getType(ctx, t.base, t.property); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled", t.base, t.property)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", t.base, t.property)); } return result; } @@ -70,8 +69,8 @@ public final class AstValue extends SimpleNode { // if our base is null (we know there are more properties to evaluate) if (base == null) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.unreachable.base", this.children[0].getImage())); + throw new PropertyNotFoundException( + MessageFactory.get("error.unreachable.base", this.children[0].getImage())); } // set up our start/end @@ -82,24 +81,19 @@ public final class AstValue extends SimpleNode { // Evaluate any properties or methods before our target ELResolver resolver = ctx.getELResolver(); while (i < propCount) { - if (i + 2 < propCount && - this.children[i + 1] instanceof AstMethodParameters) { + if (i + 2 < propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call not at end of expression - base = resolver.invoke(ctx, base, - this.children[i].getValue(ctx), null, - ((AstMethodParameters) - this.children[i + 1]).getParameters(ctx)); + base = resolver.invoke(ctx, base, this.children[i].getValue(ctx), null, + ((AstMethodParameters) this.children[i + 1]).getParameters(ctx)); i += 2; - } else if (i + 2 == propCount && - this.children[i + 1] instanceof AstMethodParameters) { + } else if (i + 2 == propCount && this.children[i + 1] instanceof AstMethodParameters) { // Method call at end of expression ctx.setPropertyResolved(false); property = this.children[i].getValue(ctx); i += 2; if (property == null) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.unreachable.property", property)); + throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.property", property)); } } else if (i + 1 < propCount) { // Object with property not at end of expression @@ -115,13 +109,11 @@ public final class AstValue extends SimpleNode { i++; if (property == null) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.unreachable.property", property)); + throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.property", property)); } } if (base == null) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.unreachable.property", property)); + throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.property", property)); } } @@ -140,24 +132,19 @@ public final class AstValue extends SimpleNode { ELResolver resolver = ctx.getELResolver(); while (base != null && i < propCount) { suffix = this.children[i].getValue(ctx); - if (i + 1 < propCount && - (this.children[i+1] instanceof AstMethodParameters)) { - AstMethodParameters mps = - (AstMethodParameters) this.children[i+1]; - if (base instanceof Optional && "orElseGet".equals(suffix) && - mps.jjtGetNumChildren() == 1) { + if (i + 1 < propCount && (this.children[i + 1] instanceof AstMethodParameters)) { + AstMethodParameters mps = (AstMethodParameters) this.children[i + 1]; + if (base instanceof Optional && "orElseGet".equals(suffix) && mps.jjtGetNumChildren() == 1) { Node paramFoOptional = mps.jjtGetChild(0); if (!(paramFoOptional instanceof AstLambdaExpression || paramFoOptional instanceof LambdaExpression)) { - throw new ELException(MessageFactory.get( - "stream.optional.paramNotLambda", suffix)); + throw new ELException(MessageFactory.get("stream.optional.paramNotLambda", suffix)); } } // This is a method Object[] paramValues = mps.getParameters(ctx); - base = resolver.invoke(ctx, base, suffix, - getTypesFromValues(paramValues), paramValues); - i+=2; + base = resolver.invoke(ctx, base, suffix, getTypesFromValues(paramValues), paramValues); + i += 2; } else { // This is a property if (suffix == null) { @@ -170,8 +157,7 @@ public final class AstValue extends SimpleNode { } } if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled", base, suffix)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", base, suffix)); } return base; } @@ -180,42 +166,35 @@ public final class AstValue extends SimpleNode { public boolean isReadOnly(EvaluationContext ctx) throws ELException { Target t = getTarget(ctx); ctx.setPropertyResolved(false); - boolean result = - ctx.getELResolver().isReadOnly(ctx, t.base, t.property); + boolean result = ctx.getELResolver().isReadOnly(ctx, t.base, t.property); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled", t.base, t.property)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", t.base, t.property)); } return result; } @Override - public void setValue(EvaluationContext ctx, Object value) - throws ELException { + public void setValue(EvaluationContext ctx, Object value) throws ELException { Target t = getTarget(ctx); ctx.setPropertyResolved(false); ELResolver resolver = ctx.getELResolver(); // coerce to the expected type Class<?> targetClass = resolver.getType(ctx, t.base, t.property); - resolver.setValue(ctx, t.base, t.property, - ELSupport.coerceToType(ctx, value, targetClass)); + resolver.setValue(ctx, t.base, t.property, ELSupport.coerceToType(ctx, value, targetClass)); if (!ctx.isPropertyResolved()) { - throw new PropertyNotFoundException(MessageFactory.get( - "error.resolver.unhandled", t.base, t.property)); + throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", t.base, t.property)); } } @Override // Interface el.parser.Node uses raw types (and is auto-generated) - public MethodInfo getMethodInfo(EvaluationContext ctx, - @SuppressWarnings("rawtypes") Class[] paramTypes) + public MethodInfo getMethodInfo(EvaluationContext ctx, @SuppressWarnings("rawtypes") Class[] paramTypes) throws ELException { Target t = getTarget(ctx); Class<?>[] types = null; if (isParametersProvided()) { - Object[] values = ((AstMethodParameters) this.jjtGetChild( - this.jjtGetNumChildren() - 1)).getParameters(ctx); + Object[] values = ((AstMethodParameters) this.jjtGetChild(this.jjtGetNumChildren() - 1)).getParameters(ctx); types = getTypesFromValues(values); } else { types = paramTypes; @@ -226,17 +205,15 @@ public final class AstValue extends SimpleNode { @Override // Interface el.parser.Node uses a raw type (and is auto-generated) - public Object invoke(EvaluationContext ctx, - @SuppressWarnings("rawtypes") Class[] paramTypes, - Object[] paramValues) throws ELException { + public Object invoke(EvaluationContext ctx, @SuppressWarnings("rawtypes") Class[] paramTypes, Object[] paramValues) + throws ELException { Target t = getTarget(ctx); Method m = null; Object[] values = null; Class<?>[] types = null; if (isParametersProvided()) { - values = ((AstMethodParameters) this.jjtGetChild( - this.jjtGetNumChildren() - 1)).getParameters(ctx); + values = ((AstMethodParameters) this.jjtGetChild(this.jjtGetNumChildren() - 1)).getParameters(ctx); types = getTypesFromValues(values); } else { values = paramValues; @@ -275,19 +252,18 @@ public final class AstValue extends SimpleNode { int paramCount = types.length; if (m.isVarArgs() && paramCount > 1 && (src == null || paramCount > src.length) || - !m.isVarArgs() && (paramCount > 0 && src == null || - src != null && src.length != paramCount)) { + !m.isVarArgs() && (paramCount > 0 && src == null || src != null && src.length != paramCount)) { String srcCount = null; if (src != null) { srcCount = Integer.toString(src.length); } String msg; if (m.isVarArgs()) { - msg = MessageFactory.get("error.invoke.tooFewParams", - m.getName(), srcCount, Integer.toString(paramCount)); + msg = MessageFactory.get("error.invoke.tooFewParams", m.getName(), srcCount, + Integer.toString(paramCount)); } else { - msg = MessageFactory.get("error.invoke.wrongParams", - m.getName(), srcCount, Integer.toString(paramCount)); + msg = MessageFactory.get("error.invoke.wrongParams", m.getName(), srcCount, + Integer.toString(paramCount)); } throw new IllegalArgumentException(msg); } @@ -307,15 +283,13 @@ public final class AstValue extends SimpleNode { if (m.isVarArgs()) { Class<?> varArgType = m.getParameterTypes()[paramCount - 1].getComponentType(); - Object[] varArgs = - (Object[]) Array.newInstance(varArgType, src.length - (paramCount - 1)); - for (int i = 0; i < src.length - (paramCount - 1); i ++) { + Object[] varArgs = (Object[]) Array.newInstance(varArgType, src.length - (paramCount - 1)); + for (int i = 0; i < src.length - (paramCount - 1); i++) { varArgs[i] = ELSupport.coerceToType(ctx, src[paramCount - 1 + i], varArgType); } dest[paramCount - 1] = varArgs; } else { - dest[paramCount - 1] = ELSupport.coerceToType( - ctx, src[paramCount - 1], types[paramCount - 1]); + dest[paramCount - 1] = ELSupport.coerceToType(ctx, src[paramCount - 1], types[paramCount - 1]); } return dest; @@ -344,8 +318,7 @@ public final class AstValue extends SimpleNode { @Override public ValueReference getValueReference(EvaluationContext ctx) { // Check this is a reference to a base and a property - if (this.children.length > 2 && - this.jjtGetChild(2) instanceof AstMethodParameters) { + if (this.children.length > 2 && this.jjtGetChild(2) instanceof AstMethodParameters) { // This is a method call return null; } diff --git a/java/org/apache/el/parser/BooleanNode.java b/java/org/apache/el/parser/BooleanNode.java index 2ef320c6bf..e8e6988425 100644 --- a/java/org/apache/el/parser/BooleanNode.java +++ b/java/org/apache/el/parser/BooleanNode.java @@ -30,8 +30,7 @@ public abstract class BooleanNode extends SimpleNode { } @Override - public Class<?> getType(EvaluationContext ctx) - throws ELException { + public Class<?> getType(EvaluationContext ctx) throws ELException { return Boolean.class; } } diff --git a/java/org/apache/el/stream/Stream.java b/java/org/apache/el/stream/Stream.java index 7990462de4..11d0acd329 100644 --- a/java/org/apache/el/stream/Stream.java +++ b/java/org/apache/el/stream/Stream.java @@ -48,8 +48,7 @@ public class Stream { protected void findNext() { while (iterator.hasNext()) { Object obj = iterator.next(); - if (ELSupport.coerceToBoolean(null, le.invoke(obj), - true).booleanValue()) { + if (ELSupport.coerceToBoolean(null, le.invoke(obj), true).booleanValue()) { next = obj; foundNext = true; break; @@ -83,8 +82,7 @@ public class Stream { @Override protected void findNext() { - while (iterator.hasNext() || - (inner != null && inner.hasNext())) { + while (iterator.hasNext() || (inner != null && inner.hasNext())) { if (inner == null || !inner.hasNext()) { inner = ((Stream) le.invoke(iterator.next())).iterator; } @@ -343,7 +341,7 @@ public class Stream { while (iterator.hasNext()) { iterator.next(); - count ++; + count++; } return Long.valueOf(count); @@ -413,8 +411,7 @@ public class Stream { if ((obj instanceof Comparable)) { result = (Comparable) obj; } else { - throw new ELException( - MessageFactory.get("stream.compare.notComparable")); + throw new ELException(MessageFactory.get("stream.compare.notComparable")); } } @@ -427,8 +424,7 @@ public class Stream { result = (Comparable) obj; } } else { - throw new ELException( - MessageFactory.get("stream.compare.notComparable")); + throw new ELException(MessageFactory.get("stream.compare.notComparable")); } } @@ -450,11 +446,9 @@ public class Stream { while (iterator.hasNext()) { Object obj = iterator.next(); - if (isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result), - Integer.class).intValue() > 0) { + if (isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result), Integer.class).intValue() > 0) { result = obj; - } else if (!isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result), - Integer.class).intValue() < 0) { + } else if (!isMax && ELSupport.coerceToNumber(null, le.invoke(obj, result), Integer.class).intValue() < 0) { result = obj; } } @@ -467,8 +461,7 @@ public class Stream { } - private static class LambdaExpressionComparator - implements Comparator<Object> { + private static class LambdaExpressionComparator implements Comparator<Object> { private final LambdaExpression le; @@ -478,8 +471,7 @@ public class Stream { @Override public int compare(Object o1, Object o2) { - return ELSupport.coerceToNumber( - null, le.invoke(o1, o2), Integer.class).intValue(); + return ELSupport.coerceToNumber(null, le.invoke(o1, o2), Integer.class).intValue(); } } diff --git a/java/org/apache/el/stream/StreamELResolverImpl.java b/java/org/apache/el/stream/StreamELResolverImpl.java index a744818015..128e0d738a 100644 --- a/java/org/apache/el/stream/StreamELResolverImpl.java +++ b/java/org/apache/el/stream/StreamELResolverImpl.java @@ -38,8 +38,7 @@ public class StreamELResolverImpl extends ELResolver { } @Override - public void setValue(ELContext context, Object base, Object property, - Object value) { + public void setValue(ELContext context, Object base, Object property, Object value) { // NO-OP } @@ -49,8 +48,7 @@ public class StreamELResolverImpl extends ELResolver { } @Override - public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, - Object base) { + public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { return null; } @@ -60,8 +58,7 @@ public class StreamELResolverImpl extends ELResolver { } @Override - public Object invoke(ELContext context, Object base, Object method, - Class<?>[] paramTypes, Object[] params) { + public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) { if ("stream".equals(method) && params.length == 0) { if (base.getClass().isArray()) { diff --git a/java/org/apache/el/util/ConcurrentCache.java b/java/org/apache/el/util/ConcurrentCache.java index 1be17abaa8..ae37cfb9e6 100644 --- a/java/org/apache/el/util/ConcurrentCache.java +++ b/java/org/apache/el/util/ConcurrentCache.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; -public final class ConcurrentCache<K,V> { +public final class ConcurrentCache<K, V> { private final int size; diff --git a/java/org/apache/el/util/ExceptionUtils.java b/java/org/apache/el/util/ExceptionUtils.java index d8a76ff184..798fd36a40 100644 --- a/java/org/apache/el/util/ExceptionUtils.java +++ b/java/org/apache/el/util/ExceptionUtils.java @@ -25,8 +25,8 @@ package org.apache.el.util; public class ExceptionUtils { /** - * Checks whether the supplied Throwable is one that needs to be - * rethrown and swallows all others. + * Checks whether the supplied Throwable is one that needs to be rethrown and swallows all others. + * * @param t the Throwable to check */ public static void handleThrowable(Throwable t) { @@ -45,10 +45,9 @@ public class ExceptionUtils { /** - * NO-OP method provided to enable simple pre-loading of this class. Since - * the class is used extensively in error handling, it is prudent to - * pre-load it to avoid any failure to load this class masking the true - * problem during error handling. + * NO-OP method provided to enable simple pre-loading of this class. Since the class is used extensively in error + * handling, it is prudent to pre-load it to avoid any failure to load this class masking the true problem during + * error handling. */ public static void preload() { // NO-OP diff --git a/java/org/apache/el/util/JreCompat.java b/java/org/apache/el/util/JreCompat.java index c749939db0..114e07d601 100644 --- a/java/org/apache/el/util/JreCompat.java +++ b/java/org/apache/el/util/JreCompat.java @@ -44,14 +44,12 @@ public class JreCompat { /** - * Is the accessibleObject accessible (as a result of appropriate module - * exports) on the provided instance? + * Is the accessibleObject accessible (as a result of appropriate module exports) on the provided instance? * - * @param base The specific instance to be tested. - * @param accessibleObject The method/field/constructor to be tested. + * @param base The specific instance to be tested. + * @param accessibleObject The method/field/constructor to be tested. * - * @return {code true} if the AccessibleObject can be accessed otherwise - * {code false} + * @return {code true} if the AccessibleObject can be accessed otherwise {code false} */ public boolean canAccess(Object base, AccessibleObject accessibleObject) { // Java 8 doesn't support modules so default to true diff --git a/java/org/apache/el/util/ReflectionUtil.java b/java/org/apache/el/util/ReflectionUtil.java index 015133bc9d..2422748cae 100644 --- a/java/org/apache/el/util/ReflectionUtil.java +++ b/java/org/apache/el/util/ReflectionUtil.java @@ -40,12 +40,11 @@ import org.apache.el.lang.EvaluationContext; */ public class ReflectionUtil { - protected static final String[] PRIMITIVE_NAMES = new String[] { "boolean", - "byte", "char", "double", "float", "int", "long", "short", "void" }; + protected static final String[] PRIMITIVE_NAMES = + new String[] { "boolean", "byte", "char", "double", "float", "int", "long", "short", "void" }; - protected static final Class<?>[] PRIMITIVES = new Class[] { boolean.class, - byte.class, char.class, double.class, float.class, int.class, - long.class, short.class, Void.TYPE }; + protected static final Class<?>[] PRIMITIVES = new Class[] { boolean.class, byte.class, char.class, double.class, + float.class, int.class, long.class, short.class, Void.TYPE }; private ReflectionUtil() { super(); @@ -80,10 +79,12 @@ public class ReflectionUtil { /** * Converts an array of Class names to Class types. - * @param s The array of class names - * @return An array of Class instance where the element at index i in the - * result is an instance of the class with the name at index i in - * the input + * + * @param s The array of class names + * + * @return An array of Class instance where the element at index i in the result is an instance of the class with + * the name at index i in the input + * * @throws ClassNotFoundException If a class of a given name cannot be found */ public static Class<?>[] toTypeArray(String[] s) throws ClassNotFoundException { @@ -99,9 +100,11 @@ public class ReflectionUtil { /** * Converts an array of Class types to Class names. + * * @param c The array of class instances - * @return An array of Class names where the element at index i in the - * result is the name of the class instance at index i in the input + * + * @return An array of Class names where the element at index i in the result is the name of the class instance at + * index i in the input */ public static String[] toTypeNameArray(Class<?>[] c) { if (c == null) { @@ -116,32 +119,30 @@ public class ReflectionUtil { /** * Returns a method based on the criteria. - * @param ctx the context in which the expression is being evaluated - * @param base the object that owns the method - * @param property the name of the method - * @param paramTypes the parameter types to use + * + * @param ctx the context in which the expression is being evaluated + * @param base the object that owns the method + * @param property the name of the method + * @param paramTypes the parameter types to use * @param paramValues the parameter values + * * @return the method specified - * @throws MethodNotFoundException If a method cannot be found that matches - * the given criteria + * + * @throws MethodNotFoundException If a method cannot be found that matches the given criteria */ /* - * This class duplicates code in javax.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in javax.el.Util. When making changes keep the code in sync. */ @SuppressWarnings("null") - public static Method getMethod(EvaluationContext ctx, Object base, Object property, - Class<?>[] paramTypes, Object[] paramValues) - throws MethodNotFoundException { + public static Method getMethod(EvaluationContext ctx, Object base, Object property, Class<?>[] paramTypes, + Object[] paramValues) throws MethodNotFoundException { if (base == null || property == null) { - throw new MethodNotFoundException(MessageFactory.get( - "error.method.notfound", base, property, - paramString(paramTypes))); + throw new MethodNotFoundException( + MessageFactory.get("error.method.notfound", base, property, paramString(paramTypes))); } - String methodName = (property instanceof String) ? (String) property - : property.toString(); + String methodName = (property instanceof String) ? (String) property : property.toString(); int paramCount; if (paramTypes == null) { @@ -168,17 +169,16 @@ public class ReflectionUtil { // Method has wrong number of parameters continue; } - if (m.isVarArgs() && paramCount < mParamCount -1) { + if (m.isVarArgs() && paramCount < mParamCount - 1) { // Method has wrong number of parameters continue; } - if (m.isVarArgs() && paramCount == mParamCount && paramValues != null && - paramValues.length > paramCount && !paramTypes[mParamCount -1].isArray()) { + if (m.isVarArgs() && paramCount == mParamCount && paramValues != null && paramValues.length > paramCount && + !paramTypes[mParamCount - 1].isArray()) { // Method arguments don't match continue; } - if (m.isVarArgs() && paramCount > mParamCount && paramValues != null && - paramValues.length != paramCount) { + if (m.isVarArgs() && paramCount > mParamCount && paramValues != null && paramValues.length != paramCount) { // Might match a different varargs method continue; } @@ -254,15 +254,14 @@ public class ReflectionUtil { if (exactMatch == paramCount && varArgsMatch == 0) { Method result = getMethod(base.getClass(), base, m); if (result == null) { - throw new MethodNotFoundException(MessageFactory.get( - "error.method.notfound", base, property, - paramString(paramTypes))); + throw new MethodNotFoundException( + MessageFactory.get("error.method.notfound", base, property, paramString(paramTypes))); } return result; } - candidates.put(m, new MatchResult( - m.isVarArgs(), exactMatch, assignableMatch, coercibleMatch, varArgsMatch, m.isBridge())); + candidates.put(m, new MatchResult(m.isVarArgs(), exactMatch, assignableMatch, coercibleMatch, varArgsMatch, + m.isBridge())); } // Look for the method that has the highest number of parameters where @@ -270,7 +269,7 @@ public class ReflectionUtil { MatchResult bestMatch = new MatchResult(true, 0, 0, 0, 0, true); Method match = null; boolean multiple = false; - for (Map.Entry<Method, MatchResult> entry : candidates.entrySet()) { + for (Map.Entry<Method,MatchResult> entry : candidates.entrySet()) { int cmp = entry.getValue().compareTo(bestMatch); if (cmp > 0 || match == null) { bestMatch = entry.getValue(); @@ -292,34 +291,29 @@ public class ReflectionUtil { if (match == null) { // If multiple methods have the same matching number of parameters // the match is ambiguous so throw an exception - throw new MethodNotFoundException(MessageFactory.get( - "error.method.ambiguous", base, property, - paramString(paramTypes))); - } + throw new MethodNotFoundException( + MessageFactory.get("error.method.ambiguous", base, property, paramString(paramTypes))); + } } // Handle case where no match at all was found if (match == null) { - throw new MethodNotFoundException(MessageFactory.get( - "error.method.notfound", base, property, - paramString(paramTypes))); + throw new MethodNotFoundException( + MessageFactory.get("error.method.notfound", base, property, paramString(paramTypes))); } Method result = getMethod(base.getClass(), base, match); if (result == null) { - throw new MethodNotFoundException(MessageFactory.get( - "error.method.notfound", base, property, - paramString(paramTypes))); + throw new MethodNotFoundException( + MessageFactory.get("error.method.notfound", base, property, paramString(paramTypes))); } return result; } /* - * This class duplicates code in javax.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in javax.el.Util. When making changes keep the code in sync. */ - private static Method resolveAmbiguousMethod(Set<Method> candidates, - Class<?>[] paramTypes) { + private static Method resolveAmbiguousMethod(Set<Method> candidates, Class<?>[] paramTypes) { // Identify which parameter isn't an exact match Method m = candidates.iterator().next(); @@ -340,12 +334,11 @@ public class ReflectionUtil { } for (Method c : candidates) { - if (c.getParameterTypes()[nonMatchIndex] == - paramTypes[nonMatchIndex]) { - // Methods have different non-matching parameters - // Result is ambiguous - return null; - } + if (c.getParameterTypes()[nonMatchIndex] == paramTypes[nonMatchIndex]) { + // Methods have different non-matching parameters + // Result is ambiguous + return null; + } } // Can't be null @@ -365,8 +358,7 @@ public class ReflectionUtil { if (Number.class.isAssignableFrom(nonMatchClass)) { for (Method c : candidates) { Class<?> candidateType = c.getParameterTypes()[nonMatchIndex]; - if (Number.class.isAssignableFrom(candidateType) || - candidateType.isPrimitive()) { + if (Number.class.isAssignableFrom(candidateType) || candidateType.isPrimitive()) { if (match == null) { match = c; } else { @@ -383,8 +375,7 @@ public class ReflectionUtil { /* - * This class duplicates code in javax.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in javax.el.Util. When making changes keep the code in sync. */ private static boolean isAssignableFrom(Class<?> src, Class<?> target) { // src will always be an object @@ -421,12 +412,11 @@ public class ReflectionUtil { /* - * This class duplicates code in javax.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in javax.el.Util. When making changes keep the code in sync. */ private static boolean isCoercibleFrom(EvaluationContext ctx, Object src, Class<?> target) { // TODO: This isn't pretty but it works. Significant refactoring would - // be required to avoid the exception. + // be required to avoid the exception. try { ELSupport.coerceToType(ctx, src, target); } catch (ELException e) { @@ -437,15 +427,13 @@ public class ReflectionUtil { /* - * This class duplicates code in javax.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in javax.el.Util. When making changes keep the code in sync. */ private static Method getMethod(Class<?> type, Object base, Method m) { JreCompat jreCompat = JreCompat.getInstance(); - if (m == null || - (Modifier.isPublic(type.getModifiers()) && - (Modifier.isStatic(m.getModifiers()) && jreCompat.canAccess(null, m) - || jreCompat.canAccess(base, m)))) { + if (m == null || (Modifier.isPublic(type.getModifiers()) && + (Modifier.isStatic(m.getModifiers()) && jreCompat.canAccess(null, m) || + jreCompat.canAccess(base, m)))) { return m; } Class<?>[] interfaces = type.getInterfaces(); @@ -518,8 +506,7 @@ public class ReflectionUtil { /* - * This class duplicates code in javax.el.Util. When making changes keep - * the code in sync. + * This class duplicates code in javax.el.Util. When making changes keep the code in sync. */ private static class MatchResult implements Comparable<MatchResult> { @@ -593,14 +580,13 @@ public class ReflectionUtil { @Override public boolean equals(Object o) { - return o == this || (null != o && - this.getClass().equals(o.getClass()) && - ((MatchResult)o).getExactCount() == this.getExactCount() && - ((MatchResult)o).getAssignableCount() == this.getAssignableCount() && - ((MatchResult)o).getCoercible() == this.getCoercible() && - ((MatchResult)o).getVarArgsCount() == this.getVarArgsCount() && - ((MatchResult)o).isVarArgs() == this.isVarArgs() && - ((MatchResult)o).isBridge() == this.isBridge()); + return o == this || (null != o && this.getClass().equals(o.getClass()) && + ((MatchResult) o).getExactCount() == this.getExactCount() && + ((MatchResult) o).getAssignableCount() == this.getAssignableCount() && + ((MatchResult) o).getCoercible() == this.getCoercible() && + ((MatchResult) o).getVarArgsCount() == this.getVarArgsCount() && + ((MatchResult) o).isVarArgs() == this.isVarArgs() && + ((MatchResult) o).isBridge() == this.isBridge()); } @Override diff --git a/java/org/apache/el/util/Validation.java b/java/org/apache/el/util/Validation.java index a27e75f26e..4eab1d8ea6 100644 --- a/java/org/apache/el/util/Validation.java +++ b/java/org/apache/el/util/Validation.java @@ -22,29 +22,24 @@ import java.security.PrivilegedAction; public class Validation { // Java keywords, boolean literals & the null literal in alphabetical order - private static final String invalidIdentifiers[] = { "abstract", "assert", - "boolean", "break", "byte", "case", "catch", "char", "class", "const", - "continue", "default", "do", "double", "else", "enum", "extends", - "false", "final", "finally", "float", "for", "goto", "if", "implements", - "import", "instanceof", "int", "interface", "long", "native", "new", - "null", "package", "private", "protected", "public", "return", "short", - "static", "strictfp", "super", "switch", "synchronized", "this", - "throw", "throws", "transient", "true", "try", "void", "volatile", - "while" }; + private static final String invalidIdentifiers[] = { "abstract", "assert", "boolean", "break", "byte", "case", + "catch", "char", "class", "const", "continue", "default", "do", "double", "else", "enum", "extends", + "false", "final", "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", "int", + "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", + "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", + "true", "try", "void", "volatile", "while" }; - private static final boolean IS_SECURITY_ENABLED = - (System.getSecurityManager() != null); + private static final boolean IS_SECURITY_ENABLED = (System.getSecurityManager() != null); private static final boolean SKIP_IDENTIFIER_CHECK; static { String skipIdentifierCheckStr; if (IS_SECURITY_ENABLED) { - skipIdentifierCheckStr = AccessController.doPrivileged( - (PrivilegedAction<String>) () -> System.getProperty("org.apache.el.parser.SKIP_IDENTIFIER_CHECK", "false")); + skipIdentifierCheckStr = AccessController.doPrivileged((PrivilegedAction<String>) () -> System + .getProperty("org.apache.el.parser.SKIP_IDENTIFIER_CHECK", "false")); } else { - skipIdentifierCheckStr = System.getProperty( - "org.apache.el.parser.SKIP_IDENTIFIER_CHECK", "false"); + skipIdentifierCheckStr = System.getProperty("org.apache.el.parser.SKIP_IDENTIFIER_CHECK", "false"); } SKIP_IDENTIFIER_CHECK = Boolean.parseBoolean(skipIdentifierCheckStr); } @@ -55,14 +50,12 @@ public class Validation { } /** - * Test whether a string is a Java identifier. Note that the behaviour of - * this method depend on the system property + * Test whether a string is a Java identifier. Note that the behaviour of this method depend on the system property * {@code org.apache.el.parser.SKIP_IDENTIFIER_CHECK} * * @param key The string to test * - * @return {@code true} if the provided String should be treated as a Java - * identifier, otherwise false + * @return {@code true} if the provided String should be treated as a Java identifier, otherwise false */ public static boolean isIdentifier(String key) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org