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

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

      
    
Rootfs path

      
    
Size
3463 (3.4 KB)
MD5
e0c6a889f88a5111f8d1534d89038a81
SHA1
453cd99531b337694d454f0c93f2b07b4108ced2
SHA256
8f7711f709a57c81414c195fdc21396d50481220471da0597e8436269c084146
SHA512

      
    
SHA1_git
a9bb5c122a9cfcf0276c8b340af7fd508515a20c
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
MapELResolver.java | 3.4 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.Collections; import java.util.HashMap; import java.util.Map; import java.util.Objects; public class MapELResolver extends ELResolver { private static final Class<?> UNMODIFIABLE = Collections.unmodifiableMap(new HashMap<>()).getClass(); private final boolean readOnly; public MapELResolver() { this.readOnly = false; } public MapELResolver(boolean readOnly) { this.readOnly = readOnly; } @Override public Class<?> getType(ELContext context, Object base, Object property) { Objects.requireNonNull(context); if (base instanceof Map<?,?> map) { context.setPropertyResolved(base, property); if (readOnly || map.getClass() == UNMODIFIABLE) { return null; } return Object.class; } return null; } @Override public Object getValue(ELContext context, Object base, Object property) { Objects.requireNonNull(context); if (base instanceof Map<?,?>) { context.setPropertyResolved(base, property); return ((Map<?,?>) base).get(property); } return null; } @Override public void setValue(ELContext context, Object base, Object property, Object value) { Objects.requireNonNull(context); if (base instanceof Map<?,?>) { context.setPropertyResolved(base, property); if (this.readOnly) { throw new PropertyNotWritableException( Util.message(context, "resolverNotWritable", base.getClass().getName())); } try { @SuppressWarnings("unchecked") // Must be OK Map<Object,Object> map = ((Map<Object,Object>) base); map.put(property, value); } catch (UnsupportedOperationException e) { throw new PropertyNotWritableException(e); } } } @Override public boolean isReadOnly(ELContext context, Object base, Object property) { Objects.requireNonNull(context); if (base instanceof Map<?,?>) { context.setPropertyResolved(base, property); return this.readOnly || UNMODIFIABLE.equals(base.getClass()); } return this.readOnly; } @Override public Class<?> getCommonPropertyType(ELContext context, Object base) { if (base instanceof Map<?,?>) { return Object.class; } return null; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
35.63
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