You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/01/23 19:57:06 UTC

[tomcat] branch 10.1.x updated: Re-format. No functional change.

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 8e8dca0504 Re-format. No functional change.
8e8dca0504 is described below

commit 8e8dca0504573fc5c9502f362654b44d84a4634b
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jan 20 20:13:18 2023 +0000

    Re-format. No functional change.
---
 java/org/apache/el/parser/AstFunction.java     | 55 ++++++++++----------------
 test/org/apache/el/parser/TestAstFunction.java |  3 +-
 2 files changed, 21 insertions(+), 37 deletions(-)

diff --git a/java/org/apache/el/parser/AstFunction.java b/java/org/apache/el/parser/AstFunction.java
index 3ce652f768..4d67cfec36 100644
--- a/java/org/apache/el/parser/AstFunction.java
+++ b/java/org/apache/el/parser/AstFunction.java
@@ -62,8 +62,7 @@ public final class AstFunction extends SimpleNode {
     }
 
     @Override
-    public Class<?> getType(EvaluationContext ctx)
-            throws ELException {
+    public Class<?> getType(EvaluationContext ctx) throws ELException {
 
         FunctionMapper fnMapper = ctx.getFunctionMapper();
 
@@ -73,15 +72,13 @@ public final class AstFunction extends SimpleNode {
         }
         Method m = fnMapper.resolveFunction(this.prefix, this.localName);
         if (m == null) {
-            throw new ELException(MessageFactory.get("error.fnMapper.method",
-                    this.getOutputName()));
+            throw new ELException(MessageFactory.get("error.fnMapper.method", this.getOutputName()));
         }
         return m.getReturnType();
     }
 
     @Override
-    public Object getValue(EvaluationContext ctx)
-            throws ELException {
+    public Object getValue(EvaluationContext ctx) throws ELException {
 
         FunctionMapper fnMapper = ctx.getFunctionMapper();
 
@@ -93,8 +90,8 @@ public final class AstFunction extends SimpleNode {
 
         if (m == null && this.prefix.length() == 0) {
             // TODO: Do we need to think about precedence of the various ways
-            //       a lambda expression may be obtained from something that
-            //       the parser thinks is a function?
+            // a lambda expression may be obtained from something that
+            // the parser thinks is a function?
             Object obj = null;
             if (ctx.isLambdaArgument(this.localName)) {
                 obj = ctx.getLambdaArgument(this.localName);
@@ -115,18 +112,15 @@ public final class AstFunction extends SimpleNode {
             if (obj instanceof LambdaExpression) {
                 // Build arguments
                 int i = 0;
-                while (obj instanceof LambdaExpression &&
-                        i < jjtGetNumChildren()) {
+                while (obj instanceof LambdaExpression && i < jjtGetNumChildren()) {
                     Node args = jjtGetChild(i);
-                    obj = ((LambdaExpression) obj).invoke(
-                            ((AstMethodParameters) args).getParameters(ctx));
+                    obj = ((LambdaExpression) obj).invoke(((AstMethodParameters) args).getParameters(ctx));
                     i++;
                 }
                 if (i < jjtGetNumChildren()) {
                     // Haven't consumed all the sets of parameters therefore
                     // there were too many sets of parameters
-                    throw new ELException(MessageFactory.get(
-                            "error.lambda.tooManyMethodParameterSets"));
+                    throw new ELException(MessageFactory.get("error.lambda.tooManyMethodParameterSets"));
                 }
                 return obj;
             }
@@ -139,22 +133,19 @@ public final class AstFunction extends SimpleNode {
             }
             obj = ctx.getImportHandler().resolveStatic(this.localName);
             if (obj != null) {
-                return ctx.getELResolver().invoke(ctx, new ELClass((Class<?>) obj), this.localName,
-                        null, ((AstMethodParameters) this.children[0]).getParameters(ctx));
+                return ctx.getELResolver().invoke(ctx, new ELClass((Class<?>) obj), this.localName, null,
+                        ((AstMethodParameters) this.children[0]).getParameters(ctx));
             }
         }
 
         if (m == null) {
-            throw new ELException(MessageFactory.get("error.fnMapper.method",
-                    this.getOutputName()));
+            throw new ELException(MessageFactory.get("error.fnMapper.method", this.getOutputName()));
         }
 
         // Not a lambda expression so must be a function. Check there is just a
         // single set of method parameters
         if (this.jjtGetNumChildren() != 1) {
-            throw new ELException(MessageFactory.get(
-                    "error.function.tooManyMethodParameterSets",
-                    getOutputName()));
+            throw new ELException(MessageFactory.get("error.function.tooManyMethodParameterSets", getOutputName()));
         }
 
         Node parameters = jjtGetChild(0);
@@ -172,16 +163,14 @@ public final class AstFunction extends SimpleNode {
                     if (m.isVarArgs() && i == methodParameterCount - 1) {
                         if (inputParameterCount < methodParameterCount) {
                             params[i] = new Object[] { null };
-                        } else if (inputParameterCount == methodParameterCount &&
-                                paramTypes[i].isArray()) {
+                        } else if (inputParameterCount == methodParameterCount && paramTypes[i].isArray()) {
                             params[i] = parameters.jjtGetChild(i).getValue(ctx);
                         } else {
-                            Object[] varargs =
-                                    new Object[inputParameterCount - methodParameterCount + 1];
+                            Object[] varargs = new Object[inputParameterCount - methodParameterCount + 1];
                             Class<?> target = paramTypes[i].getComponentType();
                             for (int j = i; j < inputParameterCount; j++) {
-                                varargs[j-i] = parameters.jjtGetChild(j).getValue(ctx);
-                                varargs[j-i] = ELSupport.coerceToType(ctx, varargs[j-i], target);
+                                varargs[j - i] = parameters.jjtGetChild(j).getValue(ctx);
+                                varargs[j - i] = ELSupport.coerceToType(ctx, varargs[j - i], target);
                             }
                             params[i] = varargs;
                         }
@@ -191,15 +180,13 @@ public final class AstFunction extends SimpleNode {
                     params[i] = ELSupport.coerceToType(ctx, params[i], paramTypes[i]);
                 }
             } catch (ELException ele) {
-                throw new ELException(MessageFactory.get("error.function", this
-                        .getOutputName()), ele);
+                throw new ELException(MessageFactory.get("error.function", this.getOutputName()), ele);
             }
         }
         try {
             result = m.invoke(null, params);
         } catch (IllegalAccessException iae) {
-            throw new ELException(MessageFactory.get("error.function", this
-                    .getOutputName()), iae);
+            throw new ELException(MessageFactory.get("error.function", this.getOutputName()), iae);
         } catch (InvocationTargetException ite) {
             Throwable cause = ite.getCause();
             if (cause instanceof ThreadDeath) {
@@ -208,8 +195,7 @@ public final class AstFunction extends SimpleNode {
             if (cause instanceof VirtualMachineError) {
                 throw (VirtualMachineError) cause;
             }
-            throw new ELException(MessageFactory.get("error.function", this
-                    .getOutputName()), cause);
+            throw new ELException(MessageFactory.get("error.function", this.getOutputName()), cause);
         }
         return result;
     }
@@ -224,8 +210,7 @@ public final class AstFunction extends SimpleNode {
 
 
     @Override
-    public String toString()
-    {
+    public String toString() {
         return ELParserTreeConstants.jjtNodeName[id] + "[" + this.getOutputName() + "]";
     }
 }
diff --git a/test/org/apache/el/parser/TestAstFunction.java b/test/org/apache/el/parser/TestAstFunction.java
index c4d72b8c43..5697f020e3 100644
--- a/test/org/apache/el/parser/TestAstFunction.java
+++ b/test/org/apache/el/parser/TestAstFunction.java
@@ -33,8 +33,7 @@ public class TestAstFunction {
     @Test
     public void testImport02() {
         ELProcessor processor = new ELProcessor();
-        processor.getELManager().getELContext().getImportHandler()
-                .importStatic("java.lang.Integer.valueOf");
+        processor.getELManager().getELContext().getImportHandler().importStatic("java.lang.Integer.valueOf");
         Object result = processor.getValue("valueOf(1000)", Integer.class);
         Assert.assertEquals(Integer.valueOf(1000), result);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org