Revert "Merge branch 'SPR-10130' into cleanup-master"
This reverts commit45fa50821a, reversing changes made toa312d900f8.
This commit is contained in:
@@ -62,17 +62,14 @@ public interface ParserContext {
|
||||
*/
|
||||
public static final ParserContext TEMPLATE_EXPRESSION = new ParserContext() {
|
||||
|
||||
@Override
|
||||
public String getExpressionPrefix() {
|
||||
return "#{";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpressionSuffix() {
|
||||
return "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemplate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -50,12 +50,10 @@ public class CompositeStringExpression implements Expression {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final String getExpressionString() {
|
||||
return this.expressionString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() throws EvaluationException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Expression expression : this.expressions) {
|
||||
@@ -67,7 +65,6 @@ public class CompositeStringExpression implements Expression {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(Object rootObject) throws EvaluationException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Expression expression : this.expressions) {
|
||||
@@ -79,7 +76,6 @@ public class CompositeStringExpression implements Expression {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(EvaluationContext context) throws EvaluationException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Expression expression : this.expressions) {
|
||||
@@ -91,7 +87,6 @@ public class CompositeStringExpression implements Expression {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Expression expression : this.expressions) {
|
||||
@@ -103,44 +98,36 @@ public class CompositeStringExpression implements Expression {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueType(EvaluationContext context) {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor() {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext context, Object value) throws EvaluationException {
|
||||
throw new EvaluationException(this.expressionString, "Cannot call setValue on a composite expression");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(EvaluationContext context, Class<T> expectedResultType) throws EvaluationException {
|
||||
Object value = getValue(context);
|
||||
return ExpressionUtils.convert(context, value, expectedResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(Class<T> expectedResultType) throws EvaluationException {
|
||||
Object value = getValue();
|
||||
return ExpressionUtils.convert(null, value, expectedResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable(EvaluationContext context) {
|
||||
return false;
|
||||
}
|
||||
@@ -150,55 +137,45 @@ public class CompositeStringExpression implements Expression {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T getValue(Object rootObject, Class<T> desiredResultType) throws EvaluationException {
|
||||
Object value = getValue(rootObject);
|
||||
return ExpressionUtils.convert(null, value, desiredResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType)
|
||||
throws EvaluationException {
|
||||
Object value = getValue(context,rootObject);
|
||||
return ExpressionUtils.convert(context, value, desiredResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueType(Object rootObject) throws EvaluationException {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueType(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException {
|
||||
throw new EvaluationException(this.expressionString, "Cannot call setValue on a composite expression");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable(Object rootObject) throws EvaluationException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object rootObject, Object value) throws EvaluationException {
|
||||
throw new EvaluationException(this.expressionString, "Cannot call setValue on a composite expression");
|
||||
}
|
||||
|
||||
@@ -41,121 +41,98 @@ public class LiteralExpression implements Expression {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final String getExpressionString() {
|
||||
return this.literalValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return this.literalValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(EvaluationContext context) {
|
||||
return this.literalValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(Object rootObject) {
|
||||
return this.literalValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueType(EvaluationContext context) {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor() {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext context, Object value) throws EvaluationException {
|
||||
throw new EvaluationException(literalValue, "Cannot call setValue() on a LiteralExpression");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(EvaluationContext context, Class<T> expectedResultType) throws EvaluationException {
|
||||
Object value = getValue(context);
|
||||
return ExpressionUtils.convert(context, value, expectedResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(Class<T> expectedResultType) throws EvaluationException {
|
||||
Object value = getValue();
|
||||
return ExpressionUtils.convert(null, value, expectedResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable(EvaluationContext context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(Object rootObject, Class<T> desiredResultType) throws EvaluationException {
|
||||
Object value = getValue(rootObject);
|
||||
return ExpressionUtils.convert(null, value, desiredResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
return this.literalValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType) throws EvaluationException {
|
||||
Object value = getValue(context, rootObject);
|
||||
return ExpressionUtils.convert(null, value, desiredResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueType(Object rootObject) throws EvaluationException {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueType(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException {
|
||||
throw new EvaluationException(literalValue, "Cannot call setValue() on a LiteralExpression");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable(Object rootObject) throws EvaluationException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object rootObject, Object value) throws EvaluationException {
|
||||
throw new EvaluationException(literalValue, "Cannot call setValue() on a LiteralExpression");
|
||||
}
|
||||
|
||||
@@ -40,27 +40,22 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
|
||||
* Default ParserContext instance for non-template expressions.
|
||||
*/
|
||||
private static final ParserContext NON_TEMPLATE_PARSER_CONTEXT = new ParserContext() {
|
||||
@Override
|
||||
public String getExpressionPrefix() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getExpressionSuffix() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean isTemplate() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
public Expression parseExpression(String expressionString) throws ParseException {
|
||||
return parseExpression(expressionString, NON_TEMPLATE_PARSER_CONTEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression parseExpression(String expressionString, ParserContext context) throws ParseException {
|
||||
if (context == null) {
|
||||
context = NON_TEMPLATE_PARSER_CONTEXT;
|
||||
|
||||
@@ -50,17 +50,14 @@ public class TemplateParserContext implements ParserContext {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean isTemplate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getExpressionPrefix() {
|
||||
return this.expressionPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getExpressionSuffix() {
|
||||
return this.expressionSuffix;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ public class InternalParseException extends RuntimeException {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpelParseException getCause() {
|
||||
return (SpelParseException) super.getCause();
|
||||
}
|
||||
|
||||
@@ -105,19 +105,16 @@ public class Indexer extends SpelNodeImpl {
|
||||
this.typeDescriptor = typeDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
Object arrayElement = accessArrayElement(this.array, this.idx);
|
||||
return new TypedValue(arrayElement, this.typeDescriptor.elementTypeDescriptor(arrayElement));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
setArrayElement(this.typeConverter, this.array, this.idx, newValue,
|
||||
this.typeDescriptor.getElementTypeDescriptor().getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return true;
|
||||
}
|
||||
@@ -142,13 +139,11 @@ public class Indexer extends SpelNodeImpl {
|
||||
this.mapEntryTypeDescriptor = mapEntryTypeDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
Object value = this.map.get(this.key);
|
||||
return new TypedValue(value, this.mapEntryTypeDescriptor.getMapValueTypeDescriptor(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
if (this.mapEntryTypeDescriptor.getMapValueTypeDescriptor() != null) {
|
||||
newValue = this.typeConverter.convertValue(newValue, TypeDescriptor.forObject(newValue),
|
||||
@@ -157,7 +152,6 @@ public class Indexer extends SpelNodeImpl {
|
||||
this.map.put(this.key, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return true;
|
||||
}
|
||||
@@ -182,7 +176,6 @@ public class Indexer extends SpelNodeImpl {
|
||||
this.td = targetObjectTypeDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
Class<?> targetObjectRuntimeClass = getObjectClass(targetObject);
|
||||
try {
|
||||
@@ -216,7 +209,6 @@ public class Indexer extends SpelNodeImpl {
|
||||
this.td.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
Class<?> contextObjectClass = getObjectClass(targetObject);
|
||||
try {
|
||||
@@ -246,7 +238,6 @@ public class Indexer extends SpelNodeImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return true;
|
||||
}
|
||||
@@ -275,7 +266,6 @@ public class Indexer extends SpelNodeImpl {
|
||||
this.growCollection = growCollection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
if (this.index >= this.collection.size()) {
|
||||
if (this.growCollection) {
|
||||
@@ -300,7 +290,6 @@ public class Indexer extends SpelNodeImpl {
|
||||
throw new IllegalStateException("Failed to find indexed element " + this.index + ": " + this.collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
if (this.index >= this.collection.size()) {
|
||||
if (this.growCollection) {
|
||||
@@ -325,7 +314,6 @@ public class Indexer extends SpelNodeImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return true;
|
||||
}
|
||||
@@ -346,7 +334,6 @@ public class Indexer extends SpelNodeImpl {
|
||||
this.td = td;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
if (this.index >= this.target.length()) {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.STRING_INDEX_OUT_OF_BOUNDS,
|
||||
@@ -355,13 +342,11 @@ public class Indexer extends SpelNodeImpl {
|
||||
return new TypedValue(String.valueOf(this.target.charAt(this.index)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
|
||||
this.td.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ public class MethodReference extends SpelNodeImpl {
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
MethodExecutor executorToUse = cachedExecutor;
|
||||
if (executorToUse != null) {
|
||||
@@ -104,12 +103,10 @@ public class MethodReference extends SpelNodeImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
throw new IllegalAccessError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,6 @@ public class OpMinus extends Operator {
|
||||
}
|
||||
return super.toStringAST();
|
||||
}
|
||||
@Override
|
||||
public SpelNodeImpl getRightOperand() {
|
||||
if (children.length<2) {return null;}
|
||||
return children[1];
|
||||
|
||||
@@ -83,17 +83,14 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
|
||||
this.isAutoGrowNullReferences = isAutoGrowNullReferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
return ref.getValueInternal(contextObject,eContext,isAutoGrowNullReferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
ref.writeProperty(contextObject,eContext, ref.name, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,6 @@ public abstract class SpelNodeImpl implements SpelNode {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object getValue(ExpressionState expressionState) throws EvaluationException {
|
||||
if (expressionState != null) {
|
||||
return getValueInternal(expressionState).getValue();
|
||||
@@ -98,7 +97,6 @@ public abstract class SpelNodeImpl implements SpelNode {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TypedValue getTypedValue(ExpressionState expressionState) throws EvaluationException {
|
||||
if (expressionState != null) {
|
||||
return getValueInternal(expressionState);
|
||||
@@ -109,27 +107,22 @@ public abstract class SpelNodeImpl implements SpelNode {
|
||||
}
|
||||
|
||||
// by default Ast nodes are not writable
|
||||
@Override
|
||||
public boolean isWritable(ExpressionState expressionState) throws EvaluationException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(ExpressionState expressionState, Object newValue) throws EvaluationException {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.SETVALUE_NOT_SUPPORTED, getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpelNode getChild(int index) {
|
||||
return children[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildCount() {
|
||||
return children.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectClass(Object obj) {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
@@ -143,15 +136,12 @@ public abstract class SpelNodeImpl implements SpelNode {
|
||||
|
||||
public abstract TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException;
|
||||
|
||||
@Override
|
||||
public abstract String toStringAST();
|
||||
|
||||
@Override
|
||||
public int getStartPosition() {
|
||||
return (pos>>16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEndPosition() {
|
||||
return (pos&0xffff);
|
||||
}
|
||||
|
||||
@@ -40,12 +40,10 @@ public interface ValueRef {
|
||||
|
||||
static NullValueRef instance = new NullValueRef();
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
return TypedValue.NULL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
// The exception position '0' isn't right but the overhead of creating
|
||||
// instances of this per node (where the node is solely for error reporting)
|
||||
@@ -53,7 +51,6 @@ public interface ValueRef {
|
||||
throw new SpelEvaluationException(0,SpelMessage.NOT_ASSIGNABLE,"null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return false;
|
||||
}
|
||||
@@ -73,18 +70,15 @@ public interface ValueRef {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
return typedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
throw new SpelEvaluationException(
|
||||
node.pos, SpelMessage.NOT_ASSIGNABLE, node.toStringAST());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -55,17 +55,14 @@ public class VariableReference extends SpelNodeImpl {
|
||||
this.eContext = evaluationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
eContext.setVariable(name, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -62,67 +62,56 @@ public class SpelExpression implements Expression {
|
||||
|
||||
// implementing Expression
|
||||
|
||||
@Override
|
||||
public Object getValue() throws EvaluationException {
|
||||
ExpressionState expressionState = new ExpressionState(getEvaluationContext(), configuration);
|
||||
return ast.getValue(expressionState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(Object rootObject) throws EvaluationException {
|
||||
ExpressionState expressionState = new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), configuration);
|
||||
return ast.getValue(expressionState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(Class<T> expectedResultType) throws EvaluationException {
|
||||
ExpressionState expressionState = new ExpressionState(getEvaluationContext(), configuration);
|
||||
TypedValue typedResultValue = ast.getTypedValue(expressionState);
|
||||
return ExpressionUtils.convertTypedValue(expressionState.getEvaluationContext(), typedResultValue, expectedResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(Object rootObject, Class<T> expectedResultType) throws EvaluationException {
|
||||
ExpressionState expressionState = new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), configuration);
|
||||
TypedValue typedResultValue = ast.getTypedValue(expressionState);
|
||||
return ExpressionUtils.convertTypedValue(expressionState.getEvaluationContext(), typedResultValue, expectedResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
return ast.getValue(new ExpressionState(context, configuration));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
return ast.getValue(new ExpressionState(context, toTypedValue(rootObject), configuration));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(EvaluationContext context, Class<T> expectedResultType) throws EvaluationException {
|
||||
TypedValue typedResultValue = ast.getTypedValue(new ExpressionState(context, configuration));
|
||||
return ExpressionUtils.convertTypedValue(context, typedResultValue, expectedResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> expectedResultType) throws EvaluationException {
|
||||
TypedValue typedResultValue = ast.getTypedValue(new ExpressionState(context, toTypedValue(rootObject), configuration));
|
||||
return ExpressionUtils.convertTypedValue(context, typedResultValue, expectedResultType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType() throws EvaluationException {
|
||||
return getValueType(getEvaluationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType(Object rootObject) throws EvaluationException {
|
||||
return getValueType(getEvaluationContext(), rootObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
ExpressionState eState = new ExpressionState(context, configuration);
|
||||
@@ -130,72 +119,60 @@ public class SpelExpression implements Expression {
|
||||
return typeDescriptor != null ? typeDescriptor.getType() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
ExpressionState eState = new ExpressionState(context, toTypedValue(rootObject), configuration);
|
||||
TypeDescriptor typeDescriptor = ast.getValueInternal(eState).getTypeDescriptor();
|
||||
return typeDescriptor != null ? typeDescriptor.getType() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor() throws EvaluationException {
|
||||
return getValueTypeDescriptor(getEvaluationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException {
|
||||
ExpressionState eState = new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), configuration);
|
||||
return ast.getValueInternal(eState).getTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
ExpressionState eState = new ExpressionState(context, configuration);
|
||||
return ast.getValueInternal(eState).getTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
ExpressionState eState = new ExpressionState(context, toTypedValue(rootObject), configuration);
|
||||
return ast.getValueInternal(eState).getTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpressionString() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable(EvaluationContext context) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
return ast.isWritable(new ExpressionState(context, configuration));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable(Object rootObject) throws EvaluationException {
|
||||
return ast.isWritable(new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), configuration));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
return ast.isWritable(new ExpressionState(context, toTypedValue(rootObject), configuration));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext context, Object value) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
ast.setValue(new ExpressionState(context, configuration), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object rootObject, Object value) throws EvaluationException {
|
||||
ast.setValue(new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), configuration), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException {
|
||||
Assert.notNull(context, "The EvaluationContext is required");
|
||||
ast.setValue(new ExpressionState(context, toTypedValue(rootObject), configuration), value);
|
||||
|
||||
@@ -54,7 +54,6 @@ class ReflectiveConstructorExecutor implements ConstructorExecutor {
|
||||
this.argsRequiringConversion = argsRequiringConversion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException {
|
||||
try {
|
||||
if (arguments != null) {
|
||||
|
||||
@@ -49,7 +49,6 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
|
||||
* registered type converter.
|
||||
* </ol>
|
||||
*/
|
||||
@Override
|
||||
public ConstructorExecutor resolve(EvaluationContext context, String typename, List<TypeDescriptor> argumentTypes)
|
||||
throws AccessException {
|
||||
|
||||
@@ -59,7 +58,6 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
|
||||
Constructor[] ctors = type.getConstructors();
|
||||
|
||||
Arrays.sort(ctors, new Comparator<Constructor>() {
|
||||
@Override
|
||||
public int compare(Constructor c1, Constructor c2) {
|
||||
int c1pl = c1.getParameterTypes().length;
|
||||
int c2pl = c2.getParameterTypes().length;
|
||||
|
||||
@@ -55,7 +55,6 @@ class ReflectiveMethodExecutor implements MethodExecutor {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TypedValue execute(EvaluationContext context, Object target, Object... arguments) throws AccessException {
|
||||
try {
|
||||
if (arguments != null) {
|
||||
|
||||
@@ -86,7 +86,6 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
||||
* according to the registered type converter.
|
||||
* </ol>
|
||||
*/
|
||||
@Override
|
||||
public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
|
||||
List<TypeDescriptor> argumentTypes) throws AccessException {
|
||||
|
||||
@@ -112,7 +111,6 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
||||
}
|
||||
|
||||
Arrays.sort(methods, new Comparator<Method>() {
|
||||
@Override
|
||||
public int compare(Method m1, Method m2) {
|
||||
int m1pl = m1.getParameterTypes().length;
|
||||
int m2pl = m2.getParameterTypes().length;
|
||||
|
||||
@@ -56,12 +56,10 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
/**
|
||||
* @return null which means this is a general purpose accessor
|
||||
*/
|
||||
@Override
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
if (target == null) {
|
||||
return false;
|
||||
@@ -96,7 +94,6 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
if (target == null) {
|
||||
throw new AccessException("Cannot read property of null target");
|
||||
@@ -163,7 +160,6 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
throw new AccessException("Neither getter nor field found for property '" + name + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
if (target == null) {
|
||||
return false;
|
||||
@@ -193,7 +189,6 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException {
|
||||
if (target == null) {
|
||||
throw new AccessException("Cannot write property on null target");
|
||||
@@ -502,12 +497,10 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class[] getSpecificTargetClasses() {
|
||||
throw new UnsupportedOperationException("Should not be called on an OptimalPropertyAccessor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
if (target == null) {
|
||||
return false;
|
||||
@@ -531,7 +524,6 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
if (this.member instanceof Method) {
|
||||
try {
|
||||
@@ -560,12 +552,10 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
throw new AccessException("Neither getter nor field found for property '" + name + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrite(EvaluationContext context, Object target, String name) {
|
||||
throw new UnsupportedOperationException("Should not be called on an OptimalPropertyAccessor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(EvaluationContext context, Object target, String name, Object newValue) {
|
||||
throw new UnsupportedOperationException("Should not be called on an OptimalPropertyAccessor");
|
||||
}
|
||||
|
||||
@@ -89,7 +89,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
this.rootObject = (rootObject != null ? new TypedValue(rootObject) : TypedValue.NULL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedValue getRootObject() {
|
||||
return this.rootObject;
|
||||
}
|
||||
@@ -104,7 +103,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
return this.constructorResolvers.remove(resolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConstructorResolver> getConstructorResolvers() {
|
||||
ensureConstructorResolversInitialized();
|
||||
return this.constructorResolvers;
|
||||
@@ -125,7 +123,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
return this.methodResolvers.remove(methodResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MethodResolver> getMethodResolvers() {
|
||||
ensureMethodResolversInitialized();
|
||||
return this.methodResolvers;
|
||||
@@ -135,7 +132,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
this.beanResolver = beanResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanResolver getBeanResolver() {
|
||||
return this.beanResolver;
|
||||
}
|
||||
@@ -154,7 +150,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
return this.propertyAccessors.remove(accessor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PropertyAccessor> getPropertyAccessors() {
|
||||
ensurePropertyAccessorsInitialized();
|
||||
return this.propertyAccessors;
|
||||
@@ -170,7 +165,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
this.typeLocator = typeLocator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeLocator getTypeLocator() {
|
||||
if (this.typeLocator == null) {
|
||||
this.typeLocator = new StandardTypeLocator();
|
||||
@@ -183,7 +177,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
this.typeConverter = typeConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeConverter getTypeConverter() {
|
||||
if (this.typeConverter == null) {
|
||||
this.typeConverter = new StandardTypeConverter();
|
||||
@@ -196,7 +189,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
this.typeComparator = typeComparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeComparator getTypeComparator() {
|
||||
return this.typeComparator;
|
||||
}
|
||||
@@ -206,12 +198,10 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
this.operatorOverloader = operatorOverloader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperatorOverloader getOperatorOverloader() {
|
||||
return this.operatorOverloader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariable(String name, Object value) {
|
||||
this.variables.put(name, value);
|
||||
}
|
||||
@@ -224,7 +214,6 @@ public class StandardEvaluationContext implements EvaluationContext {
|
||||
this.variables.put(name, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object lookupVariable(String name) {
|
||||
return this.variables.get(name);
|
||||
}
|
||||
|
||||
@@ -26,13 +26,11 @@ import org.springframework.expression.OperatorOverloader;
|
||||
*/
|
||||
public class StandardOperatorOverloader implements OperatorOverloader {
|
||||
|
||||
@Override
|
||||
public boolean overridesOperation(Operation operation, Object leftOperand, Object rightOperand)
|
||||
throws EvaluationException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object operate(Operation operation, Object leftOperand, Object rightOperand) throws EvaluationException {
|
||||
throw new EvaluationException("No operation overloaded by default");
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.springframework.expression.spel.SpelMessage;
|
||||
*/
|
||||
public class StandardTypeComparator implements TypeComparator {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public int compare(Object left, Object right) throws SpelEvaluationException {
|
||||
// If one is null, check if the other is
|
||||
@@ -73,7 +72,6 @@ public class StandardTypeComparator implements TypeComparator {
|
||||
throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCompare(Object left, Object right) {
|
||||
if (left == null || right == null) {
|
||||
return true;
|
||||
|
||||
@@ -57,12 +57,10 @@ public class StandardTypeConverter implements TypeConverter {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
return this.conversionService.canConvert(sourceType, targetType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertValue(Object value, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
try {
|
||||
return this.conversionService.convert(value, sourceType, targetType);
|
||||
|
||||
@@ -59,7 +59,6 @@ public class StandardTypeLocator implements TypeLocator {
|
||||
* @return the class object for the type
|
||||
* @throws EvaluationException if the type cannot be found
|
||||
*/
|
||||
@Override
|
||||
public Class<?> findType(String typename) throws EvaluationException {
|
||||
String nameToLookup = typename;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user