ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/el/lang/FunctionMapperImpl.java

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

      
    
Rootfs path

      
    
Size
5238 (5.1 KB)
MD5
2dbaf207920992e6533aab4524a37579
SHA1
14066ae7c07ad1c7bd48bbac6f5ccb6348791c2f
SHA256
f41ae79b993614dad476cacd53435997f37de81a495c4cfe6f5ea8e2d9509f18
SHA512

      
    
SHA1_git
2ef72e06338cf6b2b80ef78c0a53df1e93b13503
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
FunctionMapperImpl.java | 5.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 org.apache.el.lang; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serial; import java.lang.reflect.Method; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import jakarta.el.FunctionMapper; import org.apache.el.util.MessageFactory; import org.apache.el.util.ReflectionUtil; public class FunctionMapperImpl extends FunctionMapper implements Externalizable { @Serial private static final long serialVersionUID = 1L; protected ConcurrentMap<String,Function> functions = new ConcurrentHashMap<>(); @Override public Method resolveFunction(String prefix, String localName) { Function f = this.functions.get(prefix + ":" + localName); if (f == null) { return null; } return f.getMethod(); } @Override public void mapFunction(String prefix, String localName, Method m) { String key = prefix + ":" + localName; if (m == null) { functions.remove(key); } else { Function f = new Function(prefix, localName, m); functions.put(key, f); } } @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(this.functions); } @SuppressWarnings("unchecked") @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.functions = (ConcurrentMap<String,Function>) in.readObject(); } public static class Function implements Externalizable { protected transient Method m; protected String owner; protected String name; protected String[] types; protected String prefix; protected String localName; public Function(String prefix, String localName, Method m) { if (localName == null) { throw new NullPointerException(MessageFactory.get("error.nullLocalName")); } if (m == null) { throw new NullPointerException(MessageFactory.get("error.nullMethod")); } this.prefix = prefix; this.localName = localName; this.m = m; } public Function() { // for serialization } @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeUTF((this.prefix != null) ? this.prefix : ""); out.writeUTF(this.localName); if (this.owner != null && this.name != null && this.types != null) { out.writeUTF(this.owner); out.writeUTF(this.name); out.writeObject(this.types); } else { out.writeUTF(this.m.getDeclaringClass().getName()); out.writeUTF(this.m.getName()); out.writeObject(ReflectionUtil.toTypeNameArray(this.m.getParameterTypes())); } } @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.prefix = in.readUTF(); if (this.prefix.isEmpty()) { this.prefix = null; } this.localName = in.readUTF(); this.owner = in.readUTF(); this.name = in.readUTF(); this.types = (String[]) in.readObject(); } public Method getMethod() { if (this.m == null) { try { Class<?> t = ReflectionUtil.forName(this.owner); Class<?>[] p = ReflectionUtil.toTypeArray(this.types); this.m = t.getMethod(this.name, p); } catch (Exception e) { // Ignore: this results in ELException after further resolution } } return this.m; } @Override public boolean equals(Object obj) { if (obj instanceof Function) { return this.hashCode() == obj.hashCode(); } return false; } @Override public int hashCode() { return (this.prefix + this.localName).hashCode(); } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
23.52
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