init
This commit is contained in:
84
java/org/apache/el/ExpressionFactoryImpl.java
Normal file
84
java/org/apache/el/ExpressionFactoryImpl.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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 javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.ExpressionFactory;
|
||||
import javax.el.MethodExpression;
|
||||
import javax.el.ValueExpression;
|
||||
|
||||
import org.apache.el.lang.ELSupport;
|
||||
import org.apache.el.lang.ExpressionBuilder;
|
||||
import org.apache.el.stream.StreamELResolverImpl;
|
||||
import org.apache.el.util.MessageFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @see javax.el.ExpressionFactory
|
||||
*
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public class ExpressionFactoryImpl extends ExpressionFactory {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ExpressionFactoryImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object coerceToType(Object obj, Class<?> type) {
|
||||
return ELSupport.coerceToType(null, obj, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodExpression createMethodExpression(ELContext context,
|
||||
String expression, Class<?> expectedReturnType,
|
||||
Class<?>[] expectedParamTypes) {
|
||||
ExpressionBuilder builder = new ExpressionBuilder(expression, context);
|
||||
return builder.createMethodExpression(expectedReturnType,
|
||||
expectedParamTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueExpression createValueExpression(ELContext context,
|
||||
String expression, Class<?> expectedType) {
|
||||
if (expectedType == null) {
|
||||
throw new NullPointerException(MessageFactory
|
||||
.get("error.value.expectedType"));
|
||||
}
|
||||
ExpressionBuilder builder = new ExpressionBuilder(expression, context);
|
||||
return builder.createValueExpression(expectedType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueExpression createValueExpression(Object instance,
|
||||
Class<?> expectedType) {
|
||||
if (expectedType == null) {
|
||||
throw new NullPointerException(MessageFactory
|
||||
.get("error.value.expectedType"));
|
||||
}
|
||||
return new ValueExpressionLiteral(instance, expectedType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ELResolver getStreamELResolver() {
|
||||
return new StreamELResolverImpl();
|
||||
}
|
||||
}
|
||||
63
java/org/apache/el/Messages.properties
Normal file
63
java/org/apache/el/Messages.properties
Normal file
@@ -0,0 +1,63 @@
|
||||
# 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.
|
||||
|
||||
# General Errors
|
||||
error.convert=Cannot convert [{0}] of type [{1}] to [{2}]
|
||||
error.compare=Cannot compare [{0}] to [{1}]
|
||||
error.function=Problems calling function [{0}]
|
||||
error.unreachable.base=Target Unreachable, identifier [{0}] resolved to null
|
||||
error.unreachable.property=Target Unreachable, [{0}] returned null
|
||||
error.resolver.unhandled=ELResolver did not handle type: [{0}] with property of [{1}]
|
||||
error.resolver.unhandled.null=ELResolver cannot handle a null base Object with identifier [{0}]
|
||||
error.invoke.wrongParams=The method [{0}] was called with [{1}] parameter(s) when it expected [{2}]
|
||||
error.invoke.tooFewParams=The method [{0}] was called with [{1}] parameter(s) when it expected at least [{2}]
|
||||
|
||||
# ValueExpressionLiteral
|
||||
error.value.literal.write=ValueExpression is a literal and not writable: [{0}]
|
||||
|
||||
# ExpressionFactoryImpl
|
||||
error.null=Expression cannot be null
|
||||
error.mixed=Expression cannot contain both '#{...}' and '${...}' : [{0}]
|
||||
error.method=Not a valid MethodExpression : [{0}]
|
||||
error.method.nullParms=Parameter types cannot be null
|
||||
error.value.expectedType=Expected type cannot be null
|
||||
|
||||
# ExpressionBuilder
|
||||
error.parseFail=Failed to parse the expression [{0}]
|
||||
|
||||
# ValueSetVisitor
|
||||
error.syntax.set=Illegal Syntax for Set Operation
|
||||
|
||||
# ReflectionUtil
|
||||
error.method.notfound=Method not found: {0}.{1}({2})
|
||||
error.method.ambiguous=Unable to find unambiguous method: {0}.{1}({2})
|
||||
|
||||
# ValidatingVisitor
|
||||
error.fnMapper.null=Expression uses functions, but no FunctionMapper was provided
|
||||
error.fnMapper.method=Function [{0}] not found
|
||||
error.fnMapper.paramcount=Function [{0}] specifies [{1}] params, but [{2}] were declared
|
||||
|
||||
# ExpressionImpl
|
||||
error.context.null=ELContext was null
|
||||
|
||||
# Parser
|
||||
error.funciton.tooManyMethodParameterSets=There are multiple sets of parameters specified for function [{0}]
|
||||
error.identifier.notjava=The identifier [{0}] is not a valid Java identifier as required by section 1.19 of the EL specification (Identifier ::= Java language identifier). This check can be disabled by setting the system property org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true.
|
||||
error.lambda.tooManyMethodParameterSets=There are more sets of method parameters specified than there are nested lambda expressions
|
||||
|
||||
# Stream
|
||||
stream.compare.notComparable=Stream elements must implement Comparable
|
||||
stream.optional.empty=It is illegal to call get() on an empty optional
|
||||
stream.optional.paramNotLambda=The parameter for the method [{0}] should be a lambda expression
|
||||
36
java/org/apache/el/Messages_es.properties
Normal file
36
java/org/apache/el/Messages_es.properties
Normal file
@@ -0,0 +1,36 @@
|
||||
# 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.
|
||||
|
||||
error.convert = No puedo convertir [{0}] desde tipo [{1}] a [{2}]
|
||||
error.compare = No puedo comparar [{0}] con [{1}]
|
||||
error.function = Problemas llamando a funci\u00F3n [{0}]
|
||||
error.unreachable.base = Objetivo inalcanzable, identificador [{0}] resuelto a nulo
|
||||
error.unreachable.property = Objetivo inalcanzable, [{0}] devolvi\u00F3 nulo
|
||||
error.resolver.unhandled = ELResolver no manej\u00F3 el tipo: [{0}] con propiedad de [{1}]
|
||||
error.resolver.unhandled.null = ELResolver no puede manejar un Objeto base nulo con identificador de [{0}]
|
||||
error.value.literal.write = ValueExpression es un literal y no un grabable: [{0}]
|
||||
error.null = La expresi\u00F3n no puede ser nula
|
||||
error.mixed = La expresi\u00F3n no puede contenera la vez ''#{..}'' y ''${..}'' : [{0}]
|
||||
error.method = No es una MethodExpression v\u00E1lida: [{0}]
|
||||
error.method.nullParms = Los tipos de par\u00E1metro no pueden ser nulo
|
||||
error.value.expectedType = El tipo esperado no puede ser nulo
|
||||
error.syntax.set = Sit\u00E1xis ilegal para Operaci\u00F3n de Poner Valor
|
||||
error.method.notfound = M\u00E9todo no hallado: {0}.{1}({2})
|
||||
error.method.ambiguous = No pude hallar m\u00E9todo ambiguo: {0}.{1}({2})
|
||||
error.fnMapper.null = La expresi\u00F3n usa funciones, pero no se ha suministrado FunctionMapper
|
||||
error.fnMapper.method = Funci\u00F3n [{0}] no hallada
|
||||
error.fnMapper.paramcount = La funci\u00F3n [{0}] especifica [{1}] par\u00E9metros, pero [{2}] fueron declarados
|
||||
error.context.null = ELContext era nulo
|
||||
error.identifier.notjava = El identificador [{0}] no es un identificado Java v\u00E1lido seg\u00FAn se requiere en la secci\u00F3n 1.9 de la especificaci\u00F3n EL (Identificador ::= identificador de lenguaje Java). Este chequeo se puede desactivar poniendo la propiedad del sistema org.apache.el.parser.SKIP_IDENTIFIER_CHECK a verdad (true).
|
||||
331
java/org/apache/el/MethodExpressionImpl.java
Normal file
331
java/org/apache/el/MethodExpressionImpl.java
Normal file
@@ -0,0 +1,331 @@
|
||||
/*
|
||||
* 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 javax.el.ELContext;
|
||||
import javax.el.ELException;
|
||||
import javax.el.FunctionMapper;
|
||||
import javax.el.MethodExpression;
|
||||
import javax.el.MethodInfo;
|
||||
import javax.el.MethodNotFoundException;
|
||||
import javax.el.PropertyNotFoundException;
|
||||
import javax.el.VariableMapper;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
import org.apache.el.lang.ExpressionBuilder;
|
||||
import org.apache.el.parser.Node;
|
||||
import org.apache.el.util.ReflectionUtil;
|
||||
|
||||
|
||||
/**
|
||||
* An <code>Expression</code> that refers to a method on an object.
|
||||
*
|
||||
* <p>
|
||||
* The {@link javax.el.ExpressionFactory#createMethodExpression} method
|
||||
* can be used to parse an expression string and return a concrete instance
|
||||
* of <code>MethodExpression</code> that encapsulates the parsed expression.
|
||||
* The {@link FunctionMapper} is used at parse time, not evaluation time,
|
||||
* so one is not needed to evaluate an expression using this class.
|
||||
* However, the {@link ELContext} is needed at evaluation time.</p>
|
||||
*
|
||||
* <p>The {@link #getMethodInfo} and {@link #invoke} methods will evaluate the
|
||||
* expression each time they are called. The {@link javax.el.ELResolver} in the
|
||||
* <code>ELContext</code> is used to resolve the top-level variables and to
|
||||
* determine the behavior of the <code>.</code> and <code>[]</code>
|
||||
* operators. For any of the two methods, the
|
||||
* {@link javax.el.ELResolver#getValue} method is used to resolve all properties
|
||||
* up to but excluding the last one. This provides the <code>base</code> object
|
||||
* on which the method appears. If the <code>base</code> object is null, a
|
||||
* <code>NullPointerException</code> must be thrown. At the last resolution,
|
||||
* the final <code>property</code> is then coerced to a <code>String</code>,
|
||||
* which provides the name of the method to be found. A method matching the
|
||||
* name and expected parameters provided at parse time is found and it is
|
||||
* either queried or invoked (depending on the method called on this
|
||||
* <code>MethodExpression</code>).</p>
|
||||
*
|
||||
* <p>See the notes about comparison, serialization and immutability in
|
||||
* the {@link javax.el.Expression} javadocs.
|
||||
*
|
||||
* @see javax.el.ELResolver
|
||||
* @see javax.el.Expression
|
||||
* @see javax.el.ExpressionFactory
|
||||
* @see javax.el.MethodExpression
|
||||
*
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class MethodExpressionImpl extends MethodExpression implements
|
||||
Externalizable {
|
||||
|
||||
private Class<?> expectedType;
|
||||
|
||||
private String expr;
|
||||
|
||||
private FunctionMapper fnMapper;
|
||||
|
||||
private VariableMapper varMapper;
|
||||
|
||||
private transient Node node;
|
||||
|
||||
private Class<?>[] paramTypes;
|
||||
|
||||
public MethodExpressionImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MethodExpressionImpl(String expr, Node node,
|
||||
FunctionMapper fnMapper, VariableMapper varMapper,
|
||||
Class<?> expectedType, Class<?>[] paramTypes) {
|
||||
super();
|
||||
this.expr = expr;
|
||||
this.node = node;
|
||||
this.fnMapper = fnMapper;
|
||||
this.varMapper = varMapper;
|
||||
this.expectedType = expectedType;
|
||||
this.paramTypes = paramTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified object is equal to this
|
||||
* <code>Expression</code>.
|
||||
*
|
||||
* <p>
|
||||
* The result is <code>true</code> if and only if the argument is not
|
||||
* <code>null</code>, is an <code>Expression</code> object that is the
|
||||
* of the same type (<code>ValueExpression</code> or
|
||||
* <code>MethodExpression</code>), and has an identical parsed
|
||||
* representation.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Note that two expressions can be equal if their expression Strings are
|
||||
* different. For example, <code>${fn1:foo()}</code> and
|
||||
* <code>${fn2:foo()}</code> are equal if their corresponding
|
||||
* <code>FunctionMapper</code>s mapped <code>fn1:foo</code> and
|
||||
* <code>fn2:foo</code> to the same method.
|
||||
* </p>
|
||||
*
|
||||
* @param obj
|
||||
* the <code>Object</code> to test for equality.
|
||||
* @return <code>true</code> if <code>obj</code> equals this
|
||||
* <code>Expression</code>; <code>false</code> otherwise.
|
||||
* @see java.util.Hashtable
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof MethodExpressionImpl && obj.hashCode() == this
|
||||
.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the original String used to create this <code>Expression</code>,
|
||||
* unmodified.
|
||||
*
|
||||
* <p>
|
||||
* This is used for debugging purposes but also for the purposes of
|
||||
* comparison (e.g. to ensure the expression in a configuration file has not
|
||||
* changed).
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* This method does not provide sufficient information to re-create an
|
||||
* expression. Two different expressions can have exactly the same
|
||||
* expression string but different function mappings. Serialization should
|
||||
* be used to save and restore the state of an <code>Expression</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return The original expression String.
|
||||
*
|
||||
* @see javax.el.Expression#getExpressionString()
|
||||
*/
|
||||
@Override
|
||||
public String getExpressionString() {
|
||||
return this.expr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the expression relative to the provided context, and returns
|
||||
* information about the actual referenced method.
|
||||
*
|
||||
* @param context
|
||||
* The context of this evaluation
|
||||
* @return an instance of <code>MethodInfo</code> containing information
|
||||
* about the method the expression evaluated to.
|
||||
* @throws NullPointerException
|
||||
* if context is <code>null</code> or the base object is
|
||||
* <code>null</code> on the last resolution.
|
||||
* @throws PropertyNotFoundException
|
||||
* if one of the property resolutions failed because a specified
|
||||
* variable or property does not exist or is not readable.
|
||||
* @throws MethodNotFoundException
|
||||
* if no suitable method can be found.
|
||||
* @throws ELException
|
||||
* if an exception was thrown while performing property or
|
||||
* variable resolution. The thrown exception must be included as
|
||||
* the cause property of this exception, if available.
|
||||
* @see javax.el.MethodExpression#getMethodInfo(javax.el.ELContext)
|
||||
*/
|
||||
@Override
|
||||
public MethodInfo getMethodInfo(ELContext context)
|
||||
throws PropertyNotFoundException, MethodNotFoundException,
|
||||
ELException {
|
||||
Node n = this.getNode();
|
||||
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
|
||||
this.varMapper);
|
||||
ctx.notifyBeforeEvaluation(getExpressionString());
|
||||
MethodInfo result = n.getMethodInfo(ctx, this.paramTypes);
|
||||
ctx.notifyAfterEvaluation(getExpressionString());
|
||||
return result;
|
||||
}
|
||||
|
||||
private Node getNode() throws ELException {
|
||||
if (this.node == null) {
|
||||
this.node = ExpressionBuilder.createNode(this.expr);
|
||||
}
|
||||
return this.node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for this <code>Expression</code>.
|
||||
*
|
||||
* <p>
|
||||
* See the note in the {@link #equals} method on how two expressions can be
|
||||
* equal if their expression Strings are different. Recall that if two
|
||||
* objects are equal according to the <code>equals(Object)</code> method,
|
||||
* then calling the <code>hashCode</code> method on each of the two
|
||||
* objects must produce the same integer result. Implementations must take
|
||||
* special note and implement <code>hashCode</code> correctly.
|
||||
* </p>
|
||||
*
|
||||
* @return The hash code for this <code>Expression</code>.
|
||||
* @see #equals
|
||||
* @see java.util.Hashtable
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.expr.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the expression relative to the provided context, invokes the
|
||||
* method that was found using the supplied parameters, and returns the
|
||||
* result of the method invocation.
|
||||
*
|
||||
* @param context
|
||||
* The context of this evaluation.
|
||||
* @param params
|
||||
* The parameters to pass to the method, or <code>null</code>
|
||||
* if no parameters.
|
||||
* @return the result of the method invocation (<code>null</code> if the
|
||||
* method has a <code>void</code> return type).
|
||||
* @throws NullPointerException
|
||||
* if context is <code>null</code> or the base object is
|
||||
* <code>null</code> on the last resolution.
|
||||
* @throws PropertyNotFoundException
|
||||
* if one of the property resolutions failed because a specified
|
||||
* variable or property does not exist or is not readable.
|
||||
* @throws MethodNotFoundException
|
||||
* if no suitable method can be found.
|
||||
* @throws ELException
|
||||
* if an exception was thrown while performing property or
|
||||
* variable resolution. The thrown exception must be included as
|
||||
* the cause property of this exception, if available. If the
|
||||
* exception thrown is an <code>InvocationTargetException</code>,
|
||||
* extract its <code>cause</code> and pass it to the
|
||||
* <code>ELException</code> constructor.
|
||||
* @see javax.el.MethodExpression#invoke(javax.el.ELContext,
|
||||
* java.lang.Object[])
|
||||
*/
|
||||
@Override
|
||||
public Object invoke(ELContext context, Object[] params)
|
||||
throws PropertyNotFoundException, MethodNotFoundException,
|
||||
ELException {
|
||||
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
|
||||
this.varMapper);
|
||||
ctx.notifyBeforeEvaluation(getExpressionString());
|
||||
Object result = this.getNode().invoke(ctx, this.paramTypes, params);
|
||||
ctx.notifyAfterEvaluation(getExpressionString());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.io.Externalizable#readExternal(java.io.ObjectInput)
|
||||
*/
|
||||
@Override
|
||||
public void readExternal(ObjectInput in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
this.expr = in.readUTF();
|
||||
String type = in.readUTF();
|
||||
if (!"".equals(type)) {
|
||||
this.expectedType = ReflectionUtil.forName(type);
|
||||
}
|
||||
this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in
|
||||
.readObject()));
|
||||
this.fnMapper = (FunctionMapper) in.readObject();
|
||||
this.varMapper = (VariableMapper) in.readObject();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
|
||||
*/
|
||||
@Override
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeUTF(this.expr);
|
||||
out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
|
||||
: "");
|
||||
out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
|
||||
out.writeObject(this.fnMapper);
|
||||
out.writeObject(this.varMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLiteralText() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since EL 3.0
|
||||
*/
|
||||
@Override
|
||||
public boolean isParametersProvided() {
|
||||
return this.getNode().isParametersProvided();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since EL 2.2
|
||||
* Note: The spelling mistake is deliberate.
|
||||
* isParmetersProvided() - Specification definition
|
||||
* isParametersProvided() - Corrected spelling
|
||||
*/
|
||||
@Override
|
||||
public boolean isParmetersProvided() {
|
||||
return this.getNode().isParametersProvided();
|
||||
}
|
||||
|
||||
}
|
||||
112
java/org/apache/el/MethodExpressionLiteral.java
Normal file
112
java/org/apache/el/MethodExpressionLiteral.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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 javax.el.ELContext;
|
||||
import javax.el.ELException;
|
||||
import javax.el.MethodExpression;
|
||||
import javax.el.MethodInfo;
|
||||
|
||||
import org.apache.el.util.ReflectionUtil;
|
||||
|
||||
|
||||
public class MethodExpressionLiteral extends MethodExpression implements Externalizable {
|
||||
|
||||
private Class<?> expectedType;
|
||||
|
||||
private String expr;
|
||||
|
||||
private Class<?>[] paramTypes;
|
||||
|
||||
public MethodExpressionLiteral() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public MethodExpressionLiteral(String expr, Class<?> expectedType,
|
||||
Class<?>[] paramTypes) {
|
||||
this.expr = expr;
|
||||
this.expectedType = expectedType;
|
||||
this.paramTypes = paramTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodInfo getMethodInfo(ELContext context) throws ELException {
|
||||
context.notifyBeforeEvaluation(getExpressionString());
|
||||
MethodInfo result =
|
||||
new MethodInfo(this.expr, this.expectedType, this.paramTypes);
|
||||
context.notifyAfterEvaluation(getExpressionString());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(ELContext context, Object[] params) throws ELException {
|
||||
context.notifyBeforeEvaluation(getExpressionString());
|
||||
Object result;
|
||||
if (this.expectedType != null) {
|
||||
result = context.convertToType(this.expr, this.expectedType);
|
||||
} else {
|
||||
result = this.expr;
|
||||
}
|
||||
context.notifyAfterEvaluation(getExpressionString());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpressionString() {
|
||||
return this.expr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof MethodExpressionLiteral && this.hashCode() == obj.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.expr.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLiteralText() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
||||
this.expr = in.readUTF();
|
||||
String type = in.readUTF();
|
||||
if (!"".equals(type)) {
|
||||
this.expectedType = ReflectionUtil.forName(type);
|
||||
}
|
||||
this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in
|
||||
.readObject()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeUTF(this.expr);
|
||||
out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
|
||||
: "");
|
||||
out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
|
||||
}
|
||||
}
|
||||
293
java/org/apache/el/ValueExpressionImpl.java
Normal file
293
java/org/apache/el/ValueExpressionImpl.java
Normal file
@@ -0,0 +1,293 @@
|
||||
/*
|
||||
* 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 javax.el.ELContext;
|
||||
import javax.el.ELException;
|
||||
import javax.el.FunctionMapper;
|
||||
import javax.el.PropertyNotFoundException;
|
||||
import javax.el.PropertyNotWritableException;
|
||||
import javax.el.ValueExpression;
|
||||
import javax.el.ValueReference;
|
||||
import javax.el.VariableMapper;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
import org.apache.el.lang.ExpressionBuilder;
|
||||
import org.apache.el.parser.AstLiteralExpression;
|
||||
import org.apache.el.parser.Node;
|
||||
import org.apache.el.util.ReflectionUtil;
|
||||
|
||||
|
||||
/**
|
||||
* An <code>Expression</code> that can get or set a value.
|
||||
*
|
||||
* <p>
|
||||
* In previous incarnations of this API, expressions could only be read.
|
||||
* <code>ValueExpression</code> objects can now be used both to retrieve a
|
||||
* value and to set a value. Expressions that can have a value set on them are
|
||||
* referred to as l-value expressions. Those that cannot are referred to as
|
||||
* r-value expressions. Not all r-value expressions can be used as l-value
|
||||
* expressions (e.g. <code>"${1+1}"</code> or
|
||||
* <code>"${firstName} ${lastName}"</code>). See the EL Specification for
|
||||
* details. Expressions that cannot be used as l-values must always return
|
||||
* <code>true</code> from <code>isReadOnly()</code>.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The {@link javax.el.ExpressionFactory#createValueExpression} method
|
||||
* can be used to parse an expression string and return a concrete instance
|
||||
* of <code>ValueExpression</code> that encapsulates the parsed expression.
|
||||
* The {@link FunctionMapper} is used at parse time, not evaluation time,
|
||||
* so one is not needed to evaluate an expression using this class.
|
||||
* However, the {@link ELContext} is needed at evaluation time.</p>
|
||||
*
|
||||
* <p>The {@link #getValue}, {@link #setValue}, {@link #isReadOnly} and
|
||||
* {@link #getType} methods will evaluate the expression each time they are
|
||||
* called. The {@link javax.el.ELResolver} in the <code>ELContext</code> is used
|
||||
* to resolve the top-level variables and to determine the behavior of the
|
||||
* <code>.</code> and <code>[]</code> operators. For any of the four methods,
|
||||
* the {@link javax.el.ELResolver#getValue} method is used to resolve all
|
||||
* properties up to but excluding the last one. This provides the
|
||||
* <code>base</code> object. At the last resolution, the
|
||||
* <code>ValueExpression</code> will call the corresponding
|
||||
* {@link javax.el.ELResolver#getValue}, {@link javax.el.ELResolver#setValue},
|
||||
* {@link javax.el.ELResolver#isReadOnly} or {@link javax.el.ELResolver#getType}
|
||||
* method, depending on which was called on the <code>ValueExpression</code>.
|
||||
* </p>
|
||||
*
|
||||
* <p>See the notes about comparison, serialization and immutability in
|
||||
* the {@link javax.el.Expression} javadocs.
|
||||
*
|
||||
* @see javax.el.ELResolver
|
||||
* @see javax.el.Expression
|
||||
* @see javax.el.ExpressionFactory
|
||||
* @see javax.el.ValueExpression
|
||||
*
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class ValueExpressionImpl extends ValueExpression implements
|
||||
Externalizable {
|
||||
|
||||
private Class<?> expectedType;
|
||||
|
||||
private String expr;
|
||||
|
||||
private FunctionMapper fnMapper;
|
||||
|
||||
private VariableMapper varMapper;
|
||||
|
||||
private transient Node node;
|
||||
|
||||
public ValueExpressionImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper,
|
||||
VariableMapper varMapper, Class<?> expectedType) {
|
||||
this.expr = expr;
|
||||
this.node = node;
|
||||
this.fnMapper = fnMapper;
|
||||
this.varMapper = varMapper;
|
||||
this.expectedType = expectedType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ValueExpressionImpl)) {
|
||||
return false;
|
||||
}
|
||||
if (obj.hashCode() != this.hashCode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.getNode().equals(((ValueExpressionImpl) obj).getNode());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.el.ValueExpression#getExpectedType()
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getExpectedType() {
|
||||
return this.expectedType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type the result of the expression will be coerced to after
|
||||
* evaluation.
|
||||
*
|
||||
* @return the <code>expectedType</code> passed to the
|
||||
* <code>ExpressionFactory.createValueExpression</code> method
|
||||
* that created this <code>ValueExpression</code>.
|
||||
*
|
||||
* @see javax.el.Expression#getExpressionString()
|
||||
*/
|
||||
@Override
|
||||
public String getExpressionString() {
|
||||
return this.expr;
|
||||
}
|
||||
|
||||
private Node getNode() throws ELException {
|
||||
if (this.node == null) {
|
||||
this.node = ExpressionBuilder.createNode(this.expr);
|
||||
}
|
||||
return this.node;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.el.ValueExpression#getType(javax.el.ELContext)
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getType(ELContext context) throws PropertyNotFoundException,
|
||||
ELException {
|
||||
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
|
||||
this.varMapper);
|
||||
context.notifyBeforeEvaluation(getExpressionString());
|
||||
Class<?> result = this.getNode().getType(ctx);
|
||||
context.notifyAfterEvaluation(getExpressionString());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.el.ValueExpression#getValue(javax.el.ELContext)
|
||||
*/
|
||||
@Override
|
||||
public Object getValue(ELContext context) throws PropertyNotFoundException,
|
||||
ELException {
|
||||
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
|
||||
this.varMapper);
|
||||
context.notifyBeforeEvaluation(getExpressionString());
|
||||
Object value = this.getNode().getValue(ctx);
|
||||
if (this.expectedType != null) {
|
||||
value = context.convertToType(value, this.expectedType);
|
||||
}
|
||||
context.notifyAfterEvaluation(getExpressionString());
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.getNode().hashCode();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.el.ValueExpression#isLiteralText()
|
||||
*/
|
||||
@Override
|
||||
public boolean isLiteralText() {
|
||||
try {
|
||||
return this.getNode() instanceof AstLiteralExpression;
|
||||
} catch (ELException ele) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadOnly(ELContext context)
|
||||
throws PropertyNotFoundException, ELException {
|
||||
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
|
||||
this.varMapper);
|
||||
context.notifyBeforeEvaluation(getExpressionString());
|
||||
boolean result = this.getNode().isReadOnly(ctx);
|
||||
context.notifyAfterEvaluation(getExpressionString());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(ObjectInput in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
this.expr = in.readUTF();
|
||||
String type = in.readUTF();
|
||||
if (!"".equals(type)) {
|
||||
this.expectedType = ReflectionUtil.forName(type);
|
||||
}
|
||||
this.fnMapper = (FunctionMapper) in.readObject();
|
||||
this.varMapper = (VariableMapper) in.readObject();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.el.ValueExpression#setValue(javax.el.ELContext,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void setValue(ELContext context, Object value)
|
||||
throws PropertyNotFoundException, PropertyNotWritableException,
|
||||
ELException {
|
||||
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
|
||||
this.varMapper);
|
||||
context.notifyBeforeEvaluation(getExpressionString());
|
||||
this.getNode().setValue(ctx, value);
|
||||
context.notifyAfterEvaluation(getExpressionString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeUTF(this.expr);
|
||||
out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
|
||||
: "");
|
||||
out.writeObject(this.fnMapper);
|
||||
out.writeObject(this.varMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValueExpression["+this.expr+"]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @since EL 2.2
|
||||
*/
|
||||
@Override
|
||||
public ValueReference getValueReference(ELContext context) {
|
||||
EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
|
||||
this.varMapper);
|
||||
context.notifyBeforeEvaluation(getExpressionString());
|
||||
ValueReference result = this.getNode().getValueReference(ctx);
|
||||
context.notifyAfterEvaluation(getExpressionString());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
136
java/org/apache/el/ValueExpressionLiteral.java
Normal file
136
java/org/apache/el/ValueExpressionLiteral.java
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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 javax.el.ELContext;
|
||||
import javax.el.PropertyNotWritableException;
|
||||
import javax.el.ValueExpression;
|
||||
|
||||
import org.apache.el.util.MessageFactory;
|
||||
import org.apache.el.util.ReflectionUtil;
|
||||
|
||||
|
||||
public final class ValueExpressionLiteral extends ValueExpression implements
|
||||
Externalizable {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object 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 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 (!"".equals(type)) {
|
||||
this.expectedType = ReflectionUtil.forName(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
401
java/org/apache/el/lang/ELArithmetic.java
Normal file
401
java/org/apache/el/lang/ELArithmetic.java
Normal file
@@ -0,0 +1,401 @@
|
||||
/*
|
||||
* 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.lang;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.apache.el.util.MessageFactory;
|
||||
|
||||
|
||||
/**
|
||||
* A helper class of Arithmetic defined by the EL Specification
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public abstract class ELArithmetic {
|
||||
|
||||
public static final class BigDecimalDelegate extends ELArithmetic {
|
||||
|
||||
@Override
|
||||
protected Number add(Number num0, Number num1) {
|
||||
return ((BigDecimal) num0).add((BigDecimal) num1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number coerce(Number num) {
|
||||
if (num instanceof BigDecimal)
|
||||
return num;
|
||||
if (num instanceof BigInteger)
|
||||
return new BigDecimal((BigInteger) num);
|
||||
return new BigDecimal(num.doubleValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number coerce(String str) {
|
||||
return new BigDecimal(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number divide(Number num0, Number num1) {
|
||||
return ((BigDecimal) num0).divide((BigDecimal) num1,
|
||||
RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number subtract(Number num0, Number num1) {
|
||||
return ((BigDecimal) num0).subtract((BigDecimal) num1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number mod(Number num0, Number num1) {
|
||||
return Double.valueOf(num0.doubleValue() % num1.doubleValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number multiply(Number num0, Number num1) {
|
||||
return ((BigDecimal) num0).multiply((BigDecimal) num1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object obj0, Object obj1) {
|
||||
return (obj0 instanceof BigDecimal || obj1 instanceof BigDecimal);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class BigIntegerDelegate extends ELArithmetic {
|
||||
|
||||
@Override
|
||||
protected Number add(Number num0, Number num1) {
|
||||
return ((BigInteger) num0).add((BigInteger) num1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number coerce(Number num) {
|
||||
if (num instanceof BigInteger)
|
||||
return num;
|
||||
return new BigInteger(num.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number coerce(String str) {
|
||||
return new BigInteger(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number divide(Number num0, Number num1) {
|
||||
return (new BigDecimal((BigInteger) num0)).divide(new BigDecimal((BigInteger) num1), RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number multiply(Number num0, Number num1) {
|
||||
return ((BigInteger) num0).multiply((BigInteger) num1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number mod(Number num0, Number num1) {
|
||||
return ((BigInteger) num0).mod((BigInteger) num1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number subtract(Number num0, Number num1) {
|
||||
return ((BigInteger) num0).subtract((BigInteger) num1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object obj0, Object obj1) {
|
||||
return (obj0 instanceof BigInteger || obj1 instanceof BigInteger);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class DoubleDelegate extends ELArithmetic {
|
||||
|
||||
@Override
|
||||
protected Number add(Number num0, Number num1) {
|
||||
// could only be one of these
|
||||
if (num0 instanceof BigDecimal) {
|
||||
return ((BigDecimal) num0).add(new BigDecimal(num1.doubleValue()));
|
||||
} else if (num1 instanceof BigDecimal) {
|
||||
return ((new BigDecimal(num0.doubleValue()).add((BigDecimal) num1)));
|
||||
}
|
||||
return Double.valueOf(num0.doubleValue() + num1.doubleValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number coerce(Number num) {
|
||||
if (num instanceof Double)
|
||||
return num;
|
||||
if (num instanceof BigInteger)
|
||||
return new BigDecimal((BigInteger) num);
|
||||
return Double.valueOf(num.doubleValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number coerce(String str) {
|
||||
return Double.valueOf(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number divide(Number num0, Number num1) {
|
||||
return Double.valueOf(num0.doubleValue() / num1.doubleValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number mod(Number num0, Number num1) {
|
||||
return Double.valueOf(num0.doubleValue() % num1.doubleValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number subtract(Number num0, Number num1) {
|
||||
// could only be one of these
|
||||
if (num0 instanceof BigDecimal) {
|
||||
return ((BigDecimal) num0).subtract(new BigDecimal(num1.doubleValue()));
|
||||
} else if (num1 instanceof BigDecimal) {
|
||||
return ((new BigDecimal(num0.doubleValue()).subtract((BigDecimal) num1)));
|
||||
}
|
||||
return Double.valueOf(num0.doubleValue() - num1.doubleValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number multiply(Number num0, Number num1) {
|
||||
// could only be one of these
|
||||
if (num0 instanceof BigDecimal) {
|
||||
return ((BigDecimal) num0).multiply(new BigDecimal(num1.doubleValue()));
|
||||
} else if (num1 instanceof BigDecimal) {
|
||||
return ((new BigDecimal(num0.doubleValue()).multiply((BigDecimal) num1)));
|
||||
}
|
||||
return Double.valueOf(num0.doubleValue() * num1.doubleValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object obj0, Object obj1) {
|
||||
return (obj0 instanceof Double
|
||||
|| obj1 instanceof Double
|
||||
|| obj0 instanceof Float
|
||||
|| obj1 instanceof Float
|
||||
|| (obj0 instanceof String && ELSupport
|
||||
.isStringFloat((String) obj0)) || (obj1 instanceof String && ELSupport
|
||||
.isStringFloat((String) obj1)));
|
||||
}
|
||||
}
|
||||
|
||||
public static final class LongDelegate extends ELArithmetic {
|
||||
|
||||
@Override
|
||||
protected Number add(Number num0, Number num1) {
|
||||
return Long.valueOf(num0.longValue() + num1.longValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number coerce(Number num) {
|
||||
if (num instanceof Long)
|
||||
return num;
|
||||
return Long.valueOf(num.longValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number coerce(String str) {
|
||||
return Long.valueOf(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number divide(Number num0, Number num1) {
|
||||
return Long.valueOf(num0.longValue() / num1.longValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number mod(Number num0, Number num1) {
|
||||
return Long.valueOf(num0.longValue() % num1.longValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number subtract(Number num0, Number num1) {
|
||||
return Long.valueOf(num0.longValue() - num1.longValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number multiply(Number num0, Number num1) {
|
||||
return Long.valueOf(num0.longValue() * num1.longValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object obj0, Object obj1) {
|
||||
return (obj0 instanceof Long || obj1 instanceof Long);
|
||||
}
|
||||
}
|
||||
|
||||
public static final BigDecimalDelegate BIGDECIMAL = new BigDecimalDelegate();
|
||||
|
||||
public static final BigIntegerDelegate BIGINTEGER = new BigIntegerDelegate();
|
||||
|
||||
public static final DoubleDelegate DOUBLE = new DoubleDelegate();
|
||||
|
||||
public static final LongDelegate LONG = new LongDelegate();
|
||||
|
||||
private static final Long ZERO = Long.valueOf(0);
|
||||
|
||||
public static final Number add(final Object obj0, final Object obj1) {
|
||||
final ELArithmetic delegate = findDelegate(obj0, obj1);
|
||||
if (delegate == null) {
|
||||
return Long.valueOf(0);
|
||||
}
|
||||
|
||||
Number num0 = delegate.coerce(obj0);
|
||||
Number num1 = delegate.coerce(obj1);
|
||||
|
||||
return delegate.add(num0, num1);
|
||||
}
|
||||
|
||||
public static final Number mod(final Object obj0, final Object obj1) {
|
||||
if (obj0 == null && obj1 == null) {
|
||||
return Long.valueOf(0);
|
||||
}
|
||||
|
||||
final ELArithmetic delegate;
|
||||
if (BIGDECIMAL.matches(obj0, obj1))
|
||||
delegate = DOUBLE;
|
||||
else if (DOUBLE.matches(obj0, obj1))
|
||||
delegate = DOUBLE;
|
||||
else if (BIGINTEGER.matches(obj0, obj1))
|
||||
delegate = BIGINTEGER;
|
||||
else
|
||||
delegate = LONG;
|
||||
|
||||
Number num0 = delegate.coerce(obj0);
|
||||
Number num1 = delegate.coerce(obj1);
|
||||
|
||||
return delegate.mod(num0, num1);
|
||||
}
|
||||
|
||||
public static final Number subtract(final Object obj0, final Object obj1) {
|
||||
final ELArithmetic delegate = findDelegate(obj0, obj1);
|
||||
if (delegate == null) {
|
||||
return Long.valueOf(0);
|
||||
}
|
||||
|
||||
Number num0 = delegate.coerce(obj0);
|
||||
Number num1 = delegate.coerce(obj1);
|
||||
|
||||
return delegate.subtract(num0, num1);
|
||||
}
|
||||
|
||||
public static final Number divide(final Object obj0, final Object obj1) {
|
||||
if (obj0 == null && obj1 == null) {
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
final ELArithmetic delegate;
|
||||
if (BIGDECIMAL.matches(obj0, obj1))
|
||||
delegate = BIGDECIMAL;
|
||||
else if (BIGINTEGER.matches(obj0, obj1))
|
||||
delegate = BIGDECIMAL;
|
||||
else
|
||||
delegate = DOUBLE;
|
||||
|
||||
Number num0 = delegate.coerce(obj0);
|
||||
Number num1 = delegate.coerce(obj1);
|
||||
|
||||
return delegate.divide(num0, num1);
|
||||
}
|
||||
|
||||
public static final Number multiply(final Object obj0, final Object obj1) {
|
||||
final ELArithmetic delegate = findDelegate(obj0, obj1);
|
||||
if (delegate == null) {
|
||||
return Long.valueOf(0);
|
||||
}
|
||||
|
||||
Number num0 = delegate.coerce(obj0);
|
||||
Number num1 = delegate.coerce(obj1);
|
||||
|
||||
return delegate.multiply(num0, num1);
|
||||
}
|
||||
|
||||
private static ELArithmetic findDelegate(final Object obj0, final Object obj1) {
|
||||
if (obj0 == null && obj1 == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (BIGDECIMAL.matches(obj0, obj1)) {
|
||||
return BIGDECIMAL;
|
||||
} else if (DOUBLE.matches(obj0, obj1)) {
|
||||
if (BIGINTEGER.matches(obj0, obj1)) {
|
||||
return BIGDECIMAL;
|
||||
} else {
|
||||
return DOUBLE;
|
||||
}
|
||||
} else if (BIGINTEGER.matches(obj0, obj1)) {
|
||||
return BIGINTEGER;
|
||||
} else {
|
||||
return LONG;
|
||||
}
|
||||
}
|
||||
|
||||
public static final boolean isNumber(final Object obj) {
|
||||
return (obj != null && isNumberType(obj.getClass()));
|
||||
}
|
||||
|
||||
public static final boolean isNumberType(final Class<?> type) {
|
||||
return type == Long.TYPE || type == Double.TYPE ||
|
||||
type == Byte.TYPE || type == Short.TYPE ||
|
||||
type == Integer.TYPE || type == Float.TYPE ||
|
||||
Number.class.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected ELArithmetic() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected abstract Number add(final Number num0, final Number num1);
|
||||
|
||||
protected abstract Number multiply(final Number num0, final Number num1);
|
||||
|
||||
protected abstract Number subtract(final Number num0, final Number num1);
|
||||
|
||||
protected abstract Number mod(final Number num0, final Number num1);
|
||||
|
||||
protected abstract Number coerce(final Number num);
|
||||
|
||||
protected final Number coerce(final Object obj) {
|
||||
|
||||
if (isNumber(obj)) {
|
||||
return coerce((Number) obj);
|
||||
}
|
||||
if (obj == null || "".equals(obj)) {
|
||||
return coerce(ZERO);
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
return coerce((String) obj);
|
||||
}
|
||||
if (obj instanceof Character) {
|
||||
return coerce(Short.valueOf((short) ((Character) obj).charValue()));
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(MessageFactory.get("error.convert",
|
||||
obj, obj.getClass(), "Number"));
|
||||
}
|
||||
|
||||
protected abstract Number coerce(final String str);
|
||||
|
||||
protected abstract Number divide(final Number num0, final Number num1);
|
||||
|
||||
protected abstract boolean matches(final Object obj0, final Object obj1);
|
||||
|
||||
}
|
||||
655
java/org/apache/el/lang/ELSupport.java
Normal file
655
java/org/apache/el/lang/ELSupport.java
Normal file
File diff suppressed because it is too large
Load Diff
157
java/org/apache/el/lang/EvaluationContext.java
Normal file
157
java/org/apache/el/lang/EvaluationContext.java
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* 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.lang;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.EvaluationListener;
|
||||
import javax.el.FunctionMapper;
|
||||
import javax.el.ImportHandler;
|
||||
import javax.el.VariableMapper;
|
||||
|
||||
public final class EvaluationContext extends ELContext {
|
||||
|
||||
private final ELContext elContext;
|
||||
|
||||
private final FunctionMapper fnMapper;
|
||||
|
||||
private final VariableMapper varMapper;
|
||||
|
||||
public EvaluationContext(ELContext elContext, FunctionMapper fnMapper,
|
||||
VariableMapper varMapper) {
|
||||
this.elContext = elContext;
|
||||
this.fnMapper = fnMapper;
|
||||
this.varMapper = varMapper;
|
||||
}
|
||||
|
||||
public ELContext getELContext() {
|
||||
return elContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FunctionMapper getFunctionMapper() {
|
||||
return fnMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableMapper getVariableMapper() {
|
||||
return varMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
// Can't use Class<?> because API needs to match specification in superclass
|
||||
public Object getContext(@SuppressWarnings("rawtypes") Class key) {
|
||||
return elContext.getContext(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ELResolver getELResolver() {
|
||||
return elContext.getELResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPropertyResolved() {
|
||||
return elContext.isPropertyResolved();
|
||||
}
|
||||
|
||||
@Override
|
||||
// Can't use Class<?> because API needs to match specification in superclass
|
||||
public void putContext(@SuppressWarnings("rawtypes") Class key,
|
||||
Object contextObject) {
|
||||
elContext.putContext(key, contextObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyResolved(boolean resolved) {
|
||||
elContext.setPropertyResolved(resolved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return elContext.getLocale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
elContext.setLocale(locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyResolved(Object base, Object property) {
|
||||
elContext.setPropertyResolved(base, property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImportHandler getImportHandler() {
|
||||
return elContext.getImportHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvaluationListener(EvaluationListener listener) {
|
||||
elContext.addEvaluationListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EvaluationListener> getEvaluationListeners() {
|
||||
return elContext.getEvaluationListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyBeforeEvaluation(String expression) {
|
||||
elContext.notifyBeforeEvaluation(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAfterEvaluation(String expression) {
|
||||
elContext.notifyAfterEvaluation(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyPropertyResolved(Object base, Object property) {
|
||||
elContext.notifyPropertyResolved(base, property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLambdaArgument(String name) {
|
||||
return elContext.isLambdaArgument(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getLambdaArgument(String name) {
|
||||
return elContext.getLambdaArgument(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterLambdaScope(Map<String, Object> arguments) {
|
||||
elContext.enterLambdaScope(arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitLambdaScope() {
|
||||
elContext.exitLambdaScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertToType(Object obj, Class<?> type) {
|
||||
return elContext.convertToType(obj, type);
|
||||
}
|
||||
}
|
||||
337
java/org/apache/el/lang/ExpressionBuilder.java
Normal file
337
java/org/apache/el/lang/ExpressionBuilder.java
Normal file
@@ -0,0 +1,337 @@
|
||||
/*
|
||||
* 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.lang;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELException;
|
||||
import javax.el.FunctionMapper;
|
||||
import javax.el.MethodExpression;
|
||||
import javax.el.ValueExpression;
|
||||
import javax.el.VariableMapper;
|
||||
|
||||
import org.apache.el.MethodExpressionImpl;
|
||||
import org.apache.el.MethodExpressionLiteral;
|
||||
import org.apache.el.ValueExpressionImpl;
|
||||
import org.apache.el.parser.AstDeferredExpression;
|
||||
import org.apache.el.parser.AstDynamicExpression;
|
||||
import org.apache.el.parser.AstFunction;
|
||||
import org.apache.el.parser.AstIdentifier;
|
||||
import org.apache.el.parser.AstLiteralExpression;
|
||||
import org.apache.el.parser.AstValue;
|
||||
import org.apache.el.parser.ELParser;
|
||||
import org.apache.el.parser.Node;
|
||||
import org.apache.el.parser.NodeVisitor;
|
||||
import org.apache.el.util.ConcurrentCache;
|
||||
import org.apache.el.util.MessageFactory;
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class ExpressionBuilder implements NodeVisitor {
|
||||
|
||||
private static final SynchronizedStack<ELParser> parserCache = new SynchronizedStack<>();
|
||||
|
||||
private static final int CACHE_SIZE;
|
||||
private static final String CACHE_SIZE_PROP =
|
||||
"org.apache.el.ExpressionBuilder.CACHE_SIZE";
|
||||
|
||||
static {
|
||||
String cacheSizeStr;
|
||||
if (System.getSecurityManager() == null) {
|
||||
cacheSizeStr = System.getProperty(CACHE_SIZE_PROP, "5000");
|
||||
} else {
|
||||
cacheSizeStr = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
|
||||
@Override
|
||||
public String run() {
|
||||
return System.getProperty(CACHE_SIZE_PROP, "5000");
|
||||
}
|
||||
});
|
||||
}
|
||||
CACHE_SIZE = Integer.parseInt(cacheSizeStr);
|
||||
}
|
||||
|
||||
private static final ConcurrentCache<String, Node> expressionCache =
|
||||
new ConcurrentCache<>(CACHE_SIZE);
|
||||
|
||||
private FunctionMapper fnMapper;
|
||||
|
||||
private VariableMapper varMapper;
|
||||
|
||||
private final String expression;
|
||||
|
||||
public ExpressionBuilder(String expression, ELContext ctx)
|
||||
throws ELException {
|
||||
this.expression = expression;
|
||||
|
||||
FunctionMapper ctxFn = ctx.getFunctionMapper();
|
||||
VariableMapper ctxVar = ctx.getVariableMapper();
|
||||
|
||||
if (ctxFn != null) {
|
||||
this.fnMapper = new FunctionMapperFactory(ctxFn);
|
||||
}
|
||||
if (ctxVar != null) {
|
||||
this.varMapper = new VariableMapperFactory(ctxVar);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Node createNode(String expr) throws ELException {
|
||||
Node n = createNodeInternal(expr);
|
||||
return n;
|
||||
}
|
||||
|
||||
private static final Node createNodeInternal(String expr)
|
||||
throws ELException {
|
||||
if (expr == null) {
|
||||
throw new ELException(MessageFactory.get("error.null"));
|
||||
}
|
||||
|
||||
Node n = expressionCache.get(expr);
|
||||
if (n == null) {
|
||||
ELParser parser = parserCache.pop();
|
||||
try {
|
||||
if (parser == null) {
|
||||
parser = new ELParser(new StringReader(expr));
|
||||
} else {
|
||||
parser.ReInit(new StringReader(expr));
|
||||
}
|
||||
n = parser.CompositeExpression();
|
||||
|
||||
// validate composite expression
|
||||
int numChildren = n.jjtGetNumChildren();
|
||||
if (numChildren == 1) {
|
||||
n = n.jjtGetChild(0);
|
||||
} else {
|
||||
Class<?> type = null;
|
||||
Node child = null;
|
||||
for (int i = 0; i < numChildren; i++) {
|
||||
child = n.jjtGetChild(i);
|
||||
if (child instanceof AstLiteralExpression)
|
||||
continue;
|
||||
if (type == null)
|
||||
type = child.getClass();
|
||||
else {
|
||||
if (!type.equals(child.getClass())) {
|
||||
throw new ELException(MessageFactory.get(
|
||||
"error.mixed", expr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (n instanceof AstDeferredExpression
|
||||
|| n instanceof AstDynamicExpression) {
|
||||
n = n.jjtGetChild(0);
|
||||
}
|
||||
expressionCache.put(expr, n);
|
||||
} catch (Exception e) {
|
||||
throw new ELException(
|
||||
MessageFactory.get("error.parseFail", expr), e);
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parserCache.push(parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
private void prepare(Node node) throws ELException {
|
||||
try {
|
||||
node.accept(this);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ELException) {
|
||||
throw (ELException) e;
|
||||
} else {
|
||||
throw (new ELException(e));
|
||||
}
|
||||
}
|
||||
if (this.fnMapper instanceof FunctionMapperFactory) {
|
||||
this.fnMapper = ((FunctionMapperFactory) this.fnMapper).create();
|
||||
}
|
||||
if (this.varMapper instanceof VariableMapperFactory) {
|
||||
this.varMapper = ((VariableMapperFactory) this.varMapper).create();
|
||||
}
|
||||
}
|
||||
|
||||
private Node build() throws ELException {
|
||||
Node n = createNodeInternal(this.expression);
|
||||
this.prepare(n);
|
||||
if (n instanceof AstDeferredExpression
|
||||
|| n instanceof AstDynamicExpression) {
|
||||
n = n.jjtGetChild(0);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.el.parser.NodeVisitor#visit(com.sun.el.parser.Node)
|
||||
*/
|
||||
@Override
|
||||
public void visit(Node node) throws ELException {
|
||||
if (node instanceof AstFunction) {
|
||||
|
||||
AstFunction funcNode = (AstFunction) node;
|
||||
|
||||
Method m = null;
|
||||
|
||||
if (this.fnMapper != null) {
|
||||
m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode
|
||||
.getLocalName());
|
||||
}
|
||||
|
||||
// References to variables that refer to lambda expressions will be
|
||||
// parsed as functions. This is handled at runtime but at this point
|
||||
// need to treat it as a variable rather than a function.
|
||||
if (m == null && this.varMapper != null &&
|
||||
funcNode.getPrefix().length() == 0) {
|
||||
this.varMapper.resolveVariable(funcNode.getLocalName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.fnMapper == null) {
|
||||
throw new ELException(MessageFactory.get("error.fnMapper.null"));
|
||||
}
|
||||
|
||||
if (m == null) {
|
||||
throw new ELException(MessageFactory.get(
|
||||
"error.fnMapper.method", funcNode.getOutputName()));
|
||||
}
|
||||
|
||||
int methodParameterCount = m.getParameterTypes().length;
|
||||
// AstFunction->MethodParameters->Parameters()
|
||||
int inputParameterCount = node.jjtGetChild(0).jjtGetNumChildren();
|
||||
if (m.isVarArgs() && inputParameterCount < methodParameterCount - 1 ||
|
||||
!m.isVarArgs() && inputParameterCount != methodParameterCount) {
|
||||
throw new ELException(MessageFactory.get(
|
||||
"error.fnMapper.paramcount", funcNode.getOutputName(),
|
||||
"" + methodParameterCount, "" + node.jjtGetChild(0).jjtGetNumChildren()));
|
||||
}
|
||||
} else if (node instanceof AstIdentifier && this.varMapper != null) {
|
||||
String variable = ((AstIdentifier) node).getImage();
|
||||
|
||||
// simply capture it
|
||||
this.varMapper.resolveVariable(variable);
|
||||
}
|
||||
}
|
||||
|
||||
public ValueExpression createValueExpression(Class<?> expectedType)
|
||||
throws ELException {
|
||||
Node n = this.build();
|
||||
return new ValueExpressionImpl(this.expression, n, this.fnMapper,
|
||||
this.varMapper, expectedType);
|
||||
}
|
||||
|
||||
public MethodExpression createMethodExpression(Class<?> expectedReturnType,
|
||||
Class<?>[] expectedParamTypes) throws ELException {
|
||||
Node n = this.build();
|
||||
if (!n.isParametersProvided() && expectedParamTypes == null) {
|
||||
throw new NullPointerException(MessageFactory
|
||||
.get("error.method.nullParms"));
|
||||
}
|
||||
if (n instanceof AstValue || n instanceof AstIdentifier) {
|
||||
return new MethodExpressionImpl(expression, n, this.fnMapper,
|
||||
this.varMapper, expectedReturnType, expectedParamTypes);
|
||||
} else if (n instanceof AstLiteralExpression) {
|
||||
return new MethodExpressionLiteral(expression, expectedReturnType,
|
||||
expectedParamTypes);
|
||||
} else {
|
||||
throw new ELException("Not a Valid Method Expression: "
|
||||
+ expression);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copied from org.apache.tomcat.util.collections.SynchronizedStack since
|
||||
* we don't want the EL implementation to depend on the JAR where that
|
||||
* class resides.
|
||||
*/
|
||||
private static class SynchronizedStack<T> {
|
||||
|
||||
public static final int DEFAULT_SIZE = 128;
|
||||
private static final int DEFAULT_LIMIT = -1;
|
||||
|
||||
private int size;
|
||||
private final int limit;
|
||||
|
||||
/*
|
||||
* Points to the next available object in the stack
|
||||
*/
|
||||
private int index = -1;
|
||||
|
||||
private Object[] stack;
|
||||
|
||||
|
||||
public SynchronizedStack() {
|
||||
this(DEFAULT_SIZE, DEFAULT_LIMIT);
|
||||
}
|
||||
|
||||
public SynchronizedStack(int size, int limit) {
|
||||
this.size = size;
|
||||
this.limit = limit;
|
||||
stack = new Object[size];
|
||||
}
|
||||
|
||||
|
||||
public synchronized boolean push(T obj) {
|
||||
index++;
|
||||
if (index == size) {
|
||||
if (limit == -1 || size < limit) {
|
||||
expand();
|
||||
} else {
|
||||
index--;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
stack[index] = obj;
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public synchronized T pop() {
|
||||
if (index == -1) {
|
||||
return null;
|
||||
}
|
||||
T result = (T) stack[index];
|
||||
stack[index--] = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void expand() {
|
||||
int newSize = size * 2;
|
||||
if (limit != -1 && newSize > limit) {
|
||||
newSize = limit;
|
||||
}
|
||||
Object[] newStack = new Object[newSize];
|
||||
System.arraycopy(stack, 0, newStack, 0, size);
|
||||
// This is the only point where garbage is created by throwing away the
|
||||
// old array. Note it is only the array, not the contents, that becomes
|
||||
// garbage.
|
||||
stack = newStack;
|
||||
size = newSize;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
69
java/org/apache/el/lang/FunctionMapperFactory.java
Normal file
69
java/org/apache/el/lang/FunctionMapperFactory.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.lang;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.el.FunctionMapper;
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public class FunctionMapperFactory extends FunctionMapper {
|
||||
|
||||
protected FunctionMapperImpl memento = null;
|
||||
protected final FunctionMapper target;
|
||||
|
||||
public FunctionMapperFactory(FunctionMapper mapper) {
|
||||
if (mapper == null) {
|
||||
throw new NullPointerException("FunctionMapper target cannot be null");
|
||||
}
|
||||
this.target = mapper;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.el.FunctionMapper#resolveFunction(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Method resolveFunction(String prefix, String localName) {
|
||||
if (this.memento == null) {
|
||||
this.memento = new FunctionMapperImpl();
|
||||
}
|
||||
Method m = this.target.resolveFunction(prefix, localName);
|
||||
if (m != null) {
|
||||
this.memento.mapFunction(prefix, localName, m);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mapFunction(String prefix, String localName, Method method) {
|
||||
if (this.memento == null) {
|
||||
this.memento = new FunctionMapperImpl();
|
||||
}
|
||||
memento.mapFunction(prefix, localName, method);
|
||||
}
|
||||
|
||||
|
||||
public FunctionMapper create() {
|
||||
return this.memento;
|
||||
}
|
||||
|
||||
}
|
||||
188
java/org/apache/el/lang/FunctionMapperImpl.java
Normal file
188
java/org/apache/el/lang/FunctionMapperImpl.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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.lang;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import javax.el.FunctionMapper;
|
||||
|
||||
import org.apache.el.util.ReflectionUtil;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public class FunctionMapperImpl extends FunctionMapper implements
|
||||
Externalizable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected ConcurrentMap<String, Function> functions = new ConcurrentHashMap<>();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.el.FunctionMapper#resolveFunction(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Method resolveFunction(String prefix, String localName) {
|
||||
Function f = this.functions.get(prefix + ":" + localName);
|
||||
if (f == null) {
|
||||
return null;
|
||||
}
|
||||
return f.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapFunction(String prefix, String localName, Method m) {
|
||||
String key = prefix + ":" + localName;
|
||||
if (m == null) {
|
||||
functions.remove(key);
|
||||
} else {
|
||||
Function f = new Function(prefix, localName, m);
|
||||
functions.put(key, f);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
|
||||
*/
|
||||
@Override
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeObject(this.functions);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.io.Externalizable#readExternal(java.io.ObjectInput)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void readExternal(ObjectInput in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
this.functions = (ConcurrentMap<String, Function>) in.readObject();
|
||||
}
|
||||
|
||||
public static class Function implements Externalizable {
|
||||
|
||||
protected transient Method m;
|
||||
protected String owner;
|
||||
protected String name;
|
||||
protected String[] types;
|
||||
protected String prefix;
|
||||
protected String localName;
|
||||
|
||||
public Function(String prefix, String localName, Method m) {
|
||||
if (localName == null) {
|
||||
throw new NullPointerException("LocalName cannot be null");
|
||||
}
|
||||
if (m == null) {
|
||||
throw new NullPointerException("Method cannot be null");
|
||||
}
|
||||
this.prefix = prefix;
|
||||
this.localName = localName;
|
||||
this.m = m;
|
||||
}
|
||||
|
||||
public Function() {
|
||||
// for serialization
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
|
||||
*/
|
||||
@Override
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeUTF((this.prefix != null) ? this.prefix : "");
|
||||
out.writeUTF(this.localName);
|
||||
// make sure m isn't null
|
||||
getMethod();
|
||||
out.writeUTF((this.owner != null) ?
|
||||
this.owner :
|
||||
this.m.getDeclaringClass().getName());
|
||||
out.writeUTF((this.name != null) ?
|
||||
this.name :
|
||||
this.m.getName());
|
||||
out.writeObject((this.types != null) ?
|
||||
this.types :
|
||||
ReflectionUtil.toTypeNameArray(this.m.getParameterTypes()));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.io.Externalizable#readExternal(java.io.ObjectInput)
|
||||
*/
|
||||
@Override
|
||||
public void readExternal(ObjectInput in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
|
||||
this.prefix = in.readUTF();
|
||||
if ("".equals(this.prefix)) this.prefix = null;
|
||||
this.localName = in.readUTF();
|
||||
this.owner = in.readUTF();
|
||||
this.name = in.readUTF();
|
||||
this.types = (String[]) in.readObject();
|
||||
}
|
||||
|
||||
public Method getMethod() {
|
||||
if (this.m == null) {
|
||||
try {
|
||||
Class<?> t = ReflectionUtil.forName(this.owner);
|
||||
Class<?>[] p = ReflectionUtil.toTypeArray(this.types);
|
||||
this.m = t.getMethod(this.name, p);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return this.m;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Function) {
|
||||
return this.hashCode() == obj.hashCode();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (this.prefix + this.localName).hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
55
java/org/apache/el/lang/VariableMapperFactory.java
Normal file
55
java/org/apache/el/lang/VariableMapperFactory.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.lang;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
import javax.el.VariableMapper;
|
||||
|
||||
public class VariableMapperFactory extends VariableMapper {
|
||||
|
||||
private final VariableMapper target;
|
||||
private VariableMapper momento;
|
||||
|
||||
public VariableMapperFactory(VariableMapper target) {
|
||||
if (target == null) {
|
||||
throw new NullPointerException("Target VariableMapper cannot be null");
|
||||
}
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public VariableMapper create() {
|
||||
return this.momento;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueExpression resolveVariable(String variable) {
|
||||
ValueExpression expr = this.target.resolveVariable(variable);
|
||||
if (expr != null) {
|
||||
if (this.momento == null) {
|
||||
this.momento = new VariableMapperImpl();
|
||||
}
|
||||
this.momento.setVariable(variable, expr);
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueExpression setVariable(String variable, ValueExpression expression) {
|
||||
throw new UnsupportedOperationException("Cannot Set Variables on Factory");
|
||||
}
|
||||
}
|
||||
66
java/org/apache/el/lang/VariableMapperImpl.java
Normal file
66
java/org/apache/el/lang/VariableMapperImpl.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.lang;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
import javax.el.VariableMapper;
|
||||
|
||||
public class VariableMapperImpl extends VariableMapper implements Externalizable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Map<String, ValueExpression> vars = new HashMap<>();
|
||||
|
||||
public VariableMapperImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueExpression resolveVariable(String variable) {
|
||||
return this.vars.get(variable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueExpression setVariable(String variable,
|
||||
ValueExpression expression) {
|
||||
if (expression == null) {
|
||||
return vars.remove(variable);
|
||||
} else {
|
||||
return vars.put(variable, expression);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void readExternal(ObjectInput in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
this.vars = (Map<String, ValueExpression>) in.readObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeObject(this.vars);
|
||||
}
|
||||
}
|
||||
37
java/org/apache/el/parser/ArithmeticNode.java
Normal file
37
java/org/apache/el/parser/ArithmeticNode.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public abstract class ArithmeticNode extends SimpleNode {
|
||||
|
||||
public ArithmeticNode(int i) {
|
||||
super(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return Number.class;
|
||||
}
|
||||
}
|
||||
46
java/org/apache/el/parser/AstAnd.java
Normal file
46
java/org/apache/el/parser/AstAnd.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstAnd.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstAnd extends BooleanNode {
|
||||
public AstAnd(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj = children[0].getValue(ctx);
|
||||
Boolean b = coerceToBoolean(ctx, obj, true);
|
||||
if (!b.booleanValue()) {
|
||||
return b;
|
||||
}
|
||||
obj = children[1].getValue(ctx);
|
||||
b = coerceToBoolean(ctx, obj, true);
|
||||
return b;
|
||||
}
|
||||
}
|
||||
50
java/org/apache/el/parser/AstAssign.java
Normal file
50
java/org/apache/el/parser/AstAssign.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstAssign.java Version 4.3 */
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
public class AstAssign extends SimpleNode {
|
||||
|
||||
public AstAssign(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx) throws ELException {
|
||||
Object value = children[1].getValue(ctx);
|
||||
|
||||
children[0].setValue(ctx, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx) throws ELException {
|
||||
Object value = children[1].getValue(ctx);
|
||||
|
||||
children[0].setValue(ctx, value);
|
||||
|
||||
return children[1].getType(ctx);
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=151e58546054b618e758d7dc172cc7b5 (do not edit this line) */
|
||||
39
java/org/apache/el/parser/AstBracketSuffix.java
Normal file
39
java/org/apache/el/parser/AstBracketSuffix.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstBracketSuffix.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstBracketSuffix extends SimpleNode {
|
||||
public AstBracketSuffix(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.children[0].getValue(ctx);
|
||||
}
|
||||
}
|
||||
48
java/org/apache/el/parser/AstChoice.java
Normal file
48
java/org/apache/el/parser/AstChoice.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstChoice.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstChoice extends SimpleNode {
|
||||
public AstChoice(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object val = this.getValue(ctx);
|
||||
return (val != null) ? val.getClass() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
Boolean b0 = coerceToBoolean(ctx, obj0, true);
|
||||
return this.children[((b0.booleanValue() ? 1 : 2))].getValue(ctx);
|
||||
}
|
||||
}
|
||||
57
java/org/apache/el/parser/AstCompositeExpression.java
Normal file
57
java/org/apache/el/parser/AstCompositeExpression.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstCompositeExpression.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.ELSupport;
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstCompositeExpression extends SimpleNode {
|
||||
|
||||
public AstCompositeExpression(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
StringBuilder sb = new StringBuilder(16);
|
||||
Object obj = null;
|
||||
if (this.children != null) {
|
||||
for (int i = 0; i < this.children.length; i++) {
|
||||
obj = this.children[i].getValue(ctx);
|
||||
if (obj != null) {
|
||||
sb.append(ELSupport.coerceToString(ctx, obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
45
java/org/apache/el/parser/AstConcatenation.java
Normal file
45
java/org/apache/el/parser/AstConcatenation.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstConcatenation.java Version 4.3 */
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
public class AstConcatenation extends SimpleNode {
|
||||
|
||||
public AstConcatenation(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx) throws ELException {
|
||||
// Coerce the two child nodes to string and then concatenate
|
||||
String s1 = coerceToString(ctx, children[0].getValue(ctx));
|
||||
String s2 = coerceToString(ctx, children[1].getValue(ctx));
|
||||
return s1 + s2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx) throws ELException {
|
||||
return String.class;
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=a95de353974c2c05fa5c7d695a1d50fd (do not edit this line) */
|
||||
57
java/org/apache/el/parser/AstDeferredExpression.java
Normal file
57
java/org/apache/el/parser/AstDeferredExpression.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstDeferredExpression.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstDeferredExpression extends SimpleNode {
|
||||
public AstDeferredExpression(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.children[0].getType(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.children[0].getValue(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.children[0].isReadOnly(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext ctx, Object value)
|
||||
throws ELException {
|
||||
this.children[0].setValue(ctx, value);
|
||||
}
|
||||
}
|
||||
42
java/org/apache/el/parser/AstDiv.java
Normal file
42
java/org/apache/el/parser/AstDiv.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstDiv.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.ELArithmetic;
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstDiv extends ArithmeticNode {
|
||||
public AstDiv(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
return ELArithmetic.divide(obj0, obj1);
|
||||
}
|
||||
}
|
||||
50
java/org/apache/el/parser/AstDotSuffix.java
Normal file
50
java/org/apache/el/parser/AstDotSuffix.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstDotSuffix.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
import org.apache.el.util.MessageFactory;
|
||||
import org.apache.el.util.Validation;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstDotSuffix extends SimpleNode {
|
||||
public AstDotSuffix(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImage(String image) {
|
||||
if (!Validation.isIdentifier(image)) {
|
||||
throw new ELException(MessageFactory.get("error.identifier.notjava",
|
||||
image));
|
||||
}
|
||||
this.image = image;
|
||||
}
|
||||
}
|
||||
57
java/org/apache/el/parser/AstDynamicExpression.java
Normal file
57
java/org/apache/el/parser/AstDynamicExpression.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstDynamicExpression.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstDynamicExpression extends SimpleNode {
|
||||
public AstDynamicExpression(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.children[0].getType(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.children[0].getValue(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.children[0].isReadOnly(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext ctx, Object value)
|
||||
throws ELException {
|
||||
this.children[0].setValue(ctx, value);
|
||||
}
|
||||
}
|
||||
60
java/org/apache/el/parser/AstEmpty.java
Normal file
60
java/org/apache/el/parser/AstEmpty.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstEmpty.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstEmpty extends SimpleNode {
|
||||
public AstEmpty(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return Boolean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj = this.children[0].getValue(ctx);
|
||||
if (obj == null) {
|
||||
return Boolean.TRUE;
|
||||
} else if (obj instanceof String) {
|
||||
return Boolean.valueOf(((String) obj).length() == 0);
|
||||
} else if (obj instanceof Object[]) {
|
||||
return Boolean.valueOf(((Object[]) obj).length == 0);
|
||||
} else if (obj instanceof Collection<?>) {
|
||||
return Boolean.valueOf(((Collection<?>) obj).isEmpty());
|
||||
} else if (obj instanceof Map<?,?>) {
|
||||
return Boolean.valueOf(((Map<?,?>) obj).isEmpty());
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
41
java/org/apache/el/parser/AstEqual.java
Normal file
41
java/org/apache/el/parser/AstEqual.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstEqual.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstEqual extends BooleanNode {
|
||||
public AstEqual(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
return Boolean.valueOf(equals(ctx, obj0, obj1));
|
||||
}
|
||||
}
|
||||
39
java/org/apache/el/parser/AstFalse.java
Normal file
39
java/org/apache/el/parser/AstFalse.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstFalse.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstFalse extends BooleanNode {
|
||||
public AstFalse(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
60
java/org/apache/el/parser/AstFloatingPoint.java
Normal file
60
java/org/apache/el/parser/AstFloatingPoint.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstFloatingPoint.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstFloatingPoint extends SimpleNode {
|
||||
public AstFloatingPoint(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
private volatile Number number;
|
||||
|
||||
public Number getFloatingPoint() {
|
||||
if (this.number == null) {
|
||||
try {
|
||||
this.number = Double.valueOf(this.image);
|
||||
} catch (ArithmeticException e0) {
|
||||
this.number = new BigDecimal(this.image);
|
||||
}
|
||||
}
|
||||
return this.number;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.getFloatingPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.getFloatingPoint().getClass();
|
||||
}
|
||||
}
|
||||
231
java/org/apache/el/parser/AstFunction.java
Normal file
231
java/org/apache/el/parser/AstFunction.java
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstFunction.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.el.ELClass;
|
||||
import javax.el.ELException;
|
||||
import javax.el.FunctionMapper;
|
||||
import javax.el.LambdaExpression;
|
||||
import javax.el.ValueExpression;
|
||||
import javax.el.VariableMapper;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
import org.apache.el.util.MessageFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstFunction extends SimpleNode {
|
||||
|
||||
protected String localName = "";
|
||||
|
||||
protected String prefix = "";
|
||||
|
||||
public AstFunction(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public String getLocalName() {
|
||||
return localName;
|
||||
}
|
||||
|
||||
public String getOutputName() {
|
||||
if (this.prefix == null) {
|
||||
return this.localName;
|
||||
} else {
|
||||
return this.prefix + ":" + this.localName;
|
||||
}
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
|
||||
FunctionMapper fnMapper = ctx.getFunctionMapper();
|
||||
|
||||
// quickly validate again for this request
|
||||
if (fnMapper == null) {
|
||||
throw new ELException(MessageFactory.get("error.fnMapper.null"));
|
||||
}
|
||||
Method m = fnMapper.resolveFunction(this.prefix, this.localName);
|
||||
if (m == null) {
|
||||
throw new ELException(MessageFactory.get("error.fnMapper.method",
|
||||
this.getOutputName()));
|
||||
}
|
||||
return m.getReturnType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
|
||||
FunctionMapper fnMapper = ctx.getFunctionMapper();
|
||||
|
||||
// quickly validate again for this request
|
||||
if (fnMapper == null) {
|
||||
throw new ELException(MessageFactory.get("error.fnMapper.null"));
|
||||
}
|
||||
Method m = fnMapper.resolveFunction(this.prefix, this.localName);
|
||||
|
||||
if (m == null && this.prefix.length() == 0) {
|
||||
// TODO: Do we need to think about precedence of the various ways
|
||||
// a lambda expression may be obtained from something that
|
||||
// the parser thinks is a function?
|
||||
Object obj = null;
|
||||
if (ctx.isLambdaArgument(this.localName)) {
|
||||
obj = ctx.getLambdaArgument(this.localName);
|
||||
}
|
||||
if (obj == null) {
|
||||
VariableMapper varMapper = ctx.getVariableMapper();
|
||||
if (varMapper != null) {
|
||||
obj = varMapper.resolveVariable(this.localName);
|
||||
if (obj instanceof ValueExpression) {
|
||||
// See if this returns a LambdaEXpression
|
||||
obj = ((ValueExpression) obj).getValue(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (obj == null) {
|
||||
obj = ctx.getELResolver().getValue(ctx, null, this.localName);
|
||||
}
|
||||
if (obj instanceof LambdaExpression) {
|
||||
// Build arguments
|
||||
int i = 0;
|
||||
while (obj instanceof LambdaExpression &&
|
||||
i < jjtGetNumChildren()) {
|
||||
Node args = jjtGetChild(i);
|
||||
obj = ((LambdaExpression) obj).invoke(
|
||||
((AstMethodParameters) args).getParameters(ctx));
|
||||
i++;
|
||||
}
|
||||
if (i < jjtGetNumChildren()) {
|
||||
// Haven't consumed all the sets of parameters therefore
|
||||
// there were too many sets of parameters
|
||||
throw new ELException(MessageFactory.get(
|
||||
"error.lambda.tooManyMethodParameterSets"));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Call to a constructor or a static method
|
||||
obj = ctx.getImportHandler().resolveClass(this.localName);
|
||||
if (obj != null) {
|
||||
return ctx.getELResolver().invoke(ctx, new ELClass((Class<?>) obj), "<init>", null,
|
||||
((AstMethodParameters) this.children[0]).getParameters(ctx));
|
||||
}
|
||||
obj = ctx.getImportHandler().resolveStatic(this.localName);
|
||||
if (obj != null) {
|
||||
return ctx.getELResolver().invoke(ctx, new ELClass((Class<?>) obj), this.localName,
|
||||
null, ((AstMethodParameters) this.children[0]).getParameters(ctx));
|
||||
}
|
||||
}
|
||||
|
||||
if (m == null) {
|
||||
throw new ELException(MessageFactory.get("error.fnMapper.method",
|
||||
this.getOutputName()));
|
||||
}
|
||||
|
||||
// Not a lambda expression so must be a function. Check there is just a
|
||||
// single set of method parameters
|
||||
if (this.jjtGetNumChildren() != 1) {
|
||||
throw new ELException(MessageFactory.get(
|
||||
"error.funciton.tooManyMethodParameterSets",
|
||||
getOutputName()));
|
||||
}
|
||||
|
||||
Node parameters = jjtGetChild(0);
|
||||
Class<?>[] paramTypes = m.getParameterTypes();
|
||||
Object[] params = null;
|
||||
Object result = null;
|
||||
int inputParameterCount = parameters.jjtGetNumChildren();
|
||||
int methodParameterCount = paramTypes.length;
|
||||
if (inputParameterCount == 0 && methodParameterCount == 1 && m.isVarArgs()) {
|
||||
params = new Object[] { null };
|
||||
} else if (inputParameterCount > 0) {
|
||||
params = new Object[methodParameterCount];
|
||||
try {
|
||||
for (int i = 0; i < methodParameterCount; i++) {
|
||||
if (m.isVarArgs() && i == methodParameterCount - 1) {
|
||||
if (inputParameterCount < methodParameterCount) {
|
||||
params[i] = new Object[] { null };
|
||||
} else if (inputParameterCount == methodParameterCount &&
|
||||
paramTypes[i].isArray()) {
|
||||
params[i] = parameters.jjtGetChild(i).getValue(ctx);
|
||||
} else {
|
||||
Object[] varargs =
|
||||
new Object[inputParameterCount - methodParameterCount + 1];
|
||||
Class<?> target = paramTypes[i].getComponentType();
|
||||
for (int j = i; j < inputParameterCount; j++) {
|
||||
varargs[j-i] = parameters.jjtGetChild(j).getValue(ctx);
|
||||
varargs[j-i] = coerceToType(ctx, varargs[j-i], target);
|
||||
}
|
||||
params[i] = varargs;
|
||||
}
|
||||
} else {
|
||||
params[i] = parameters.jjtGetChild(i).getValue(ctx);
|
||||
}
|
||||
params[i] = coerceToType(ctx, params[i], paramTypes[i]);
|
||||
}
|
||||
} catch (ELException ele) {
|
||||
throw new ELException(MessageFactory.get("error.function", this
|
||||
.getOutputName()), ele);
|
||||
}
|
||||
}
|
||||
try {
|
||||
result = m.invoke(null, params);
|
||||
} catch (IllegalAccessException iae) {
|
||||
throw new ELException(MessageFactory.get("error.function", this
|
||||
.getOutputName()), iae);
|
||||
} catch (InvocationTargetException ite) {
|
||||
Throwable cause = ite.getCause();
|
||||
if (cause instanceof ThreadDeath) {
|
||||
throw (ThreadDeath) cause;
|
||||
}
|
||||
if (cause instanceof VirtualMachineError) {
|
||||
throw (VirtualMachineError) cause;
|
||||
}
|
||||
throw new ELException(MessageFactory.get("error.function", this
|
||||
.getOutputName()), cause);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setLocalName(String localName) {
|
||||
this.localName = localName;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return ELParserTreeConstants.jjtNodeName[id] + "[" + this.getOutputName() + "]";
|
||||
}
|
||||
}
|
||||
47
java/org/apache/el/parser/AstGreaterThan.java
Normal file
47
java/org/apache/el/parser/AstGreaterThan.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstGreaterThan.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstGreaterThan extends BooleanNode {
|
||||
public AstGreaterThan(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
if (obj0 == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
if (obj1 == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return (compare(ctx, obj0, obj1) > 0) ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
47
java/org/apache/el/parser/AstGreaterThanEqual.java
Normal file
47
java/org/apache/el/parser/AstGreaterThanEqual.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstGreaterThanEqual.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstGreaterThanEqual extends BooleanNode {
|
||||
public AstGreaterThanEqual(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
if (obj0 == obj1) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if (obj0 == null || obj1 == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return (compare(ctx, obj0, obj1) >= 0) ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
238
java/org/apache/el/parser/AstIdentifier.java
Normal file
238
java/org/apache/el/parser/AstIdentifier.java
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstIdentifier.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELClass;
|
||||
import javax.el.ELException;
|
||||
import javax.el.MethodExpression;
|
||||
import javax.el.MethodInfo;
|
||||
import javax.el.MethodNotFoundException;
|
||||
import javax.el.PropertyNotFoundException;
|
||||
import javax.el.ValueExpression;
|
||||
import javax.el.ValueReference;
|
||||
import javax.el.VariableMapper;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
import org.apache.el.util.MessageFactory;
|
||||
import org.apache.el.util.Validation;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstIdentifier extends SimpleNode {
|
||||
public AstIdentifier(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx) throws ELException {
|
||||
VariableMapper varMapper = ctx.getVariableMapper();
|
||||
if (varMapper != null) {
|
||||
ValueExpression expr = varMapper.resolveVariable(this.image);
|
||||
if (expr != null) {
|
||||
return expr.getType(ctx.getELContext());
|
||||
}
|
||||
}
|
||||
ctx.setPropertyResolved(false);
|
||||
Class<?> result = ctx.getELResolver().getType(ctx, null, this.image);
|
||||
if (!ctx.isPropertyResolved()) {
|
||||
throw new PropertyNotFoundException(MessageFactory.get(
|
||||
"error.resolver.unhandled.null", this.image));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx) throws ELException {
|
||||
// Lambda parameters
|
||||
if (ctx.isLambdaArgument(this.image)) {
|
||||
return ctx.getLambdaArgument(this.image);
|
||||
}
|
||||
|
||||
// Variable mapper
|
||||
VariableMapper varMapper = ctx.getVariableMapper();
|
||||
if (varMapper != null) {
|
||||
ValueExpression expr = varMapper.resolveVariable(this.image);
|
||||
if (expr != null) {
|
||||
return expr.getValue(ctx.getELContext());
|
||||
}
|
||||
}
|
||||
|
||||
// EL Resolvers
|
||||
ctx.setPropertyResolved(false);
|
||||
Object result;
|
||||
/* Putting the Boolean into the ELContext is part of a performance
|
||||
* optimisation for ScopedAttributeELResolver. When looking up "foo",
|
||||
* the resolver can't differentiate between ${ foo } and ${ foo.bar }.
|
||||
* This is important because the expensive class lookup only needs to
|
||||
* be performed in the later case. This flag tells the resolver if the
|
||||
* lookup can be skipped.
|
||||
*/
|
||||
if (parent instanceof AstValue) {
|
||||
ctx.putContext(this.getClass(), Boolean.FALSE);
|
||||
} else {
|
||||
ctx.putContext(this.getClass(), Boolean.TRUE);
|
||||
}
|
||||
try {
|
||||
result = ctx.getELResolver().getValue(ctx, null, this.image);
|
||||
} finally {
|
||||
// Always reset the flag to false so the optimisation is not applied
|
||||
// inappropriately
|
||||
ctx.putContext(this.getClass(), Boolean.FALSE);
|
||||
}
|
||||
|
||||
if (ctx.isPropertyResolved()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Import
|
||||
result = ctx.getImportHandler().resolveClass(this.image);
|
||||
if (result != null) {
|
||||
return new ELClass((Class<?>) result);
|
||||
}
|
||||
result = ctx.getImportHandler().resolveStatic(this.image);
|
||||
if (result != null) {
|
||||
try {
|
||||
return ((Class<?>) result).getField(this.image).get(null);
|
||||
} catch (IllegalArgumentException | IllegalAccessException
|
||||
| NoSuchFieldException | SecurityException e) {
|
||||
throw new ELException(e);
|
||||
}
|
||||
}
|
||||
|
||||
throw new PropertyNotFoundException(MessageFactory.get(
|
||||
"error.resolver.unhandled.null", this.image));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(EvaluationContext ctx) throws ELException {
|
||||
VariableMapper varMapper = ctx.getVariableMapper();
|
||||
if (varMapper != null) {
|
||||
ValueExpression expr = varMapper.resolveVariable(this.image);
|
||||
if (expr != null) {
|
||||
return expr.isReadOnly(ctx.getELContext());
|
||||
}
|
||||
}
|
||||
ctx.setPropertyResolved(false);
|
||||
boolean result = ctx.getELResolver().isReadOnly(ctx, null, this.image);
|
||||
if (!ctx.isPropertyResolved()) {
|
||||
throw new PropertyNotFoundException(MessageFactory.get(
|
||||
"error.resolver.unhandled.null", this.image));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext ctx, Object value)
|
||||
throws ELException {
|
||||
VariableMapper varMapper = ctx.getVariableMapper();
|
||||
if (varMapper != null) {
|
||||
ValueExpression expr = varMapper.resolveVariable(this.image);
|
||||
if (expr != null) {
|
||||
expr.setValue(ctx.getELContext(), value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ctx.setPropertyResolved(false);
|
||||
ctx.getELResolver().setValue(ctx, null, this.image, value);
|
||||
if (!ctx.isPropertyResolved()) {
|
||||
throw new PropertyNotFoundException(MessageFactory.get(
|
||||
"error.resolver.unhandled.null", this.image));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(EvaluationContext ctx, Class<?>[] paramTypes,
|
||||
Object[] paramValues) throws ELException {
|
||||
return this.getMethodExpression(ctx).invoke(ctx.getELContext(), paramValues);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MethodInfo getMethodInfo(EvaluationContext ctx,
|
||||
Class<?>[] paramTypes) throws ELException {
|
||||
return this.getMethodExpression(ctx).getMethodInfo(ctx.getELContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImage(String image) {
|
||||
if (!Validation.isIdentifier(image)) {
|
||||
throw new ELException(MessageFactory.get("error.identifier.notjava",
|
||||
image));
|
||||
}
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ValueReference getValueReference(EvaluationContext ctx) {
|
||||
VariableMapper varMapper = ctx.getVariableMapper();
|
||||
|
||||
if (varMapper == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ValueExpression expr = varMapper.resolveVariable(this.image);
|
||||
|
||||
if (expr == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return expr.getValueReference(ctx);
|
||||
}
|
||||
|
||||
|
||||
private final MethodExpression getMethodExpression(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj = null;
|
||||
|
||||
// case A: ValueExpression exists, getValue which must
|
||||
// be a MethodExpression
|
||||
VariableMapper varMapper = ctx.getVariableMapper();
|
||||
ValueExpression ve = null;
|
||||
if (varMapper != null) {
|
||||
ve = varMapper.resolveVariable(this.image);
|
||||
if (ve != null) {
|
||||
obj = ve.getValue(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
// case B: evaluate the identity against the ELResolver, again, must be
|
||||
// a MethodExpression to be able to invoke
|
||||
if (ve == null) {
|
||||
ctx.setPropertyResolved(false);
|
||||
obj = ctx.getELResolver().getValue(ctx, null, this.image);
|
||||
}
|
||||
|
||||
// finally provide helpful hints
|
||||
if (obj instanceof MethodExpression) {
|
||||
return (MethodExpression) obj;
|
||||
} else if (obj == null) {
|
||||
throw new MethodNotFoundException("Identity '" + this.image
|
||||
+ "' was null and was unable to invoke");
|
||||
} else {
|
||||
throw new ELException(
|
||||
"Identity '"
|
||||
+ this.image
|
||||
+ "' does not reference a MethodExpression instance, returned type: "
|
||||
+ obj.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
60
java/org/apache/el/parser/AstInteger.java
Normal file
60
java/org/apache/el/parser/AstInteger.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstInteger.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstInteger extends SimpleNode {
|
||||
public AstInteger(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
private volatile Number number;
|
||||
|
||||
protected Number getInteger() {
|
||||
if (this.number == null) {
|
||||
try {
|
||||
this.number = Long.valueOf(this.image);
|
||||
} catch (ArithmeticException e1) {
|
||||
this.number = new BigInteger(this.image);
|
||||
}
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.getInteger().getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return this.getInteger();
|
||||
}
|
||||
}
|
||||
182
java/org/apache/el/parser/AstLambdaExpression.java
Normal file
182
java/org/apache/el/parser/AstLambdaExpression.java
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstLambdaExpression.java Version 4.3 */
|
||||
package org.apache.el.parser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.el.ELException;
|
||||
import javax.el.LambdaExpression;
|
||||
|
||||
import org.apache.el.ValueExpressionImpl;
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
import org.apache.el.util.MessageFactory;
|
||||
|
||||
public class AstLambdaExpression extends SimpleNode {
|
||||
|
||||
private NestedState nestedState = null;
|
||||
|
||||
public AstLambdaExpression(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx) throws ELException {
|
||||
|
||||
// Correct evaluation requires knowledge of the whole set of nested
|
||||
// expressions, not just the current expression
|
||||
NestedState state = getNestedState();
|
||||
|
||||
// Check that there are not more sets of parameters than there are
|
||||
// nested expressions.
|
||||
int methodParameterSetCount = jjtGetNumChildren() - 2;
|
||||
if (methodParameterSetCount > state.getNestingCount()) {
|
||||
throw new ELException(MessageFactory.get(
|
||||
"error.lambda.tooManyMethodParameterSets"));
|
||||
}
|
||||
|
||||
// First child is always parameters even if there aren't any
|
||||
AstLambdaParameters formalParametersNode =
|
||||
(AstLambdaParameters) children[0];
|
||||
Node[] formalParamNodes = formalParametersNode.children;
|
||||
|
||||
// Second child is a value expression
|
||||
ValueExpressionImpl ve = new ValueExpressionImpl("", children[1],
|
||||
ctx.getFunctionMapper(), ctx.getVariableMapper(), null);
|
||||
|
||||
// Build a LambdaExpression
|
||||
List<String> formalParameters = new ArrayList<>();
|
||||
if (formalParamNodes != null) {
|
||||
for (Node formalParamNode : formalParamNodes) {
|
||||
formalParameters.add(formalParamNode.getImage());
|
||||
}
|
||||
}
|
||||
LambdaExpression le = new LambdaExpression(formalParameters, ve);
|
||||
le.setELContext(ctx);
|
||||
|
||||
if (jjtGetNumChildren() == 2) {
|
||||
// No method parameters
|
||||
// Can only invoke the expression if none of the lambda expressions
|
||||
// in the nesting declare parameters
|
||||
if (state.getHasFormalParameters()) {
|
||||
return le;
|
||||
} else {
|
||||
return le.invoke(ctx, (Object[]) null);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a (possibly nested) lambda expression with one or more sets
|
||||
* of parameters provided.
|
||||
*
|
||||
* If there are more nested expressions than sets of parameters this may
|
||||
* return a LambdaExpression.
|
||||
*
|
||||
* If there are more sets of parameters than nested expressions an
|
||||
* ELException will have been thrown by the check at the start of this
|
||||
* method.
|
||||
*/
|
||||
|
||||
// Always have to invoke the outer-most expression
|
||||
int methodParameterIndex = 2;
|
||||
Object result = le.invoke(((AstMethodParameters)
|
||||
children[methodParameterIndex]).getParameters(ctx));
|
||||
methodParameterIndex++;
|
||||
|
||||
while (result instanceof LambdaExpression &&
|
||||
methodParameterIndex < jjtGetNumChildren()) {
|
||||
result = ((LambdaExpression) result).invoke(((AstMethodParameters)
|
||||
children[methodParameterIndex]).getParameters(ctx));
|
||||
methodParameterIndex++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private NestedState getNestedState() {
|
||||
if (nestedState == null) {
|
||||
setNestedState(new NestedState());
|
||||
}
|
||||
return nestedState;
|
||||
}
|
||||
|
||||
|
||||
private void setNestedState(NestedState nestedState) {
|
||||
if (this.nestedState != null) {
|
||||
// Should never happen
|
||||
throw new IllegalStateException("nestedState may only be set once");
|
||||
}
|
||||
this.nestedState = nestedState;
|
||||
|
||||
// Increment the nesting count for the current expression
|
||||
nestedState.incrementNestingCount();
|
||||
|
||||
if (jjtGetNumChildren() > 1) {
|
||||
Node firstChild = jjtGetChild(0);
|
||||
if (firstChild instanceof AstLambdaParameters) {
|
||||
if (firstChild.jjtGetNumChildren() > 0) {
|
||||
nestedState.setHasFormalParameters();
|
||||
}
|
||||
} else {
|
||||
// Can't be a lambda expression
|
||||
return;
|
||||
}
|
||||
Node secondChild = jjtGetChild(1);
|
||||
if (secondChild instanceof AstLambdaExpression) {
|
||||
((AstLambdaExpression) secondChild).setNestedState(nestedState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// Purely for debug purposes. May not be complete or correct. Certainly
|
||||
// is not efficient. Be sure not to call this from 'real' code.
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (Node n : children) {
|
||||
result.append(n.toString());
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
private static class NestedState {
|
||||
|
||||
private int nestingCount = 0;
|
||||
private boolean hasFormalParameters = false;
|
||||
|
||||
private void incrementNestingCount() {
|
||||
nestingCount++;
|
||||
}
|
||||
|
||||
private int getNestingCount() {
|
||||
return nestingCount;
|
||||
}
|
||||
|
||||
private void setHasFormalParameters() {
|
||||
hasFormalParameters = true;
|
||||
}
|
||||
|
||||
private boolean getHasFormalParameters() {
|
||||
return hasFormalParameters;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=071159eff10c8e15ec612c765ae4480a (do not edit this line) */
|
||||
43
java/org/apache/el/parser/AstLambdaParameters.java
Normal file
43
java/org/apache/el/parser/AstLambdaParameters.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstLambdaParameters.java Version 4.3 */
|
||||
package org.apache.el.parser;
|
||||
|
||||
public class AstLambdaParameters extends SimpleNode {
|
||||
|
||||
public AstLambdaParameters(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// Purely for debug purposes. May not be complete or correct. Certainly
|
||||
// is not efficient. Be sure not to call this from 'real' code.
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append('(');
|
||||
if (children != null) {
|
||||
for (Node n : children) {
|
||||
result.append(n.toString());
|
||||
result.append(',');
|
||||
}
|
||||
}
|
||||
result.append(")->");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=a8c1609257dac59e41c43d6ed91072c6 (do not edit this line) */
|
||||
47
java/org/apache/el/parser/AstLessThan.java
Normal file
47
java/org/apache/el/parser/AstLessThan.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstLessThan.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstLessThan extends BooleanNode {
|
||||
public AstLessThan(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
if (obj0 == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
if (obj1 == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return (compare(ctx, obj0, obj1) < 0) ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
47
java/org/apache/el/parser/AstLessThanEqual.java
Normal file
47
java/org/apache/el/parser/AstLessThanEqual.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstLessThanEqual.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstLessThanEqual extends BooleanNode {
|
||||
public AstLessThanEqual(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
if (obj0 == obj1) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if (obj0 == null || obj1 == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return (compare(ctx, obj0, obj1) <= 0) ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
50
java/org/apache/el/parser/AstListData.java
Normal file
50
java/org/apache/el/parser/AstListData.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstListData.java Version 4.3 */
|
||||
package org.apache.el.parser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
public class AstListData extends SimpleNode {
|
||||
public AstListData(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx) throws ELException {
|
||||
List<Object> result = new ArrayList<>();
|
||||
|
||||
if (children != null) {
|
||||
for (Node child : children) {
|
||||
result.add(child.getValue(ctx));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx) throws ELException {
|
||||
return List.class;
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=7f2694086a9ba64558ee39d1cd719db1 (do not edit this line) */
|
||||
66
java/org/apache/el/parser/AstLiteralExpression.java
Normal file
66
java/org/apache/el/parser/AstLiteralExpression.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstLiteralExpression.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstLiteralExpression extends SimpleNode {
|
||||
public AstLiteralExpression(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx) throws ELException {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx) throws ELException {
|
||||
return this.image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImage(String image) {
|
||||
if (image.indexOf('\\') == -1) {
|
||||
this.image = image;
|
||||
return;
|
||||
}
|
||||
int size = image.length();
|
||||
StringBuilder buf = new StringBuilder(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
char c = image.charAt(i);
|
||||
if (c == '\\' && i + 2 < size) {
|
||||
char c1 = image.charAt(i + 1);
|
||||
char c2 = image.charAt(i + 2);
|
||||
if ((c1 == '#' || c1 == '$') && c2 == '{') {
|
||||
c = c1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
buf.append(c);
|
||||
}
|
||||
this.image = buf.toString();
|
||||
}
|
||||
}
|
||||
56
java/org/apache/el/parser/AstMapData.java
Normal file
56
java/org/apache/el/parser/AstMapData.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstMapData.java Version 4.3 */
|
||||
package org.apache.el.parser;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
public class AstMapData extends SimpleNode {
|
||||
|
||||
public AstMapData(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx) throws ELException {
|
||||
Map<Object,Object> result = new HashMap<>();
|
||||
|
||||
if (children != null) {
|
||||
for (Node child : children) {
|
||||
AstMapEntry mapEntry = (AstMapEntry) child;
|
||||
Object key = mapEntry.children[0].getValue(ctx);
|
||||
Object value = mapEntry.children[1].getValue(ctx);
|
||||
result.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx) throws ELException {
|
||||
return Map.class;
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=a68b5c6f0a0708f478fdf8c0e6e1263e (do not edit this line) */
|
||||
26
java/org/apache/el/parser/AstMapEntry.java
Normal file
26
java/org/apache/el/parser/AstMapEntry.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstMapEntry.java Version 4.3 */
|
||||
package org.apache.el.parser;
|
||||
|
||||
public
|
||||
class AstMapEntry extends SimpleNode {
|
||||
public AstMapEntry(int id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=6a7910e58a583371769800554113a8d3 (do not edit this line) */
|
||||
53
java/org/apache/el/parser/AstMethodParameters.java
Normal file
53
java/org/apache/el/parser/AstMethodParameters.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstDotSuffix.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
public final class AstMethodParameters extends SimpleNode {
|
||||
public AstMethodParameters(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public Object[] getParameters(EvaluationContext ctx) {
|
||||
ArrayList<Object> params = new ArrayList<>();
|
||||
for (int i = 0; i < this.jjtGetNumChildren(); i++) {
|
||||
params.add(this.jjtGetChild(i).getValue(ctx));
|
||||
}
|
||||
return params.toArray(new Object[params.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// Purely for debug purposes. May not be complete or correct. Certainly
|
||||
// is not efficient. Be sure not to call this from 'real' code.
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append('(');
|
||||
if (children != null) {
|
||||
for (Node n : children) {
|
||||
result.append(n.toString());
|
||||
result.append(',');
|
||||
}
|
||||
}
|
||||
result.append(')');
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
42
java/org/apache/el/parser/AstMinus.java
Normal file
42
java/org/apache/el/parser/AstMinus.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstMinus.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.ELArithmetic;
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstMinus extends ArithmeticNode {
|
||||
public AstMinus(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
return ELArithmetic.subtract(obj0, obj1);
|
||||
}
|
||||
}
|
||||
42
java/org/apache/el/parser/AstMod.java
Normal file
42
java/org/apache/el/parser/AstMod.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstMod.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.ELArithmetic;
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstMod extends ArithmeticNode {
|
||||
public AstMod(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
return ELArithmetic.mod(obj0, obj1);
|
||||
}
|
||||
}
|
||||
42
java/org/apache/el/parser/AstMult.java
Normal file
42
java/org/apache/el/parser/AstMult.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstMult.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.ELArithmetic;
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstMult extends ArithmeticNode {
|
||||
public AstMult(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
return ELArithmetic.multiply(obj0, obj1);
|
||||
}
|
||||
}
|
||||
84
java/org/apache/el/parser/AstNegative.java
Normal file
84
java/org/apache/el/parser/AstNegative.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstNegative.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstNegative extends SimpleNode {
|
||||
public AstNegative(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return Number.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj = this.children[0].getValue(ctx);
|
||||
|
||||
if (obj == null) {
|
||||
return Long.valueOf(0);
|
||||
}
|
||||
if (obj instanceof BigDecimal) {
|
||||
return ((BigDecimal) obj).negate();
|
||||
}
|
||||
if (obj instanceof BigInteger) {
|
||||
return ((BigInteger) obj).negate();
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
if (isStringFloat((String) obj)) {
|
||||
return Double.valueOf(-Double.parseDouble((String) obj));
|
||||
}
|
||||
return Long.valueOf(-Long.parseLong((String) obj));
|
||||
}
|
||||
if (obj instanceof Long) {
|
||||
return Long.valueOf(-((Long) obj).longValue());
|
||||
}
|
||||
if (obj instanceof Double) {
|
||||
return Double.valueOf(-((Double) obj).doubleValue());
|
||||
}
|
||||
if (obj instanceof Integer) {
|
||||
return Integer.valueOf(-((Integer) obj).intValue());
|
||||
}
|
||||
if (obj instanceof Float) {
|
||||
return Float.valueOf(-((Float) obj).floatValue());
|
||||
}
|
||||
if (obj instanceof Short) {
|
||||
return Short.valueOf((short) -((Short) obj).shortValue());
|
||||
}
|
||||
if (obj instanceof Byte) {
|
||||
return Byte.valueOf((byte) -((Byte) obj).byteValue());
|
||||
}
|
||||
Long num = (Long) coerceToNumber(ctx, obj, Long.class);
|
||||
return Long.valueOf(-num.longValue());
|
||||
}
|
||||
}
|
||||
47
java/org/apache/el/parser/AstNot.java
Normal file
47
java/org/apache/el/parser/AstNot.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstNot.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstNot extends SimpleNode {
|
||||
public AstNot(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
return Boolean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj = this.children[0].getValue(ctx);
|
||||
Boolean b = coerceToBoolean(ctx, obj, true);
|
||||
return Boolean.valueOf(!b.booleanValue());
|
||||
}
|
||||
}
|
||||
41
java/org/apache/el/parser/AstNotEqual.java
Normal file
41
java/org/apache/el/parser/AstNotEqual.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. AstNotEqual.java */
|
||||
|
||||
package org.apache.el.parser;
|
||||
|
||||
import javax.el.ELException;
|
||||
|
||||
import org.apache.el.lang.EvaluationContext;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacob Hookom [jacob@hookom.net]
|
||||
*/
|
||||
public final class AstNotEqual extends BooleanNode {
|
||||
public AstNotEqual(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext ctx)
|
||||
throws ELException {
|
||||
Object obj0 = this.children[0].getValue(ctx);
|
||||
Object obj1 = this.children[1].getValue(ctx);
|
||||
return Boolean.valueOf(!equals(ctx, obj0, obj1));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user