ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/jakarta/el/LambdaExpression.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/jakarta/el/LambdaExpression.java
Status
scanned
Type
file
Name
LambdaExpression.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3137 (3.1 KB)
MD5
8c86684feab0551b78a248ca0fa9874e
SHA1
4dfb87cefc9e1bab49b9e5dbe95c6ed43c2015c2
SHA256
1ac17dc344f7d89932fe3cba76d144f9a9ba68879d3df3922f6d6a9e66ef03b3
SHA512

      
    
SHA1_git
b11b6b5a1efed603541bc648ca2968278c508ec0
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
LambdaExpression.java | 3.1 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jakarta.el; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; public class LambdaExpression { private final List<String> formalParameters; private final ValueExpression expression; private final Map<String,Object> nestedArguments = new HashMap<>(); private ELContext context = null; public LambdaExpression(List<String> formalParameters, ValueExpression expression) { this.formalParameters = formalParameters; this.expression = expression; } public void setELContext(ELContext context) { this.context = context; } @SuppressWarnings("null") // args[i] can't be null due to earlier checks public Object invoke(ELContext context, Object... args) throws ELException { Objects.requireNonNull(context); int formalParamCount = 0; if (formalParameters != null) { formalParamCount = formalParameters.size(); } int argCount = 0; if (args != null) { argCount = args.length; } if (formalParamCount > argCount) { throw new ELException(Util.message(context, "lambdaExpression.tooFewArgs", Integer.valueOf(argCount), Integer.valueOf(formalParamCount))); } // Build the argument map // Start with the arguments from any outer expressions so if there is // any overlap the local arguments have priority Map<String,Object> lambdaArguments = new HashMap<>(nestedArguments); for (int i = 0; i < formalParamCount; i++) { lambdaArguments.put(formalParameters.get(i), args[i]); } context.enterLambdaScope(lambdaArguments); try { Object result = expression.getValue(context); // Make arguments from this expression available to any nested // expression if (result instanceof LambdaExpression) { ((LambdaExpression) result).nestedArguments.putAll(lambdaArguments); } return result; } finally { context.exitLambdaScope(); } } public Object invoke(Object... args) { return invoke(context, args); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
36.39
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9