change from SpelMessages to SpelMessage. Changed exception getter to getMessageCode() from getMessageUnformatted

This commit is contained in:
Andy Clement
2009-06-11 16:17:44 +00:00
parent b9b893f868
commit 69e48828cc
41 changed files with 190 additions and 190 deletions

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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));
}

View File

@@ -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());
}
}

View File

@@ -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);
}
}

View File

@@ -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));
}
}

View File

@@ -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()));
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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());
}
}
}

View File

@@ -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));
}
}

View File

@@ -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());
}
}

View File

@@ -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) {

View File

@@ -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);
}
}

View File

@@ -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) {

View File

@@ -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);
}
}
}

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -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());
}
}

View File

@@ -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);
}
/**