diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/TypedValue.java b/org.springframework.expression/src/main/java/org/springframework/expression/TypedValue.java
index 79d7f6ed1b..00c56fce36 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/TypedValue.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/TypedValue.java
@@ -57,5 +57,11 @@ public class TypedValue {
public TypeDescriptor getTypeDescriptor() {
return this.typeDescriptor;
}
-
+
+ @Override
+ public String toString() {
+ StringBuffer str = new StringBuffer();
+ str.append("TypedValue: ").append(value).append(" of type "+typeDescriptor.asString());
+ return str.toString();
+ }
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Assign.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Assign.java
index 95086aa2ae..5afb0adb72 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Assign.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Assign.java
@@ -20,7 +20,6 @@ import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
/**
* Represents assignment. An alternative to calling setValue() for an expression is to use an assign.
@@ -49,9 +48,4 @@ public class Assign extends SpelNodeImpl {
.toString();
}
- @Override
- public boolean isWritable(ExpressionState expressionState) throws SpelException {
- return false;
- }
-
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
index 0fbe46ed7a..dc4aab2b90 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
@@ -16,11 +16,9 @@
package org.springframework.expression.spel.ast;
-import java.lang.reflect.Array;
import java.util.List;
import org.antlr.runtime.Token;
-import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.ConstructorExecutor;
import org.springframework.expression.ConstructorResolver;
@@ -31,6 +29,7 @@ import org.springframework.expression.spel.ExpressionState;
import org.springframework.expression.spel.SpelException;
import org.springframework.expression.spel.SpelMessages;
+// TODO asc array constructor call logic has been removed for now
/**
* Represents the invocation of a constructor. Either a constructor on a regular type or construction of an array. When
* an array is constructed, an initializer can be specified.
@@ -46,201 +45,22 @@ import org.springframework.expression.spel.SpelMessages;
*/
public class ConstructorReference extends SpelNodeImpl {
- /**
- * If true then this is an array constructor, for example, 'new String[]', rather than a simple constructor 'new
- * String()'
- */
- private final boolean isArrayConstructor;
-
+ // TODO is this caching safe - passing the expression around will mean this executor is also being passed around
/**
* The cached executor that may be reused on subsequent evaluations.
*/
private ConstructorExecutor cachedExecutor;
-
- public ConstructorReference(Token payload, boolean isArrayConstructor) {
+ public ConstructorReference(Token payload) {
super(payload);
- this.isArrayConstructor = isArrayConstructor;
}
-
/**
* Implements getValue() - delegating to the code for building an array or a simple type.
*/
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
- if (this.isArrayConstructor) {
- return createArray(state);
- }
- else {
- return createNewInstance(state);
- }
- }
-
- @Override
- public String toStringAST() {
- StringBuilder sb = new StringBuilder();
- sb.append("new ");
-
- int index = 0;
- sb.append(getChild(index++).toStringAST());
-
- if (!this.isArrayConstructor) {
- sb.append("(");
- for (int i = index; i < getChildCount(); i++) {
- if (i > index)
- sb.append(",");
- sb.append(getChild(i).toStringAST());
- }
- sb.append(")");
- }
- else {
- // Next child is EXPRESSIONLIST token with children that are the
- // expressions giving array size
- sb.append("[");
- SpelNodeImpl arrayRank = getChild(index++);
- for (int i = 0; i < arrayRank.getChildCount(); i++) {
- if (i > 0)
- sb.append(",");
- sb.append(arrayRank.getChild(i).toStringAST());
- }
- sb.append("]");
- if (index < getChildCount())
- sb.append(" ").append(getChild(index).toStringAST());
- }
- return sb.toString();
- }
-
- @Override
- public boolean isWritable(ExpressionState expressionState) throws SpelException {
- return false;
- }
-
-
- /**
- * Create an array and return it. The children of this node indicate the type of array, the array ranks and any
- * optional initializer that might have been supplied.
- * @param state the expression state within which this expression is being evaluated
- * @return the new array
- * @throws EvaluationException if there is a problem creating the array
- */
- private TypedValue createArray(ExpressionState state) throws EvaluationException {
- TypedValue intendedArrayType = getChild(0).getValueInternal(state);
- if (!(intendedArrayType.getValue() instanceof String)) {
- throw new SpelException(getChild(0).getCharPositionInLine(),
- SpelMessages.TYPE_NAME_EXPECTED_FOR_ARRAY_CONSTRUCTION,
- FormatHelper.formatClassNameForMessage(intendedArrayType.getClass()));
- }
- String type = (String) intendedArrayType.getValue();
- Class> componentType = null;
- TypeCode arrayTypeCode = TypeCode.forName(type);
- if (arrayTypeCode == TypeCode.OBJECT) {
- componentType = state.findType(type);
- } else {
- componentType = arrayTypeCode.getType();
- }
-
- Object newArray = null;
- TypeDescriptor newArrayTypeDescriptor = null;
-
- if (getChild(1).getChildCount() == 0) { // are the array ranks defined?
- if (getChildCount() < 3) {
- throw new SpelException(getCharPositionInLine(),
- SpelMessages.NO_SIZE_OR_INITIALIZER_FOR_ARRAY_CONSTRUCTION);
- }
- // no array ranks so use the size of the initializer to determine array size
- int arraySize = getChild(2).getChildCount();
- newArray = Array.newInstance(componentType, arraySize);
- newArrayTypeDescriptor = TypeDescriptor.valueOf(newArray.getClass());
- }
- else {
- // Array ranks are specified but is it a single or multiple dimension array?
- int dimensions = getChild(1).getChildCount();
- if (dimensions == 1) {
- Object o = getChild(1).getValueInternal(state);
- int arraySize = state.convertValue(o, INTEGER_TYPE_DESCRIPTOR);
- if (getChildCount() == 3) {
- // Check initializer length matches array size length
- int initializerLength = getChild(2).getChildCount();
- if (initializerLength != arraySize) {
- throw new SpelException(getChild(2).getCharPositionInLine(),
- SpelMessages.INITIALIZER_LENGTH_INCORRECT, initializerLength, arraySize);
- }
- }
- newArray = Array.newInstance(componentType, arraySize);
- newArrayTypeDescriptor = TypeDescriptor.valueOf(newArray.getClass());
- }
- else {
- // Multi-dimensional - hold onto your hat !
- int[] dims = new int[dimensions];
- for (int d = 0; d < dimensions; d++) {
- dims[d] = state.convertValue(getChild(1).getChild(d).getValueInternal(state), INTEGER_TYPE_DESCRIPTOR);
- }
- newArray = Array.newInstance(componentType, dims);
- newArrayTypeDescriptor = TypeDescriptor.valueOf(newArray.getClass());
- // TODO check any specified initializer for the multidim array matches
- }
- }
-
- // Populate the array using the initializer if one is specified
- if (getChildCount() == 3) {
- SpelNodeImpl initializer = getChild(2);
- if (arrayTypeCode == TypeCode.OBJECT) {
- Object[] newObjectArray = (Object[]) newArray;
- for (int i = 0; i < newObjectArray.length; i++) {
- SpelNodeImpl elementNode = initializer.getChild(i);
- Object arrayEntry = elementNode.getValueInternal(state);
- if (!componentType.isAssignableFrom(arrayEntry.getClass())) {
- throw new SpelException(elementNode.getCharPositionInLine(),
- SpelMessages.INCORRECT_ELEMENT_TYPE_FOR_ARRAY, componentType.getName(), arrayEntry
- .getClass().getName());
- }
- newObjectArray[i] = arrayEntry;
- }
- } else if (arrayTypeCode == TypeCode.INT) {
- int[] newIntArray = (int[]) newArray;
- for (int i = 0; i < newIntArray.length; i++) {
- newIntArray[i] = state.convertValue(initializer.getChild(i).getValueInternal(state), INTEGER_TYPE_DESCRIPTOR);
- }
- } else if (arrayTypeCode == TypeCode.BOOLEAN) {
- boolean[] newBooleanArray = (boolean[]) newArray;
- for (int i = 0; i < newBooleanArray.length; i++) {
- newBooleanArray[i] = state.convertValue(initializer.getChild(i).getValueInternal(state), BOOLEAN_TYPE_DESCRIPTOR);
- }
- } else if (arrayTypeCode == TypeCode.CHAR) {
- char[] newCharArray = (char[]) newArray;
- for (int i = 0; i < newCharArray.length; i++) {
- newCharArray[i] = state.convertValue(initializer.getChild(i).getValueInternal(state), CHARACTER_TYPE_DESCRIPTOR);
- }
- } else if (arrayTypeCode == TypeCode.SHORT) {
- short[] newShortArray = (short[]) newArray;
- for (int i = 0; i < newShortArray.length; i++) {
- newShortArray[i] = state.convertValue(initializer.getChild(i).getValueInternal(state), SHORT_TYPE_DESCRIPTOR);
- }
- } else if (arrayTypeCode == TypeCode.LONG) {
- long[] newLongArray = (long[]) newArray;
- for (int i = 0; i < newLongArray.length; i++) {
- newLongArray[i] = state.convertValue(initializer.getChild(i).getValueInternal(state), LONG_TYPE_DESCRIPTOR);
- }
- } else if (arrayTypeCode == TypeCode.FLOAT) {
- float[] newFloatArray = (float[]) newArray;
- for (int i = 0; i < newFloatArray.length; i++) {
- newFloatArray[i] = state.convertValue(initializer.getChild(i).getValueInternal(state), FLOAT_TYPE_DESCRIPTOR);
- }
- } else if (arrayTypeCode == TypeCode.DOUBLE) {
- double[] newDoubleArray = (double[]) newArray;
- for (int i = 0; i < newDoubleArray.length; i++) {
- newDoubleArray[i] = state.convertValue(initializer.getChild(i).getValueInternal(state), DOUBLE_TYPE_DESCRIPTOR);
- }
- } else if (arrayTypeCode == TypeCode.BYTE) {
- byte[] newByteArray = (byte[]) newArray;
- for (int i = 0; i < newByteArray.length; i++) {
- newByteArray[i] = state.convertValue(initializer.getChild(i).getValueInternal(state), BYTE_TYPE_DESCRIPTOR);
- }
- }
- }
-
- return new TypedValue(newArray, newArrayTypeDescriptor);
+ return createNewInstance(state);
}
/**
@@ -274,9 +94,10 @@ public class ConstructorReference extends SpelNodeImpl {
String typename = (String) getChild(0).getValueInternal(state).getValue();
executorToUse = findExecutorForConstructor(typename, argumentTypes, state);
try {
- return executorToUse.execute(state.getEvaluationContext(), arguments);
- }
- catch (AccessException ae) {
+ this.cachedExecutor = executorToUse;
+ TypedValue result = executorToUse.execute(state.getEvaluationContext(), arguments);
+ return result;
+ } catch (AccessException ae) {
throw new SpelException(ae, SpelMessages.EXCEPTION_DURING_CONSTRUCTOR_INVOCATION, typename, ae.getMessage());
}
}
@@ -314,4 +135,22 @@ public class ConstructorReference extends SpelNodeImpl {
argumentTypes));
}
+ @Override
+ public String toStringAST() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("new ");
+
+ int index = 0;
+ sb.append(getChild(index++).toStringAST());
+
+ sb.append("(");
+ for (int i = index; i < getChildCount(); i++) {
+ if (i > index)
+ sb.append(",");
+ sb.append(getChild(i).toStringAST());
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FormatHelper.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FormatHelper.java
index a0b0eea3c3..ac9bf742b7 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FormatHelper.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FormatHelper.java
@@ -21,7 +21,7 @@ package org.springframework.expression.spel.ast;
*
* @author Andy Clement
*/
-class FormatHelper {
+public class FormatHelper {
/**
* Produce a nice string for a given method name with specified arguments.
@@ -33,13 +33,11 @@ class FormatHelper {
StringBuilder sb = new StringBuilder();
sb.append(name);
sb.append("(");
- if (argumentTypes != null) {
- for (int i = 0; i < argumentTypes.length; i++) {
- if (i > 0) {
- sb.append(",");
- }
- sb.append(argumentTypes[i].getName());
+ for (int i = 0; i < argumentTypes.length; i++) {
+ if (i > 0) {
+ sb.append(",");
}
+ sb.append(formatClassNameForMessage(argumentTypes[i]));
}
sb.append(")");
return sb.toString();
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
index f59e1925cd..4811246750 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
@@ -128,10 +128,6 @@ public class FunctionReference extends SpelNodeImpl {
}
// to 'assign' to a function don't use the () suffix and so it is just a variable reference
- @Override
- public boolean isWritable(ExpressionState expressionState) throws EvaluationException {
- return false;
- }
/**
* Compute the arguments to the function, they are the children of this expression node.
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Literal.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Literal.java
index 792dc4259b..d24bdc0fe9 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Literal.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Literal.java
@@ -52,11 +52,6 @@ public abstract class Literal extends SpelNodeImpl {
return toString();
}
- @Override
- public boolean isWritable(ExpressionState expressionState) throws SpelException {
- return false;
- }
-
/**
* Process the string form of a number, using the specified base if supplied and return an appropriate literal to
* hold it. Any suffix to indicate a long will be taken into account (either 'l' or 'L' is supported).
@@ -71,9 +66,7 @@ public abstract class Literal extends SpelNodeImpl {
boolean isLong = false;
boolean isHex = (radix == 16);
- if (numberString.length() > 0) {
- isLong = numberString.endsWith("L") || numberString.endsWith("l");
- }
+ isLong = numberString.endsWith("L") || numberString.endsWith("l");
if (isLong || isHex) { // needs to be chopped up a little
int len = numberString.length();
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
index 6ea2dc740a..8725b2d402 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
@@ -78,10 +78,9 @@ public class MethodReference extends SpelNodeImpl {
try {
return executorToUse.execute(
state.getEvaluationContext(), state.getActiveContextObject().getValue(), arguments);
- }
- catch (AccessException ae) {
+ } catch (AccessException ae) {
throw new SpelException(getCharPositionInLine(), ae, SpelMessages.EXCEPTION_DURING_METHOD_INVOCATION,
- this.name, state.getActiveContextObject().getClass().getName(), ae.getMessage());
+ this.name, state.getActiveContextObject().getValue().getClass().getName(), ae.getMessage());
}
}
@@ -130,11 +129,6 @@ public class MethodReference extends SpelNodeImpl {
return sb.toString();
}
- @Override
- public boolean isWritable(ExpressionState expressionState) throws SpelException {
- return false;
- }
-
protected MethodExecutor findAccessorForMethod(String name, Class>[] argumentTypes, ExpressionState state)
throws SpelException {
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Operator.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Operator.java
index efa06f7fe8..670bfb8b38 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Operator.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Operator.java
@@ -17,8 +17,6 @@
package org.springframework.expression.spel.ast;
import org.antlr.runtime.Token;
-import org.springframework.expression.spel.SpelException;
-import org.springframework.expression.spel.ExpressionState;
/**
* Common supertype for operators that operate on either one or two operands. In the case of multiply or divide there
@@ -32,15 +30,7 @@ public abstract class Operator extends SpelNodeImpl {
public Operator(Token payload) {
super(payload);
}
-
- /**
- * Operator expressions can never be written to
- */
- @Override
- public final boolean isWritable(ExpressionState expressionState) throws SpelException {
- return false;
- }
-
+
public SpelNodeImpl getLeftOperand() {
return getChild(0);
}
@@ -57,17 +47,13 @@ public abstract class Operator extends SpelNodeImpl {
@Override
public String toStringAST() {
StringBuilder sb = new StringBuilder();
- if (getChildCount() > 0) {
- sb.append("(");
- }
+ sb.append("(");
sb.append(getChild(0).toStringAST());
for (int i = 1; i < getChildCount(); i++) {
sb.append(" ").append(getOperatorName()).append(" ");
sb.append(getChild(i).toStringAST());
}
- if (getChildCount() > 0) {
- sb.append(")");
- }
+ sb.append(")");
return sb.toString();
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java
index 5c7b33ae1b..574713b3e9 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java
@@ -53,9 +53,4 @@ public class OperatorNot extends SpelNodeImpl { // Not is a unary operator so do
return sb.toString();
}
- @Override
- public boolean isWritable(ExpressionState expressionState) throws SpelException {
- return false;
- }
-
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPlus.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPlus.java
index 51160516d1..59f22e2b75 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPlus.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPlus.java
@@ -28,11 +28,10 @@ import org.springframework.expression.spel.ExpressionState;
*
add doubles (floats are represented as doubles)
* add longs
* add integers
- * add a string of one character and a number (effectively increasing that character), so 'a'+3='d'
+ * concatenate strings
*
* It can be used as a unary operator for numbers (double/long/int). The standard promotions are performed
- * when the operand types vary (double+int=double).
- * For other options it defers to the registered overloader.
+ * when the operand types vary (double+int=double). For other options it defers to the registered overloader.
*
* @author Andy Clement
* @since 3.0
@@ -75,16 +74,6 @@ public class OperatorPlus extends Operator {
}
} else if (operandOne instanceof String && operandTwo instanceof String) {
return new TypedValue(new StringBuilder((String) operandOne).append((String) operandTwo).toString(),STRING_TYPE_DESCRIPTOR);
- } else if (operandOne instanceof String && operandTwo instanceof Integer && ((String)operandOne).length()==1) {
- String theString = (String) operandOne;
- Integer theInteger = (Integer) operandTwo;
- // implements character + int (ie. a + 1 = b)
- return new TypedValue(Character.toString((char) (theString.charAt(0) + theInteger)),STRING_TYPE_DESCRIPTOR);
- } else if (operandOne instanceof Integer && ((operandTwo instanceof String) && ((String)operandTwo).length()==1)) {
- String theString = (String) operandTwo;
- Integer theInteger = (Integer) operandOne;
- // implements character + int (ie. 1 + a = b)
- return new TypedValue(Character.toString((char) (theString.charAt(0) + theInteger)),STRING_TYPE_DESCRIPTOR);
}
return state.operate(Operation.ADD, operandOne, operandTwo);
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Placeholder.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Placeholder.java
deleted file mode 100644
index ea04f26748..0000000000
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Placeholder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2002-2009 the original author or authors.
- *
- * Licensed 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.springframework.expression.spel.ast;
-
-import org.antlr.runtime.Token;
-import org.springframework.expression.TypedValue;
-import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
-import org.springframework.expression.spel.SpelMessages;
-
-/**
- * PlaceHolder nodes are created for tokens that come through from the grammar purely to give us additional positional
- * information for messages/etc.
- *
- * @author Andy Clement
- * @since 3.0
- */
-public class Placeholder extends SpelNodeImpl {
-
- public Placeholder(Token payload) {
- super(payload);
- }
-
- @Override
- public TypedValue getValueInternal(ExpressionState state) throws SpelException {
- throw new SpelException(getCharPositionInLine(), SpelMessages.PLACEHOLDER_SHOULD_NEVER_BE_EVALUATED);
- }
-
- @Override
- public String toStringAST() {
- return getText();
- }
-
-}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java
index d0ff02cb22..18b7190003 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java
@@ -61,7 +61,7 @@ public class Projection extends SpelNodeImpl {
for (Object k : mapdata.keySet()) {
try {
state.pushActiveContextObject(new TypedValue(new KeyValuePair(k, mapdata.get(k)),TypeDescriptor.valueOf(KeyValuePair.class)));
- result.add(getChild(0).getValueInternal(state));
+ result.add(getChild(0).getValueInternal(state).getValue());
} finally {
state.popActiveContextObject();
}
@@ -76,7 +76,7 @@ public class Projection extends SpelNodeImpl {
try {
state.pushActiveContextObject(new TypedValue(element,TypeDescriptor.valueOf(op.getTypeDescriptor().getType())));
state.enterScope("index", idx);
- result.add(getChild(0).getValueInternal(state));
+ result.add(getChild(0).getValueInternal(state).getValue());
} finally {
state.exitScope();
state.popActiveContextObject();
@@ -95,9 +95,4 @@ public class Projection extends SpelNodeImpl {
return sb.append("!{").append(getChild(0).toStringAST()).append("}").toString();
}
- @Override
- public boolean isWritable(ExpressionState expressionState) throws SpelException {
- return false;
- }
-
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
index 48c0f809f9..cb04fa4a13 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
@@ -145,6 +145,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
}
}
} catch (AccessException ae) {
+ ae.printStackTrace();
throw new SpelException(getCharPositionInLine(), ae, SpelMessages.EXCEPTION_DURING_PROPERTY_WRITE,
name, ae.getMessage());
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/QualifiedIdentifier.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/QualifiedIdentifier.java
index 7a6740a59f..fbdf6fd9f0 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/QualifiedIdentifier.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/QualifiedIdentifier.java
@@ -31,7 +31,7 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class QualifiedIdentifier extends SpelNodeImpl {
- private String value;
+ private TypedValue value;
public QualifiedIdentifier(Token payload) {
super(payload);
@@ -49,18 +49,17 @@ public class QualifiedIdentifier extends SpelNodeImpl {
}
sb.append(getChild(i).getValueInternal(state).getValue());
}
- this.value = sb.toString();
+ this.value = new TypedValue(sb.toString(),STRING_TYPE_DESCRIPTOR);
}
- return new TypedValue(this.value,STRING_TYPE_DESCRIPTOR);
+ return this.value;
}
@Override
public String toStringAST() {
StringBuilder sb = new StringBuilder();
if (this.value != null) {
- sb.append(this.value);
- }
- else {
+ sb.append(this.value.getValue());
+ } else {
for (int i = 0; i < getChildCount(); i++) {
if (i > 0) {
sb.append(".");
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java
index 325b2179f6..a7cdbdc0db 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java
@@ -18,6 +18,7 @@ package org.springframework.expression.spel.ast;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -59,17 +60,21 @@ public class Selection extends SpelNodeImpl {
SpelNodeImpl selectionCriteria = getChild(0);
if (operand instanceof Map) {
Map, ?> mapdata = (Map, ?>) operand;
- List