change from SpelMessages to SpelMessage. Changed exception getter to getMessageCode() from getMessageUnformatted
This commit is contained in:
parent
b9b893f868
commit
69e48828cc
|
|
@ -167,7 +167,7 @@ public class ExpressionState {
|
|||
else {
|
||||
String leftType = (left==null?"null":left.getClass().getName());
|
||||
String rightType = (right==null?"null":right.getClass().getName());
|
||||
throw new SpelEvaluationException(SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES, op, leftType, rightType);
|
||||
throw new SpelEvaluationException(SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES, op, leftType, rightType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import org.springframework.expression.EvaluationException;
|
|||
|
||||
/**
|
||||
* Root exception for Spring EL related exceptions. Rather than holding a hard coded string indicating the problem, it
|
||||
* records a message key and the inserts for the message. See {@link SpelMessages} for the list of all possible messages
|
||||
* records a message key and the inserts for the message. See {@link SpelMessage} for the list of all possible messages
|
||||
* that can occur.
|
||||
*
|
||||
* @author Andy Clement
|
||||
|
|
@ -27,29 +27,29 @@ import org.springframework.expression.EvaluationException;
|
|||
*/
|
||||
public class SpelEvaluationException extends EvaluationException {
|
||||
|
||||
private SpelMessages message;
|
||||
private SpelMessage message;
|
||||
private Object[] inserts;
|
||||
|
||||
public SpelEvaluationException(SpelMessages message, Object... inserts) {
|
||||
public SpelEvaluationException(SpelMessage message, Object... inserts) {
|
||||
super(message.formatMessage(0, inserts)); // TODO poor position information, can the callers not really supply something?
|
||||
this.message = message;
|
||||
this.inserts = inserts;
|
||||
}
|
||||
|
||||
public SpelEvaluationException(int position, SpelMessages message, Object... inserts) {
|
||||
public SpelEvaluationException(int position, SpelMessage message, Object... inserts) {
|
||||
super(position, message.formatMessage(position, inserts));
|
||||
this.message = message;
|
||||
this.inserts = inserts;
|
||||
}
|
||||
|
||||
public SpelEvaluationException(int position, Throwable cause,
|
||||
SpelMessages message, Object... inserts) {
|
||||
SpelMessage message, Object... inserts) {
|
||||
super(position,message.formatMessage(position,inserts),cause);
|
||||
this.message = message;
|
||||
this.inserts = inserts;
|
||||
}
|
||||
|
||||
public SpelEvaluationException(Throwable cause, SpelMessages message, Object... inserts) {
|
||||
public SpelEvaluationException(Throwable cause, SpelMessage message, Object... inserts) {
|
||||
super(message.formatMessage(0,inserts),cause);
|
||||
this.message = message;
|
||||
this.inserts = inserts;
|
||||
|
|
@ -67,9 +67,9 @@ public class SpelEvaluationException extends EvaluationException {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the unformatted message
|
||||
* @return the message code
|
||||
*/
|
||||
public SpelMessages getMessageUnformatted() {
|
||||
public SpelMessage getMessageCode() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import java.text.MessageFormat;
|
|||
* @author Andy Clement
|
||||
* @since 3.0
|
||||
*/
|
||||
public enum SpelMessages {
|
||||
public enum SpelMessage {
|
||||
|
||||
TYPE_CONVERSION_ERROR(Kind.ERROR, 1001, "Type conversion problem, cannot convert from {0} to {1}"), //
|
||||
CONSTRUCTOR_NOT_FOUND(Kind.ERROR, 1002, "Constructor call: No suitable constructor found on type {0} for arguments {1}"), //
|
||||
|
|
@ -98,7 +98,7 @@ public enum SpelMessages {
|
|||
private String message;
|
||||
|
||||
|
||||
private SpelMessages(Kind kind, int code, String message) {
|
||||
private SpelMessage(Kind kind, int code, String message) {
|
||||
this.kind = kind;
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
|
|
@ -20,7 +20,7 @@ import org.springframework.expression.ParseException;
|
|||
|
||||
/**
|
||||
* Root exception for Spring EL related exceptions. Rather than holding a hard coded string indicating the problem, it
|
||||
* records a message key and the inserts for the message. See {@link SpelMessages} for the list of all possible messages
|
||||
* records a message key and the inserts for the message. See {@link SpelMessage} for the list of all possible messages
|
||||
* that can occur.
|
||||
*
|
||||
* @author Andy Clement
|
||||
|
|
@ -28,7 +28,7 @@ import org.springframework.expression.ParseException;
|
|||
*/
|
||||
public class SpelParseException extends ParseException {
|
||||
|
||||
private SpelMessages message;
|
||||
private SpelMessage message;
|
||||
private Object[] inserts;
|
||||
|
||||
// public SpelParseException(String expressionString, int position, Throwable cause, SpelMessages message, Object... inserts) {
|
||||
|
|
@ -37,21 +37,21 @@ public class SpelParseException extends ParseException {
|
|||
// this.inserts = inserts;
|
||||
// }
|
||||
|
||||
public SpelParseException(String expressionString, int position, SpelMessages message, Object... inserts) {
|
||||
public SpelParseException(String expressionString, int position, SpelMessage message, Object... inserts) {
|
||||
super(expressionString, position, message.formatMessage(position,inserts));
|
||||
this.position = position;
|
||||
this.message = message;
|
||||
this.inserts = inserts;
|
||||
}
|
||||
|
||||
public SpelParseException(int position, SpelMessages message, Object... inserts) {
|
||||
public SpelParseException(int position, SpelMessage message, Object... inserts) {
|
||||
super(position, message.formatMessage(position,inserts));
|
||||
this.position = position;
|
||||
this.message = message;
|
||||
this.inserts = inserts;
|
||||
}
|
||||
|
||||
public SpelParseException(int position, Throwable cause, SpelMessages message, Object... inserts) {
|
||||
public SpelParseException(int position, Throwable cause, SpelMessage message, Object... inserts) {
|
||||
super(position, message.formatMessage(position,inserts), cause);
|
||||
this.position = position;
|
||||
this.message = message;
|
||||
|
|
@ -91,9 +91,9 @@ public class SpelParseException extends ParseException {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the unformatted message
|
||||
* @return the message code
|
||||
*/
|
||||
public SpelMessages getMessageUnformatted() {
|
||||
public SpelMessage getMessageCode() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.springframework.expression.EvaluationException;
|
|||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
|
||||
// TODO asc array constructor call logic has been removed for now
|
||||
// TODO make this like the method referencing one
|
||||
|
|
@ -104,7 +104,7 @@ public class ConstructorReference extends SpelNodeImpl {
|
|||
TypedValue result = executorToUse.execute(state.getEvaluationContext(), arguments);
|
||||
return result;
|
||||
} catch (AccessException ae) {
|
||||
throw new SpelEvaluationException(getStartPosition(), ae, SpelMessages.CONSTRUCTOR_INVOCATION_PROBLEM, typename,
|
||||
throw new SpelEvaluationException(getStartPosition(), ae, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typename,
|
||||
FormatHelper.formatMethodForMessage("", argumentTypes));
|
||||
|
||||
}
|
||||
|
|
@ -133,12 +133,12 @@ public class ConstructorReference extends SpelNodeImpl {
|
|||
return cEx;
|
||||
}
|
||||
} catch (AccessException ex) {
|
||||
throw new SpelEvaluationException(getStartPosition(),ex, SpelMessages.CONSTRUCTOR_INVOCATION_PROBLEM, typename,
|
||||
throw new SpelEvaluationException(getStartPosition(),ex, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typename,
|
||||
FormatHelper.formatMethodForMessage("", argumentTypes));
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.CONSTRUCTOR_NOT_FOUND, typename, FormatHelper.formatMethodForMessage("",
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.CONSTRUCTOR_NOT_FOUND, typename, FormatHelper.formatMethodForMessage("",
|
||||
argumentTypes));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.springframework.expression.TypeConverter;
|
|||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.support.ReflectionHelper;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
|
|
@ -56,12 +56,12 @@ public class FunctionReference extends SpelNodeImpl {
|
|||
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
|
||||
TypedValue o = state.lookupVariable(name);
|
||||
if (o == null) {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessages.FUNCTION_NOT_DEFINED, name);
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.FUNCTION_NOT_DEFINED, name);
|
||||
}
|
||||
|
||||
// Two possibilities: a lambda function or a Java static method registered as a function
|
||||
if (!(o.getValue() instanceof Method)) {
|
||||
throw new SpelEvaluationException(SpelMessages.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, name, o.getClass());
|
||||
throw new SpelEvaluationException(SpelMessage.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, name, o.getClass());
|
||||
}
|
||||
try {
|
||||
return executeFunctionJLRMethod(state, (Method) o.getValue());
|
||||
|
|
@ -83,12 +83,12 @@ public class FunctionReference extends SpelNodeImpl {
|
|||
Object[] functionArgs = getArguments(state);
|
||||
|
||||
if (!m.isVarArgs() && m.getParameterTypes().length != functionArgs.length) {
|
||||
throw new SpelEvaluationException(SpelMessages.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION, functionArgs.length, m
|
||||
throw new SpelEvaluationException(SpelMessage.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION, functionArgs.length, m
|
||||
.getParameterTypes().length);
|
||||
}
|
||||
// Only static methods can be called in this way
|
||||
if (!Modifier.isStatic(m.getModifiers())) {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessages.FUNCTION_MUST_BE_STATIC, m
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.FUNCTION_MUST_BE_STATIC, m
|
||||
.getDeclaringClass().getName()
|
||||
+ "." + m.getName(), name);
|
||||
}
|
||||
|
|
@ -107,13 +107,13 @@ public class FunctionReference extends SpelNodeImpl {
|
|||
Object result = m.invoke(m.getClass(), functionArgs);
|
||||
return new TypedValue(result, new TypeDescriptor(new MethodParameter(m,-1)));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.EXCEPTION_DURING_FUNCTION_CALL, name, e
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessage.EXCEPTION_DURING_FUNCTION_CALL, name, e
|
||||
.getMessage());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.EXCEPTION_DURING_FUNCTION_CALL, name, e
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessage.EXCEPTION_DURING_FUNCTION_CALL, name, e
|
||||
.getMessage());
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.EXCEPTION_DURING_FUNCTION_CALL, name, e
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessage.EXCEPTION_DURING_FUNCTION_CALL, name, e
|
||||
.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import org.springframework.expression.EvaluationException;
|
|||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
|
||||
// TODO support multidimensional arrays
|
||||
// TODO support correct syntax for multidimensional [][][] and not [,,,]
|
||||
|
|
@ -61,7 +61,7 @@ public class Indexer extends SpelNodeImpl {
|
|||
int idx = (Integer)state.convertValue(index, INTEGER_TYPE_DESCRIPTOR);
|
||||
|
||||
if (targetObject == null) {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.CANNOT_INDEX_INTO_NULL_VALUE);
|
||||
}
|
||||
|
||||
if (targetObject.getClass().isArray()) {
|
||||
|
|
@ -76,7 +76,7 @@ public class Indexer extends SpelNodeImpl {
|
|||
int newElements = idx-c.size();
|
||||
Class elementClass = targetObjectTypeDescriptor.getElementType();
|
||||
if (elementClass == null) {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessages.UNABLE_TO_GROW_COLLECTION_UNKNOWN_ELEMENT_TYPE);
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.UNABLE_TO_GROW_COLLECTION_UNKNOWN_ELEMENT_TYPE);
|
||||
}
|
||||
while (newElements>0) {
|
||||
c.add(elementClass.newInstance());
|
||||
|
|
@ -84,14 +84,14 @@ public class Indexer extends SpelNodeImpl {
|
|||
}
|
||||
newCollectionElement = targetObjectTypeDescriptor.getElementType().newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.UNABLE_TO_GROW_COLLECTION);
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessage.UNABLE_TO_GROW_COLLECTION);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.UNABLE_TO_GROW_COLLECTION);
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessage.UNABLE_TO_GROW_COLLECTION);
|
||||
}
|
||||
c.add(newCollectionElement);
|
||||
return new TypedValue(newCollectionElement,TypeDescriptor.valueOf(targetObjectTypeDescriptor.getElementType()));
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.COLLECTION_INDEX_OUT_OF_BOUNDS, c.size(), idx);
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.COLLECTION_INDEX_OUT_OF_BOUNDS, c.size(), idx);
|
||||
}
|
||||
}
|
||||
int pos = 0;
|
||||
|
|
@ -104,11 +104,11 @@ public class Indexer extends SpelNodeImpl {
|
|||
} else if (targetObject instanceof String) {
|
||||
String ctxString = (String) targetObject;
|
||||
if (idx >= ctxString.length()) {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.STRING_INDEX_OUT_OF_BOUNDS, ctxString.length(), idx);
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.STRING_INDEX_OUT_OF_BOUNDS, ctxString.length(), idx);
|
||||
}
|
||||
return new TypedValue(String.valueOf(ctxString.charAt(idx)),STRING_TYPE_DESCRIPTOR);
|
||||
}
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.INDEXING_NOT_SUPPORTED_FOR_TYPE, targetObjectTypeDescriptor.asString());
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE, targetObjectTypeDescriptor.asString());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ public class Indexer extends SpelNodeImpl {
|
|||
TypedValue index = children[0].getValueInternal(state);
|
||||
|
||||
if (targetObject == null) {
|
||||
throw new SpelEvaluationException(SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
|
||||
throw new SpelEvaluationException(SpelMessage.CANNOT_INDEX_INTO_NULL_VALUE);
|
||||
}
|
||||
// Indexing into a Map
|
||||
if (targetObjectTypeDescriptor.isMap()) {
|
||||
|
|
@ -144,17 +144,17 @@ public class Indexer extends SpelNodeImpl {
|
|||
int idx = (Integer)state.convertValue(index, INTEGER_TYPE_DESCRIPTOR);
|
||||
Collection c = (Collection) targetObject;
|
||||
if (idx >= c.size()) {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.COLLECTION_INDEX_OUT_OF_BOUNDS, c.size(), idx);
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.COLLECTION_INDEX_OUT_OF_BOUNDS, c.size(), idx);
|
||||
}
|
||||
if (targetObject instanceof List) {
|
||||
List list = (List)targetObject;
|
||||
Object possiblyConvertedValue = state.convertValue(newValue,TypeDescriptor.valueOf(targetObjectTypeDescriptor.getElementType()));
|
||||
list.set(idx,possiblyConvertedValue);
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.INDEXING_NOT_SUPPORTED_FOR_TYPE, contextObject.getClass().getName());
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE, contextObject.getClass().getName());
|
||||
}
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.INDEXING_NOT_SUPPORTED_FOR_TYPE, contextObject.getClass().getName());
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE, contextObject.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ public class Indexer extends SpelNodeImpl {
|
|||
|
||||
private void checkAccess(int arrayLength, int index) throws SpelEvaluationException {
|
||||
if (index > arrayLength) {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessages.ARRAY_INDEX_OUT_OF_BOUNDS, arrayLength, index);
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.ARRAY_INDEX_OUT_OF_BOUNDS, arrayLength, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.expression.spel.ast;
|
|||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.SpelParseException;
|
||||
import org.springframework.expression.spel.standard.InternalParseException;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public abstract class Literal extends SpelNodeImpl {
|
|||
int value = Integer.parseInt(numberToken, radix);
|
||||
return new IntLiteral(numberToken, pos, value);
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw new InternalParseException(new SpelParseException(pos>>16, nfe, SpelMessages.NOT_AN_INTEGER, numberToken));
|
||||
throw new InternalParseException(new SpelParseException(pos>>16, nfe, SpelMessage.NOT_AN_INTEGER, numberToken));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ public abstract class Literal extends SpelNodeImpl {
|
|||
long value = Long.parseLong(numberToken, radix);
|
||||
return new LongLiteral(numberToken, pos, value);
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw new InternalParseException(new SpelParseException(pos>>16, nfe, SpelMessages.NOT_A_LONG, numberToken));
|
||||
throw new InternalParseException(new SpelParseException(pos>>16, nfe, SpelMessage.NOT_A_LONG, numberToken));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ public abstract class Literal extends SpelNodeImpl {
|
|||
return new RealLiteral(numberToken, pos, value);
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw new InternalParseException(new SpelParseException(pos>>16, nfe, SpelMessages.NOT_A_REAL, numberToken));
|
||||
throw new InternalParseException(new SpelParseException(pos>>16, nfe, SpelMessage.NOT_A_REAL, numberToken));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.springframework.expression.MethodResolver;
|
|||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
|
||||
/**
|
||||
* @author Andy Clement
|
||||
|
|
@ -59,7 +59,7 @@ public class MethodReference extends SpelNodeImpl {
|
|||
if (nullSafe) {
|
||||
return TypedValue.NULL_TYPED_VALUE;
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessages.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED,
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED,
|
||||
FormatHelper.formatMethodForMessage(name, getTypes(arguments)));
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ public class MethodReference extends SpelNodeImpl {
|
|||
return executorToUse.execute(
|
||||
state.getEvaluationContext(), state.getActiveContextObject().getValue(), arguments);
|
||||
} catch (AccessException ae) {
|
||||
throw new SpelEvaluationException( getStartPosition(), ae, SpelMessages.EXCEPTION_DURING_METHOD_INVOCATION,
|
||||
throw new SpelEvaluationException( getStartPosition(), ae, SpelMessage.EXCEPTION_DURING_METHOD_INVOCATION,
|
||||
this.name, state.getActiveContextObject().getValue().getClass().getName(), ae.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -128,11 +128,11 @@ public class MethodReference extends SpelNodeImpl {
|
|||
}
|
||||
}
|
||||
catch (AccessException ex) {
|
||||
throw new SpelEvaluationException(getStartPosition(),ex, SpelMessages.PROBLEM_LOCATING_METHOD, name, contextObject.getClass());
|
||||
throw new SpelEvaluationException(getStartPosition(),ex, SpelMessage.PROBLEM_LOCATING_METHOD, name, contextObject.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.METHOD_NOT_FOUND, FormatHelper.formatMethodForMessage(name, argumentTypes),
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.METHOD_NOT_FOUND, FormatHelper.formatMethodForMessage(name, argumentTypes),
|
||||
FormatHelper.formatClassNameForMessage(contextObject instanceof Class ? ((Class<?>) contextObject) : contextObject.getClass()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.springframework.expression.EvaluationException;
|
|||
import org.springframework.expression.TypeComparator;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.support.BooleanTypedValue;
|
||||
|
||||
/**
|
||||
|
|
@ -52,7 +52,7 @@ public class OperatorBetween extends Operator {
|
|||
Object right = getRightOperand().getValueInternal(state).getValue();
|
||||
if (!(right instanceof List) || ((List<?>) right).size() != 2) {
|
||||
throw new SpelEvaluationException(getRightOperand().getStartPosition(),
|
||||
SpelMessages.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST);
|
||||
SpelMessage.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST);
|
||||
}
|
||||
List<?> l = (List<?>) right;
|
||||
Object low = l.get(0);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.springframework.expression.EvaluationException;
|
|||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.support.BooleanTypedValue;
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +54,7 @@ public class OperatorInstanceof extends Operator {
|
|||
}
|
||||
if (rightValue == null || !(rightValue instanceof Class<?>)) {
|
||||
throw new SpelEvaluationException(getRightOperand().getStartPosition(),
|
||||
SpelMessages.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND,
|
||||
SpelMessage.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND,
|
||||
(rightValue == null ? "null" : rightValue.getClass().getName()));
|
||||
}
|
||||
Class<?> rightClass = (Class<?>) rightValue;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.regex.PatternSyntaxException;
|
|||
import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.support.BooleanTypedValue;
|
||||
|
||||
/**
|
||||
|
|
@ -54,18 +54,18 @@ public class OperatorMatches extends Operator {
|
|||
try {
|
||||
if (!(left instanceof String)) {
|
||||
throw new SpelEvaluationException(leftOp.getStartPosition(),
|
||||
SpelMessages.INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR, left);
|
||||
SpelMessage.INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR, left);
|
||||
}
|
||||
if (!(right instanceof String)) {
|
||||
throw new SpelEvaluationException(rightOp.getStartPosition(),
|
||||
SpelMessages.INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR, right);
|
||||
SpelMessage.INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR, right);
|
||||
}
|
||||
Pattern pattern = Pattern.compile((String) right);
|
||||
Matcher matcher = pattern.matcher((String) left);
|
||||
return BooleanTypedValue.forValue(matcher.matches());
|
||||
}
|
||||
catch (PatternSyntaxException pse) {
|
||||
throw new SpelEvaluationException(rightOp.getStartPosition(), pse, SpelMessages.INVALID_PATTERN, right);
|
||||
throw new SpelEvaluationException(rightOp.getStartPosition(), pse, SpelMessage.INVALID_PATTERN, right);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.springframework.expression.EvaluationException;
|
|||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
|
||||
/**
|
||||
* Represents projection, where a given operation is performed on all elements in some input sequence, returning
|
||||
|
|
@ -92,10 +92,10 @@ public class Projection extends SpelNodeImpl {
|
|||
if (nullSafe) {
|
||||
return TypedValue.NULL_TYPED_VALUE;
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.PROJECTION_NOT_SUPPORTED_ON_TYPE, "null");
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.PROJECTION_NOT_SUPPORTED_ON_TYPE, "null");
|
||||
}
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.PROJECTION_NOT_SUPPORTED_ON_TYPE, operand.getClass().getName());
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.PROJECTION_NOT_SUPPORTED_ON_TYPE, operand.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.springframework.expression.PropertyAccessor;
|
|||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
|
||||
/**
|
||||
* Represents a simple property or field reference.
|
||||
|
|
@ -63,9 +63,9 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
|
|||
result = readProperty(state, this.name);
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
|
||||
throw new SpelEvaluationException(getStartPosition(), e, SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -129,13 +129,13 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
|
|||
}
|
||||
}
|
||||
catch (AccessException ae) {
|
||||
throw new SpelEvaluationException(ae, SpelMessages.EXCEPTION_DURING_PROPERTY_READ, name, ae.getMessage());
|
||||
throw new SpelEvaluationException(ae, SpelMessage.EXCEPTION_DURING_PROPERTY_READ, name, ae.getMessage());
|
||||
}
|
||||
}
|
||||
if (contextObject.getValue() == null) {
|
||||
throw new SpelEvaluationException(SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL, name);
|
||||
throw new SpelEvaluationException(SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL, name);
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE, name,
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE, name,
|
||||
FormatHelper.formatClassNameForMessage(contextObjectClass));
|
||||
}
|
||||
}
|
||||
|
|
@ -174,14 +174,14 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
|
|||
}
|
||||
}
|
||||
} catch (AccessException ae) {
|
||||
throw new SpelEvaluationException(getStartPosition(), ae, SpelMessages.EXCEPTION_DURING_PROPERTY_WRITE,
|
||||
throw new SpelEvaluationException(getStartPosition(), ae, SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE,
|
||||
name, ae.getMessage());
|
||||
}
|
||||
}
|
||||
if (contextObject.getValue()==null) {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL, name);
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL, name);
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE, name, FormatHelper
|
||||
throw new SpelEvaluationException(getStartPosition(),SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE, name, FormatHelper
|
||||
.formatClassNameForMessage(contextObjectClass));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.springframework.expression.EvaluationException;
|
|||
import org.springframework.expression.TypedValue;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
|
||||
/**
|
||||
* Represents selection over a map or collection. For example: {1,2,3,4,5,6,7,8,9,10}.?{#isEven(#this) == 'y'} returns
|
||||
|
|
@ -81,7 +81,7 @@ public class Selection extends SpelNodeImpl {
|
|||
}
|
||||
} else {
|
||||
throw new SpelEvaluationException(selectionCriteria.getStartPosition(),
|
||||
SpelMessages.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);// ,selectionCriteria.stringifyAST());
|
||||
SpelMessage.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);// ,selectionCriteria.stringifyAST());
|
||||
}
|
||||
} finally {
|
||||
state.popActiveContextObject();
|
||||
|
|
@ -116,7 +116,7 @@ public class Selection extends SpelNodeImpl {
|
|||
}
|
||||
} else {
|
||||
throw new SpelEvaluationException(selectionCriteria.getStartPosition(),
|
||||
SpelMessages.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);// ,selectionCriteria.stringifyAST());
|
||||
SpelMessage.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);// ,selectionCriteria.stringifyAST());
|
||||
}
|
||||
idx++;
|
||||
} finally {
|
||||
|
|
@ -136,11 +136,11 @@ public class Selection extends SpelNodeImpl {
|
|||
if (nullSafe) {
|
||||
return TypedValue.NULL_TYPED_VALUE;
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessages.INVALID_TYPE_FOR_SELECTION,
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.INVALID_TYPE_FOR_SELECTION,
|
||||
"null");
|
||||
}
|
||||
} else {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessages.INVALID_TYPE_FOR_SELECTION,
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.INVALID_TYPE_FOR_SELECTION,
|
||||
operand.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.springframework.expression.TypedValue;
|
|||
import org.springframework.expression.common.ExpressionUtils;
|
||||
import org.springframework.expression.spel.ExpressionState;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.SpelNode;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ public abstract class SpelNodeImpl implements SpelNode, CommonTypeDescriptors {
|
|||
}
|
||||
|
||||
public void setValue(ExpressionState expressionState, Object newValue) throws EvaluationException {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessages.SETVALUE_NOT_SUPPORTED, getClass());
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.SETVALUE_NOT_SUPPORTED, getClass());
|
||||
}
|
||||
|
||||
public SpelNode getChild(int index) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.springframework.expression.ParseException;
|
|||
import org.springframework.expression.ParserContext;
|
||||
import org.springframework.expression.common.TemplateAwareExpressionParser;
|
||||
import org.springframework.expression.spel.SpelExpression;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.SpelParseException;
|
||||
import org.springframework.expression.spel.ast.Assign;
|
||||
import org.springframework.expression.spel.ast.BooleanLiteral;
|
||||
|
|
@ -117,7 +117,7 @@ public class SpelExpressionParser extends TemplateAwareExpressionParser {
|
|||
constructedNodes.clear();
|
||||
SpelNodeImpl ast = eatExpression();
|
||||
if (moreTokens()) {
|
||||
throw new SpelParseException(peekToken().startpos,SpelMessages.MORE_INPUT,toString(nextToken()));
|
||||
throw new SpelParseException(peekToken().startpos,SpelMessage.MORE_INPUT,toString(nextToken()));
|
||||
}
|
||||
assert constructedNodes.isEmpty();
|
||||
return new SpelExpression(expressionString, ast, configuration);
|
||||
|
|
@ -339,7 +339,7 @@ public class SpelExpressionParser extends TemplateAwareExpressionParser {
|
|||
if (maybeEatMethodOrProperty(nullSafeNavigation) || maybeEatFunctionOrVar() || maybeEatProjection(nullSafeNavigation) || maybeEatSelection(nullSafeNavigation)) {
|
||||
return pop();
|
||||
}
|
||||
raiseInternalException(t.startpos,SpelMessages.UNEXPECTED_DATA_AFTER_DOT,toString(peekToken()));
|
||||
raiseInternalException(t.startpos,SpelMessage.UNEXPECTED_DATA_AFTER_DOT,toString(peekToken()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -378,7 +378,7 @@ public class SpelExpressionParser extends TemplateAwareExpressionParser {
|
|||
|
||||
private void eatConstructorArgs(List<SpelNodeImpl> accumulatedArguments) {
|
||||
if (!peekToken(TokenKind.LPAREN)) {
|
||||
throw new InternalParseException(new SpelParseException(expressionString,positionOf(peekToken()),SpelMessages.MISSING_CONSTRUCTOR_ARGS));
|
||||
throw new InternalParseException(new SpelParseException(expressionString,positionOf(peekToken()),SpelMessage.MISSING_CONSTRUCTOR_ARGS));
|
||||
}
|
||||
consumeArguments(accumulatedArguments);
|
||||
eatToken(TokenKind.RPAREN);
|
||||
|
|
@ -394,7 +394,7 @@ public class SpelExpressionParser extends TemplateAwareExpressionParser {
|
|||
nextToken();// consume ( (first time through) or comma (subsequent times)
|
||||
Token t = peekToken();
|
||||
if (t==null) {
|
||||
raiseInternalException(pos,SpelMessages.RUN_OUT_OF_ARGUMENTS);
|
||||
raiseInternalException(pos,SpelMessage.RUN_OUT_OF_ARGUMENTS);
|
||||
}
|
||||
if (t.kind!=TokenKind.RPAREN) {
|
||||
accumulatedArguments.add(eatExpression());
|
||||
|
|
@ -402,7 +402,7 @@ public class SpelExpressionParser extends TemplateAwareExpressionParser {
|
|||
next = peekToken();
|
||||
} while (next!=null && next.kind==TokenKind.COMMA);
|
||||
if (next==null) {
|
||||
raiseInternalException(pos,SpelMessages.RUN_OUT_OF_ARGUMENTS);
|
||||
raiseInternalException(pos,SpelMessage.RUN_OUT_OF_ARGUMENTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -647,10 +647,10 @@ public class SpelExpressionParser extends TemplateAwareExpressionParser {
|
|||
assert moreTokens();
|
||||
Token t = nextToken();
|
||||
if (t==null) {
|
||||
raiseInternalException( expressionString.length(), SpelMessages.OOD);
|
||||
raiseInternalException( expressionString.length(), SpelMessage.OOD);
|
||||
}
|
||||
if (t.kind!=expectedKind) {
|
||||
raiseInternalException(t.startpos,SpelMessages.NOT_EXPECTED_TOKEN, expectedKind.toString().toLowerCase(),t.getKind().toString().toLowerCase());
|
||||
raiseInternalException(t.startpos,SpelMessage.NOT_EXPECTED_TOKEN, expectedKind.toString().toLowerCase(),t.getKind().toString().toLowerCase());
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
|
@ -719,7 +719,7 @@ public class SpelExpressionParser extends TemplateAwareExpressionParser {
|
|||
return tokenStream.get(tokenStreamPointer);
|
||||
}
|
||||
|
||||
private void raiseInternalException(int pos, SpelMessages message,Object... inserts) {
|
||||
private void raiseInternalException(int pos, SpelMessage message,Object... inserts) {
|
||||
throw new InternalParseException(new SpelParseException(expressionString,pos,message,inserts));
|
||||
}
|
||||
|
||||
|
|
@ -733,7 +733,7 @@ public class SpelExpressionParser extends TemplateAwareExpressionParser {
|
|||
|
||||
private void checkRightOperand(Token token, SpelNodeImpl operandExpression) {
|
||||
if (operandExpression==null) {
|
||||
raiseInternalException(token.startpos,SpelMessages.RIGHT_OPERAND_PROBLEM);
|
||||
raiseInternalException(token.startpos,SpelMessage.RIGHT_OPERAND_PROBLEM);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.SpelParseException;
|
||||
|
||||
/**
|
||||
|
|
@ -201,7 +201,7 @@ public class Tokenizer {
|
|||
}
|
||||
}
|
||||
if (ch==0) {
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessages.NON_TERMINATING_QUOTED_STRING));
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessage.NON_TERMINATING_QUOTED_STRING));
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
|
|
@ -219,7 +219,7 @@ public class Tokenizer {
|
|||
terminated = true;
|
||||
}
|
||||
if (ch==0) {
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessages.NON_TERMINATING_DOUBLE_QUOTED_STRING));
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessage.NON_TERMINATING_DOUBLE_QUOTED_STRING));
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
|
|
@ -286,7 +286,7 @@ public class Tokenizer {
|
|||
// is it a long ?
|
||||
if (isChar('L','l')) {
|
||||
if (isReal) { // 3.4L - not allowed
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessages.REAL_CANNOT_BE_LONG));
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessage.REAL_CANNOT_BE_LONG));
|
||||
}
|
||||
pushIntToken(subarray(start, endOfNumber), true, start, endOfNumber);
|
||||
pos++;
|
||||
|
|
@ -349,9 +349,9 @@ public class Tokenizer {
|
|||
private void pushHexIntToken(char[] data,boolean isLong, int start, int end) {
|
||||
if (data.length==0) {
|
||||
if (isLong) {
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessages.NOT_A_LONG,expressionString.substring(start,end+1)));
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessage.NOT_A_LONG,expressionString.substring(start,end+1)));
|
||||
} else {
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessages.NOT_AN_INTEGER,expressionString.substring(start,end)));
|
||||
throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessage.NOT_AN_INTEGER,expressionString.substring(start,end)));
|
||||
}
|
||||
}
|
||||
if (isLong) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.TypeConverter;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ public class ReflectionHelper {
|
|||
try {
|
||||
if (arguments[i] != null && arguments[i].getClass() != targetType) {
|
||||
if (converter == null) {
|
||||
throw new SpelEvaluationException(SpelMessages.TYPE_CONVERSION_ERROR, arguments[i].getClass().getName(),targetType);
|
||||
throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, arguments[i].getClass().getName(),targetType);
|
||||
}
|
||||
arguments[i] = converter.convertValue(arguments[i], targetType);
|
||||
}
|
||||
|
|
@ -257,7 +257,7 @@ public class ReflectionHelper {
|
|||
if (ex instanceof SpelEvaluationException) {
|
||||
throw (SpelEvaluationException)ex;
|
||||
} else {
|
||||
throw new SpelEvaluationException(ex, SpelMessages.TYPE_CONVERSION_ERROR,arguments[i].getClass().getName(),targetType);
|
||||
throw new SpelEvaluationException(ex, SpelMessage.TYPE_CONVERSION_ERROR,arguments[i].getClass().getName(),targetType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import org.springframework.expression.MethodExecutor;
|
|||
import org.springframework.expression.MethodResolver;
|
||||
import org.springframework.expression.TypeConverter;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
|
||||
/**
|
||||
* A method resolver that uses reflection to locate the method that should be invoked
|
||||
|
|
@ -88,7 +88,7 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
|||
}
|
||||
else if (matchRequiringConversion != null) {
|
||||
if (multipleOptions) {
|
||||
throw new SpelEvaluationException(SpelMessages.MULTIPLE_POSSIBLE_METHODS, name);
|
||||
throw new SpelEvaluationException(SpelMessage.MULTIPLE_POSSIBLE_METHODS, name);
|
||||
}
|
||||
return new ReflectiveMethodExecutor(matchRequiringConversion, argsToConvert);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.springframework.expression.spel.support;
|
|||
|
||||
import org.springframework.expression.TypeComparator;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
|
||||
/**
|
||||
* A simple basic TypeComparator implementation. It supports comparison of numbers and types implementing Comparable.
|
||||
|
|
@ -65,7 +65,7 @@ public class StandardTypeComparator implements TypeComparator {
|
|||
return ((Comparable) left).compareTo(right);
|
||||
}
|
||||
|
||||
throw new SpelEvaluationException(SpelMessages.NOT_COMPARABLE, left.getClass(), right.getClass());
|
||||
throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass());
|
||||
}
|
||||
|
||||
public boolean canCompare(Object left, Object right) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.springframework.core.convert.support.DefaultTypeConverter;
|
|||
import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.TypeConverter;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
|
@ -55,10 +55,10 @@ public class StandardTypeConverter implements TypeConverter {
|
|||
return this.typeConverter.convert(value, typeDescriptor);
|
||||
}
|
||||
catch (ConverterNotFoundException cenfe) {
|
||||
throw new SpelEvaluationException(cenfe, SpelMessages.TYPE_CONVERSION_ERROR, value.getClass(), typeDescriptor.asString());
|
||||
throw new SpelEvaluationException(cenfe, SpelMessage.TYPE_CONVERSION_ERROR, value.getClass(), typeDescriptor.asString());
|
||||
}
|
||||
catch (ConvertException ce) {
|
||||
throw new SpelEvaluationException(ce, SpelMessages.TYPE_CONVERSION_ERROR, value.getClass(), typeDescriptor.asString());
|
||||
throw new SpelEvaluationException(ce, SpelMessage.TYPE_CONVERSION_ERROR, value.getClass(), typeDescriptor.asString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.TypeLocator;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -76,7 +76,7 @@ public class StandardTypeLocator implements TypeLocator {
|
|||
// might be a different prefix
|
||||
}
|
||||
}
|
||||
throw new SpelEvaluationException(SpelMessages.TYPE_NOT_FOUND, typename);
|
||||
throw new SpelEvaluationException(SpelMessage.TYPE_NOT_FOUND, typename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -73,11 +73,11 @@ public class BooleanExpressionTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testBooleanErrors01() {
|
||||
evaluateAndCheckError("1.0 or false", SpelMessages.TYPE_CONVERSION_ERROR, 0);
|
||||
evaluateAndCheckError("false or 39.4", SpelMessages.TYPE_CONVERSION_ERROR, 9);
|
||||
evaluateAndCheckError("true and 'hello'", SpelMessages.TYPE_CONVERSION_ERROR, 9);
|
||||
evaluateAndCheckError(" 'hello' and 'goodbye'", SpelMessages.TYPE_CONVERSION_ERROR, 1);
|
||||
evaluateAndCheckError("!35.2", SpelMessages.TYPE_CONVERSION_ERROR, 1);
|
||||
evaluateAndCheckError("! 'foob'", SpelMessages.TYPE_CONVERSION_ERROR, 2);
|
||||
evaluateAndCheckError("1.0 or false", SpelMessage.TYPE_CONVERSION_ERROR, 0);
|
||||
evaluateAndCheckError("false or 39.4", SpelMessage.TYPE_CONVERSION_ERROR, 9);
|
||||
evaluateAndCheckError("true and 'hello'", SpelMessage.TYPE_CONVERSION_ERROR, 9);
|
||||
evaluateAndCheckError(" 'hello' and 'goodbye'", SpelMessage.TYPE_CONVERSION_ERROR, 1);
|
||||
evaluateAndCheckError("!35.2", SpelMessage.TYPE_CONVERSION_ERROR, 1);
|
||||
evaluateAndCheckError("! 'foob'", SpelMessage.TYPE_CONVERSION_ERROR, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testNonExistentType() {
|
||||
evaluateAndCheckError("new FooBar()",SpelMessages.CONSTRUCTOR_INVOCATION_PROBLEM);
|
||||
evaluateAndCheckError("new FooBar()",SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class EvaluationTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testRelOperatorsInstanceof06() {
|
||||
evaluateAndCheckError("'A' instanceof null", SpelMessages.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND, 15, "null");
|
||||
evaluateAndCheckError("'A' instanceof null", SpelMessage.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND, 15, "null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -138,12 +138,12 @@ public class EvaluationTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testRelOperatorsMatches03() {
|
||||
evaluateAndCheckError("null matches '^.*$'", SpelMessages.INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR, 0, null);
|
||||
evaluateAndCheckError("null matches '^.*$'", SpelMessage.INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR, 0, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelOperatorsMatches04() {
|
||||
evaluateAndCheckError("'abc' matches null", SpelMessages.INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR, 14, null);
|
||||
evaluateAndCheckError("'abc' matches null", SpelMessage.INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR, 14, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -162,7 +162,7 @@ public class EvaluationTests extends ExpressionTestCase {
|
|||
public void testPropertyField01() {
|
||||
evaluate("name", "Nikola Tesla", String.class, false);
|
||||
// not writable because (1) name is private (2) there is no setter, only a getter
|
||||
evaluateAndCheckError("madeup", SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE, 0, "madeup",
|
||||
evaluateAndCheckError("madeup", SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE, 0, "madeup",
|
||||
"org.springframework.expression.spel.testresources.Inventor");
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ public class EvaluationTests extends ExpressionTestCase {
|
|||
new SpelExpressionParser().parse("placeOfBirth.23");
|
||||
Assert.fail();
|
||||
} catch (SpelParseException spe) {
|
||||
Assert.assertEquals(spe.getMessageUnformatted(), SpelMessages.UNEXPECTED_DATA_AFTER_DOT);
|
||||
Assert.assertEquals(spe.getMessageCode(), SpelMessage.UNEXPECTED_DATA_AFTER_DOT);
|
||||
Assert.assertEquals("23", spe.getInserts()[0]);
|
||||
}
|
||||
}
|
||||
|
|
@ -261,7 +261,7 @@ public class EvaluationTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testTernaryOperator03() {
|
||||
evaluateAndCheckError("'hello'?1:2", SpelMessages.TYPE_CONVERSION_ERROR); // cannot convert String to boolean
|
||||
evaluateAndCheckError("'hello'?1:2", SpelMessage.TYPE_CONVERSION_ERROR); // cannot convert String to boolean
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -285,7 +285,7 @@ public class EvaluationTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testIndexerError() {
|
||||
evaluateAndCheckError("new org.springframework.expression.spel.testresources.Inventor().inventions[1]",SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
|
||||
evaluateAndCheckError("new org.springframework.expression.spel.testresources.Inventor().inventions[1]",SpelMessage.CANNOT_INDEX_INTO_NULL_VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
|
|||
expr.setValue(ctx, Color.blue);
|
||||
Assert.fail("Should not be allowed to set oranges to be blue !");
|
||||
} catch (SpelEvaluationException ee) {
|
||||
Assert.assertEquals(ee.getMessageUnformatted(), SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
Assert.assertEquals(ee.getMessageCode(), SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
|
|||
Assert.fail("Should not be allowed to set peas to be blue !");
|
||||
}
|
||||
catch (SpelEvaluationException ee) {
|
||||
Assert.assertEquals(ee.getMessageUnformatted(), SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
Assert.assertEquals(ee.getMessageCode(), SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ public class ExpressionStateTests extends ExpressionTestCase {
|
|||
Assert.fail("should have failed");
|
||||
} catch (EvaluationException ee) {
|
||||
SpelEvaluationException sEx = (SpelEvaluationException)ee;
|
||||
Assert.assertEquals(SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageCode());
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -211,7 +211,7 @@ public class ExpressionStateTests extends ExpressionTestCase {
|
|||
Assert.fail("should have failed");
|
||||
} catch (EvaluationException ee) {
|
||||
SpelEvaluationException sEx = (SpelEvaluationException)ee;
|
||||
Assert.assertEquals(SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ public class ExpressionStateTests extends ExpressionTestCase {
|
|||
Assert.fail("Should have failed to find it");
|
||||
} catch (EvaluationException ee) {
|
||||
SpelEvaluationException sEx = (SpelEvaluationException)ee;
|
||||
Assert.assertEquals(SpelMessages.TYPE_NOT_FOUND,sEx.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.TYPE_NOT_FOUND,sEx.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ public abstract class ExpressionTestCase {
|
|||
* @param expectedMessage The expected message
|
||||
* @param otherProperties The expected inserts within the message
|
||||
*/
|
||||
protected void evaluateAndCheckError(String expression, SpelMessages expectedMessage, Object... otherProperties) {
|
||||
protected void evaluateAndCheckError(String expression, SpelMessage expectedMessage, Object... otherProperties) {
|
||||
evaluateAndCheckError(expression, null, expectedMessage, otherProperties);
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ public abstract class ExpressionTestCase {
|
|||
* @param expectedMessage The expected message
|
||||
* @param otherProperties The expected inserts within the message
|
||||
*/
|
||||
protected void evaluateAndCheckError(String expression, Class<?> expectedReturnType, SpelMessages expectedMessage,
|
||||
protected void evaluateAndCheckError(String expression, Class<?> expectedReturnType, SpelMessage expectedMessage,
|
||||
Object... otherProperties) {
|
||||
try {
|
||||
Expression expr = parser.parseExpression(expression);
|
||||
|
|
@ -233,10 +233,10 @@ public abstract class ExpressionTestCase {
|
|||
Assert.fail("Should have failed with message " + expectedMessage);
|
||||
} catch (EvaluationException ee) {
|
||||
SpelEvaluationException ex = (SpelEvaluationException) ee;
|
||||
if (ex.getMessageUnformatted() != expectedMessage) {
|
||||
if (ex.getMessageCode() != expectedMessage) {
|
||||
// System.out.println(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
Assert.assertEquals("Failed to get expected message", expectedMessage, ex.getMessageUnformatted());
|
||||
Assert.assertEquals("Failed to get expected message", expectedMessage, ex.getMessageCode());
|
||||
}
|
||||
if (otherProperties != null && otherProperties.length != 0) {
|
||||
// first one is expected position of the error within the string
|
||||
|
|
@ -288,7 +288,7 @@ public abstract class ExpressionTestCase {
|
|||
* @param expectedMessage The expected message
|
||||
* @param otherProperties The expected inserts within the message
|
||||
*/
|
||||
protected void parseAndCheckError(String expression, SpelMessages expectedMessage, Object... otherProperties) {
|
||||
protected void parseAndCheckError(String expression, SpelMessage expectedMessage, Object... otherProperties) {
|
||||
try {
|
||||
Expression expr = parser.parseExpression(expression);
|
||||
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
|
||||
|
|
@ -306,10 +306,10 @@ public abstract class ExpressionTestCase {
|
|||
// SpelEvaluationException ex = (SpelEvaluationException) t;
|
||||
// pe.printStackTrace();
|
||||
SpelParseException ex = (SpelParseException)pe;
|
||||
if (ex.getMessageUnformatted() != expectedMessage) {
|
||||
if (ex.getMessageCode() != expectedMessage) {
|
||||
// System.out.println(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
Assert.assertEquals("Failed to get expected message", expectedMessage, ex.getMessageUnformatted());
|
||||
Assert.assertEquals("Failed to get expected message", expectedMessage, ex.getMessageCode());
|
||||
}
|
||||
if (otherProperties != null && otherProperties.length != 0) {
|
||||
// first one is expected position of the error within the string
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ public class HelperTests extends ExpressionTestCase {
|
|||
ReflectionHelper.convertAllArguments(new Class[]{String.class,String[].class}, true, null, args);
|
||||
Assert.fail("Should have failed because no converter supplied");
|
||||
} catch (SpelEvaluationException se) {
|
||||
Assert.assertEquals(SpelMessages.TYPE_CONVERSION_ERROR,se.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.TYPE_CONVERSION_ERROR,se.getMessageCode());
|
||||
}
|
||||
|
||||
// null value
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ public class InProgressTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testRelOperatorsBetweenErrors01() {
|
||||
evaluateAndCheckError("1 between T(String)", SpelMessages.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST, 10);
|
||||
evaluateAndCheckError("1 between T(String)", SpelMessage.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST, 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelOperatorsBetweenErrors03() {
|
||||
evaluateAndCheckError("1 between listOfNumbersUpToTen", SpelMessages.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST, 10);
|
||||
evaluateAndCheckError("1 between listOfNumbersUpToTen", SpelMessage.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST, 10);
|
||||
}
|
||||
|
||||
// PROJECTION
|
||||
|
|
@ -64,8 +64,8 @@ public class InProgressTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testProjection05() {
|
||||
evaluateAndCheckError("'abc'.![true]", SpelMessages.PROJECTION_NOT_SUPPORTED_ON_TYPE);
|
||||
evaluateAndCheckError("null.![true]", SpelMessages.PROJECTION_NOT_SUPPORTED_ON_TYPE);
|
||||
evaluateAndCheckError("'abc'.![true]", SpelMessage.PROJECTION_NOT_SUPPORTED_ON_TYPE);
|
||||
evaluateAndCheckError("null.![true]", SpelMessage.PROJECTION_NOT_SUPPORTED_ON_TYPE);
|
||||
evaluate("null?.![true]", null, null);
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ public class InProgressTests extends ExpressionTestCase {
|
|||
@Test
|
||||
public void testSelectionError_NonBooleanSelectionCriteria() {
|
||||
evaluateAndCheckError("listOfNumbersUpToTen.?['nonboolean']",
|
||||
SpelMessages.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);
|
||||
SpelMessage.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -100,7 +100,7 @@ public class InProgressTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testSelection04() {
|
||||
evaluateAndCheckError("mapOfNumbersUpToTen.?['hello'].size()",SpelMessages.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);
|
||||
evaluateAndCheckError("mapOfNumbersUpToTen.?['hello'].size()",SpelMessage.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -109,8 +109,8 @@ public class InProgressTests extends ExpressionTestCase {
|
|||
evaluate("mapOfNumbersUpToTen.^[key>11]", null, null);
|
||||
evaluate("mapOfNumbersUpToTen.$[key>11]", null, null);
|
||||
evaluate("null?.$[key>11]", null, null);
|
||||
evaluateAndCheckError("null.?[key>11]", SpelMessages.INVALID_TYPE_FOR_SELECTION);
|
||||
evaluateAndCheckError("'abc'.?[key>11]", SpelMessages.INVALID_TYPE_FOR_SELECTION);
|
||||
evaluateAndCheckError("null.?[key>11]", SpelMessage.INVALID_TYPE_FOR_SELECTION);
|
||||
evaluateAndCheckError("'abc'.?[key>11]", SpelMessage.INVALID_TYPE_FOR_SELECTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class LiteralTests extends ExpressionTestCase {
|
|||
// ask for the result to be made into an Integer
|
||||
evaluateAndAskForReturnType("0x20 * 2L", 64, Integer.class);
|
||||
// ask for the result to be made into an Integer knowing that it will not fit
|
||||
evaluateAndCheckError("0x1220 * 0xffffffffL", Integer.class, SpelMessages.TYPE_CONVERSION_ERROR, 0);
|
||||
evaluateAndCheckError("0x1220 * 0xffffffffL", Integer.class, SpelMessage.TYPE_CONVERSION_ERROR, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -144,8 +144,8 @@ public class LiteralTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testLiteralReal04_BadExpressions() {
|
||||
parseAndCheckError("6.1e23e22", SpelMessages.MORE_INPUT, 6, "e22");
|
||||
parseAndCheckError("6.1f23e22", SpelMessages.MORE_INPUT, 4, "23e22");
|
||||
parseAndCheckError("6.1e23e22", SpelMessage.MORE_INPUT, 6, "e22");
|
||||
parseAndCheckError("6.1f23e22", SpelMessage.MORE_INPUT, 4, "23e22");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class MethodInvocationTests extends ExpressionTestCase {
|
|||
@Test
|
||||
public void testNonExistentMethods() {
|
||||
// name is ok but madeup() does not exist
|
||||
evaluateAndCheckError("name.madeup()", SpelMessages.METHOD_NOT_FOUND, 5);
|
||||
evaluateAndCheckError("name.madeup()", SpelMessage.METHOD_NOT_FOUND, 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -96,7 +96,7 @@ public class MethodInvocationTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testInvocationOnNullContextObject() {
|
||||
evaluateAndCheckError("null.toString()",SpelMessages.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED);
|
||||
evaluateAndCheckError("null.toString()",SpelMessage.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class OperatorOverloaderTests extends ExpressionTestCase {
|
|||
@Test
|
||||
public void testSimpleOperations() throws Exception {
|
||||
// no built in support for this:
|
||||
evaluateAndCheckError("'abc'+true",SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("'abc'+true",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
|
||||
StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
|
||||
eContext.setOperatorOverloader(new StringAndBooleanAddition());
|
||||
|
|
|
|||
|
|
@ -153,9 +153,9 @@ public class OperatorTests extends ExpressionTestCase {
|
|||
evaluate("3.0f + 5.0f", 8.0d, Double.class);
|
||||
evaluate("3.0d + 5.0d", 8.0d, Double.class);
|
||||
|
||||
evaluateAndCheckError("'ab' + 2", SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("2+'a' ", SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("2+'ab'",SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("'ab' + 2", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("2+'a' ", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("2+'ab'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
|
||||
// AST:
|
||||
SpelExpression expr = (SpelExpression)parser.parseExpression("+3");
|
||||
|
|
@ -167,7 +167,7 @@ public class OperatorTests extends ExpressionTestCase {
|
|||
evaluate("+5d",5d,Double.class);
|
||||
evaluate("+5L",5L,Long.class);
|
||||
evaluate("+5",5,Integer.class);
|
||||
evaluateAndCheckError("+'abc'",SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("+'abc'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
|
||||
// string concatenation
|
||||
evaluate("'abc'+'def'","abcdef",String.class);
|
||||
|
|
@ -180,8 +180,8 @@ public class OperatorTests extends ExpressionTestCase {
|
|||
public void testMinus() throws Exception {
|
||||
evaluate("'c' - 2", "a", String.class);
|
||||
evaluate("3.0f - 5.0f", -2.0d, Double.class);
|
||||
evaluateAndCheckError("'ab' - 2", SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("2-'ab'",SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("'ab' - 2", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("2-'ab'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
SpelExpression expr = (SpelExpression)parser.parseExpression("-3");
|
||||
Assert.assertEquals("-3",expr.toStringAST());
|
||||
expr = (SpelExpression)parser.parseExpression("2-3");
|
||||
|
|
@ -190,7 +190,7 @@ public class OperatorTests extends ExpressionTestCase {
|
|||
evaluate("-5d",-5d,Double.class);
|
||||
evaluate("-5L",-5L,Long.class);
|
||||
evaluate("-5",-5,Integer.class);
|
||||
evaluateAndCheckError("-'abc'",SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("-'abc'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -199,14 +199,14 @@ public class OperatorTests extends ExpressionTestCase {
|
|||
evaluate("3L%2L",1L,Long.class);
|
||||
evaluate("3.0f%2.0f",1d,Double.class);
|
||||
evaluate("5.0d % 3.1d", 1.9d, Double.class);
|
||||
evaluateAndCheckError("'abc'%'def'",SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("'abc'%'def'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDivide() {
|
||||
evaluate("3.0f / 5.0f", 0.6d, Double.class);
|
||||
evaluate("4L/2L",2L,Long.class);
|
||||
evaluateAndCheckError("'abc'/'def'",SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("'abc'/'def'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -273,8 +273,8 @@ public class OperatorTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testOperatorOverloading() {
|
||||
evaluateAndCheckError("'a' * '2'", SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("'a' ^ '2'", SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("'a' * '2'", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
evaluateAndCheckError("'a' ^ '2'", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -28,34 +28,34 @@ public class ParserErrorMessagesTests extends ExpressionTestCase {
|
|||
@Test
|
||||
public void testBrokenExpression01() {
|
||||
// will not fit into an int, needs L suffix
|
||||
parseAndCheckError("0xCAFEBABE", SpelMessages.NOT_AN_INTEGER);
|
||||
parseAndCheckError("0xCAFEBABE", SpelMessage.NOT_AN_INTEGER);
|
||||
evaluate("0xCAFEBABEL", 0xCAFEBABEL, Long.class);
|
||||
parseAndCheckError("0xCAFEBABECAFEBABEL", SpelMessages.NOT_A_LONG);
|
||||
parseAndCheckError("0xCAFEBABECAFEBABEL", SpelMessage.NOT_A_LONG);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrokenExpression02() {
|
||||
// rogue 'G' on the end
|
||||
parseAndCheckError("0xB0BG", SpelMessages.MORE_INPUT, 5, "G");
|
||||
parseAndCheckError("0xB0BG", SpelMessage.MORE_INPUT, 5, "G");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrokenExpression04() {
|
||||
// missing right operand
|
||||
parseAndCheckError("true or ", SpelMessages.RIGHT_OPERAND_PROBLEM, 5);
|
||||
parseAndCheckError("true or ", SpelMessage.RIGHT_OPERAND_PROBLEM, 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrokenExpression05() {
|
||||
// missing right operand
|
||||
parseAndCheckError("1 + ", SpelMessages.RIGHT_OPERAND_PROBLEM, 2);
|
||||
parseAndCheckError("1 + ", SpelMessage.RIGHT_OPERAND_PROBLEM, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrokenExpression07() {
|
||||
// T() can only take an identifier (possibly qualified), not a literal
|
||||
// message ought to say identifier rather than ID
|
||||
parseAndCheckError("null instanceof T('a')", SpelMessages.NOT_EXPECTED_TOKEN, 18,
|
||||
parseAndCheckError("null instanceof T('a')", SpelMessage.NOT_EXPECTED_TOKEN, 18,
|
||||
"identifier","literal_string");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ public class PropertyAccessTests extends ExpressionTestCase {
|
|||
@Test
|
||||
public void testNonExistentPropertiesAndMethods() {
|
||||
// madeup does not exist as a property
|
||||
evaluateAndCheckError("madeup", SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE, 0);
|
||||
evaluateAndCheckError("madeup", SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE, 0);
|
||||
|
||||
// name is ok but foobar does not exist:
|
||||
evaluateAndCheckError("name.foobar", SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE, 5);
|
||||
evaluateAndCheckError("name.foobar", SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -74,20 +74,20 @@ public class PropertyAccessTests extends ExpressionTestCase {
|
|||
expr.getValue(context);
|
||||
Assert.fail("Should have failed - default property resolver cannot resolve on null");
|
||||
} catch (Exception e) {
|
||||
checkException(e,SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL);
|
||||
checkException(e,SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL);
|
||||
}
|
||||
Assert.assertFalse(expr.isWritable(context));
|
||||
try {
|
||||
expr.setValue(context,"abc");
|
||||
Assert.fail("Should have failed - default property resolver cannot resolve on null");
|
||||
} catch (Exception e) {
|
||||
checkException(e,SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
checkException(e,SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkException(Exception e, SpelMessages expectedMessage) {
|
||||
private void checkException(Exception e, SpelMessage expectedMessage) {
|
||||
if (e instanceof SpelEvaluationException) {
|
||||
SpelMessages sm = ((SpelEvaluationException)e).getMessageUnformatted();
|
||||
SpelMessage sm = ((SpelEvaluationException)e).getMessageCode();
|
||||
Assert.assertEquals("Expected exception type did not occur",expectedMessage,sm);
|
||||
} else {
|
||||
Assert.fail("Should be a SpelException "+e);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class SetValueTests extends ExpressionTestCase {
|
|||
|
||||
@Test
|
||||
public void testSetElementOfNull() {
|
||||
setValueExpectError("new org.springframework.expression.spel.testresources.Inventor().inventions[1]",SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
|
||||
setValueExpectError("new org.springframework.expression.spel.testresources.Inventor().inventions[1]",SpelMessage.CANNOT_INDEX_INTO_NULL_VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class StandardTypeLocatorTests {
|
|||
Assert.fail("Should have failed");
|
||||
} catch (EvaluationException ee) {
|
||||
SpelEvaluationException sEx = (SpelEvaluationException)ee;
|
||||
Assert.assertEquals(SpelMessages.TYPE_NOT_FOUND,sEx.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.TYPE_NOT_FOUND,sEx.getMessageCode());
|
||||
}
|
||||
locator.registerImport("java.net");
|
||||
Assert.assertEquals(java.net.URL.class,locator.findType("URL"));
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class VariableAndFunctionTests extends ExpressionTestCase {
|
|||
public void testFunctionAccess01() {
|
||||
evaluate("#reverseInt(1,2,3)", "int[3]{3,2,1}", int[].class);
|
||||
evaluate("#reverseInt('1',2,3)", "int[3]{3,2,1}", int[].class); // requires type conversion of '1' to 1
|
||||
evaluateAndCheckError("#reverseInt(1)", SpelMessages.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION, 0, 1, 3);
|
||||
evaluateAndCheckError("#reverseInt(1)", SpelMessage.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION, 0, 1, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -79,10 +79,10 @@ public class VariableAndFunctionTests extends ExpressionTestCase {
|
|||
Object v = parser.parseExpression("#notStatic()").getValue(ctx);
|
||||
Assert.fail("Should have failed with exception - cannot call non static method that way");
|
||||
} catch (SpelEvaluationException se) {
|
||||
if (se.getMessageUnformatted() != SpelMessages.FUNCTION_MUST_BE_STATIC) {
|
||||
if (se.getMessageCode() != SpelMessage.FUNCTION_MUST_BE_STATIC) {
|
||||
se.printStackTrace();
|
||||
Assert.fail("Should have failed a message about the function needing to be static, not: "
|
||||
+ se.getMessageUnformatted());
|
||||
+ se.getMessageCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.springframework.expression.EvaluationException;
|
|||
import org.springframework.expression.ExpressionException;
|
||||
import org.springframework.expression.ParseException;
|
||||
import org.springframework.expression.spel.SpelExpression;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelMessage;
|
||||
import org.springframework.expression.spel.SpelNode;
|
||||
import org.springframework.expression.spel.SpelParseException;
|
||||
import org.springframework.expression.spel.ast.OpAnd;
|
||||
|
|
@ -114,7 +114,7 @@ public class SpelParserTests {
|
|||
} catch (ParseException e) {
|
||||
Assert.assertTrue(e instanceof SpelParseException);
|
||||
SpelParseException spe = (SpelParseException)e;
|
||||
Assert.assertEquals(SpelMessages.MISSING_CONSTRUCTOR_ARGS,spe.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.MISSING_CONSTRUCTOR_ARGS,spe.getMessageCode());
|
||||
Assert.assertEquals(10,spe.getPosition());
|
||||
}
|
||||
try {
|
||||
|
|
@ -124,7 +124,7 @@ public class SpelParserTests {
|
|||
} catch (ParseException e) {
|
||||
Assert.assertTrue(e instanceof SpelParseException);
|
||||
SpelParseException spe = (SpelParseException)e;
|
||||
Assert.assertEquals(SpelMessages.MISSING_CONSTRUCTOR_ARGS,spe.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.MISSING_CONSTRUCTOR_ARGS,spe.getMessageCode());
|
||||
Assert.assertEquals(10,spe.getPosition());
|
||||
}
|
||||
try {
|
||||
|
|
@ -134,7 +134,7 @@ public class SpelParserTests {
|
|||
} catch (ParseException e) {
|
||||
Assert.assertTrue(e instanceof SpelParseException);
|
||||
SpelParseException spe = (SpelParseException)e;
|
||||
Assert.assertEquals(SpelMessages.RUN_OUT_OF_ARGUMENTS,spe.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.RUN_OUT_OF_ARGUMENTS,spe.getMessageCode());
|
||||
Assert.assertEquals(10,spe.getPosition());
|
||||
}
|
||||
try {
|
||||
|
|
@ -144,7 +144,7 @@ public class SpelParserTests {
|
|||
} catch (ParseException e) {
|
||||
Assert.assertTrue(e instanceof SpelParseException);
|
||||
SpelParseException spe = (SpelParseException)e;
|
||||
Assert.assertEquals(SpelMessages.RUN_OUT_OF_ARGUMENTS,spe.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.RUN_OUT_OF_ARGUMENTS,spe.getMessageCode());
|
||||
Assert.assertEquals(10,spe.getPosition());
|
||||
}
|
||||
try {
|
||||
|
|
@ -154,7 +154,7 @@ public class SpelParserTests {
|
|||
} catch (ParseException e) {
|
||||
Assert.assertTrue(e instanceof SpelParseException);
|
||||
SpelParseException spe = (SpelParseException)e;
|
||||
Assert.assertEquals(SpelMessages.RUN_OUT_OF_ARGUMENTS,spe.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.RUN_OUT_OF_ARGUMENTS,spe.getMessageCode());
|
||||
Assert.assertEquals(10,spe.getPosition());
|
||||
}
|
||||
try {
|
||||
|
|
@ -164,7 +164,7 @@ public class SpelParserTests {
|
|||
} catch (ParseException e) {
|
||||
Assert.assertTrue(e instanceof SpelParseException);
|
||||
SpelParseException spe = (SpelParseException)e;
|
||||
Assert.assertEquals(SpelMessages.NON_TERMINATING_DOUBLE_QUOTED_STRING,spe.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.NON_TERMINATING_DOUBLE_QUOTED_STRING,spe.getMessageCode());
|
||||
Assert.assertEquals(0,spe.getPosition());
|
||||
}
|
||||
try {
|
||||
|
|
@ -174,7 +174,7 @@ public class SpelParserTests {
|
|||
} catch (ParseException e) {
|
||||
Assert.assertTrue(e instanceof SpelParseException);
|
||||
SpelParseException spe = (SpelParseException)e;
|
||||
Assert.assertEquals(SpelMessages.NON_TERMINATING_QUOTED_STRING,spe.getMessageUnformatted());
|
||||
Assert.assertEquals(SpelMessage.NON_TERMINATING_QUOTED_STRING,spe.getMessageCode());
|
||||
Assert.assertEquals(0,spe.getPosition());
|
||||
}
|
||||
|
||||
|
|
@ -332,12 +332,12 @@ public class SpelParserTests {
|
|||
checkNumber("0xa",10,Integer.class);
|
||||
checkNumber("0xAL",10L,Long.class);
|
||||
|
||||
checkNumberError("0x",SpelMessages.NOT_AN_INTEGER);
|
||||
checkNumberError("0xL",SpelMessages.NOT_A_LONG);
|
||||
checkNumberError("0x",SpelMessage.NOT_AN_INTEGER);
|
||||
checkNumberError("0xL",SpelMessage.NOT_A_LONG);
|
||||
|
||||
checkNumberError(".324",SpelMessages.UNEXPECTED_DATA_AFTER_DOT);
|
||||
checkNumberError(".324",SpelMessage.UNEXPECTED_DATA_AFTER_DOT);
|
||||
|
||||
checkNumberError("3.4L",SpelMessages.REAL_CANNOT_BE_LONG);
|
||||
checkNumberError("3.4L",SpelMessage.REAL_CANNOT_BE_LONG);
|
||||
|
||||
// Number is parsed as a float, but immediately promoted to a double
|
||||
checkNumber("3.5f",3.5d,Double.class);
|
||||
|
|
@ -363,7 +363,7 @@ public class SpelParserTests {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkNumberError(String expression, SpelMessages expectedMessage) {
|
||||
private void checkNumberError(String expression, SpelMessage expectedMessage) {
|
||||
try {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
parser.parse(expression);
|
||||
|
|
@ -371,7 +371,7 @@ public class SpelParserTests {
|
|||
} catch (ParseException e) {
|
||||
Assert.assertTrue(e instanceof SpelParseException);
|
||||
SpelParseException spe = (SpelParseException)e;
|
||||
Assert.assertEquals(expectedMessage,spe.getMessageUnformatted());
|
||||
Assert.assertEquals(expectedMessage,spe.getMessageCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue