ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/el/ValueExpressionLiteral.java

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

      
    
Rootfs path

      
    
Size
4382 (4.3 KB)
MD5
4a589b94376b56f8165d1477e141c5fa
SHA1
5f28a3a8b426ad290673a026bab5a01bb4bc28ea
SHA256
e0c48efab980363f08cc28e148ac74d90d2d0e95890832cdc2eee26e8cc6d25f
SHA512

      
    
SHA1_git
b1885c63b443c5de1efb26a33449848e7e30e238
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ValueExpressionLiteral.java | 4.3 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.el; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serial; import jakarta.el.ELContext; import jakarta.el.PropertyNotWritableException; import jakarta.el.ValueExpression; import org.apache.el.util.MessageFactory; import org.apache.el.util.ReflectionUtil; public final class ValueExpressionLiteral extends ValueExpression implements Externalizable { @Serial private static final long serialVersionUID = 1L; private Object value; private String valueString; private Class<?> expectedType; public ValueExpressionLiteral() { super(); } public ValueExpressionLiteral(Object value, Class<?> expectedType) { this.value = value; this.expectedType = expectedType; } @SuppressWarnings("unchecked") @Override public <T> T getValue(ELContext context) { context.notifyBeforeEvaluation(getExpressionString()); Object result; if (this.expectedType != null) { result = context.convertToType(this.value, this.expectedType); } else { result = this.value; } context.notifyAfterEvaluation(getExpressionString()); return (T) result; } @Override public void setValue(ELContext context, Object value) { context.notifyBeforeEvaluation(getExpressionString()); throw new PropertyNotWritableException(MessageFactory.get("error.value.literal.write", this.value)); } @Override public boolean isReadOnly(ELContext context) { context.notifyBeforeEvaluation(getExpressionString()); context.notifyAfterEvaluation(getExpressionString()); return true; } @Override public Class<?> getType(ELContext context) { context.notifyBeforeEvaluation(getExpressionString()); Class<?> result = (this.value != null) ? this.value.getClass() : null; context.notifyAfterEvaluation(getExpressionString()); return result; } @Override public Class<?> getExpectedType() { return this.expectedType; } @Override public String getExpressionString() { if (this.valueString == null) { this.valueString = (this.value != null) ? this.value.toString() : null; } return this.valueString; } @Override public boolean equals(Object obj) { return (obj instanceof ValueExpressionLiteral && this.equals((ValueExpressionLiteral) obj)); } public boolean equals(ValueExpressionLiteral ve) { return (ve != null && (this.value != null && ve.value != null && (this.value == ve.value || this.value.equals(ve.value)))); } @Override public int hashCode() { return (this.value != null) ? this.value.hashCode() : 0; } @Override public boolean isLiteralText() { return true; } @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(this.value); out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : ""); } @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.value = in.readObject(); String type = in.readUTF(); if (!type.isEmpty()) { this.expectedType = ReflectionUtil.forName(type); } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
28.27
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