ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/jasper/optimizations/StringInterpreterEnum.java

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

      
    
Rootfs path

      
    
Size
2121 (2.1 KB)
MD5
c23be41a3f617080a5298e49f86c755a
SHA1
c1037d5bf607e9a8f1679d0719e1cc3e7e01a80f
SHA256
b1f4f729f8badd41d7f0292947afcc22df9246aa83fb04b138669da2c5a194df
SHA512

      
    
SHA1_git
383e8ecf3aba483a2c7857600be688b895a53cbe
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
StringInterpreterEnum.java | 2.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.jasper.optimizations; import org.apache.jasper.compiler.Localizer; import org.apache.jasper.compiler.StringInterpreterFactory.DefaultStringInterpreter; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; /** * Provides an optimised conversion of string values to Enums. It bypasses the check for registered PropertyEditor. */ public class StringInterpreterEnum extends DefaultStringInterpreter { // Can't be static private final Log log = LogFactory.getLog(ELInterpreterTagSetters.class); @Override protected String coerceToOtherType(Class<?> c, String s, boolean isNamedAttribute) { if (c.isEnum() && !isNamedAttribute) { try { @SuppressWarnings({ "unchecked", "rawtypes" }) Enum<?> enumValue = Enum.valueOf((Class<? extends Enum>) c, s); return c.getName() + "." + enumValue.name(); } catch (IllegalArgumentException iae) { if (log.isDebugEnabled()) { log.debug(Localizer.getMessage("jsp.error.typeConversion", s, "Enum[" + c.getName() + "]"), iae); } // Continue and resolve the value at runtime } } return null; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
50.21
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