ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/util/ErrorPageSupport.java

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

      
    
Rootfs path

      
    
Size
3482 (3.4 KB)
MD5
ef42386606ea251f847aff675706d317
SHA1
d18034c5ec73612de88ce6635eb9949c687cc546
SHA256
2447daf90ee6ca81f1ad6492ad27411c57da324e379bf48de8ce2fe32bd25b8a
SHA512

      
    
SHA1_git
4103354ed0dc55e80eec861e23088bd5193b0b3a
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ErrorPageSupport.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 org.apache.catalina.util; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.apache.tomcat.util.descriptor.web.ErrorPage; /** * Provides support for tracking per exception type and per HTTP status code error pages. */ public class ErrorPageSupport { // Fully qualified class name to error page private final Map<String,ErrorPage> exceptionPages = new ConcurrentHashMap<>(); // HTTP status code to error page private final Map<Integer,ErrorPage> statusPages = new ConcurrentHashMap<>(); public void add(ErrorPage errorPage) { String exceptionType = errorPage.getExceptionType(); if (exceptionType == null) { statusPages.put(Integer.valueOf(errorPage.getErrorCode()), errorPage); } else { exceptionPages.put(exceptionType, errorPage); } } public void remove(ErrorPage errorPage) { String exceptionType = errorPage.getExceptionType(); if (exceptionType == null) { statusPages.remove(Integer.valueOf(errorPage.getErrorCode()), errorPage); } else { exceptionPages.remove(exceptionType, errorPage); } } public ErrorPage find(int statusCode) { return statusPages.get(Integer.valueOf(statusCode)); } /** * Find the ErrorPage, if any, for the named exception type. * * @param exceptionType The fully qualified class name of the exception type * * @return The ErrorPage for the named exception type, or {@code null} if none is configured */ public ErrorPage find(String exceptionType) { return exceptionPages.get(exceptionType); } public ErrorPage find(Throwable exceptionType) { if (exceptionType == null) { return null; } Class<?> clazz = exceptionType.getClass(); String name = clazz.getName(); while (!Object.class.equals(clazz)) { ErrorPage errorPage = exceptionPages.get(name); if (errorPage != null) { return errorPage; } clazz = clazz.getSuperclass(); if (clazz == null) { break; } name = clazz.getName(); } return null; } public ErrorPage[] findAll() { Set<ErrorPage> errorPages = new HashSet<>(); errorPages.addAll(exceptionPages.values()); errorPages.addAll(statusPages.values()); return errorPages.toArray(new ErrorPage[0]); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
32.96
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