introduced TypeDescriptor.OBJECT and TypeDescriptor.STRING
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.expression;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
@@ -34,7 +35,7 @@ public interface Expression {
|
||||
* @return the evaluation result
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public Object getValue() throws EvaluationException;
|
||||
Object getValue() throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Evaluate this expression against the specified root object
|
||||
@@ -43,7 +44,7 @@ public interface Expression {
|
||||
* @return the evaluation result
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public Object getValue(Object rootObject) throws EvaluationException;
|
||||
Object getValue(Object rootObject) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Evaluate the expression in the default context. If the result of the evaluation does not match (and
|
||||
@@ -53,7 +54,7 @@ public interface Expression {
|
||||
* @return the evaluation result
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public <T> T getValue(Class<T> desiredResultType) throws EvaluationException;
|
||||
<T> T getValue(Class<T> desiredResultType) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Evaluate the expression in the default context against the specified root object. If the
|
||||
@@ -65,7 +66,7 @@ public interface Expression {
|
||||
* @return the evaluation result
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public <T> T getValue(Object rootObject, Class<T> desiredResultType) throws EvaluationException;
|
||||
<T> T getValue(Object rootObject, Class<T> desiredResultType) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Evaluate this expression in the provided context and return the result of evaluation.
|
||||
@@ -74,7 +75,7 @@ public interface Expression {
|
||||
* @return the evaluation result
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public Object getValue(EvaluationContext context) throws EvaluationException;
|
||||
Object getValue(EvaluationContext context) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Evaluate this expression in the provided context and return the result of evaluation, but use
|
||||
@@ -85,7 +86,7 @@ public interface Expression {
|
||||
* @return the evaluation result
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public Object getValue(EvaluationContext context, Object rootObject) throws EvaluationException;
|
||||
Object getValue(EvaluationContext context, Object rootObject) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc -
|
||||
@@ -97,7 +98,7 @@ public interface Expression {
|
||||
* @return the evaluation result
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public <T> T getValue(EvaluationContext context, Class<T> desiredResultType) throws EvaluationException;
|
||||
<T> T getValue(EvaluationContext context, Class<T> desiredResultType) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc -
|
||||
@@ -111,7 +112,7 @@ public interface Expression {
|
||||
* @return the evaluation result
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType) throws EvaluationException;
|
||||
<T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)} method using
|
||||
@@ -120,107 +121,97 @@ public interface Expression {
|
||||
* @return the most general type of value that can be set on this context
|
||||
* @throws EvaluationException if there is a problem determining the type
|
||||
*/
|
||||
public Class getValueType() throws EvaluationException;
|
||||
Class getValueType() throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)} method using
|
||||
* the default context.
|
||||
*
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)}
|
||||
* method using the default context.
|
||||
* @param rootObject the root object against which to evaluate the expression
|
||||
* @return the most general type of value that can be set on this context
|
||||
* @throws EvaluationException if there is a problem determining the type
|
||||
*/
|
||||
public Class getValueType(Object rootObject) throws EvaluationException;
|
||||
Class getValueType(Object rootObject) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)} method for
|
||||
* the given context.
|
||||
*
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)}
|
||||
* method for the given context.
|
||||
* @param context the context in which to evaluate the expression
|
||||
* @return the most general type of value that can be set on this context
|
||||
* @throws EvaluationException if there is a problem determining the type
|
||||
*/
|
||||
public Class getValueType(EvaluationContext context) throws EvaluationException;
|
||||
Class getValueType(EvaluationContext context) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)} method for
|
||||
* the given context. The supplied root object overrides any specified in the context.
|
||||
*
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)}
|
||||
* method for the given context. The supplied root object overrides any specified in the context.
|
||||
* @param context the context in which to evaluate the expression
|
||||
* @param rootObject the root object against which to evaluate the expression
|
||||
* @return the most general type of value that can be set on this context
|
||||
* @throws EvaluationException if there is a problem determining the type
|
||||
*/
|
||||
public Class getValueType(EvaluationContext context, Object rootObject) throws EvaluationException;
|
||||
Class getValueType(EvaluationContext context, Object rootObject) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)} method using
|
||||
* the default context.
|
||||
*
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)}
|
||||
* method using the default context.
|
||||
* @return a type descriptor for the most general type of value that can be set on this context
|
||||
* @throws EvaluationException if there is a problem determining the type
|
||||
*/
|
||||
public TypeDescriptor getValueTypeDescriptor() throws EvaluationException;
|
||||
TypeDescriptor getValueTypeDescriptor() throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)} method using
|
||||
* the default context.
|
||||
*
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)}
|
||||
* method using the default context.
|
||||
* @param rootObject the root object against which to evaluate the expression
|
||||
* @return a type descriptor for the most general type of value that can be set on this context
|
||||
* @throws EvaluationException if there is a problem determining the type
|
||||
*/
|
||||
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException;
|
||||
TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)} method for
|
||||
* the given context.
|
||||
*
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)}
|
||||
* method for the given context.
|
||||
* @param context the context in which to evaluate the expression
|
||||
* @return a type descriptor for the most general type of value that can be set on this context
|
||||
* @throws EvaluationException if there is a problem determining the type
|
||||
*/
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException;
|
||||
TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the most general type that can be passed to the {@link #setValue(EvaluationContext, Object)} method for
|
||||
* the given context. The supplied root object overrides any specified in the context.
|
||||
*
|
||||
* @param context the context in which to evaluate the expression
|
||||
* @param rootObject the root object against which to evaluate the expression
|
||||
* @return a type descriptor for the most general type of value that can be set on this context
|
||||
* @throws EvaluationException if there is a problem determining the type
|
||||
*/
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException;
|
||||
TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Determine if an expression can be written to, i.e. setValue() can be called.
|
||||
*
|
||||
* @param context the context in which the expression should be checked
|
||||
* @return true if the expression is writable
|
||||
* @throws EvaluationException if there is a problem determining if it is writable
|
||||
*/
|
||||
public boolean isWritable(EvaluationContext context) throws EvaluationException;
|
||||
boolean isWritable(EvaluationContext context) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Determine if an expression can be written to, i.e. setValue() can be called.
|
||||
* The supplied root object overrides any specified in the context.
|
||||
*
|
||||
* @param context the context in which the expression should be checked
|
||||
* @param rootObject the root object against which to evaluate the expression
|
||||
* @return true if the expression is writable
|
||||
* @throws EvaluationException if there is a problem determining if it is writable
|
||||
*/
|
||||
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException;
|
||||
boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Determine if an expression can be written to, i.e. setValue() can be called.
|
||||
*
|
||||
* @param rootObject the root object against which to evaluate the expression
|
||||
* @return true if the expression is writable
|
||||
* @throws EvaluationException if there is a problem determining if it is writable
|
||||
*/
|
||||
public boolean isWritable(Object rootObject) throws EvaluationException;
|
||||
boolean isWritable(Object rootObject) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Set this expression in the provided context to the value provided.
|
||||
@@ -229,33 +220,30 @@ public interface Expression {
|
||||
* @param value the new value
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public void setValue(EvaluationContext context, Object value) throws EvaluationException;
|
||||
void setValue(EvaluationContext context, Object value) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Set this expression in the provided context to the value provided.
|
||||
*
|
||||
* @param rootObject the root object against which to evaluate the expression
|
||||
* @param value the new value
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public void setValue(Object rootObject, Object value) throws EvaluationException;
|
||||
void setValue(Object rootObject, Object value) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Set this expression in the provided context to the value provided.
|
||||
* The supplied root object overrides any specified in the context.
|
||||
*
|
||||
* @param context the context in which to set the value of the expression
|
||||
* @param rootObject the root object against which to evaluate the expression
|
||||
* @param value the new value
|
||||
* @throws EvaluationException if there is a problem during evaluation
|
||||
*/
|
||||
public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException;
|
||||
void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException;
|
||||
|
||||
/**
|
||||
* Returns the original string used to create this expression, unmodified.
|
||||
*
|
||||
* @return the original expression string
|
||||
*/
|
||||
public String getExpressionString();
|
||||
String getExpressionString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,11 +107,11 @@ public class CompositeStringExpression implements Expression {
|
||||
}
|
||||
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
return TypeDescriptor.STRING;
|
||||
}
|
||||
|
||||
public TypeDescriptor getValueTypeDescriptor() {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
return TypeDescriptor.STRING;
|
||||
}
|
||||
|
||||
public void setValue(EvaluationContext context, Object value) throws EvaluationException {
|
||||
@@ -157,12 +157,11 @@ public class CompositeStringExpression implements Expression {
|
||||
}
|
||||
|
||||
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
return TypeDescriptor.STRING;
|
||||
}
|
||||
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject)
|
||||
throws EvaluationException {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
return TypeDescriptor.STRING;
|
||||
}
|
||||
|
||||
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
|
||||
@@ -22,9 +22,10 @@ import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.Expression;
|
||||
|
||||
/**
|
||||
* A very simple hardcoded implementation of the Expression interface that represents a string literal. It is used with
|
||||
* CompositeStringExpression when representing a template expression which is made up of pieces - some being real
|
||||
* expressions to be handled by an EL implementation like Spel, and some being just textual elements.
|
||||
* A very simple hardcoded implementation of the Expression interface that represents a string literal.
|
||||
* It is used with CompositeStringExpression when representing a template expression which is made up
|
||||
* of pieces - some being real expressions to be handled by an EL implementation like Spel, and some
|
||||
* being just textual elements.
|
||||
*
|
||||
* @author Andy Clement
|
||||
* @since 3.0
|
||||
@@ -61,11 +62,11 @@ public class LiteralExpression implements Expression {
|
||||
}
|
||||
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
return TypeDescriptor.STRING;
|
||||
}
|
||||
|
||||
public TypeDescriptor getValueTypeDescriptor() {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
return TypeDescriptor.STRING;
|
||||
}
|
||||
|
||||
public void setValue(EvaluationContext context, Object value) throws EvaluationException {
|
||||
@@ -102,8 +103,7 @@ public class LiteralExpression implements Expression {
|
||||
}
|
||||
|
||||
|
||||
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType)
|
||||
throws EvaluationException {
|
||||
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType) throws EvaluationException {
|
||||
Object value = getValue(context, rootObject);
|
||||
return ExpressionUtils.convert(null, value, desiredResultType);
|
||||
}
|
||||
@@ -120,13 +120,12 @@ public class LiteralExpression implements Expression {
|
||||
|
||||
|
||||
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
return TypeDescriptor.STRING;
|
||||
}
|
||||
|
||||
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject)
|
||||
throws EvaluationException {
|
||||
return TypeDescriptor.valueOf(String.class);
|
||||
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||
return TypeDescriptor.STRING;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Indexer extends SpelNodeImpl {
|
||||
if (targetObject instanceof Map && (children[0] instanceof PropertyOrFieldReference)) {
|
||||
PropertyOrFieldReference reference = (PropertyOrFieldReference)children[0];
|
||||
index = reference.getName();
|
||||
indexValue = new TypedValue(index, TypeDescriptor.valueOf(String.class));
|
||||
indexValue = new TypedValue(index, TypeDescriptor.STRING);
|
||||
}
|
||||
else {
|
||||
// In case the map key is unqualified, we want it evaluated against the root object so
|
||||
@@ -86,8 +86,8 @@ public class Indexer extends SpelNodeImpl {
|
||||
possiblyConvertedKey = state.convertValue(index,TypeDescriptor.valueOf(targetObjectTypeDescriptor.getMapKeyType()));
|
||||
}
|
||||
Object o = ((Map<?, ?>) targetObject).get(possiblyConvertedKey);
|
||||
TypeDescriptor resultDescriptor = targetObjectTypeDescriptor.isMapEntryTypeKnown()?
|
||||
TypeDescriptor.valueOf(targetObjectTypeDescriptor.getMapValueType()): TypeDescriptor.valueOf(Object.class);
|
||||
TypeDescriptor resultDescriptor = (targetObjectTypeDescriptor.isMapEntryTypeKnown() ?
|
||||
TypeDescriptor.valueOf(targetObjectTypeDescriptor.getMapValueType()) : TypeDescriptor.OBJECT);
|
||||
return new TypedValue(o,resultDescriptor);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.expression.spel.ast;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.common.ExpressionUtils;
|
||||
@@ -24,7 +25,7 @@ import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.SpelNode;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The common supertype of all AST nodes in a parsed Spring Expression Language format expression.
|
||||
@@ -34,17 +35,17 @@ import org.springframework.core.convert.TypeDescriptor;
|
||||
*/
|
||||
public abstract class SpelNodeImpl implements SpelNode {
|
||||
|
||||
static TypeDescriptor OBJECT_TYPE_DESCRIPTOR = TypeDescriptor.OBJECT;
|
||||
static TypeDescriptor STRING_TYPE_DESCRIPTOR = TypeDescriptor.STRING;
|
||||
static TypeDescriptor CLASS_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Class.class);
|
||||
static TypeDescriptor BOOLEAN_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Boolean.class);
|
||||
static TypeDescriptor INTEGER_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Integer.class);
|
||||
static TypeDescriptor CHARACTER_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Character.class);
|
||||
static TypeDescriptor LONG_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Long.class);
|
||||
static TypeDescriptor SHORT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Short.class);
|
||||
static TypeDescriptor BYTE_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Byte.class);
|
||||
static TypeDescriptor SHORT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Short.class);
|
||||
static TypeDescriptor INTEGER_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Integer.class);
|
||||
static TypeDescriptor LONG_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Long.class);
|
||||
static TypeDescriptor FLOAT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Float.class);
|
||||
static TypeDescriptor DOUBLE_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Double.class);
|
||||
static TypeDescriptor STRING_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(String.class);
|
||||
static TypeDescriptor CLASS_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Class.class);
|
||||
static TypeDescriptor OBJECT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Object.class);
|
||||
|
||||
private static SpelNodeImpl[] NO_CHILDREN = new SpelNodeImpl[0];
|
||||
|
||||
@@ -55,10 +56,10 @@ public abstract class SpelNodeImpl implements SpelNode {
|
||||
public SpelNodeImpl(int pos, SpelNodeImpl... operands) {
|
||||
this.pos = pos;
|
||||
// pos combines start and end so can never be zero because tokens cannot be zero length
|
||||
assert pos!=0;
|
||||
if (operands!=null && operands.length>0) {
|
||||
Assert.isTrue(pos != 0);
|
||||
if (operands != null && operands.length > 0) {
|
||||
this.children = operands;
|
||||
for (SpelNodeImpl childnode: operands) {
|
||||
for (SpelNodeImpl childnode : operands) {
|
||||
childnode.parent = this;
|
||||
}
|
||||
}
|
||||
@@ -66,8 +67,8 @@ public abstract class SpelNodeImpl implements SpelNode {
|
||||
|
||||
protected SpelNodeImpl getPreviousChild() {
|
||||
SpelNodeImpl result = null;
|
||||
if (parent!=null) {
|
||||
for (SpelNodeImpl child: parent.children) {
|
||||
if (parent != null) {
|
||||
for (SpelNodeImpl child : parent.children) {
|
||||
if (this==child) break;
|
||||
result = child;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ import org.springframework.expression.spel.ast.StringLiteral;
|
||||
import org.springframework.expression.spel.ast.Ternary;
|
||||
import org.springframework.expression.spel.ast.TypeReference;
|
||||
import org.springframework.expression.spel.ast.VariableReference;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Hand written SpEL parser. Instances are reusable but are not thread safe.
|
||||
@@ -114,7 +115,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
if (moreTokens()) {
|
||||
throw new SpelParseException(peekToken().startpos,SpelMessage.MORE_INPUT,toString(nextToken()));
|
||||
}
|
||||
assert constructedNodes.isEmpty();
|
||||
Assert.isTrue(constructedNodes.isEmpty());
|
||||
return new SpelExpression(expressionString, ast, configuration);
|
||||
}
|
||||
catch (InternalParseException ipe) {
|
||||
@@ -179,7 +180,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
private SpelNodeImpl eatRelationalExpression() {
|
||||
SpelNodeImpl expr = eatSumExpression();
|
||||
Token relationalOperatorToken = maybeEatRelationalOperator();
|
||||
if (relationalOperatorToken!=null) {
|
||||
if (relationalOperatorToken != null) {
|
||||
Token t = nextToken(); //consume relational operator token
|
||||
SpelNodeImpl rhExpr = eatSumExpression();
|
||||
checkRightOperand(t,rhExpr);
|
||||
@@ -194,10 +195,10 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
return new OpLE(pos,expr,rhExpr);
|
||||
} else if (tk==TokenKind.GE) {
|
||||
return new OpGE(pos,expr,rhExpr);
|
||||
} else if (tk==TokenKind.EQ) {
|
||||
} else if (tk == TokenKind.EQ) {
|
||||
return new OpEQ(pos,expr,rhExpr);
|
||||
} else {
|
||||
assert tk==TokenKind.NE;
|
||||
Assert.isTrue(tk == TokenKind.NE);
|
||||
return new OpNE(pos,expr,rhExpr);
|
||||
}
|
||||
}
|
||||
@@ -206,7 +207,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
} else if (tk==TokenKind.MATCHES) {
|
||||
return new OperatorMatches(toPos(t),expr,rhExpr);
|
||||
} else {
|
||||
assert tk==TokenKind.BETWEEN;
|
||||
Assert.isTrue(tk==TokenKind.BETWEEN);
|
||||
return new org.springframework.expression.spel.ast.OperatorBetween(toPos(t),expr,rhExpr);
|
||||
}
|
||||
}
|
||||
@@ -223,7 +224,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
if (t.kind==TokenKind.PLUS) {
|
||||
expr = new OpPlus(toPos(t),expr,rhExpr);
|
||||
} else {
|
||||
assert t.kind==TokenKind.MINUS;
|
||||
Assert.isTrue(t.kind==TokenKind.MINUS);
|
||||
expr = new OpMinus(toPos(t),expr,rhExpr);
|
||||
}
|
||||
}
|
||||
@@ -242,7 +243,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
} else if (t.kind==TokenKind.DIV) {
|
||||
expr = new OpDivide(toPos(t),expr,rhExpr);
|
||||
} else {
|
||||
assert t.kind==TokenKind.MOD;
|
||||
Assert.isTrue(t.kind==TokenKind.MOD);
|
||||
expr = new OpModulus(toPos(t),expr,rhExpr);
|
||||
}
|
||||
}
|
||||
@@ -271,7 +272,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
} else if (t.kind==TokenKind.PLUS) {
|
||||
return new OpPlus(toPos(t),expr);
|
||||
} else {
|
||||
assert t.kind==TokenKind.MINUS;
|
||||
Assert.isTrue(t.kind==TokenKind.MINUS);
|
||||
return new OpMinus(toPos(t),expr);
|
||||
}
|
||||
} else {
|
||||
@@ -653,7 +654,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
}
|
||||
|
||||
private Token eatToken(TokenKind expectedKind) {
|
||||
assert moreTokens();
|
||||
Assert.isTrue(moreTokens());
|
||||
Token t = nextToken();
|
||||
if (t==null) {
|
||||
raiseInternalException( expressionString.length(), SpelMessage.OOD);
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import org.springframework.expression.spel.InternalParseException;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.SpelParseException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Lex some input data into a stream of tokens that can then be parsed.
|
||||
@@ -395,8 +396,8 @@ class Tokenizer {
|
||||
* Check if this might be a two character token.
|
||||
*/
|
||||
private boolean isTwoCharToken(TokenKind kind) {
|
||||
assert kind.tokenChars.length==2;
|
||||
assert toProcess[pos] == kind.tokenChars[0];
|
||||
Assert.isTrue(kind.tokenChars.length == 2);
|
||||
Assert.isTrue(toProcess[pos] == kind.tokenChars[0]);
|
||||
return toProcess[pos+1] == kind.tokenChars[1];
|
||||
}
|
||||
|
||||
|
||||
@@ -257,10 +257,10 @@ public class ExpressionStateTests extends ExpressionTestCase {
|
||||
@Test
|
||||
public void testTypeConversion() throws EvaluationException {
|
||||
ExpressionState state = getState();
|
||||
String s = (String)state.convertValue(34,TypeDescriptor.valueOf(String.class));
|
||||
String s = (String)state.convertValue(34,TypeDescriptor.STRING);
|
||||
Assert.assertEquals("34",s);
|
||||
|
||||
s = (String)state.convertValue(new TypedValue(34),TypeDescriptor.valueOf(String.class));
|
||||
s = (String)state.convertValue(new TypedValue(34),TypeDescriptor.STRING);
|
||||
Assert.assertEquals("34",s);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class MapAccessTests extends ExpressionTestCase {
|
||||
}
|
||||
|
||||
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
return new TypedValue(((Map) target).get(name), TypeDescriptor.valueOf(Object.class));
|
||||
return new TypedValue(((Map) target).get(name), TypeDescriptor.OBJECT);
|
||||
}
|
||||
|
||||
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
|
||||
@@ -155,7 +155,7 @@ public class PropertyAccessTests extends ExpressionTestCase {
|
||||
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
if (!name.equals("flibbles"))
|
||||
throw new RuntimeException("Assertion Failed! name should be flibbles");
|
||||
return new TypedValue(flibbles, TypeDescriptor.valueOf(String.class));
|
||||
return new TypedValue(flibbles, TypeDescriptor.STRING);
|
||||
}
|
||||
|
||||
public void write(EvaluationContext context, Object target, String name, Object newValue)
|
||||
|
||||
@@ -219,7 +219,7 @@ public class SpringEL300Tests extends ExpressionTestCase {
|
||||
}
|
||||
|
||||
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
return new TypedValue(((Map) target).get(name), TypeDescriptor.valueOf(Object.class));
|
||||
return new TypedValue(((Map) target).get(name), TypeDescriptor.OBJECT);
|
||||
}
|
||||
|
||||
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
|
||||
Reference in New Issue
Block a user