ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/jakarta/servlet/jsp/TesterPageContextWithAttributes.java

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

      
    
Rootfs path

      
    
Size
4292 (4.2 KB)
MD5
8bba22e7f4c90274e12b51905b21aaa3
SHA1
af8557c4be29e1a7692fec3a139a45e5d948dc01
SHA256
c55bd197660078cb017894ba460da5adc80927b23ca2e15d8976742a2e2312a2
SHA512

      
    
SHA1_git
49caf3c2e883923168031eb9e6e2b9c82c507427
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TesterPageContextWithAttributes.java | 4.2 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.servlet.jsp; import java.util.HashMap; import java.util.Map; import jakarta.el.ELContext; import org.apache.jasper.compiler.Localizer; public class TesterPageContextWithAttributes extends TesterPageContext { private final Map<String,Object> applicationAttributes = new HashMap<>(); private final Map<String,Object> pageAttributes = new HashMap<>(); private final Map<String,Object> requestAttributes = new HashMap<>(); private final Map<String,Object> sessionAttributes = new HashMap<>(); public TesterPageContextWithAttributes() { super(); } public TesterPageContextWithAttributes(ELContext elContext) { super(elContext); } @Override public Object getAttribute(String name) { return getAttribute(name, PAGE_SCOPE); } @Override public Object getAttribute(String name, int scope) { if (name == null) { throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name")); } return switch (scope) { case PAGE_SCOPE -> pageAttributes.get(name); case REQUEST_SCOPE -> requestAttributes.get(name); case SESSION_SCOPE -> sessionAttributes.get(name); case APPLICATION_SCOPE -> applicationAttributes.get(name); default -> throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope")); }; } @Override public void removeAttribute(String name) { removeAttribute(name, PAGE_SCOPE); removeAttribute(name, REQUEST_SCOPE); removeAttribute(name, SESSION_SCOPE); removeAttribute(name, APPLICATION_SCOPE); } @Override public void removeAttribute(String name, int scope) { switch (scope) { case PageContext.APPLICATION_SCOPE: applicationAttributes.remove(name); break; case PageContext.PAGE_SCOPE: pageAttributes.remove(name); break; case PageContext.REQUEST_SCOPE: requestAttributes.remove(name); break; case PageContext.SESSION_SCOPE: sessionAttributes.remove(name); break; default: throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope")); } } @Override public void setAttribute(String name, Object value) { setAttribute(name, value, PAGE_SCOPE); } @Override public void setAttribute(String name, Object value, int scope) { if (value == null) { removeAttribute(name, scope); } else { switch (scope) { case PAGE_SCOPE: pageAttributes.put(name, value); break; case REQUEST_SCOPE: requestAttributes.put(name, value); break; case SESSION_SCOPE: sessionAttributes.put(name, value); break; case APPLICATION_SCOPE: applicationAttributes.put(name, value); break; default: throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.scope")); } } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
29.31
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