ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/valves/rewrite/InternalRewriteMap.java

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

      
    
Rootfs path

      
    
Size
3536 (3.5 KB)
MD5
157e6c2f05c5763f730280b210a0c273
SHA1
38ea694fbe257b2d590369c758d247e93e77003f
SHA256
0f47b69cd4933dbff81375157a392708797dacf4f1619e64c0b55a18e9890b66
SHA512

      
    
SHA1_git
cf488f438c99f69de59be705cbcdcde9753cb89e
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
InternalRewriteMap.java | 3.5 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.valves.rewrite; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Locale; import org.apache.catalina.util.URLEncoder; import org.apache.tomcat.util.buf.UDecoder; public class InternalRewriteMap { public static RewriteMap toMap(String name) { if ("toupper".equals(name)) { return new UpperCase(); } else if ("tolower".equals(name)) { return new LowerCase(); } else if ("escape".equals(name)) { return new Escape(); } else if ("unescape".equals(name)) { return new Unescape(); } else { return null; } } public static class LowerCase implements RewriteMap { private Locale locale = Locale.getDefault(); @Override public String setParameters(String params) { this.locale = Locale.forLanguageTag(params); return null; } @Override public String lookup(String key) { if (key != null) { return key.toLowerCase(locale); } return null; } } public static class UpperCase implements RewriteMap { private Locale locale = Locale.getDefault(); @Override public String setParameters(String params) { this.locale = Locale.forLanguageTag(params); return null; } @Override public String lookup(String key) { if (key != null) { return key.toUpperCase(locale); } return null; } } public static class Escape implements RewriteMap { private Charset charset = StandardCharsets.UTF_8; @Override public String setParameters(String params) { this.charset = Charset.forName(params); return null; } @Override public String lookup(String key) { if (key != null) { return URLEncoder.DEFAULT.encode(key, charset); } return null; } } public static class Unescape implements RewriteMap { private Charset charset = StandardCharsets.UTF_8; @Override public String setParameters(String params) { this.charset = Charset.forName(params); return null; } @Override public String lookup(String key) { if (key != null) { return UDecoder.URLDecode(key, charset); } return null; } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
33.9
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