diff --git a/org.springframework.expression/.classpath b/org.springframework.expression/.classpath
index 53d7155a071..334a45cf1f4 100644
--- a/org.springframework.expression/.classpath
+++ b/org.springframework.expression/.classpath
@@ -1,13 +1,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.springframework.expression/ivy.xml b/org.springframework.expression/ivy.xml
index be9b1d15d8c..684467adadc 100644
--- a/org.springframework.expression/ivy.xml
+++ b/org.springframework.expression/ivy.xml
@@ -22,7 +22,6 @@
-
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/EvaluationException.java b/org.springframework.expression/src/main/java/org/springframework/expression/EvaluationException.java
index 589d6cd1e10..995c65d0d3a 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/EvaluationException.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/EvaluationException.java
@@ -17,66 +17,51 @@
package org.springframework.expression;
/**
- * Base class for exceptions occurring during expression parsing and evaluation.
+ * Represent an exception that occurs during expression evaluation.
*
* @author Andy Clement
* @since 3.0
*/
-public class EvaluationException extends Exception {
-
- private String expressionString;
-
+public class EvaluationException extends ExpressionException {
/**
- * Creates a new expression exception.
- * @param cause the underlying cause of this exception
- */
- public EvaluationException(Throwable cause) {
- super(cause);
+ * Creates a new expression evaluation exception.
+ * @param position the position in the expression where the problem occurred
+ * @param message description of the problem that occurred
+ */
+ public EvaluationException(int position, String message) {
+ super(position, message);
}
/**
- * Creates a new expression parsing exception.
- * @param expressionString the expression string that could not be parsed
- * @param cause the underlying cause of this exception
- */
- public EvaluationException(String expressionString, Throwable cause) {
- this(expressionString, "Exception occurred whilst handling '" + expressionString + "'", cause);
- }
-
- /**
- * Creates a new expression exception.
- * @param expressionString the expression string
- * @param message a descriptive message
- * @param cause the underlying cause of this exception
- */
- public EvaluationException(String expressionString, String message, Throwable cause) {
- super(message, cause);
- this.expressionString = expressionString;
- }
-
- /**
- * Creates a new expression exception.
- * @param expressionString the expression string
- * @param message a descriptive message
- */
+ * Creates a new expression evaluation exception.
+ * @param expressionString the expression that could not be evaluated
+ * @param message description of the problem that occurred
+ */
public EvaluationException(String expressionString, String message) {
- super(message);
- this.expressionString = expressionString;
+ super(expressionString, message);
}
/**
- * Creates a new expression exception. The expressionString field should be set by a later call to
- * setExpressionString().
- * @param message a descriptive message
- */
+ * Creates a new expression evaluation exception.
+ * @param position the position in the expression where the problem occurred
+ * @param message description of the problem that occurred
+ * @param cause the underlying cause of this exception
+ */
+ public EvaluationException(int position, String message, Throwable cause) {
+ super(position, message, cause);
+ }
+
+ /**
+ * Creates a new expression evaluation exception.
+ * @param message description of the problem that occurred
+ */
public EvaluationException(String message) {
super(message);
}
-
- public final String getExpressionString() {
- return this.expressionString;
+ public EvaluationException(String message, Throwable cause) {
+ super(message,cause);
}
}
\ No newline at end of file
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/ExpressionException.java b/org.springframework.expression/src/main/java/org/springframework/expression/ExpressionException.java
new file mode 100644
index 00000000000..1aaa566c3c5
--- /dev/null
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/ExpressionException.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.expression;
+
+
+/**
+ * Super class for exceptions that can occur whilst processing expressions
+ *
+ * @author Andy Clement
+ * @since 3.0
+ */
+public class ExpressionException extends Exception {
+
+ protected String expressionString;
+ protected int position; // -1 if not known - but should be known in all reasonable cases
+
+ /**
+ * Creates a new expression exception.
+ * @param expressionString the expression string
+ * @param message a descriptive message
+ */
+ public ExpressionException(String expressionString, String message) {
+ super(message);
+ this.position = -1;
+ this.expressionString = expressionString;
+ }
+
+ /**
+ * Creates a new expression exception.
+ * @param expressionString the expression string
+ * @param position the position in the expression string where the problem occurred
+ * @param message a descriptive message
+ */
+ public ExpressionException(String expressionString, int position, String message) {
+ super(message);
+ this.position = position;
+ this.expressionString = expressionString;
+ }
+
+ /**
+ * Creates a new expression exception.
+ * @param position the position in the expression string where the problem occurred
+ * @param message a descriptive message
+ */
+ public ExpressionException(int position, String message) {
+ super(message);
+ this.position = position;
+ }
+
+ /**
+ * Creates a new expression exception.
+ * @param position the position in the expression string where the problem occurred
+ * @param message a descriptive message
+ * @param cause the underlying cause of this exception
+ */
+ public ExpressionException(int position, String message, Throwable cause) {
+ super(message,cause);
+ this.position = position;
+ }
+
+ /**
+ * Creates a new expression exception.
+ * @param message a descriptive message
+ */
+ public ExpressionException(String message) {
+ super(message);
+ }
+
+ public ExpressionException(String message, Throwable cause) {
+ super(message,cause);
+ }
+
+ public String toDetailedString() {
+ StringBuilder output = new StringBuilder();
+ if (expressionString!=null) {
+ output.append("Expression '");
+ output.append(expressionString);
+ output.append("'");
+ if (position!=-1) {
+ output.append(" @ ");
+ output.append(position);
+ }
+ output.append(": ");
+ }
+ output.append(getMessage());
+ return output.toString();
+ }
+
+ public final String getExpressionString() {
+ return this.expressionString;
+ }
+
+ public final int getPosition() {
+ return position;
+ }
+
+}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/OperatorOverloader.java b/org.springframework.expression/src/main/java/org/springframework/expression/OperatorOverloader.java
index 788638ac9e7..0dd7bd2e6c9 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/OperatorOverloader.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/OperatorOverloader.java
@@ -25,9 +25,6 @@ package org.springframework.expression;
*/
public interface OperatorOverloader {
- // TODO does type OperatorOverloader need a better name?
- // TODO Operator overloading needs some testing!
-
/**
* Return true if the operator overloader supports the specified operation
* between the two operands and so should be invoked to handle it.
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/ParseException.java b/org.springframework.expression/src/main/java/org/springframework/expression/ParseException.java
index 615d01a60e5..5c94688169b 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/ParseException.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/ParseException.java
@@ -17,57 +17,40 @@
package org.springframework.expression;
/**
- * Base class for exceptions occurring during expression parsing and evaluation.
+ * Represent an exception that occurs during expression parsing.
*
* @author Andy Clement
* @since 3.0
*/
-public class ParseException extends Exception {
-
- private String expressionString;
-
-
- /**
- * Creates a new expression exception.
- * @param cause the underlying cause of this exception
- */
- public ParseException(Throwable cause) {
- super(cause);
- }
+public class ParseException extends ExpressionException {
/**
* Creates a new expression parsing exception.
* @param expressionString the expression string that could not be parsed
- * @param cause the underlying cause of this exception
- */
- public ParseException(String expressionString, Throwable cause) {
- this(expressionString, "Exception occurred whilst handling '" + expressionString + "'", cause);
+ * @param position the position in the expression string where the problem occurred
+ * @param message description of the problem that occurred
+ */
+ public ParseException(String expressionString, int position, String message) {
+ super(expressionString, position, message);
}
/**
- * Creates a new expression exception.
- * @param expressionString the expression string
- * @param message a descriptive message
+ * Creates a new expression parsing exception.
+ * @param position the position in the expression string where the problem occurred
+ * @param message description of the problem that occurred
* @param cause the underlying cause of this exception
- */
- public ParseException(String expressionString, String message, Throwable cause) {
- super(message, cause);
- this.expressionString = expressionString;
- }
-
- /**
- * Creates a new expression exception.
- * @param expressionString the expression string
- * @param message a descriptive message
- */
- public ParseException(String expressionString, String message) {
+ */
+ public ParseException(int position, String message, Throwable cause) {
super(message);
- this.expressionString = expressionString;
}
-
-
- public final String getExpressionString() {
- return this.expressionString;
+
+ /**
+ * Creates a new expression parsing exception.
+ * @param position the position in the expression string where the problem occurred
+ * @param message description of the problem that occurred
+ */
+ public ParseException(int position, String message) {
+ super(message);
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java b/org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java
index 414e65434bd..cdf9896fe32 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java
@@ -1 +1 @@
-/*
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.expression.common;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParseException;
import org.springframework.expression.ParserContext;
/**
* An expression parser that understands templates. It can be subclassed
* by expression parsers that do not offer first class support for templating.
*
* @author Keith Donald
* @author Juergen Hoeller
* @author Andy Clement
* @since 3.0
*/
public abstract class TemplateAwareExpressionParser implements ExpressionParser {
/**
* Default ParserContext instance for non-template expressions.
*/
private static final ParserContext NON_TEMPLATE_PARSER_CONTEXT = new ParserContext() {
public String getExpressionPrefix() {
return null;
}
public String getExpressionSuffix() {
return null;
}
public boolean isTemplate() {
return false;
}
};
public Expression parseExpression(String expressionString) throws ParseException {
return parseExpression(expressionString, NON_TEMPLATE_PARSER_CONTEXT);
}
public Expression parseExpression(String expressionString, ParserContext context) throws ParseException {
if (context == null) {
context = NON_TEMPLATE_PARSER_CONTEXT;
}
if (context.isTemplate()) {
return parseTemplate(expressionString, context);
} else {
return doParseExpression(expressionString, context);
}
}
private Expression parseTemplate(String expressionString, ParserContext context) throws ParseException {
if (expressionString.length() == 0) {
return new LiteralExpression("");
}
Expression[] expressions = parseExpressions(expressionString, context);
if (expressions.length == 1) {
return expressions[0];
} else {
return new CompositeStringExpression(expressionString, expressions);
}
}
/**
* Helper that parses given expression string using the configured parser. The expression string can contain any
* number of expressions all contained in "${...}" markers. For instance: "foo${expr0}bar${expr1}". The static
* pieces of text will also be returned as Expressions that just return that static piece of text. As a result,
* evaluating all returned expressions and concatenating the results produces the complete evaluated string.
* Unwrapping is only done of the outermost delimiters found, so the string 'hello ${foo${abc}}' would break into
* the pieces 'hello ' and 'foo${abc}'. This means that expression languages that used ${..} as part of their
* functionality are supported without any problem.
* The parsing is aware of the structure of an embedded expression. It assumes that parentheses '(',
* square brackets '[' and curly brackets '}' must be in pairs within the expression unless they are within a
* string literal and a string literal starts and terminates with a single quote '.
*
* @param expressionString the expression string
* @return the parsed expressions
* @throws ParseException when the expressions cannot be parsed
*/
private Expression[] parseExpressions(String expressionString, ParserContext context) throws ParseException {
List expressions = new LinkedList();
String prefix = context.getExpressionPrefix();
String suffix = context.getExpressionSuffix();
int startIdx = 0;
while (startIdx < expressionString.length()) {
int prefixIndex = expressionString.indexOf(prefix,startIdx);
if (prefixIndex >= startIdx) {
// an inner expression was found - this is a composite
if (prefixIndex > startIdx) {
expressions.add(createLiteralExpression(context,expressionString.substring(startIdx, prefixIndex)));
}
int afterPrefixIndex = prefixIndex + prefix.length();
int suffixIndex = skipToCorrectEndSuffix(prefix,suffix,expressionString,afterPrefixIndex);
if (suffixIndex == -1) {
throw new ParseException(expressionString, "No ending suffix '" + suffix +
"' for expression starting at character " + prefixIndex + ": " +
expressionString.substring(prefixIndex));
}
if (suffixIndex == afterPrefixIndex) {
throw new ParseException(expressionString, "No expression defined within delimiter '" +
prefix + suffix + "' at character " + prefixIndex);
} else {
String expr = expressionString.substring(prefixIndex + prefix.length(), suffixIndex);
expr = expr.trim();
if (expr.length()==0) {
throw new ParseException(expressionString, "No expression defined within delimiter '" +
prefix + suffix + "' at character " + prefixIndex);
}
expressions.add(doParseExpression(expr, context));
startIdx = suffixIndex + suffix.length();
}
} else {
// no more ${expressions} found in string, add rest as static text
expressions.add(createLiteralExpression(context,expressionString.substring(startIdx)));
startIdx = expressionString.length();
}
}
return expressions.toArray(new Expression[expressions.size()]);
}
private Expression createLiteralExpression(ParserContext context, String text) {
return new LiteralExpression(text);
}
/**
* Return true if the specified suffix can be found at the supplied position in the supplied expression string.
* @param expressionString the expression string which may contain the suffix
* @param pos the start position at which to check for the suffix
* @param suffix the suffix string
* @return
*/
private boolean isSuffixHere(String expressionString,int pos,String suffix) {
int suffixPosition = 0;
for (int i=0;i stack = new Stack();
while (pos expressions = new LinkedList();
String prefix = context.getExpressionPrefix();
String suffix = context.getExpressionSuffix();
int startIdx = 0;
while (startIdx < expressionString.length()) {
int prefixIndex = expressionString.indexOf(prefix,startIdx);
if (prefixIndex >= startIdx) {
// an inner expression was found - this is a composite
if (prefixIndex > startIdx) {
expressions.add(createLiteralExpression(context,expressionString.substring(startIdx, prefixIndex)));
}
int afterPrefixIndex = prefixIndex + prefix.length();
int suffixIndex = skipToCorrectEndSuffix(prefix,suffix,expressionString,afterPrefixIndex);
if (suffixIndex == -1) {
throw new ParseException(expressionString, prefixIndex, "No ending suffix '" + suffix +
"' for expression starting at character " + prefixIndex + ": " +
expressionString.substring(prefixIndex));
}
if (suffixIndex == afterPrefixIndex) {
throw new ParseException(expressionString, prefixIndex, "No expression defined within delimiter '" +
prefix + suffix + "' at character " + prefixIndex);
} else {
String expr = expressionString.substring(prefixIndex + prefix.length(), suffixIndex);
expr = expr.trim();
if (expr.length()==0) {
throw new ParseException(expressionString, prefixIndex, "No expression defined within delimiter '" +
prefix + suffix + "' at character " + prefixIndex);
}
expressions.add(doParseExpression(expr, context));
startIdx = suffixIndex + suffix.length();
}
} else {
// no more ${expressions} found in string, add rest as static text
expressions.add(createLiteralExpression(context,expressionString.substring(startIdx)));
startIdx = expressionString.length();
}
}
return expressions.toArray(new Expression[expressions.size()]);
}
private Expression createLiteralExpression(ParserContext context, String text) {
return new LiteralExpression(text);
}
/**
* Return true if the specified suffix can be found at the supplied position in the supplied expression string.
* @param expressionString the expression string which may contain the suffix
* @param pos the start position at which to check for the suffix
* @param suffix the suffix string
* @return
*/
private boolean isSuffixHere(String expressionString,int pos,String suffix) {
int suffixPosition = 0;
for (int i=0;i stack = new Stack();
while (pos variableScopes = new Stack();
private final Stack contextObjects = new Stack();
@@ -158,7 +158,7 @@ public class ExpressionState {
else {
String leftType = (left==null?"null":left.getClass().getName());
String rightType = (right==null?"null":right.getClass().getName());
- throw new SpelException(SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES, op, leftType, rightType);
+ throw new SpelEvaluationException(SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES, op, leftType, rightType);
}
}
@@ -169,8 +169,7 @@ public class ExpressionState {
public EvaluationContext getEvaluationContext() {
return this.relatedContext;
}
-
-
+
/**
* A new scope is entered when a function is called and it is used to hold the parameters to the function call. If the names
* of the parameters clash with those in a higher level scope, those in the higher level scope will not be accessible whilst
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelException.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelEvaluationException.java
similarity index 63%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelException.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelEvaluationException.java
index e2c702e9d8c..22345caad07 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelException.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelEvaluationException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2008 the original author or authors.
+ * Copyright 2004-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,41 +25,32 @@ import org.springframework.expression.EvaluationException;
* @author Andy Clement
* @since 3.0
*/
-public class SpelException extends EvaluationException {
+public class SpelEvaluationException extends EvaluationException {
private SpelMessages message;
- private int position = -1;
private Object[] inserts;
- public SpelException(int position, Throwable cause, SpelMessages message, Object... inserts) {
- super(cause);
- this.position = position;
+ public SpelEvaluationException(SpelMessages 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 SpelException(Throwable cause, SpelMessages message, Object... inserts) {
- super(cause);
+ public SpelEvaluationException(int position, SpelMessages message, Object... inserts) {
+ super(position, message.formatMessage(position, inserts));
this.message = message;
this.inserts = inserts;
}
- public SpelException(int position, SpelMessages message, Object... inserts) {
- super((Throwable)null);
- this.position = position;
+ public SpelEvaluationException(int position, Throwable cause,
+ SpelMessages message, Object... inserts) {
+ super(position,message.formatMessage(position,inserts),cause);
this.message = message;
this.inserts = inserts;
}
- public SpelException(SpelMessages message, Object... inserts) {
- super((Throwable)null);
- this.message = message;
- this.inserts = inserts;
- }
-
- public SpelException(String expressionString, int position, Throwable cause, SpelMessages message, Object... inserts) {
- super(expressionString, cause);
- this.position = position;
+ public SpelEvaluationException(Throwable cause, SpelMessages message, Object... inserts) {
+ super(message.formatMessage(0,inserts),cause);
this.message = message;
this.inserts = inserts;
}
@@ -75,13 +66,6 @@ public class SpelException extends EvaluationException {
return super.getMessage();
}
- /**
- * @return the position within the expression that gave rise to the exception (or -1 if unknown)
- */
- public int getPosition() {
- return this.position;
- }
-
/**
* @return the unformatted message
*/
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/WrappedSpelException.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelExpressionParserFactory.java
similarity index 53%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/WrappedSpelException.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelExpressionParserFactory.java
index ea7bad24460..f11e6e4bfbe 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/WrappedSpelException.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelExpressionParserFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2008 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,23 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.expression.spel;
+ package org.springframework.expression.spel;
+import org.springframework.expression.ExpressionParser;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
/**
- * Wrap a checked SpelException temporarily so that it can be passed through some infrastructure code
- * (for example Antlr) before being unwrapped at the top level.
- *
* @author Andy Clement
+ * @since 3.0
*/
-public class WrappedSpelException extends RuntimeException {
+public class SpelExpressionParserFactory {
- public WrappedSpelException(SpelException e) {
- super(e);
- }
-
- @Override
- public SpelException getCause() {
- return (SpelException) super.getCause();
+ public static ExpressionParser getParser() {
+ return new SpelExpressionParser();
}
+
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelMessages.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelMessages.java
index 7f5265cddb4..e0d030c41ac 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelMessages.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelMessages.java
@@ -36,69 +36,58 @@ import java.text.MessageFormat;
* @since 3.0
*/
public enum SpelMessages {
- // TODO put keys and messages into bundles for easy NLS
- // TODO review if any messages are not used
- // TODO sort messages into better groups if possible, sharing a name prefix perhaps
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}"), //
- METHOD_NOT_FOUND(Kind.ERROR, 1003, "Method call: Method {0} cannot be found on {1} type"), //
- TYPE_NOT_FOUND(Kind.ERROR, 1004, "Type cannot be found ''{0}''"), //
- VARIABLE_NOT_FOUND(Kind.ERROR, 1005, "Variable named ''{0}'' cannot be found"), //
- LOCAL_VARIABLE_NOT_DEFINED(Kind.ERROR, 1006, "Local variable named ''{0}'' could not be found"), //
- FUNCTION_NOT_DEFINED(Kind.ERROR, 1007, "The function ''{0}'' could not be found"), //
- PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL(Kind.ERROR, 1008, "Field or property ''{0}'' cannot be found on null"), //
- PROPERTY_OR_FIELD_NOT_READABLE(Kind.ERROR, 1009, "Field or property ''{0}'' cannot be found on object of type ''{1}''"), //
- PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL(Kind.ERROR, 1010, "Field or property ''{0}'' cannot be set on null"), //
+ CONSTRUCTOR_INVOCATION_PROBLEM(Kind.ERROR, 1003, "A problem occurred whilst attempting to construct an object of type ''{0}'' using arguments ''{1}''"), //
+ METHOD_NOT_FOUND(Kind.ERROR, 1004, "Method call: Method {0} cannot be found on {1} type"), //
+ TYPE_NOT_FOUND(Kind.ERROR, 1005, "Type cannot be found ''{0}''"), //
+ FUNCTION_NOT_DEFINED(Kind.ERROR, 1006, "The function ''{0}'' could not be found"), //
+ PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL(Kind.ERROR, 1007, "Field or property ''{0}'' cannot be found on null"), //
+ PROPERTY_OR_FIELD_NOT_READABLE(Kind.ERROR, 1008, "Field or property ''{0}'' cannot be found on object of type ''{1}''"), //
+ PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL(Kind.ERROR, 1009, "Field or property ''{0}'' cannot be set on null"), //
PROPERTY_OR_FIELD_NOT_WRITABLE(Kind.ERROR, 1010, "Field or property ''{0}'' cannot be set on object of type ''{1}''"), //
-
METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED(Kind.ERROR, 1011, "Method call: Attempted to call method {0} on null context object"), //
- PROPERTY_OR_FIELD_ACCESS_ON_NULL_OBJECT_NOT_ALLOWED(Kind.ERROR, 1012, "Field or property reference: Attempted to refer to field or property ''{0}'' on null context object"), //
- CANNOT_INDEX_INTO_NULL_VALUE(Kind.ERROR, 1013, "Cannot index into a null value"),
-
- NOT_COMPARABLE(Kind.ERROR, 1014, "Cannot compare instances of {0} and {1}"), //
- NOT_COMPARABLE_CANNOT_COERCE(Kind.ERROR, 1015, "Cannot compare instances of {0} and {1} because they cannot be coerced to the same type"), //
- INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION(Kind.ERROR, 1016, "Incorrect number of arguments for function, {0} supplied but function takes {1}"), //
- INVALID_TYPE_FOR_SELECTION(Kind.ERROR, 1017, "Cannot perform selection on input data of type ''{0}''"), //
- RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN(Kind.ERROR, 1018, "Result of selection criteria is not boolean"), //
- NULL_OPERAND_TO_OPERATOR(Kind.ERROR, 1019, "Operand evaluated to null and that is not supported for this operator"), //
- BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST(Kind.ERROR, 1020, "Right operand for the 'between' operator has to be a two-element list"), //
- UNABLE_TO_ACCESS_FIELD(Kind.ERROR, 1021, "Unable to access field ''{0}'' on type ''{1}''"), //
- UNABLE_TO_ACCESS_PROPERTY_THROUGH_GETTER(Kind.ERROR, 1022, "Unable to access property ''{0}'' through getter on type ''{1}''"), //
- UNABLE_TO_ACCESS_PROPERTY_THROUGH_SETTER(Kind.ERROR, 1023, "Unable to access property ''{0}'' through setter on type ''{1}''"), //
- INVALID_PATTERN(Kind.ERROR, 1024, "Pattern is not valid ''{0}''"), //
- RECOGNITION_ERROR(Kind.ERROR, 1025, "Recognition error: {0}"), // TODO poor message when a recognition exception occurs
- PROJECTION_NOT_SUPPORTED_ON_TYPE(Kind.ERROR, 1026, "Projection is not supported on the type ''{0}''"), //
- ARGLIST_SHOULD_NOT_BE_EVALUATED(Kind.ERROR, 1027, "The argument list of a lambda expression should never have getValue() called upon it"), //
- MAPENTRY_SHOULD_NOT_BE_EVALUATED(Kind.ERROR, 1028, "A map entry should never have getValue() called upon it"), //
- EXCEPTION_DURING_PROPERTY_READ(Kind.ERROR, 1029, "A problem occurred whilst attempting to access the property ''{0}'': ''{1}''"), //
- EXCEPTION_DURING_CONSTRUCTOR_INVOCATION(Kind.ERROR, 1030, "A problem occurred whilst attempting to construct ''{0}'': ''{1}''"), //
- DATE_CANNOT_BE_PARSED(Kind.ERROR, 1031, "Unable to parse date ''{0}'' using format ''{1}''"), //
- FUNCTION_REFERENCE_CANNOT_BE_INVOKED(Kind.ERROR, 1032, "The function ''{0}'' mapped to an object of type ''{1}'' which cannot be invoked"), //
- EXCEPTION_DURING_FUNCTION_CALL(Kind.ERROR, 1033, "A problem occurred whilst attempting to invoke the function ''{0}'': ''{1}''"), //
-
- // indexing
- ARRAY_INDEX_OUT_OF_BOUNDS(Kind.ERROR, 1034, "The array has ''{0}'' elements, index ''{1}'' is invalid"), //
- COLLECTION_INDEX_OUT_OF_BOUNDS(Kind.ERROR, 1035, "The collection has ''{0}'' elements, index ''{1}'' is invalid"), //
- STRING_INDEX_OUT_OF_BOUNDS(Kind.ERROR, 1036, "The string has ''{0}'' characters, index ''{1}'' is invalid"), //
- INDEXING_NOT_SUPPORTED_FOR_TYPE(Kind.ERROR, 1037, "Indexing into type ''{0}'' is not supported"), //
-
- INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND(Kind.ERROR, 1038, "The operator 'instanceof' needs the right operand to be a class, not a ''{0}''"), //
- EXCEPTION_DURING_METHOD_INVOCATION(Kind.ERROR, 1039, "A problem occurred when trying to execute method ''{0}'' on object of type ''{1}'': ''{2}''"), //
- OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES(Kind.ERROR, 1040, "The operator ''{0}'' is not supported between objects of type ''{1}'' and ''{2}''"), //
- UNEXPECTED_PROBLEM_INVOKING_OPERATOR(Kind.ERROR, 1041, "Unexpected problem invoking operator ''{0}'' between objects of type ''{1}'' and ''{2}'': {3}"), //
- PROBLEM_LOCATING_METHOD(Kind.ERROR, 1042, "Problem locating method {0} cannot on type {1}"),
- PROBLEM_LOCATING_CONSTRUCTOR(Kind.ERROR, 1043, "A problem occurred whilst attempting to construct an object of type ''{0}'' using arguments ''{1}''"), //
- SETVALUE_NOT_SUPPORTED( Kind.ERROR, 1044, "setValue(ExpressionState, Object) not implemented for ''{0}'' (''{1}''"), //
- PROBLEM_DURING_TYPE_CONVERSION(Kind.ERROR, 1045, "Problem occurred during type conversion: {0}"), //
- MULTIPLE_POSSIBLE_METHODS(Kind.ERROR, 1046, "Method call of ''{0}'' is ambiguous, supported type conversions allow multiple variants to match"), //
- EXCEPTION_DURING_PROPERTY_WRITE(Kind.ERROR, 1047, "A problem occurred whilst attempting to set the property ''{0}'': {1}"), //
- NOT_AN_INTEGER(Kind.ERROR, 1048, "The value ''{0}'' cannot be parsed as an int"), //
- NOT_A_LONG(Kind.ERROR, 1049, "The value ''{0}'' cannot be parsed as a long"), //
- PARSE_PROBLEM(Kind.ERROR, 1050, "Error occurred during expression parse: {0}"), //
- INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR(Kind.ERROR, 1051, "First operand to matches operator must be a string. ''{0}'' is not"), //
- INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR(Kind.ERROR, 1052, "Second operand to matches operator must be a string. ''{0}'' is not"), //
- FUNCTION_MUST_BE_STATIC(Kind.ERROR, 1053, "Only static methods can be called via function references. The method ''{0}'' referred to by name ''{1}'' is not static."),//
+ CANNOT_INDEX_INTO_NULL_VALUE(Kind.ERROR, 1012, "Cannot index into a null value"),
+ NOT_COMPARABLE(Kind.ERROR, 1013, "Cannot compare instances of {0} and {1}"), //
+ INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION(Kind.ERROR, 1014, "Incorrect number of arguments for function, {0} supplied but function takes {1}"), //
+ INVALID_TYPE_FOR_SELECTION(Kind.ERROR, 1015, "Cannot perform selection on input data of type ''{0}''"), //
+ RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN(Kind.ERROR, 1016, "Result of selection criteria is not boolean"), //
+ BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST(Kind.ERROR, 1017, "Right operand for the 'between' operator has to be a two-element list"), //
+ INVALID_PATTERN(Kind.ERROR, 1018, "Pattern is not valid ''{0}''"), //
+ PROJECTION_NOT_SUPPORTED_ON_TYPE(Kind.ERROR, 1019, "Projection is not supported on the type ''{0}''"), //
+ ARGLIST_SHOULD_NOT_BE_EVALUATED(Kind.ERROR, 1020, "The argument list of a lambda expression should never have getValue() called upon it"), //
+ EXCEPTION_DURING_PROPERTY_READ(Kind.ERROR, 1021, "A problem occurred whilst attempting to access the property ''{0}'': ''{1}''"), //
+ FUNCTION_REFERENCE_CANNOT_BE_INVOKED(Kind.ERROR, 1022, "The function ''{0}'' mapped to an object of type ''{1}'' which cannot be invoked"), //
+ EXCEPTION_DURING_FUNCTION_CALL(Kind.ERROR, 1023, "A problem occurred whilst attempting to invoke the function ''{0}'': ''{1}''"), //
+ ARRAY_INDEX_OUT_OF_BOUNDS(Kind.ERROR, 1024, "The array has ''{0}'' elements, index ''{1}'' is invalid"), //
+ COLLECTION_INDEX_OUT_OF_BOUNDS(Kind.ERROR, 1025, "The collection has ''{0}'' elements, index ''{1}'' is invalid"), //
+ STRING_INDEX_OUT_OF_BOUNDS(Kind.ERROR, 1026, "The string has ''{0}'' characters, index ''{1}'' is invalid"), //
+ INDEXING_NOT_SUPPORTED_FOR_TYPE(Kind.ERROR, 1027, "Indexing into type ''{0}'' is not supported"), //
+ INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND(Kind.ERROR, 1028, "The operator 'instanceof' needs the right operand to be a class, not a ''{0}''"), //
+ EXCEPTION_DURING_METHOD_INVOCATION(Kind.ERROR, 1029, "A problem occurred when trying to execute method ''{0}'' on object of type ''{1}'': ''{2}''"), //
+ OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES(Kind.ERROR, 1030, "The operator ''{0}'' is not supported between objects of type ''{1}'' and ''{2}''"), //
+ PROBLEM_LOCATING_METHOD(Kind.ERROR, 1031, "Problem locating method {0} cannot on type {1}"),
+ SETVALUE_NOT_SUPPORTED( Kind.ERROR, 1032, "setValue(ExpressionState, Object) not supported for ''{0}''"), //
+ MULTIPLE_POSSIBLE_METHODS(Kind.ERROR, 1033, "Method call of ''{0}'' is ambiguous, supported type conversions allow multiple variants to match"), //
+ EXCEPTION_DURING_PROPERTY_WRITE(Kind.ERROR, 1034, "A problem occurred whilst attempting to set the property ''{0}'': {1}"), //
+ NOT_AN_INTEGER(Kind.ERROR, 1035, "The value ''{0}'' cannot be parsed as an int"), //
+ NOT_A_LONG(Kind.ERROR, 1036, "The value ''{0}'' cannot be parsed as a long"), //
+ INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR(Kind.ERROR, 1037, "First operand to matches operator must be a string. ''{0}'' is not"), //
+ INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR(Kind.ERROR, 1038, "Second operand to matches operator must be a string. ''{0}'' is not"), //
+ FUNCTION_MUST_BE_STATIC(Kind.ERROR, 1039, "Only static methods can be called via function references. The method ''{0}'' referred to by name ''{1}'' is not static."),//
+ NOT_A_REAL(Kind.ERROR, 1040, "The value ''{0}'' cannot be parsed as a double"), //
+ MORE_INPUT(Kind.ERROR,1041, "After parsing a valid expression, there is still more data in the expression: ''{0}''"),
+ RIGHT_OPERAND_PROBLEM(Kind.ERROR,1042, "Problem parsing right operand"),
+ NOT_EXPECTED_TOKEN(Kind.ERROR,1043,"Unexpected token. Expected ''{0}'' but was ''{1}''"),
+ OOD(Kind.ERROR,1044,"Unexpectedly ran out of input"), //
+ NON_TERMINATING_DOUBLE_QUOTED_STRING(Kind.ERROR,1045,"Cannot find terminating \" for string"),//
+ NON_TERMINATING_QUOTED_STRING(Kind.ERROR,1046,"Cannot find terminating ' for string"), //
+ MISSING_LEADING_ZERO_FOR_NUMBER(Kind.ERROR,1047,"A real number must be prefixed by zero, it cannot start with just ''.''"), //
+ REAL_CANNOT_BE_LONG(Kind.ERROR,1048,"Real number cannot be suffixed with a long (L or l) suffix"),//
+ UNEXPECTED_DATA_AFTER_DOT(Kind.ERROR,1049,"Unexpected data after ''.'': ''{0}''"),//
+ MISSING_CONSTRUCTOR_ARGS(Kind.ERROR,1050,"The arguments '(...)' for the constructor call are missing"),//
+ RUN_OUT_OF_ARGUMENTS(Kind.ERROR,1051,"Unexpected ran out of arguments"),//
;
private Kind kind;
@@ -125,12 +114,12 @@ public enum SpelMessages {
StringBuilder formattedMessage = new StringBuilder();
formattedMessage.append("EL").append(code);
switch (kind) {
- case WARNING:
- formattedMessage.append("W");
- break;
- case INFO:
- formattedMessage.append("I");
- break;
+// case WARNING:
+// formattedMessage.append("W");
+// break;
+// case INFO:
+// formattedMessage.append("I");
+// break;
case ERROR:
formattedMessage.append("E");
break;
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelNode.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelNode.java
index b5db72c38c3..2fd880c01a9 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelNode.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelNode.java
@@ -79,4 +79,9 @@ public interface SpelNode {
*/
int getStartPosition();
+ /**
+ * @return the end position of this Ast node in the expression string
+ */
+ int getEndPosition();
+
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelParseException.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelParseException.java
new file mode 100644
index 00000000000..ef94b00ed44
--- /dev/null
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelParseException.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2004-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.expression.spel;
+
+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
+ * that can occur.
+ *
+ * @author Andy Clement
+ * @since 3.0
+ */
+public class SpelParseException extends ParseException {
+
+ private SpelMessages message;
+ private Object[] inserts;
+
+// public SpelParseException(String expressionString, int position, Throwable cause, SpelMessages message, Object... inserts) {
+// super(expressionString, position, message.formatMessage(position,inserts), cause);
+// this.message = message;
+// this.inserts = inserts;
+// }
+
+ public SpelParseException(String expressionString, int position, SpelMessages 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) {
+ 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) {
+ super(position, message.formatMessage(position,inserts), cause);
+ this.position = position;
+ this.message = message;
+ this.inserts = inserts;
+ }
+
+//
+// public SpelException(Throwable cause, SpelMessages message, Object... inserts) {
+// super(cause);
+// this.message = message;
+// this.inserts = inserts;
+// }
+//
+// public SpelException(int position, SpelMessages message, Object... inserts) {
+// super((Throwable)null);
+// this.position = position;
+// this.message = message;
+// this.inserts = inserts;
+// }
+//
+// public SpelException(SpelMessages message, Object... inserts) {
+// super((Throwable)null);
+// this.message = message;
+// this.inserts = inserts;
+// }
+
+
+ /**
+ * @return a formatted message with inserts applied
+ */
+ @Override
+ public String getMessage() {
+ if (message != null)
+ return message.formatMessage(position, inserts);
+ else
+ return super.getMessage();
+ }
+
+ /**
+ * @return the unformatted message
+ */
+ public SpelMessages getMessageUnformatted() {
+ return this.message;
+ }
+
+ /**
+ * @return the message inserts
+ */
+ public Object[] getInserts() {
+ return inserts;
+ }
+
+}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/antlr/SpelAntlrExpressionParser.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/antlr/SpelAntlrExpressionParser.java
deleted file mode 100644
index 5696d113585..00000000000
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/antlr/SpelAntlrExpressionParser.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2002-2009 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.expression.spel.antlr;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
-import org.springframework.expression.Expression;
-import org.springframework.expression.ParseException;
-import org.springframework.expression.ParserContext;
-import org.springframework.expression.common.TemplateAwareExpressionParser;
-import org.springframework.expression.spel.SpelException;
-import org.springframework.expression.spel.SpelExpression;
-import org.springframework.expression.spel.SpelNode;
-import org.springframework.expression.spel.WrappedSpelException;
-import org.springframework.expression.spel.generated.SpringExpressionsLexer;
-import org.springframework.expression.spel.generated.SpringExpressionsParser.expr_return;
-
-/**
- * Default {@link org.springframework.expression.ExpressionParser} implementation,
- * wrapping an Antlr lexer and parser that implements standard Spring EL syntax.
- *
- * @author Andy Clement
- * @author Juergen Hoeller
- * @since 3.0
- */
-public class SpelAntlrExpressionParser extends TemplateAwareExpressionParser {
-
- private final SpringExpressionsLexer lexer;
-
- private final SpringExpressionsParserExtender parser;
-
-
- public SpelAntlrExpressionParser() {
- this.lexer = new SpringExpressionsLexerExtender();
- CommonTokenStream tokens = new CommonTokenStream(this.lexer);
- this.parser = new SpringExpressionsParserExtender(tokens);
- }
-
-
- /**
- * Parse an expression string.
- * @param expressionString the expression to parse
- * @param context the parser context in which to perform the parse
- * @return a parsed expression object
- * @throws ParseException if the expression is invalid
- */
- protected Expression doParseExpression(String expressionString, ParserContext context) throws ParseException {
- try {
- this.lexer.setCharStream(new ANTLRStringStream(expressionString));
- CommonTokenStream tokens = new CommonTokenStream(this.lexer);
- this.parser.setTokenStream(tokens);
- expr_return exprReturn = this.parser.expr();
- return new SpelExpression(expressionString, (SpelNode) exprReturn.getTree());
- } catch (RecognitionException re) {
- throw new ParseException(expressionString,
- "Recognition error at position: " + re.charPositionInLine + ": " + re.getMessage(), re);
- } catch (WrappedSpelException ex) {
- SpelException wrappedException = ex.getCause();
- throw new ParseException(expressionString,
- "Parsing problem: " + wrappedException.getMessage(), wrappedException);
- }
- }
-
-}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/antlr/SpringExpressionsLexerExtender.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/antlr/SpringExpressionsLexerExtender.java
deleted file mode 100644
index 127ae581cbb..00000000000
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/antlr/SpringExpressionsLexerExtender.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2002-2009 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.expression.spel.antlr;
-
-import org.antlr.runtime.RecognitionException;
-import org.springframework.expression.spel.SpelException;
-import org.springframework.expression.spel.SpelMessages;
-import org.springframework.expression.spel.WrappedSpelException;
-import org.springframework.expression.spel.generated.SpringExpressionsLexer;
-
-/**
- * @author Andy Clement
- * @since 3.0
- */
-class SpringExpressionsLexerExtender extends SpringExpressionsLexer {
-
- /**
- * recover() attempts to provide better error messages once something has gone wrong. It then throws a
- * InternalELException (has to be this unchecked exception as the exception must flow through Antlr lexer methods
- * that do not have declared exceptions). The InternalELException will be caught at the top level and altered to
- * include context (line,column) information before being rethrown.
- *
- * This error analysis code is in recover() rather than reportError() because reportError() isn't always called by
- * the lexer and there is no way to add the calls to it by editing the .g file.
- */
- @Override
- public void recover(RecognitionException re) {
- // TODO recovery needs an overhaul once the expression language syntax is agreed
-
- // List> rules = getRuleInvocationStack(re, SpringExpressionsLexer.class.getName());
- // String failedRule = (String) rules.get(rules.size() - 1);
- // System.out.println("DBG: lexer rule " + failedRule);
- // need a concrete example of error recovery in here please! then i can delete the below
- // if (re instanceof NoViableAltException) {
- // NoViableAltException nvae = (NoViableAltException) re;
- // // example error data: { "abc": def }
- // if (failedRule.equals("mTokens") && Character.isLetter((char) (nvae.getUnexpectedType()))) {
- // logger.error(ParserMessage.ERROR_STRINGS_MUST_BE_QUOTED, re.line, re.charPositionInLine);
- // }
- //
- // } else if (re instanceof MismatchedRangeException) {
- // // MismatchedRangeException mre = (MismatchedRangeException) re;
- // // example error data: [ 123e ]
- // if (failedRule.equals("mDIGIT") && rules.size() > 3 && ((String) rules.get(rules.size() -
- // 3)).equals("mExponent")) {
- // logger.error(ParserMessage.ERROR_INVALID_EXPONENT, re.line, re.charPositionInLine);
- // }
- // } else if (re instanceof MismatchedTokenException) {
- // MismatchedTokenException mte = (MismatchedTokenException) re;
- // logger.error(ParserMessage.ERROR_MISMATCHED_CHARACTER, mte.charPositionInLine, mte.charPositionInLine,
- // getCharErrorDisplay(mte.expecting), getCharErrorDisplay(mte.c));
- // }
- SpelException realException = new SpelException(re, SpelMessages.RECOGNITION_ERROR, re.toString());
- throw new WrappedSpelException(realException);
- }
-
- @Override
- public void reportError(RecognitionException re) {
- // Do not report anything. If better messages could be reported they will have been reported
- // by the recover() method above.
- }
-
-// private String getTokenForId(int id) {
-// if (id == -1)
-// return "EOF";
-// return getTokenNames()[id];
-// }
-
-}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/antlr/SpringExpressionsParserExtender.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/antlr/SpringExpressionsParserExtender.java
deleted file mode 100644
index 0e4f390aee7..00000000000
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/antlr/SpringExpressionsParserExtender.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2002-2009 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.expression.spel.antlr;
-
-import org.antlr.runtime.BitSet;
-import org.antlr.runtime.IntStream;
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.Token;
-import org.antlr.runtime.TokenStream;
-import org.springframework.expression.spel.SpelException;
-import org.springframework.expression.spel.SpelMessages;
-import org.springframework.expression.spel.WrappedSpelException;
-import org.springframework.expression.spel.ast.SpelTreeAdaptor;
-import org.springframework.expression.spel.generated.SpringExpressionsParser;
-
-/**
- * @author Andy Clement
- * @since 3.0
- */
-class SpringExpressionsParserExtender extends SpringExpressionsParser {
-
- public SpringExpressionsParserExtender(TokenStream input) {
- super(input);
- setTreeAdaptor(new SpelTreeAdaptor());
- }
-
- /**
- * Override super type implementation and just include the character position rather than the line number since the
- * expressions are nearly all going to be just one line.
- */
- @Override
- public String getErrorHeader(RecognitionException e) {
- StringBuilder retval = new StringBuilder();
- retval.append("(pos ").append(e.charPositionInLine).append("): ");
- return retval.toString();
- }
-
- @Override
- public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
- String message = getErrorMessage(e, tokenNames);
- // TODO would something like this be worthwhile to improve messages?
- // if (message.equals("no viable alternative at input ''") && !paraphrase.isEmpty()) {
- // // This means we ran out of input building something, that something is named in paraphrase
- // message = "no more input data to process whilst constructing " + paraphrase.peek();
- // }
- SpelException parsingProblem = new SpelException(e.charPositionInLine, e, SpelMessages.PARSE_PROBLEM, message);
- throw new WrappedSpelException(parsingProblem);
- }
-
- /**
- * Overridden purely because the base implementation does a System.err.println()
- */
- @Override
- public void recoverFromMismatchedToken(IntStream input, RecognitionException e, int ttype, BitSet follow)
- throws RecognitionException {
- // if next token is what we are looking for then "delete" this token
- if (input.LA(2) == ttype) {
- reportError(e);
- /*
- * System.err.println("recoverFromMismatchedToken deleting "+input.LT(1)+ " since "+input.LT(2)+" is what we
- * want");
- */
- beginResync();
- input.consume(); // simply delete extra token
- endResync();
- input.consume(); // move past ttype token as if all were ok
- return;
- }
- if (!recoverFromMismatchedElement(input, e, follow)) {
- throw e;
- }
- }
-
- @Override
- public String getTokenErrorDisplay(Token t) {
- if (t == null) {
- return "";
- }
- return super.getTokenErrorDisplay(t);
- }
-}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Assign.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Assign.java
index 5afb0adb72a..c472ed63933 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Assign.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Assign.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
@@ -31,13 +30,13 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class Assign extends SpelNodeImpl {
- public Assign(Token payload) {
- super(payload);
+ public Assign(int pos,SpelNodeImpl... operands) {
+ super(pos,operands);
}
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
- TypedValue newValue = getChild(1).getValueInternal(state);
+ TypedValue newValue = children[1].getValueInternal(state);
getChild(0).setValue(state, newValue.getValue());
return newValue;
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/BooleanLiteral.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/BooleanLiteral.java
index 6843ee02571..b5f22baac01 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/BooleanLiteral.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/BooleanLiteral.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.spel.support.BooleanTypedValue;
/**
@@ -29,8 +28,8 @@ public class BooleanLiteral extends Literal {
private final BooleanTypedValue value;
- public BooleanLiteral(Token payload, boolean value) {
- super(payload);
+ public BooleanLiteral(String payload, int pos, boolean value) {
+ super(payload, pos);
this.value = BooleanTypedValue.forValue(value);
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/CommonTypeDescriptors.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/CommonTypeDescriptors.java
index 4505025473b..1c8cd1efaae 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/CommonTypeDescriptors.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/CommonTypeDescriptors.java
@@ -22,17 +22,16 @@ import org.springframework.core.convert.TypeDescriptor;
* @since 3.0
*/
public interface CommonTypeDescriptors {
- // TODO push into TypeDescriptor?
- static TypeDescriptor BOOLEAN_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Boolean.class);
- static TypeDescriptor INTEGER_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Integer.class);
- static TypeDescriptor CHARACTER_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Character.class);
- static TypeDescriptor LONG_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Long.class);
- static TypeDescriptor SHORT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Short.class);
- static TypeDescriptor BYTE_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Byte.class);
- static TypeDescriptor FLOAT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Float.class);
- static TypeDescriptor DOUBLE_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Double.class);
- static TypeDescriptor STRING_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(String.class);
- static TypeDescriptor CLASS_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Class.class);
- static TypeDescriptor OBJECT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Object.class);
-
+ // need a better home for these - TypeDescriptor?
+ static TypeDescriptor BOOLEAN_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Boolean.class);
+ static TypeDescriptor INTEGER_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Integer.class);
+ static TypeDescriptor CHARACTER_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Character.class);
+ static TypeDescriptor LONG_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Long.class);
+ static TypeDescriptor SHORT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Short.class);
+ static TypeDescriptor BYTE_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Byte.class);
+ static TypeDescriptor FLOAT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Float.class);
+ static TypeDescriptor DOUBLE_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Double.class);
+ static TypeDescriptor STRING_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(String.class);
+ static TypeDescriptor CLASS_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Class.class);
+ static TypeDescriptor OBJECT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Object.class);
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/CompoundExpression.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/CompoundExpression.java
index cf33e21a158..c12f736ac6c 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/CompoundExpression.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/CompoundExpression.java
@@ -16,11 +16,10 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
/**
* Represents a DOT separated expression sequence, such as 'property1.property2.methodOne()'
@@ -30,9 +29,13 @@ import org.springframework.expression.spel.SpelException;
*/
public class CompoundExpression extends SpelNodeImpl {
- public CompoundExpression(Token payload) {
- super(payload);
+ public CompoundExpression(int pos,SpelNodeImpl... expressionComponents) {
+ super(pos,expressionComponents);
+ if (expressionComponents.length<2) {
+ throw new IllegalStateException("Dont build compound expression less than one entry: "+expressionComponents.length);
+ }
}
+
/**
* Evalutes a compound expression. This involves evaluating each piece in turn and the return value from each piece
@@ -45,20 +48,20 @@ public class CompoundExpression extends SpelNodeImpl {
TypedValue result = null;
SpelNodeImpl nextNode = null;
try {
- nextNode = getChild(0);
+ nextNode = children[0];
result = nextNode.getValueInternal(state);
for (int i = 1; i < getChildCount(); i++) {
try {
state.pushActiveContextObject(result);
- nextNode = getChild(i);
+ nextNode = children[i];
result = nextNode.getValueInternal(state);
} finally {
state.popActiveContextObject();
}
}
- } catch (SpelException ee) {
+ } catch (SpelEvaluationException ee) {
// Correct the position for the error before rethrowing
- ee.setPosition(nextNode.getCharPositionInLine());
+ ee.setPosition(nextNode.getStartPosition());
throw ee;
}
return result;
@@ -70,11 +73,11 @@ public class CompoundExpression extends SpelNodeImpl {
getChild(0).setValue(state, value);
return;
}
- TypedValue ctx = getChild(0).getValueInternal(state);
+ TypedValue ctx = children[0].getValueInternal(state);
for (int i = 1; i < getChildCount() - 1; i++) {
try {
state.pushActiveContextObject(ctx);
- ctx = getChild(i).getValueInternal(state);
+ ctx = children[i].getValueInternal(state);
} finally {
state.popActiveContextObject();
}
@@ -92,11 +95,11 @@ public class CompoundExpression extends SpelNodeImpl {
if (getChildCount() == 1) {
return getChild(0).isWritable(state);
}
- TypedValue ctx = getChild(0).getValueInternal(state);
+ TypedValue ctx = children[0].getValueInternal(state);
for (int i = 1; i < getChildCount() - 1; i++) {
try {
state.pushActiveContextObject(ctx);
- ctx = getChild(i).getValueInternal(state);
+ ctx = children[i].getValueInternal(state);
} finally {
state.popActiveContextObject();
}
@@ -113,6 +116,7 @@ public class CompoundExpression extends SpelNodeImpl {
public String toStringAST() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < getChildCount(); i++) {
+ if (i>0) { sb.append("."); }
sb.append(getChild(i).toStringAST());
}
return sb.toString();
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
index 1325e9c9ceb..57dba45ba20 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
@@ -18,7 +18,6 @@ package org.springframework.expression.spel.ast;
import java.util.List;
-import org.antlr.runtime.Token;
import org.springframework.expression.AccessException;
import org.springframework.expression.ConstructorExecutor;
import org.springframework.expression.ConstructorResolver;
@@ -26,10 +25,11 @@ import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
// TODO asc array constructor call logic has been removed for now
+// TODO make this like the method referencing one
/**
* Represents the invocation of a constructor. Either a constructor on a regular type or construction of an array. When
* an array is constructed, an initializer can be specified.
@@ -42,7 +42,7 @@ import org.springframework.expression.spel.SpelMessages;
* @author Andy Clement
* @author Juergen Hoeller
* @since 3.0
- */
+ */
public class ConstructorReference extends SpelNodeImpl {
// TODO is this caching safe - passing the expression around will mean this executor is also being passed around
@@ -51,8 +51,13 @@ public class ConstructorReference extends SpelNodeImpl {
*/
private volatile ConstructorExecutor cachedExecutor;
- public ConstructorReference(Token payload) {
- super(payload);
+
+ /**
+ * Create a constructor reference. The first argument is the type, the rest are the parameters to the
+ * constructor call
+ */
+ public ConstructorReference(int pos, SpelNodeImpl... arguments) {
+ super(pos,arguments);
}
/**
@@ -73,7 +78,7 @@ public class ConstructorReference extends SpelNodeImpl {
Object[] arguments = new Object[getChildCount() - 1];
Class>[] argumentTypes = new Class[getChildCount() - 1];
for (int i = 0; i < arguments.length; i++) {
- TypedValue childValue = getChild(i + 1).getValueInternal(state);
+ TypedValue childValue = children[i + 1].getValueInternal(state);
Object value = childValue.getValue();
arguments[i] = value;
argumentTypes[i] = (value==null?Object.class:value.getClass());
@@ -92,14 +97,16 @@ public class ConstructorReference extends SpelNodeImpl {
}
// either there was no accessor or it no longer exists
- String typename = (String) getChild(0).getValueInternal(state).getValue();
+ String typename = (String) children[0].getValueInternal(state).getValue();
executorToUse = findExecutorForConstructor(typename, argumentTypes, state);
try {
this.cachedExecutor = executorToUse;
TypedValue result = executorToUse.execute(state.getEvaluationContext(), arguments);
return result;
} catch (AccessException ae) {
- throw new SpelException(ae, SpelMessages.EXCEPTION_DURING_CONSTRUCTOR_INVOCATION, typename, ae.getMessage());
+ throw new SpelEvaluationException(getStartPosition(), ae, SpelMessages.CONSTRUCTOR_INVOCATION_PROBLEM, typename,
+ FormatHelper.formatMethodForMessage("", argumentTypes));
+
}
}
@@ -110,10 +117,10 @@ public class ConstructorReference extends SpelNodeImpl {
* @param argumentTypes the types of the arguments supplied that the constructor must take
* @param state the current state of the expression
* @return a reusable ConstructorExecutor that can be invoked to run the constructor or null
- * @throws SpelException if there is a problem locating the constructor
+ * @throws SpelEvaluationException if there is a problem locating the constructor
*/
private ConstructorExecutor findExecutorForConstructor(
- String typename, Class>[] argumentTypes, ExpressionState state) throws SpelException {
+ String typename, Class>[] argumentTypes, ExpressionState state) throws SpelEvaluationException {
EvaluationContext eContext = state.getEvaluationContext();
List cResolvers = eContext.getConstructorResolvers();
@@ -125,14 +132,13 @@ public class ConstructorReference extends SpelNodeImpl {
if (cEx != null) {
return cEx;
}
- }
- catch (AccessException ex) {
- throw new SpelException(ex, SpelMessages.PROBLEM_LOCATING_CONSTRUCTOR, typename,
+ } catch (AccessException ex) {
+ throw new SpelEvaluationException(getStartPosition(),ex, SpelMessages.CONSTRUCTOR_INVOCATION_PROBLEM, typename,
FormatHelper.formatMethodForMessage("", argumentTypes));
}
}
}
- throw new SpelException(SpelMessages.CONSTRUCTOR_NOT_FOUND, typename, FormatHelper.formatMethodForMessage("",
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.CONSTRUCTOR_NOT_FOUND, typename, FormatHelper.formatMethodForMessage("",
argumentTypes));
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Dot.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Elvis.java
similarity index 50%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Dot.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Elvis.java
index c27700015ec..b551bcd9bb9 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Dot.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Elvis.java
@@ -16,33 +16,42 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
+import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
/**
- * This is used for preserving positional information from the input expression.
+ * Represents the elvis operator ?:. For an expression "a?:b" if a is not null, the value of the expression
+ * is "a", if a is null then the value of the expression is "b".
*
* @author Andy Clement
* @since 3.0
*/
-public class Dot extends SpelNodeImpl {
- // TODO Keep Dot for the positional information or remove it?
+public class Elvis extends SpelNodeImpl {
- public Dot(Token payload) {
- super(payload);
+ public Elvis(int pos, SpelNodeImpl... args) {
+ super(pos,args);
+ }
+
+ /**
+ * Evaluate the condition and if not null, return it. If it is null return the other value.
+ * @param state the expression state
+ * @throws EvaluationException if the condition does not evaluate correctly to a boolean or there is a problem
+ * executing the chosen alternative
+ */
+ @Override
+ public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
+ TypedValue value = children[0].getValueInternal(state);
+ if (value.getValue()!=null) {
+ return value;
+ } else {
+ return children[1].getValueInternal(state);
+ }
}
@Override
public String toStringAST() {
- return ".";
- }
-
- @Override
- public TypedValue getValueInternal(ExpressionState state) throws SpelException {
- // This makes Dot a do-nothing operation, but this is not free in terms of computation
- return state.getActiveContextObject();
+ return new StringBuilder().append(getChild(0).toStringAST()).append(" ?: ").append(getChild(1).toStringAST()).toString();
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
index 9721153c8db..cba4e59d096 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/FunctionReference.java
@@ -20,14 +20,13 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import org.antlr.runtime.Token;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypeConverter;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
import org.springframework.expression.spel.support.ReflectionHelper;
import org.springframework.util.ReflectionUtils;
@@ -48,26 +47,28 @@ public class FunctionReference extends SpelNodeImpl {
private final String name;
-
- public FunctionReference(Token payload) {
- super(payload);
- this.name = payload.getText();
+ public FunctionReference(String functionName, int pos, SpelNodeImpl... arguments) {
+ super(pos,arguments);
+ name = functionName;
}
-
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
TypedValue o = state.lookupVariable(name);
if (o == null) {
- throw new SpelException(SpelMessages.FUNCTION_NOT_DEFINED, name);
+ throw new SpelEvaluationException(getStartPosition(), SpelMessages.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 SpelException(SpelMessages.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, name, o.getClass());
+ throw new SpelEvaluationException(SpelMessages.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, name, o.getClass());
+ }
+ try {
+ return executeFunctionJLRMethod(state, (Method) o.getValue());
+ } catch (SpelEvaluationException se) {
+ se.setPosition(getStartPosition());
+ throw se;
}
-
- return executeFunctionJLRMethod(state, (Method) o.getValue());
}
/**
@@ -82,12 +83,12 @@ public class FunctionReference extends SpelNodeImpl {
Object[] functionArgs = getArguments(state);
if (!m.isVarArgs() && m.getParameterTypes().length != functionArgs.length) {
- throw new SpelException(SpelMessages.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION, functionArgs.length, m
+ throw new SpelEvaluationException(SpelMessages.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 SpelException(getCharPositionInLine(), SpelMessages.FUNCTION_MUST_BE_STATIC, m
+ throw new SpelEvaluationException(getStartPosition(), SpelMessages.FUNCTION_MUST_BE_STATIC, m
.getDeclaringClass().getName()
+ "." + m.getName(), name);
}
@@ -106,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 SpelException(getCharPositionInLine(), e, SpelMessages.EXCEPTION_DURING_FUNCTION_CALL, name, e
+ throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.EXCEPTION_DURING_FUNCTION_CALL, name, e
.getMessage());
} catch (IllegalAccessException e) {
- throw new SpelException(getCharPositionInLine(), e, SpelMessages.EXCEPTION_DURING_FUNCTION_CALL, name, e
+ throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.EXCEPTION_DURING_FUNCTION_CALL, name, e
.getMessage());
} catch (InvocationTargetException e) {
- throw new SpelException(getCharPositionInLine(), e, SpelMessages.EXCEPTION_DURING_FUNCTION_CALL, name, e
+ throw new SpelEvaluationException(getStartPosition(), e, SpelMessages.EXCEPTION_DURING_FUNCTION_CALL, name, e
.getMessage());
}
}
@@ -140,7 +141,7 @@ public class FunctionReference extends SpelNodeImpl {
// Compute arguments to the function
Object[] arguments = new Object[getChildCount()];
for (int i = 0; i < arguments.length; i++) {
- arguments[i] = getChild(i).getValueInternal(state).getValue();
+ arguments[i] = children[i].getValueInternal(state).getValue();
}
return arguments;
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Identifier.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Identifier.java
index f369f0c7e8e..f0a5b00411e 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Identifier.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Identifier.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
@@ -28,9 +27,9 @@ public class Identifier extends SpelNodeImpl {
private final TypedValue id;
- public Identifier(Token payload) {
- super(payload);
- this.id = new TypedValue(payload.getText(), STRING_TYPE_DESCRIPTOR);
+ public Identifier(String payload,int pos) {
+ super(pos);
+ this.id = new TypedValue(payload, STRING_TYPE_DESCRIPTOR);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java
index 76e329555c2..73c6f2e9914 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java
@@ -20,12 +20,11 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
-import org.antlr.runtime.Token;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
// TODO support multidimensional arrays
@@ -39,16 +38,17 @@ import org.springframework.expression.spel.SpelMessages;
*/
public class Indexer extends SpelNodeImpl {
- public Indexer(Token payload) {
- super(payload);
+ public Indexer(int pos,SpelNodeImpl expr) {
+ super(pos,expr);
}
+ @SuppressWarnings("unchecked")
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
TypedValue context = state.getActiveContextObject();
Object targetObject = context.getValue();
TypeDescriptor targetObjectTypeDescriptor = context.getTypeDescriptor();
- TypedValue indexValue = getChild(0).getValueInternal(state);
+ TypedValue indexValue = children[0].getValueInternal(state);
Object index = indexValue.getValue();
// Indexing into a Map
@@ -61,7 +61,7 @@ public class Indexer extends SpelNodeImpl {
int idx = (Integer)state.convertValue(index, INTEGER_TYPE_DESCRIPTOR);
if (targetObject == null) {
- throw new SpelException(SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
}
if (targetObject.getClass().isArray()) {
@@ -69,7 +69,7 @@ public class Indexer extends SpelNodeImpl {
} else if (targetObject instanceof Collection) {
Collection> c = (Collection>) targetObject;
if (idx >= c.size()) {
- throw new SpelException(SpelMessages.COLLECTION_INDEX_OUT_OF_BOUNDS, c.size(), idx);
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.COLLECTION_INDEX_OUT_OF_BOUNDS, c.size(), idx);
}
int pos = 0;
for (Object o : c) {
@@ -81,16 +81,16 @@ public class Indexer extends SpelNodeImpl {
} else if (targetObject instanceof String) {
String ctxString = (String) targetObject;
if (idx >= ctxString.length()) {
- throw new SpelException(SpelMessages.STRING_INDEX_OUT_OF_BOUNDS, ctxString.length(), idx);
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.STRING_INDEX_OUT_OF_BOUNDS, ctxString.length(), idx);
}
return new TypedValue(String.valueOf(ctxString.charAt(idx)),STRING_TYPE_DESCRIPTOR);
}
- throw new SpelException(SpelMessages.INDEXING_NOT_SUPPORTED_FOR_TYPE, targetObjectTypeDescriptor.asString());
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.INDEXING_NOT_SUPPORTED_FOR_TYPE, targetObjectTypeDescriptor.asString());
}
@Override
- public boolean isWritable(ExpressionState expressionState) throws SpelException {
+ public boolean isWritable(ExpressionState expressionState) throws SpelEvaluationException {
return true;
}
@@ -100,10 +100,10 @@ public class Indexer extends SpelNodeImpl {
TypedValue contextObject = state.getActiveContextObject();
Object targetObject = contextObject.getValue();
TypeDescriptor targetObjectTypeDescriptor = contextObject.getTypeDescriptor();
- TypedValue index = getChild(0).getValueInternal(state);
+ TypedValue index = children[0].getValueInternal(state);
if (targetObject == null) {
- throw new SpelException(SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
+ throw new SpelEvaluationException(SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
}
// Indexing into a Map
if (targetObjectTypeDescriptor.isMap()) {
@@ -121,17 +121,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 SpelException(SpelMessages.COLLECTION_INDEX_OUT_OF_BOUNDS, c.size(), idx);
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.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 SpelException(SpelMessages.INDEXING_NOT_SUPPORTED_FOR_TYPE, contextObject.getClass().getName());
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.INDEXING_NOT_SUPPORTED_FOR_TYPE, contextObject.getClass().getName());
}
} else {
- throw new SpelException(SpelMessages.INDEXING_NOT_SUPPORTED_FOR_TYPE, contextObject.getClass().getName());
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.INDEXING_NOT_SUPPORTED_FOR_TYPE, contextObject.getClass().getName());
}
}
@@ -148,6 +148,7 @@ public class Indexer extends SpelNodeImpl {
return sb.toString();
}
+ @SuppressWarnings("unchecked")
private void setArrayElement(ExpressionState state, Object ctx, int idx, Object newValue, Class clazz) throws EvaluationException {
Class> arrayComponentType = clazz;
if (arrayComponentType == Integer.TYPE) {
@@ -190,7 +191,7 @@ public class Indexer extends SpelNodeImpl {
}
- private Object accessArrayElement(Object ctx, int idx) throws SpelException {
+ private Object accessArrayElement(Object ctx, int idx) throws SpelEvaluationException {
Class> arrayComponentType = ctx.getClass().getComponentType();
if (arrayComponentType == Integer.TYPE) {
int[] array = (int[]) ctx;
@@ -232,9 +233,9 @@ public class Indexer extends SpelNodeImpl {
}
- private void checkAccess(int arrayLength, int index) throws SpelException {
+ private void checkAccess(int arrayLength, int index) throws SpelEvaluationException {
if (index > arrayLength) {
- throw new SpelException(getCharPositionInLine(), SpelMessages.ARRAY_INDEX_OUT_OF_BOUNDS, arrayLength, index);
+ throw new SpelEvaluationException(getStartPosition(), SpelMessages.ARRAY_INDEX_OUT_OF_BOUNDS, arrayLength, index);
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/IntLiteral.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/IntLiteral.java
index 2a5a92dbe0d..2b9c845fc09 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/IntLiteral.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/IntLiteral.java
@@ -1,42 +1,25 @@
-/*
- * Copyright 2002-2009 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.expression.spel.ast;
-
-import org.antlr.runtime.Token;
-import org.springframework.expression.TypedValue;
-
-/**
- * Expression language AST node that represents an integer literal.
- *
- * @author Andy Clement
- * @since 3.0
- */
-public class IntLiteral extends Literal {
-
- private final TypedValue value;
-
- IntLiteral(Token payload, int value) {
- super(payload);
- this.value = new TypedValue(value, INTEGER_TYPE_DESCRIPTOR);
- }
-
- @Override
- public TypedValue getLiteralValue() {
- return this.value;
- }
-
-}
+package org.springframework.expression.spel.ast;
+
+import org.springframework.expression.TypedValue;
+
+/**
+ * Expression language AST node that represents an integer literal.
+ *
+ * @author Andy Clement
+ * @since 3.0
+ */
+public class IntLiteral extends Literal {
+
+ private final TypedValue value;
+
+ IntLiteral(String payload, int pos, int value) {
+ super(payload, pos);
+ this.value = new TypedValue(value, INTEGER_TYPE_DESCRIPTOR);
+ }
+
+ @Override
+ public TypedValue getLiteralValue() {
+ return this.value;
+ }
+
+}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Literal.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Literal.java
index d24bdc0fe9b..f67b12556c5 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Literal.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Literal.java
@@ -16,29 +16,31 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
-import org.springframework.expression.spel.WrappedSpelException;
+import org.springframework.expression.spel.SpelParseException;
+import org.springframework.expression.spel.standard.InternalParseException;
/**
* Common superclass for nodes representing literals (boolean, string, number, etc).
*
* @author Andy Clement
- *
*/
public abstract class Literal extends SpelNodeImpl {
- public Literal(Token payload) {
- super(payload);
+ protected String literalValue;
+
+ public Literal(String payload, int pos) {
+ super(pos);
+ this.literalValue = payload;
}
public abstract TypedValue getLiteralValue();
@Override
- public final TypedValue getValueInternal(ExpressionState state) throws SpelException {
+ public final TypedValue getValueInternal(ExpressionState state) throws SpelEvaluationException {
return getLiteralValue();
}
@@ -60,37 +62,38 @@ public abstract class Literal extends SpelNodeImpl {
* @param radix the base of number
* @return a subtype of Literal that can represent it
*/
- public static Literal getIntLiteral(Token numberToken, int radix) {
- String numberString = numberToken.getText();
-
- boolean isLong = false;
- boolean isHex = (radix == 16);
-
- isLong = numberString.endsWith("L") || numberString.endsWith("l");
-
- if (isLong || isHex) { // needs to be chopped up a little
- int len = numberString.length();
- // assert: if hex then startsWith 0x or 0X
- numberString = numberString.substring((isHex ? 2 : 0), isLong ? len - 1 : len);
+ public static Literal getIntLiteral(String numberToken, int pos, int radix) {
+ try {
+ 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));
}
+ }
- if (isLong) {
- try {
- long value = Long.parseLong(numberString, radix);
- return new LongLiteral(numberToken, value);
- } catch (NumberFormatException nfe) {
- throw new WrappedSpelException(new SpelException(numberToken.getCharPositionInLine(), nfe,
- SpelMessages.NOT_A_LONG, numberToken.getText()));
- }
- } else {
- try {
- int value = Integer.parseInt(numberString, radix);
- return new IntLiteral(numberToken, value);
- } catch (NumberFormatException nfe) {
- throw new WrappedSpelException(new SpelException(numberToken.getCharPositionInLine(), nfe,
- SpelMessages.NOT_AN_INTEGER, numberToken.getText()));
+ public static Literal getLongLiteral(String numberToken, int pos, int radix) {
+ try {
+ 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));
+ }
+ }
+
+ // TODO should allow for 'f' for float, not just double
+ public static Literal getRealLiteral(String numberToken, int pos, boolean isFloat) {
+ try {
+ if (isFloat) {
+ float value = Float.parseFloat(numberToken);
+ return new RealLiteral(numberToken, pos, value);
+ } else {
+ double value = Double.parseDouble(numberToken);
+ return new RealLiteral(numberToken, pos, value);
}
+ } catch (NumberFormatException nfe) {
+ throw new InternalParseException(new SpelParseException(pos>>16, nfe, SpelMessages.NOT_A_REAL, numberToken));
}
}
}
+
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/LongLiteral.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/LongLiteral.java
index 4aaa70788c5..77eeba6a76f 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/LongLiteral.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/LongLiteral.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.TypedValue;
/**
@@ -29,8 +28,8 @@ public class LongLiteral extends Literal {
private final TypedValue value;
- LongLiteral(Token payload, long value) {
- super(payload);
+ LongLiteral(String payload, int pos, long value) {
+ super(payload, pos);
this.value = new TypedValue(value, LONG_TYPE_DESCRIPTOR);
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
index 2d60fe59f43..ef27d3b7854 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
@@ -18,7 +18,6 @@ package org.springframework.expression.spel.ast;
import java.util.List;
-import org.antlr.runtime.Token;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
@@ -26,7 +25,7 @@ import org.springframework.expression.MethodExecutor;
import org.springframework.expression.MethodResolver;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
/**
@@ -39,11 +38,12 @@ public class MethodReference extends SpelNodeImpl {
private final String name;
private volatile MethodExecutor cachedExecutor;
+ private final boolean nullSafe;
-
- public MethodReference(Token payload) {
- super(payload);
- name = payload.getText();
+ public MethodReference(boolean nullSafe, String methodName, int pos, SpelNodeImpl... arguments) {
+ super(pos,arguments);
+ name = methodName;
+ this.nullSafe = nullSafe;
}
@@ -52,11 +52,16 @@ public class MethodReference extends SpelNodeImpl {
TypedValue currentContext = state.getActiveContextObject();
Object[] arguments = new Object[getChildCount()];
for (int i = 0; i < arguments.length; i++) {
- arguments[i] = getChild(i).getValueInternal(state).getValue();
+// System.out.println(i);
+ arguments[i] = children[i].getValueInternal(state).getValue();
}
if (currentContext.getValue() == null) {
- throw new SpelException(getCharPositionInLine(), SpelMessages.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED,
- FormatHelper.formatMethodForMessage(name, getTypes(arguments)));
+ if (nullSafe) {
+ return TypedValue.NULL_TYPED_VALUE;
+ } else {
+ throw new SpelEvaluationException(getStartPosition(), SpelMessages.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED,
+ FormatHelper.formatMethodForMessage(name, getTypes(arguments)));
+ }
}
MethodExecutor executorToUse = this.cachedExecutor;
@@ -79,7 +84,7 @@ public class MethodReference extends SpelNodeImpl {
return executorToUse.execute(
state.getEvaluationContext(), state.getActiveContextObject().getValue(), arguments);
} catch (AccessException ae) {
- throw new SpelException(getCharPositionInLine(), ae, SpelMessages.EXCEPTION_DURING_METHOD_INVOCATION,
+ throw new SpelEvaluationException( getStartPosition(), ae, SpelMessages.EXCEPTION_DURING_METHOD_INVOCATION,
this.name, state.getActiveContextObject().getValue().getClass().getName(), ae.getMessage());
}
}
@@ -106,7 +111,7 @@ public class MethodReference extends SpelNodeImpl {
}
private MethodExecutor findAccessorForMethod(String name, Class>[] argumentTypes, ExpressionState state)
- throws SpelException {
+ throws SpelEvaluationException {
TypedValue context = state.getActiveContextObject();
Object contextObject = context.getValue();
@@ -123,11 +128,11 @@ public class MethodReference extends SpelNodeImpl {
}
}
catch (AccessException ex) {
- throw new SpelException(ex, SpelMessages.PROBLEM_LOCATING_METHOD, name, contextObject.getClass());
+ throw new SpelEvaluationException(getStartPosition(),ex, SpelMessages.PROBLEM_LOCATING_METHOD, name, contextObject.getClass());
}
}
}
- throw new SpelException(SpelMessages.METHOD_NOT_FOUND, FormatHelper.formatMethodForMessage(name, argumentTypes),
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.METHOD_NOT_FOUND, FormatHelper.formatMethodForMessage(name, argumentTypes),
FormatHelper.formatClassNameForMessage(contextObject instanceof Class ? ((Class>) contextObject) : contextObject.getClass()));
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/NullLiteral.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/NullLiteral.java
index 8e342e9ab5f..e79adf8dd4f 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/NullLiteral.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/NullLiteral.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.TypedValue;
/**
@@ -25,8 +24,8 @@ import org.springframework.expression.TypedValue;
*/
public class NullLiteral extends Literal {
- public NullLiteral(Token payload) {
- super(payload);
+ public NullLiteral(int pos) {
+ super(null,pos);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorEquality.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java
similarity index 90%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorEquality.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java
index 828447148ae..936f651cafc 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorEquality.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.ExpressionState;
import org.springframework.expression.spel.support.BooleanTypedValue;
@@ -27,15 +26,10 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
* @author Andy Clement
* @since 3.0
*/
-public class OperatorEquality extends Operator {
+public class OpEQ extends Operator {
- public OperatorEquality(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return "==";
+ public OpEQ(int pos, SpelNodeImpl... operands) {
+ super("==", pos, operands);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorGreaterThanOrEqual.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpGE.java
similarity index 89%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorGreaterThanOrEqual.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpGE.java
index e028bc0feb7..d3cd0c9df7c 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorGreaterThanOrEqual.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpGE.java
@@ -15,7 +15,6 @@
*/
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.ExpressionState;
import org.springframework.expression.spel.support.BooleanTypedValue;
@@ -26,15 +25,10 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
* @author Andy Clement
* @since 3.0
*/
-public class OperatorGreaterThanOrEqual extends Operator {
+public class OpGE extends Operator {
- public OperatorGreaterThanOrEqual(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return ">=";
+ public OpGE(int pos, SpelNodeImpl... operands) {
+ super(">=", pos, operands);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorGreaterThan.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpGT.java
similarity index 89%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorGreaterThan.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpGT.java
index 0636b9e4871..e2b088a2f51 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorGreaterThan.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpGT.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.ExpressionState;
import org.springframework.expression.spel.support.BooleanTypedValue;
@@ -27,15 +26,10 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
* @author Andy Clement
* @since 3.0
*/
-public class OperatorGreaterThan extends Operator {
+public class OpGT extends Operator {
- public OperatorGreaterThan(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return ">";
+ public OpGT(int pos, SpelNodeImpl... operands) {
+ super(">", pos, operands);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorLessThanOrEqual.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpLE.java
similarity index 89%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorLessThanOrEqual.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpLE.java
index 54555d18674..559cd7ea440 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorLessThanOrEqual.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpLE.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.ExpressionState;
import org.springframework.expression.spel.support.BooleanTypedValue;
@@ -27,10 +26,10 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
* @author Andy Clement
* @since 3.0
*/
-public class OperatorLessThanOrEqual extends Operator {
+public class OpLE extends Operator {
- public OperatorLessThanOrEqual(Token payload) {
- super(payload);
+ public OpLE(int pos, SpelNodeImpl... operands) {
+ super("<=", pos, operands);
}
@Override
@@ -51,9 +50,4 @@ public class OperatorLessThanOrEqual extends Operator {
return BooleanTypedValue.forValue( state.getTypeComparator().compare(left, right) <= 0);
}
- @Override
- public String getOperatorName() {
- return "<=";
- }
-
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorLessThan.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpLT.java
similarity index 90%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorLessThan.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpLT.java
index 1917d1f4fc9..4b708fbeedd 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorLessThan.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpLT.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.ExpressionState;
import org.springframework.expression.spel.support.BooleanTypedValue;
@@ -27,17 +26,12 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
* @author Andy Clement
* @since 3.0
*/
-public class OperatorLessThan extends Operator {
+public class OpLT extends Operator {
- public OperatorLessThan(Token payload) {
- super(payload);
+ public OpLT(int pos, SpelNodeImpl... operands) {
+ super("<", pos, operands);
}
-
- @Override
- public String getOperatorName() {
- return "<";
- }
-
+
@Override
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
Object left = getLeftOperand().getValueInternal(state).getValue();
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorInequality.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java
similarity index 90%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorInequality.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java
index 6a21a5289e6..aebcb852777 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorInequality.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.ExpressionState;
import org.springframework.expression.spel.support.BooleanTypedValue;
@@ -27,15 +26,10 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
* @author Andy Clement
* @since 3.0
*/
-public class OperatorInequality extends Operator {
+public class OpNE extends Operator {
- public OperatorInequality(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return "!=";
+ public OpNE(int pos, SpelNodeImpl... operands) {
+ super("!=", pos, operands);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Operator.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Operator.java
index 670bfb8b38e..79c190f4640 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Operator.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Operator.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
/**
* Common supertype for operators that operate on either one or two operands. In the case of multiply or divide there
@@ -27,19 +26,24 @@ import org.antlr.runtime.Token;
*/
public abstract class Operator extends SpelNodeImpl {
- public Operator(Token payload) {
- super(payload);
+ String operatorName;
+
+ public Operator(String payload,int pos,SpelNodeImpl... operands) {
+ super(pos, operands);
+ this.operatorName = payload;
}
public SpelNodeImpl getLeftOperand() {
- return getChild(0);
+ return children[0];
}
public SpelNodeImpl getRightOperand() {
- return getChild(1);
+ return children[1];
}
- public abstract String getOperatorName();
+ public final String getOperatorName() {
+ return operatorName;
+ }
/**
* String format for all operators is the same '(' [operand] [operator] [operand] ')'
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorAnd.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorAnd.java
index 8a4d048bf3e..2dffb11a9e8 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorAnd.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorAnd.java
@@ -16,11 +16,10 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.support.BooleanTypedValue;
/**
@@ -31,13 +30,8 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
*/
public class OperatorAnd extends Operator {
- public OperatorAnd(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return "and";
+ public OperatorAnd(int pos, SpelNodeImpl... operands) {
+ super("and", pos, operands);
}
@Override
@@ -48,8 +42,8 @@ public class OperatorAnd extends Operator {
try {
leftValue = (Boolean)state.convertValue(getLeftOperand().getValueInternal(state), BOOLEAN_TYPE_DESCRIPTOR);
}
- catch (SpelException ee) {
- ee.setPosition(getLeftOperand().getCharPositionInLine());
+ catch (SpelEvaluationException ee) {
+ ee.setPosition(getLeftOperand().getStartPosition());
throw ee;
}
@@ -60,8 +54,8 @@ public class OperatorAnd extends Operator {
try {
rightValue = (Boolean)state.convertValue(getRightOperand().getValueInternal(state), BOOLEAN_TYPE_DESCRIPTOR);
}
- catch (SpelException ee) {
- ee.setPosition(getRightOperand().getCharPositionInLine());
+ catch (SpelEvaluationException ee) {
+ ee.setPosition(getRightOperand().getStartPosition());
throw ee;
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorBetween.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorBetween.java
index 8dd7c7870cf..12d3461f371 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorBetween.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorBetween.java
@@ -18,11 +18,10 @@ package org.springframework.expression.spel.ast;
import java.util.List;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypeComparator;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
import org.springframework.expression.spel.support.BooleanTypedValue;
@@ -36,13 +35,8 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
*/
public class OperatorBetween extends Operator {
- public OperatorBetween(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return "between";
+ public OperatorBetween(int pos, SpelNodeImpl... operands) {
+ super("between", pos, operands);
}
/**
@@ -57,7 +51,7 @@ public class OperatorBetween extends Operator {
Object left = getLeftOperand().getValueInternal(state).getValue();
Object right = getRightOperand().getValueInternal(state).getValue();
if (!(right instanceof List) || ((List>) right).size() != 2) {
- throw new SpelException(getRightOperand().getCharPositionInLine(),
+ throw new SpelEvaluationException(getRightOperand().getStartPosition(),
SpelMessages.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST);
}
List> l = (List>) right;
@@ -66,8 +60,8 @@ public class OperatorBetween extends Operator {
TypeComparator comparator = state.getTypeComparator();
try {
return BooleanTypedValue.forValue((comparator.compare(left, low) >= 0 && comparator.compare(left, high) <= 0));
- } catch (SpelException ex) {
- ex.setPosition(getCharPositionInLine());
+ } catch (SpelEvaluationException ex) {
+ ex.setPosition(getStartPosition());
throw ex;
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorDivide.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorDivide.java
index 4521d331d9c..503b3acd89a 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorDivide.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorDivide.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Operation;
@@ -31,13 +30,8 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class OperatorDivide extends Operator {
- public OperatorDivide(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return "/";
+ public OperatorDivide(int pos, SpelNodeImpl... operands) {
+ super("/", pos, operands);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java
index 5c67ae00426..1c7fded5f5b 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java
@@ -16,11 +16,10 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
import org.springframework.expression.spel.support.BooleanTypedValue;
@@ -33,13 +32,8 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
*/
public class OperatorInstanceof extends Operator {
- public OperatorInstanceof(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return "instanceof";
+ public OperatorInstanceof(int pos, SpelNodeImpl... operands) {
+ super("instanceof", pos, operands);
}
/**
@@ -59,7 +53,7 @@ public class OperatorInstanceof extends Operator {
return BooleanTypedValue.False; // null is not an instanceof anything
}
if (rightValue == null || !(rightValue instanceof Class>)) {
- throw new SpelException(getRightOperand().getCharPositionInLine(),
+ throw new SpelEvaluationException(getRightOperand().getStartPosition(),
SpelMessages.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND,
(rightValue == null ? "null" : rightValue.getClass().getName()));
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMatches.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMatches.java
index c52e9d0d4e3..9bd20ece67b 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMatches.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMatches.java
@@ -20,10 +20,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
import org.springframework.expression.spel.support.BooleanTypedValue;
@@ -36,13 +35,8 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
*/
public class OperatorMatches extends Operator {
- public OperatorMatches(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return "matches";
+ public OperatorMatches(int pos, SpelNodeImpl... operands) {
+ super("matches", pos, operands);
}
/**
@@ -59,11 +53,11 @@ public class OperatorMatches extends Operator {
Object right = getRightOperand().getValueInternal(state).getValue();
try {
if (!(left instanceof String)) {
- throw new SpelException(leftOp.getCharPositionInLine(),
+ throw new SpelEvaluationException(leftOp.getStartPosition(),
SpelMessages.INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR, left);
}
if (!(right instanceof String)) {
- throw new SpelException(rightOp.getCharPositionInLine(),
+ throw new SpelEvaluationException(rightOp.getStartPosition(),
SpelMessages.INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR, right);
}
Pattern pattern = Pattern.compile((String) right);
@@ -71,7 +65,7 @@ public class OperatorMatches extends Operator {
return BooleanTypedValue.forValue(matcher.matches());
}
catch (PatternSyntaxException pse) {
- throw new SpelException(rightOp.getCharPositionInLine(), pse, SpelMessages.INVALID_PATTERN, right);
+ throw new SpelEvaluationException(rightOp.getStartPosition(), pse, SpelMessages.INVALID_PATTERN, right);
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMinus.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMinus.java
index 45a2ac3dff2..db7dcbe5257 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMinus.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMinus.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Operation;
import org.springframework.expression.TypedValue;
@@ -39,8 +38,8 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class OperatorMinus extends Operator {
- public OperatorMinus(Token payload) {
- super(payload);
+ public OperatorMinus(int pos, SpelNodeImpl... operands) {
+ super("-", pos, operands);
}
@Override
@@ -83,11 +82,6 @@ public class OperatorMinus extends Operator {
}
}
- @Override
- public String getOperatorName() {
- return "-";
- }
-
@Override
public String toStringAST() {
if (getRightOperand() == null) { // unary minus
@@ -95,5 +89,9 @@ public class OperatorMinus extends Operator {
}
return super.toStringAST();
}
+ public SpelNodeImpl getRightOperand() {
+ if (children.length<2) {return null;}
+ return children[1];
+ }
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorModulus.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorModulus.java
index 20789c75f5f..08504b55e2a 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorModulus.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorModulus.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Operation;
import org.springframework.expression.TypedValue;
@@ -30,13 +29,8 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class OperatorModulus extends Operator {
- public OperatorModulus(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return "%";
+ public OperatorModulus(int pos, SpelNodeImpl... operands) {
+ super("%", pos, operands);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMultiply.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMultiply.java
index e788f7e3386..80561ce3cc1 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMultiply.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorMultiply.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Operation;
import org.springframework.expression.TypedValue;
@@ -39,8 +38,9 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class OperatorMultiply extends Operator {
- public OperatorMultiply(Token payload) {
- super(payload);
+
+ public OperatorMultiply(int pos, SpelNodeImpl... operands) {
+ super("*", pos, operands);
}
/**
@@ -77,9 +77,4 @@ public class OperatorMultiply extends Operator {
return state.operate(Operation.MULTIPLY, operandOne, operandTwo);
}
- @Override
- public String getOperatorName() {
- return "*";
- }
-
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java
index 771e681acbd..426693e247c 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java
@@ -16,10 +16,9 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.support.BooleanTypedValue;
/**
@@ -30,18 +29,18 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
*/
public class OperatorNot extends SpelNodeImpl { // Not is a unary operator so do not extend BinaryOperator
- public OperatorNot(Token payload) {
- super(payload);
+ public OperatorNot(int pos, SpelNodeImpl operand) {
+ super(pos, operand);
}
-
+
@Override
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
try {
- boolean value = (Boolean)state.convertValue(getChild(0).getValueInternal(state), BOOLEAN_TYPE_DESCRIPTOR);
+ boolean value = (Boolean)state.convertValue(children[0].getValueInternal(state), BOOLEAN_TYPE_DESCRIPTOR);
return BooleanTypedValue.forValue(!value);
}
- catch (SpelException see) {
- see.setPosition(getChild(0).getCharPositionInLine());
+ catch (SpelEvaluationException see) {
+ see.setPosition(getChild(0).getStartPosition());
throw see;
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorOr.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorOr.java
index 8087c80d080..4df05be373e 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorOr.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorOr.java
@@ -16,10 +16,9 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.support.BooleanTypedValue;
/**
@@ -30,13 +29,8 @@ import org.springframework.expression.spel.support.BooleanTypedValue;
*/
public class OperatorOr extends Operator {
- public OperatorOr(Token payload) {
- super(payload);
- }
-
- @Override
- public String getOperatorName() {
- return "or";
+ public OperatorOr(int pos, SpelNodeImpl... operands) {
+ super("or", pos, operands);
}
@Override
@@ -46,8 +40,8 @@ public class OperatorOr extends Operator {
try {
leftValue = (Boolean)state.convertValue(getLeftOperand().getValueInternal(state), BOOLEAN_TYPE_DESCRIPTOR);
}
- catch (SpelException see) {
- see.setPosition(getLeftOperand().getCharPositionInLine());
+ catch (SpelEvaluationException see) {
+ see.setPosition(getLeftOperand().getStartPosition());
throw see;
}
@@ -58,8 +52,8 @@ public class OperatorOr extends Operator {
try {
rightValue = (Boolean)state.convertValue(getRightOperand().getValueInternal(state), BOOLEAN_TYPE_DESCRIPTOR);
}
- catch (SpelException see) {
- see.setPosition(getRightOperand().getCharPositionInLine());
+ catch (SpelEvaluationException see) {
+ see.setPosition(getRightOperand().getStartPosition()); // TODO end positions here and in similar situations
throw see;
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPlus.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPlus.java
index 59f22e2b759..85fbc178130 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPlus.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPlus.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Operation;
import org.springframework.expression.TypedValue;
@@ -38,8 +37,8 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class OperatorPlus extends Operator {
- public OperatorPlus(Token payload) {
- super(payload);
+ public OperatorPlus(int pos, SpelNodeImpl... operands) {
+ super("+", pos, operands);
}
@Override
@@ -79,17 +78,18 @@ public class OperatorPlus extends Operator {
}
}
- @Override
- public String getOperatorName() {
- return "+";
- }
-
@Override
public String toStringAST() {
- if (getRightOperand() == null) { // unary plus
+ if (children.length<2) { // unary plus
return new StringBuilder().append("+").append(getLeftOperand().toStringAST()).toString();
}
return super.toStringAST();
}
+ public SpelNodeImpl getRightOperand() {
+ if (children.length<2) {return null;}
+ return children[1];
+ }
+
+
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPower.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPower.java
index 2e84e169fe2..24134b47cad 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPower.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorPower.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Operation;
import org.springframework.expression.TypedValue;
@@ -30,8 +29,8 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class OperatorPower extends Operator {
- public OperatorPower(Token payload) {
- super(payload);
+ public OperatorPower(int pos, SpelNodeImpl... operands) {
+ super("^", pos, operands);
}
@Override
@@ -61,9 +60,4 @@ public class OperatorPower extends Operator {
return state.operate(Operation.POWER, operandOne, operandTwo);
}
- @Override
- public String getOperatorName() {
- return "^";
- }
-
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java
index 1e22430aa5d..50ed7d94ea6 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java
@@ -21,12 +21,11 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
-import org.antlr.runtime.Token;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
/**
@@ -39,10 +38,14 @@ import org.springframework.expression.spel.SpelMessages;
*/
public class Projection extends SpelNodeImpl {
- public Projection(Token payload) {
- super(payload);
+ private final boolean nullSafe;
+
+ public Projection(boolean nullSafe, int pos,SpelNodeImpl expression) {
+ super(pos,expression);
+ this.nullSafe = nullSafe;
}
+ @SuppressWarnings("unchecked")
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
TypedValue op = state.getActiveContextObject();
@@ -61,7 +64,7 @@ public class Projection extends SpelNodeImpl {
for (Map.Entry entry : mapdata.entrySet()) {
try {
state.pushActiveContextObject(new TypedValue(entry,TypeDescriptor.valueOf(Map.Entry.class)));
- result.add(getChild(0).getValueInternal(state).getValue());
+ result.add(children[0].getValueInternal(state).getValue());
} finally {
state.popActiveContextObject();
}
@@ -76,7 +79,7 @@ public class Projection extends SpelNodeImpl {
try {
state.pushActiveContextObject(new TypedValue(element,TypeDescriptor.valueOf(op.getTypeDescriptor().getType())));
state.enterScope("index", idx);
- result.add(getChild(0).getValueInternal(state).getValue());
+ result.add(children[0].getValueInternal(state).getValue());
} finally {
state.exitScope();
state.popActiveContextObject();
@@ -85,7 +88,11 @@ public class Projection extends SpelNodeImpl {
}
return new TypedValue(result,op.getTypeDescriptor());
} else {
- throw new SpelException(SpelMessages.PROJECTION_NOT_SUPPORTED_ON_TYPE, operand.getClass().getName());
+ if (operand==null && nullSafe) {
+ return TypedValue.NULL_TYPED_VALUE;
+ } else {
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.PROJECTION_NOT_SUPPORTED_ON_TYPE, operand.getClass().getName());
+ }
}
}
@@ -94,5 +101,5 @@ public class Projection extends SpelNodeImpl {
StringBuilder sb = new StringBuilder();
return sb.append("![").append(getChild(0).toStringAST()).append("]").toString();
}
-
+
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
index 6673cfcddea..4ee7970aa64 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
@@ -19,13 +19,12 @@ package org.springframework.expression.spel.ast;
import java.util.ArrayList;
import java.util.List;
-import org.antlr.runtime.Token;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
/**
@@ -43,24 +42,26 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
private volatile PropertyAccessor cachedWriteAccessor;
- public PropertyOrFieldReference(Token payload) {
- super(payload);
- this.name = payload.getText();
+ private final boolean nullSafe;
+
+ public PropertyOrFieldReference(boolean nullSafe, String propertyOrFieldName, int pos) {
+ super(pos);
+ name = propertyOrFieldName;
+ this.nullSafe = nullSafe;
}
-
@Override
- public TypedValue getValueInternal(ExpressionState state) throws SpelException {
+ public TypedValue getValueInternal(ExpressionState state) throws SpelEvaluationException {
return readProperty(state, this.name);
}
@Override
- public void setValue(ExpressionState state, Object newValue) throws SpelException {
+ public void setValue(ExpressionState state, Object newValue) throws SpelEvaluationException {
writeProperty(state, this.name, newValue);
}
@Override
- public boolean isWritable(ExpressionState state) throws SpelException {
+ public boolean isWritable(ExpressionState state) throws SpelEvaluationException {
return isWritableProperty(this.name, state);
}
@@ -74,12 +75,16 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
* @param state the evaluation state
* @param name the name of the property
* @return the value of the property
- * @throws SpelException if any problem accessing the property or it cannot be found
+ * @throws SpelEvaluationException if any problem accessing the property or it cannot be found
*/
- private TypedValue readProperty(ExpressionState state, String name) throws SpelException {
+ private TypedValue readProperty(ExpressionState state, String name) throws SpelEvaluationException {
TypedValue contextObject = state.getActiveContextObject();
EvaluationContext eContext = state.getEvaluationContext();
+ if (contextObject.getValue() == null && nullSafe) {
+ return TypedValue.NULL_TYPED_VALUE;
+ }
+
PropertyAccessor accessorToUse = this.cachedReadAccessor;
if (accessorToUse != null) {
try {
@@ -108,20 +113,24 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
}
}
catch (AccessException ae) {
- throw new SpelException(ae, SpelMessages.EXCEPTION_DURING_PROPERTY_READ, name, ae.getMessage());
+ throw new SpelEvaluationException(ae, SpelMessages.EXCEPTION_DURING_PROPERTY_READ, name, ae.getMessage());
}
}
if (contextObject.getValue() == null) {
- throw new SpelException(SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL, name);
+ throw new SpelEvaluationException(SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL, name);
} else {
- throw new SpelException(SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE, name,
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE, name,
FormatHelper.formatClassNameForMessage(contextObjectClass));
}
}
- private void writeProperty(ExpressionState state, String name, Object newValue) throws SpelException {
+ private void writeProperty(ExpressionState state, String name, Object newValue) throws SpelEvaluationException {
TypedValue contextObject = state.getActiveContextObject();
EvaluationContext eContext = state.getEvaluationContext();
+
+ if (contextObject.getValue() == null && nullSafe) {
+ return;
+ }
PropertyAccessor accessorToUse = this.cachedWriteAccessor;
if (accessorToUse != null) {
@@ -149,19 +158,19 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
}
}
} catch (AccessException ae) {
- throw new SpelException(getCharPositionInLine(), ae, SpelMessages.EXCEPTION_DURING_PROPERTY_WRITE,
+ throw new SpelEvaluationException(getStartPosition(), ae, SpelMessages.EXCEPTION_DURING_PROPERTY_WRITE,
name, ae.getMessage());
}
}
if (contextObject.getValue()==null) {
- throw new SpelException(SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL, name);
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL, name);
} else {
- throw new SpelException(SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE, name, FormatHelper
+ throw new SpelEvaluationException(getStartPosition(),SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE, name, FormatHelper
.formatClassNameForMessage(contextObjectClass));
}
}
- public boolean isWritableProperty(String name, ExpressionState state) throws SpelException {
+ public boolean isWritableProperty(String name, ExpressionState state) throws SpelEvaluationException {
Object contextObject = state.getActiveContextObject().getValue();
EvaluationContext eContext = state.getEvaluationContext();
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/QualifiedIdentifier.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/QualifiedIdentifier.java
index fbdf6fd9f00..fc990dcd95a 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/QualifiedIdentifier.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/QualifiedIdentifier.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
@@ -31,11 +30,11 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class QualifiedIdentifier extends SpelNodeImpl {
+ // TODO safe to cache? dont think so
private TypedValue value;
- public QualifiedIdentifier(Token payload) {
- super(payload);
- // value = payload.getText();
+ public QualifiedIdentifier(int pos,SpelNodeImpl... operands) {
+ super(pos,operands);
}
@Override
@@ -47,7 +46,7 @@ public class QualifiedIdentifier extends SpelNodeImpl {
if (i > 0) {
sb.append(".");
}
- sb.append(getChild(i).getValueInternal(state).getValue());
+ sb.append(children[i].getValueInternal(state).getValue());
}
this.value = new TypedValue(sb.toString(),STRING_TYPE_DESCRIPTOR);
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/RealLiteral.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/RealLiteral.java
index 3a9c36864f8..6f1a67de9b2 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/RealLiteral.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/RealLiteral.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.TypedValue;
/**
@@ -27,9 +26,9 @@ public class RealLiteral extends Literal {
private final TypedValue value;
- public RealLiteral(Token payload) {
- super(payload);
- value = new TypedValue(Double.parseDouble(payload.getText()),DOUBLE_TYPE_DESCRIPTOR);
+ public RealLiteral(String payload, int pos, double value) {
+ super(payload, pos);
+ this.value = new TypedValue(value,DOUBLE_TYPE_DESCRIPTOR);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java
index 8efaffefb56..55188a84934 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java
@@ -22,12 +22,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.antlr.runtime.Token;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
/**
@@ -46,18 +45,21 @@ public class Selection extends SpelNodeImpl {
public final static int LAST = 2; // $[]
private final int variant;
+ private final boolean nullSafe;
- public Selection(Token payload, int variant) {
- super(payload);
+ public Selection(boolean nullSafe, int variant,int pos,SpelNodeImpl expression) {
+ super(pos,expression);
+ this.nullSafe = nullSafe;
this.variant = variant;
}
+ @SuppressWarnings("unchecked")
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
TypedValue op = state.getActiveContextObject();
Object operand = op.getValue();
- SpelNodeImpl selectionCriteria = getChild(0);
+ SpelNodeImpl selectionCriteria = children[0];
if (operand instanceof Map) {
Map, ?> mapdata = (Map, ?>) operand;
// TODO don't lose generic info for the new map
@@ -78,7 +80,7 @@ public class Selection extends SpelNodeImpl {
result.put(entry.getKey(),entry.getValue());
}
} else {
- throw new SpelException(selectionCriteria.getCharPositionInLine(),
+ throw new SpelEvaluationException(selectionCriteria.getStartPosition(),
SpelMessages.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);// ,selectionCriteria.stringifyAST());
}
} finally {
@@ -113,7 +115,7 @@ public class Selection extends SpelNodeImpl {
result.add(element);
}
} else {
- throw new SpelException(selectionCriteria.getCharPositionInLine(),
+ throw new SpelEvaluationException(selectionCriteria.getStartPosition(),
SpelMessages.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);// ,selectionCriteria.stringifyAST());
}
idx++;
@@ -130,8 +132,12 @@ public class Selection extends SpelNodeImpl {
}
return new TypedValue(result,op.getTypeDescriptor());
} else {
- throw new SpelException(getCharPositionInLine(), SpelMessages.INVALID_TYPE_FOR_SELECTION,
- (operand == null ? "null" : operand.getClass().getName()));
+ if (operand==null && nullSafe) {
+ return TypedValue.NULL_TYPED_VALUE;
+ } else {
+ throw new SpelEvaluationException(getStartPosition(), SpelMessages.INVALID_TYPE_FOR_SELECTION,
+ (operand == null ? "null" : operand.getClass().getName()));
+ }
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
index 1f75ea90c75..a798a554bde 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
@@ -16,18 +16,13 @@
package org.springframework.expression.spel.ast;
-import java.io.Serializable;
-
-import org.antlr.runtime.Token;
-import org.antlr.runtime.tree.CommonTree;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.common.ExpressionUtils;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
import org.springframework.expression.spel.SpelNode;
-import org.springframework.expression.spel.generated.SpringExpressionsParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
/**
@@ -36,14 +31,22 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
* @author Andy Clement
* @since 3.0
*/
-public abstract class SpelNodeImpl extends CommonTree implements SpelNode, Serializable, CommonTypeDescriptors {
+public abstract class SpelNodeImpl implements SpelNode, CommonTypeDescriptors {
- /**
- * The Antlr parser uses this constructor to build SpelNodes.
- * @param payload the token for the node that has been parsed
- */
- protected SpelNodeImpl(Token payload) {
- super(payload);
+ private static SpelNodeImpl[] NO_CHILDREN = new SpelNodeImpl[0];
+
+ protected int pos; // start = top 16bits, end = bottom 16bits
+ protected SpelNodeImpl[] children = SpelNodeImpl.NO_CHILDREN;
+
+ public SpelNodeImpl(int pos, SpelNodeImpl... operands) {
+ this.pos = pos;
+ if (pos==0) {
+ // pos embodies start and end so can never be zero because tokens cannot be zero length
+ throw new IllegalStateException("Node cannot have zero position: "+this.getClass());
+ }
+ if (operands!=null && operands.length>0) {
+ this.children = operands;
+ }
}
public final Object getValue(ExpressionState expressionState) throws EvaluationException {
@@ -60,20 +63,15 @@ public abstract class SpelNodeImpl extends CommonTree implements SpelNode, Seria
}
public void setValue(ExpressionState expressionState, Object newValue) throws EvaluationException {
- throw new SpelException(
- getCharPositionInLine(), SpelMessages.SETVALUE_NOT_SUPPORTED, getClass(), getTokenName());
+ throw new SpelEvaluationException(getStartPosition(), SpelMessages.SETVALUE_NOT_SUPPORTED, getClass());
}
- protected String getTokenName() {
- if (getToken() == null) {
- return "UNKNOWN";
- }
- return SpringExpressionsParser.tokenNames[getToken().getType()];
+ public SpelNode getChild(int index) {
+ return children[index];
}
-
- @Override
- public SpelNodeImpl getChild(int index) {
- return (SpelNodeImpl) super.getChild(index);
+
+ public int getChildCount() {
+ return children.length;
}
public Class> getObjectClass(Object obj) {
@@ -97,13 +95,16 @@ public abstract class SpelNodeImpl extends CommonTree implements SpelNode, Seria
return (T) result;
}
- public int getStartPosition() {
- return getCharPositionInLine();
- }
-
-
public abstract TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException;
public abstract String toStringAST();
+ public int getStartPosition() {
+ return (pos>>16);
+ }
+
+ public int getEndPosition() {
+ return (pos&0xffff);
+ }
+
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/SpelTreeAdaptor.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/SpelTreeAdaptor.java
deleted file mode 100644
index cfcd3f3a5a1..00000000000
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/SpelTreeAdaptor.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2002-2009 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.expression.spel.ast;
-
-import org.antlr.runtime.Token;
-import org.antlr.runtime.tree.CommonTreeAdaptor;
-import org.springframework.expression.spel.generated.SpringExpressionsLexer;
-
-/**
- * @author Andy Clement
- * @since 3.0
- */
-public class SpelTreeAdaptor extends CommonTreeAdaptor {
-
- @Override
- public Object create(Token payload) {
- if (payload != null) {
- switch (payload.getType()) {
-
- case SpringExpressionsLexer.TRUE:
- return new BooleanLiteral(payload, true);
- case SpringExpressionsLexer.FALSE:
- return new BooleanLiteral(payload, false);
-
- case SpringExpressionsLexer.OR:
- return new OperatorOr(payload);
- case SpringExpressionsLexer.AND:
- return new OperatorAnd(payload);
- case SpringExpressionsLexer.BANG:
- return new OperatorNot(payload);
-
- case SpringExpressionsLexer.REAL_LITERAL:
- return new RealLiteral(payload);
- case SpringExpressionsLexer.INTEGER_LITERAL:
- return Literal.getIntLiteral(payload, 10);
- case SpringExpressionsLexer.HEXADECIMAL_INTEGER_LITERAL:
- return Literal.getIntLiteral(payload, 16);
-
- case SpringExpressionsLexer.NOT_EQUAL:
- return new OperatorInequality(payload);
- case SpringExpressionsLexer.EQUAL:
- return new OperatorEquality(payload);
- case SpringExpressionsLexer.GREATER_THAN:
- return new OperatorGreaterThan(payload);
- case SpringExpressionsLexer.LESS_THAN:
- return new OperatorLessThan(payload);
- case SpringExpressionsLexer.LESS_THAN_OR_EQUAL:
- return new OperatorLessThanOrEqual(payload);
- case SpringExpressionsLexer.GREATER_THAN_OR_EQUAL:
- return new OperatorGreaterThanOrEqual(payload);
- case SpringExpressionsLexer.PLUS:
- return new OperatorPlus(payload);
- case SpringExpressionsLexer.MINUS:
- return new OperatorMinus(payload);
- case SpringExpressionsLexer.STAR/* MULTIPLY */:
- return new OperatorMultiply(payload);
- case SpringExpressionsLexer.DIV/* DIVIDE */:
- return new OperatorDivide(payload);
- case SpringExpressionsLexer.MOD:
- return new OperatorModulus(payload);
- case SpringExpressionsLexer.POWER:
- return new OperatorPower(payload);
-
-
- case SpringExpressionsLexer.STRING_LITERAL:
- case SpringExpressionsLexer.DQ_STRING_LITERAL:
- return new StringLiteral(payload);
- case SpringExpressionsLexer.NULL_LITERAL:
- return new NullLiteral(payload);
-
- case SpringExpressionsLexer.ID:
- return new Identifier(payload);
- case SpringExpressionsLexer.PROPERTY_OR_FIELD:
- return new PropertyOrFieldReference(payload);
- case SpringExpressionsLexer.METHOD:
- return new MethodReference(payload);
- case SpringExpressionsLexer.QUALIFIED_IDENTIFIER:
- return new QualifiedIdentifier(payload);
- case SpringExpressionsLexer.TYPEREF:
- return new TypeReference(payload);
-
- case SpringExpressionsLexer.EXPRESSION:
- return new CompoundExpression(payload);
-
- case SpringExpressionsLexer.CONSTRUCTOR:
- return new ConstructorReference(payload);
- case SpringExpressionsLexer.VARIABLEREF:
- return new VariableReference(payload);
- case SpringExpressionsLexer.FUNCTIONREF:
- return new FunctionReference(payload);
- case SpringExpressionsLexer.PROJECT:
- return new Projection(payload);
- case SpringExpressionsLexer.SELECT:
- return new Selection(payload, Selection.ALL);
- case SpringExpressionsLexer.SELECT_FIRST:
- return new Selection(payload, Selection.FIRST);
- case SpringExpressionsLexer.SELECT_LAST:
- return new Selection(payload, Selection.LAST);
-
- case SpringExpressionsLexer.ASSIGN:
- return new Assign(payload);
- case SpringExpressionsLexer.QMARK:
- return new Ternary(payload);
- case SpringExpressionsLexer.INDEXER:
- return new Indexer(payload);
-
- case SpringExpressionsLexer.BETWEEN:
- return new OperatorBetween(payload);
- case SpringExpressionsLexer.MATCHES:
- return new OperatorMatches(payload);
- case SpringExpressionsLexer.INSTANCEOF:
- return new OperatorInstanceof(payload);
-
- case SpringExpressionsLexer.DOT:
- return new Dot(payload);
-
- default:
- throw new RuntimeException("Not implemented for '" + payload + "' " + getToken(payload) + "' "
- + payload.getType());
- }
- }
- return new EmptySpelNode(payload);
- }
-
-}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/StringLiteral.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/StringLiteral.java
index 89e21659e46..729cefb7463 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/StringLiteral.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/StringLiteral.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.TypedValue;
/**
@@ -28,12 +27,11 @@ public class StringLiteral extends Literal {
private final TypedValue value;
- public StringLiteral(Token payload) {
- super(payload);
- String val = payload.getText();
+ public StringLiteral(String payload, int pos, String value) {
+ super(payload,pos);
// TODO should these have been skipped being created by the parser rules? or not?
- val = val.substring(1, val.length() - 1);
- this.value = new TypedValue(val.replaceAll("''", "'"),STRING_TYPE_DESCRIPTOR);
+ value = value.substring(1, value.length() - 1);
+ this.value = new TypedValue(value.replaceAll("''", "'"),STRING_TYPE_DESCRIPTOR);
}
@Override
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Ternary.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Ternary.java
index 2f858633673..46f1f389339 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Ternary.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Ternary.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
@@ -30,8 +29,9 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class Ternary extends SpelNodeImpl {
- public Ternary(Token payload) {
- super(payload);
+
+ public Ternary(int pos, SpelNodeImpl... args) {
+ super(pos,args);
}
/**
@@ -42,11 +42,11 @@ public class Ternary extends SpelNodeImpl {
*/
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
- Boolean value = getChild(0).getValue(state, Boolean.class);
+ Boolean value = children[0].getValue(state, Boolean.class);
if (value.booleanValue()) {
- return getChild(1).getValueInternal(state);
+ return children[1].getValueInternal(state);
} else {
- return getChild(2).getValueInternal(state);
+ return children[2].getValueInternal(state);
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java
index 8368e9a3993..ac7b38a3f11 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/TypeReference.java
@@ -16,7 +16,6 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
@@ -28,14 +27,14 @@ import org.springframework.expression.spel.ExpressionState;
*/
public class TypeReference extends SpelNodeImpl {
- public TypeReference(Token payload) {
- super(payload);
+ public TypeReference(int pos,SpelNodeImpl qualifiedId) {
+ super(pos,qualifiedId);
}
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
// TODO possible optimization here if we cache the discovered type reference, but can we do that?
- String typename = (String) getChild(0).getValueInternal(state).getValue();
+ String typename = (String) children[0].getValueInternal(state).getValue();
if (typename.indexOf(".") == -1 && Character.isLowerCase(typename.charAt(0))) {
TypeCode tc = TypeCode.valueOf(typename.toUpperCase());
if (tc != TypeCode.OBJECT) {
@@ -54,5 +53,5 @@ public class TypeReference extends SpelNodeImpl {
sb.append(")");
return sb.toString();
}
-
+
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/VariableReference.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/VariableReference.java
index a7cb23c96b1..87e72441698 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/VariableReference.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/VariableReference.java
@@ -16,10 +16,9 @@
package org.springframework.expression.spel.ast;
-import org.antlr.runtime.Token;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
/**
* Represents a variable reference, eg. #someVar. Note this is different to a *local* variable like $someVar
@@ -36,14 +35,14 @@ public class VariableReference extends SpelNodeImpl {
private final String name;
- public VariableReference(Token payload) {
- super(payload);
- this.name = payload.getText();
+ public VariableReference(String variableName, int pos) {
+ super(pos);
+ name = variableName;
}
@Override
- public TypedValue getValueInternal(ExpressionState state) throws SpelException {
+ public TypedValue getValueInternal(ExpressionState state) throws SpelEvaluationException {
if (this.name.equals(THIS)) {
return state.getActiveContextObject();
}
@@ -56,7 +55,7 @@ public class VariableReference extends SpelNodeImpl {
}
@Override
- public void setValue(ExpressionState state, Object value) throws SpelException {
+ public void setValue(ExpressionState state, Object value) throws SpelEvaluationException {
state.setVariable(this.name, value);
}
@@ -66,7 +65,7 @@ public class VariableReference extends SpelNodeImpl {
}
@Override
- public boolean isWritable(ExpressionState expressionState) throws SpelException {
+ public boolean isWritable(ExpressionState expressionState) throws SpelEvaluationException {
return !(this.name.equals(THIS) || this.name.equals(ROOT));
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/generated/SpringExpressions.tokens b/org.springframework.expression/src/main/java/org/springframework/expression/spel/generated/SpringExpressions.tokens
deleted file mode 100644
index 76a17bfef53..00000000000
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/generated/SpringExpressions.tokens
+++ /dev/null
@@ -1,74 +0,0 @@
-SIGN=76
-DOLLAR=71
-DECIMAL_DIGIT=52
-APOS=68
-TYPEREF=13
-HEXADECIMAL_INTEGER_LITERAL=48
-STAR=29
-MOD=31
-VARIABLEREF=14
-AND=26
-ID=36
-SUBTRACT=17
-UPTO=73
-LPAREN=23
-TYPE=44
-HOLDER=10
-AT=72
-LBRACKET=38
-QUALIFIED_IDENTIFIER=6
-RPAREN=24
-STRING_LITERAL=45
-MATCHES=63
-REAL_LITERAL=49
-NOT_EQUAL=56
-COMMA=37
-FUNCTIONREF=12
-EQUAL=55
-PIPE=67
-PLUS=27
-RBRACKET=39
-DOT=34
-SELECT=41
-EXPRESSION=5
-ADD=16
-LESS_THAN_OR_EQUAL=58
-GREATER_THAN=59
-POUND=35
-PROJECT=40
-SELECT_LAST=43
-DEFAULT=20
-NUMBER=18
-REAL_TYPE_SUFFIX=75
-HEX_DIGIT=54
-POWER=32
-LCURLY=65
-NULL_LITERAL=47
-PROPERTY_OR_FIELD=7
-BANG=33
-INSTANCEOF=61
-MINUS=28
-SEMI=64
-TRUE=50
-COLON=22
-GREATER_THAN_OR_EQUAL=60
-WS=70
-DOT_ESCAPED=69
-DQ_STRING_LITERAL=46
-INTEGER_LITERAL=4
-RCURLY=66
-INDEXER=8
-OR=25
-LESS_THAN=57
-ASSIGN=19
-NAMED_ARGUMENT=11
-SELECT_FIRST=42
-DIV=30
-FALSE=51
-EXPONENT_PART=74
-BETWEEN=62
-INTEGER_TYPE_SUFFIX=53
-METHOD=15
-CONSTRUCTOR=9
-QMARK=21
-'new'=77
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/generated/SpringExpressionsLexer.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/generated/SpringExpressionsLexer.java
deleted file mode 100644
index 0c8268cd7ee..00000000000
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/generated/SpringExpressionsLexer.java
+++ /dev/null
@@ -1,2687 +0,0 @@
-// $ANTLR 3.0.1 F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g 2009-04-15 13:33:59
-package org.springframework.expression.spel.generated;
-
-import org.antlr.runtime.*;
-import java.util.Stack;
-import java.util.List;
-import java.util.ArrayList;
-
-public class SpringExpressionsLexer extends Lexer {
- public static final int SIGN=76;
- public static final int DOLLAR=71;
- public static final int DECIMAL_DIGIT=52;
- public static final int TYPEREF=13;
- public static final int APOS=68;
- public static final int HEXADECIMAL_INTEGER_LITERAL=48;
- public static final int STAR=29;
- public static final int T77=77;
- public static final int MOD=31;
- public static final int VARIABLEREF=14;
- public static final int ID=36;
- public static final int AND=26;
- public static final int SUBTRACT=17;
- public static final int EOF=-1;
- public static final int UPTO=73;
- public static final int LPAREN=23;
- public static final int HOLDER=10;
- public static final int TYPE=44;
- public static final int AT=72;
- public static final int LBRACKET=38;
- public static final int QUALIFIED_IDENTIFIER=6;
- public static final int RPAREN=24;
- public static final int STRING_LITERAL=45;
- public static final int MATCHES=63;
- public static final int REAL_LITERAL=49;
- public static final int NOT_EQUAL=56;
- public static final int COMMA=37;
- public static final int FUNCTIONREF=12;
- public static final int EQUAL=55;
- public static final int PIPE=67;
- public static final int PLUS=27;
- public static final int RBRACKET=39;
- public static final int DOT=34;
- public static final int SELECT=41;
- public static final int EXPRESSION=5;
- public static final int ADD=16;
- public static final int LESS_THAN_OR_EQUAL=58;
- public static final int GREATER_THAN=59;
- public static final int POUND=35;
- public static final int PROJECT=40;
- public static final int SELECT_LAST=43;
- public static final int DEFAULT=20;
- public static final int NUMBER=18;
- public static final int POWER=32;
- public static final int HEX_DIGIT=54;
- public static final int REAL_TYPE_SUFFIX=75;
- public static final int LCURLY=65;
- public static final int BANG=33;
- public static final int PROPERTY_OR_FIELD=7;
- public static final int NULL_LITERAL=47;
- public static final int INSTANCEOF=61;
- public static final int MINUS=28;
- public static final int Tokens=78;
- public static final int TRUE=50;
- public static final int SEMI=64;
- public static final int COLON=22;
- public static final int GREATER_THAN_OR_EQUAL=60;
- public static final int WS=70;
- public static final int DQ_STRING_LITERAL=46;
- public static final int DOT_ESCAPED=69;
- public static final int INTEGER_LITERAL=4;
- public static final int OR=25;
- public static final int INDEXER=8;
- public static final int RCURLY=66;
- public static final int ASSIGN=19;
- public static final int LESS_THAN=57;
- public static final int NAMED_ARGUMENT=11;
- public static final int SELECT_FIRST=42;
- public static final int DIV=30;
- public static final int FALSE=51;
- public static final int EXPONENT_PART=74;
- public static final int QMARK=21;
- public static final int CONSTRUCTOR=9;
- public static final int METHOD=15;
- public static final int INTEGER_TYPE_SUFFIX=53;
- public static final int BETWEEN=62;
- public SpringExpressionsLexer() {;}
- public SpringExpressionsLexer(CharStream input) {
- super(input);
- }
- public String getGrammarFileName() { return "F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g"; }
-
- // $ANTLR start T77
- public final void mT77() throws RecognitionException {
- try {
- int _type = T77;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:8:5: ( 'new' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:8:7: 'new'
- {
- match("new");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end T77
-
- // $ANTLR start INTEGER_LITERAL
- public final void mINTEGER_LITERAL() throws RecognitionException {
- try {
- int _type = INTEGER_LITERAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:184:2: ( ( DECIMAL_DIGIT )+ ( INTEGER_TYPE_SUFFIX )? )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:184:4: ( DECIMAL_DIGIT )+ ( INTEGER_TYPE_SUFFIX )?
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:184:4: ( DECIMAL_DIGIT )+
- int cnt1=0;
- loop1:
- do {
- int alt1=2;
- int LA1_0 = input.LA(1);
-
- if ( ((LA1_0>='0' && LA1_0<='9')) ) {
- alt1=1;
- }
-
-
- switch (alt1) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:184:5: DECIMAL_DIGIT
- {
- mDECIMAL_DIGIT();
-
- }
- break;
-
- default :
- if ( cnt1 >= 1 ) break loop1;
- EarlyExitException eee =
- new EarlyExitException(1, input);
- throw eee;
- }
- cnt1++;
- } while (true);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:184:21: ( INTEGER_TYPE_SUFFIX )?
- int alt2=2;
- int LA2_0 = input.LA(1);
-
- if ( (LA2_0=='L'||LA2_0=='l') ) {
- alt2=1;
- }
- switch (alt2) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:184:22: INTEGER_TYPE_SUFFIX
- {
- mINTEGER_TYPE_SUFFIX();
-
- }
- break;
-
- }
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end INTEGER_LITERAL
-
- // $ANTLR start HEXADECIMAL_INTEGER_LITERAL
- public final void mHEXADECIMAL_INTEGER_LITERAL() throws RecognitionException {
- try {
- int _type = HEXADECIMAL_INTEGER_LITERAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:186:29: ( ( '0x' | '0X' ) ( HEX_DIGIT )+ ( INTEGER_TYPE_SUFFIX )? )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:186:31: ( '0x' | '0X' ) ( HEX_DIGIT )+ ( INTEGER_TYPE_SUFFIX )?
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:186:31: ( '0x' | '0X' )
- int alt3=2;
- int LA3_0 = input.LA(1);
-
- if ( (LA3_0=='0') ) {
- int LA3_1 = input.LA(2);
-
- if ( (LA3_1=='x') ) {
- alt3=1;
- }
- else if ( (LA3_1=='X') ) {
- alt3=2;
- }
- else {
- NoViableAltException nvae =
- new NoViableAltException("186:31: ( '0x' | '0X' )", 3, 1, input);
-
- throw nvae;
- }
- }
- else {
- NoViableAltException nvae =
- new NoViableAltException("186:31: ( '0x' | '0X' )", 3, 0, input);
-
- throw nvae;
- }
- switch (alt3) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:186:32: '0x'
- {
- match("0x");
-
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:186:39: '0X'
- {
- match("0X");
-
-
- }
- break;
-
- }
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:186:45: ( HEX_DIGIT )+
- int cnt4=0;
- loop4:
- do {
- int alt4=2;
- int LA4_0 = input.LA(1);
-
- if ( ((LA4_0>='0' && LA4_0<='9')||(LA4_0>='A' && LA4_0<='F')||(LA4_0>='a' && LA4_0<='f')) ) {
- alt4=1;
- }
-
-
- switch (alt4) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:186:46: HEX_DIGIT
- {
- mHEX_DIGIT();
-
- }
- break;
-
- default :
- if ( cnt4 >= 1 ) break loop4;
- EarlyExitException eee =
- new EarlyExitException(4, input);
- throw eee;
- }
- cnt4++;
- } while (true);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:186:58: ( INTEGER_TYPE_SUFFIX )?
- int alt5=2;
- int LA5_0 = input.LA(1);
-
- if ( (LA5_0=='L'||LA5_0=='l') ) {
- alt5=1;
- }
- switch (alt5) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:186:59: INTEGER_TYPE_SUFFIX
- {
- mINTEGER_TYPE_SUFFIX();
-
- }
- break;
-
- }
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end HEXADECIMAL_INTEGER_LITERAL
-
- // $ANTLR start ASSIGN
- public final void mASSIGN() throws RecognitionException {
- try {
- int _type = ASSIGN;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:200:7: ( '=' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:200:9: '='
- {
- match('=');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end ASSIGN
-
- // $ANTLR start EQUAL
- public final void mEQUAL() throws RecognitionException {
- try {
- int _type = EQUAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:201:6: ( '==' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:201:8: '=='
- {
- match("==");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end EQUAL
-
- // $ANTLR start NOT_EQUAL
- public final void mNOT_EQUAL() throws RecognitionException {
- try {
- int _type = NOT_EQUAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:202:10: ( '!=' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:202:12: '!='
- {
- match("!=");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end NOT_EQUAL
-
- // $ANTLR start LESS_THAN
- public final void mLESS_THAN() throws RecognitionException {
- try {
- int _type = LESS_THAN;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:203:10: ( '<' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:203:12: '<'
- {
- match('<');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end LESS_THAN
-
- // $ANTLR start LESS_THAN_OR_EQUAL
- public final void mLESS_THAN_OR_EQUAL() throws RecognitionException {
- try {
- int _type = LESS_THAN_OR_EQUAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:204:19: ( '<=' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:204:21: '<='
- {
- match("<=");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end LESS_THAN_OR_EQUAL
-
- // $ANTLR start GREATER_THAN
- public final void mGREATER_THAN() throws RecognitionException {
- try {
- int _type = GREATER_THAN;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:205:13: ( '>' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:205:15: '>'
- {
- match('>');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end GREATER_THAN
-
- // $ANTLR start GREATER_THAN_OR_EQUAL
- public final void mGREATER_THAN_OR_EQUAL() throws RecognitionException {
- try {
- int _type = GREATER_THAN_OR_EQUAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:206:22: ( '>=' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:206:24: '>='
- {
- match(">=");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end GREATER_THAN_OR_EQUAL
-
- // $ANTLR start INSTANCEOF
- public final void mINSTANCEOF() throws RecognitionException {
- try {
- int _type = INSTANCEOF;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:207:11: ( 'instanceof' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:207:17: 'instanceof'
- {
- match("instanceof");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end INSTANCEOF
-
- // $ANTLR start BETWEEN
- public final void mBETWEEN() throws RecognitionException {
- try {
- int _type = BETWEEN;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:208:8: ( 'between' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:208:9: 'between'
- {
- match("between");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end BETWEEN
-
- // $ANTLR start MATCHES
- public final void mMATCHES() throws RecognitionException {
- try {
- int _type = MATCHES;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:209:8: ( 'matches' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:209:9: 'matches'
- {
- match("matches");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end MATCHES
-
- // $ANTLR start NULL_LITERAL
- public final void mNULL_LITERAL() throws RecognitionException {
- try {
- int _type = NULL_LITERAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:210:13: ( 'null' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:210:15: 'null'
- {
- match("null");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end NULL_LITERAL
-
- // $ANTLR start SEMI
- public final void mSEMI() throws RecognitionException {
- try {
- int _type = SEMI;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:212:5: ( ';' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:212:7: ';'
- {
- match(';');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end SEMI
-
- // $ANTLR start DOT
- public final void mDOT() throws RecognitionException {
- try {
- int _type = DOT;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:213:4: ( '.' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:213:9: '.'
- {
- match('.');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end DOT
-
- // $ANTLR start COMMA
- public final void mCOMMA() throws RecognitionException {
- try {
- int _type = COMMA;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:214:6: ( ',' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:214:8: ','
- {
- match(',');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end COMMA
-
- // $ANTLR start LPAREN
- public final void mLPAREN() throws RecognitionException {
- try {
- int _type = LPAREN;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:215:7: ( '(' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:215:9: '('
- {
- match('(');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end LPAREN
-
- // $ANTLR start RPAREN
- public final void mRPAREN() throws RecognitionException {
- try {
- int _type = RPAREN;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:216:7: ( ')' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:216:9: ')'
- {
- match(')');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end RPAREN
-
- // $ANTLR start LCURLY
- public final void mLCURLY() throws RecognitionException {
- try {
- int _type = LCURLY;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:217:7: ( '{' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:217:9: '{'
- {
- match('{');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end LCURLY
-
- // $ANTLR start RCURLY
- public final void mRCURLY() throws RecognitionException {
- try {
- int _type = RCURLY;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:218:7: ( '}' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:218:9: '}'
- {
- match('}');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end RCURLY
-
- // $ANTLR start LBRACKET
- public final void mLBRACKET() throws RecognitionException {
- try {
- int _type = LBRACKET;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:219:9: ( '[' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:219:11: '['
- {
- match('[');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end LBRACKET
-
- // $ANTLR start RBRACKET
- public final void mRBRACKET() throws RecognitionException {
- try {
- int _type = RBRACKET;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:220:9: ( ']' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:220:11: ']'
- {
- match(']');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end RBRACKET
-
- // $ANTLR start PIPE
- public final void mPIPE() throws RecognitionException {
- try {
- int _type = PIPE;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:221:5: ( '|' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:221:7: '|'
- {
- match('|');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end PIPE
-
- // $ANTLR start AND
- public final void mAND() throws RecognitionException {
- try {
- int _type = AND;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:223:4: ( 'and' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:223:9: 'and'
- {
- match("and");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end AND
-
- // $ANTLR start OR
- public final void mOR() throws RecognitionException {
- try {
- int _type = OR;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:224:3: ( 'or' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:224:9: 'or'
- {
- match("or");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end OR
-
- // $ANTLR start FALSE
- public final void mFALSE() throws RecognitionException {
- try {
- int _type = FALSE;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:225:6: ( 'false' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:225:9: 'false'
- {
- match("false");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end FALSE
-
- // $ANTLR start TRUE
- public final void mTRUE() throws RecognitionException {
- try {
- int _type = TRUE;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:226:5: ( 'true' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:226:9: 'true'
- {
- match("true");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end TRUE
-
- // $ANTLR start PLUS
- public final void mPLUS() throws RecognitionException {
- try {
- int _type = PLUS;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:228:5: ( '+' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:228:7: '+'
- {
- match('+');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end PLUS
-
- // $ANTLR start MINUS
- public final void mMINUS() throws RecognitionException {
- try {
- int _type = MINUS;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:229:6: ( '-' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:229:8: '-'
- {
- match('-');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end MINUS
-
- // $ANTLR start DIV
- public final void mDIV() throws RecognitionException {
- try {
- int _type = DIV;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:230:4: ( '/' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:230:6: '/'
- {
- match('/');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end DIV
-
- // $ANTLR start STAR
- public final void mSTAR() throws RecognitionException {
- try {
- int _type = STAR;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:231:5: ( '*' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:231:7: '*'
- {
- match('*');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end STAR
-
- // $ANTLR start MOD
- public final void mMOD() throws RecognitionException {
- try {
- int _type = MOD;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:232:4: ( '%' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:232:6: '%'
- {
- match('%');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end MOD
-
- // $ANTLR start POWER
- public final void mPOWER() throws RecognitionException {
- try {
- int _type = POWER;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:233:6: ( '^' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:233:8: '^'
- {
- match('^');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end POWER
-
- // $ANTLR start BANG
- public final void mBANG() throws RecognitionException {
- try {
- int _type = BANG;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:234:5: ( '!' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:234:7: '!'
- {
- match('!');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end BANG
-
- // $ANTLR start POUND
- public final void mPOUND() throws RecognitionException {
- try {
- int _type = POUND;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:235:6: ( '#' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:235:8: '#'
- {
- match('#');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end POUND
-
- // $ANTLR start QMARK
- public final void mQMARK() throws RecognitionException {
- try {
- int _type = QMARK;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:236:6: ( '?' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:236:8: '?'
- {
- match('?');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end QMARK
-
- // $ANTLR start DEFAULT
- public final void mDEFAULT() throws RecognitionException {
- try {
- int _type = DEFAULT;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:237:8: ( '??' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:237:10: '??'
- {
- match("??");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end DEFAULT
-
- // $ANTLR start PROJECT
- public final void mPROJECT() throws RecognitionException {
- try {
- int _type = PROJECT;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:238:8: ( '![' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:238:10: '!['
- {
- match("![");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end PROJECT
-
- // $ANTLR start SELECT
- public final void mSELECT() throws RecognitionException {
- try {
- int _type = SELECT;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:239:7: ( '?[' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:239:9: '?['
- {
- match("?[");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end SELECT
-
- // $ANTLR start SELECT_FIRST
- public final void mSELECT_FIRST() throws RecognitionException {
- try {
- int _type = SELECT_FIRST;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:240:13: ( '^[' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:240:15: '^['
- {
- match("^[");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end SELECT_FIRST
-
- // $ANTLR start SELECT_LAST
- public final void mSELECT_LAST() throws RecognitionException {
- try {
- int _type = SELECT_LAST;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:241:12: ( '$[' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:241:14: '$['
- {
- match("$[");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end SELECT_LAST
-
- // $ANTLR start TYPE
- public final void mTYPE() throws RecognitionException {
- try {
- int _type = TYPE;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:242:5: ( 'T(' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:242:7: 'T('
- {
- match("T(");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end TYPE
-
- // $ANTLR start STRING_LITERAL
- public final void mSTRING_LITERAL() throws RecognitionException {
- try {
- int _type = STRING_LITERAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:244:15: ( '\\'' ( APOS | ~ '\\'' )* '\\'' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:244:17: '\\'' ( APOS | ~ '\\'' )* '\\''
- {
- match('\'');
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:244:23: ( APOS | ~ '\\'' )*
- loop6:
- do {
- int alt6=3;
- int LA6_0 = input.LA(1);
-
- if ( (LA6_0=='\'') ) {
- int LA6_1 = input.LA(2);
-
- if ( (LA6_1=='\'') ) {
- alt6=1;
- }
-
-
- }
- else if ( ((LA6_0>='\u0000' && LA6_0<='&')||(LA6_0>='(' && LA6_0<='\uFFFE')) ) {
- alt6=2;
- }
-
-
- switch (alt6) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:244:24: APOS
- {
- mAPOS();
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:244:29: ~ '\\''
- {
- if ( (input.LA(1)>='\u0000' && input.LA(1)<='&')||(input.LA(1)>='(' && input.LA(1)<='\uFFFE') ) {
- input.consume();
-
- }
- else {
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recover(mse); throw mse;
- }
-
-
- }
- break;
-
- default :
- break loop6;
- }
- } while (true);
-
- match('\'');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end STRING_LITERAL
-
- // $ANTLR start DQ_STRING_LITERAL
- public final void mDQ_STRING_LITERAL() throws RecognitionException {
- try {
- int _type = DQ_STRING_LITERAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:245:18: ( '\"' (~ '\"' )* '\"' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:245:20: '\"' (~ '\"' )* '\"'
- {
- match('\"');
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:245:25: (~ '\"' )*
- loop7:
- do {
- int alt7=2;
- int LA7_0 = input.LA(1);
-
- if ( ((LA7_0>='\u0000' && LA7_0<='!')||(LA7_0>='#' && LA7_0<='\uFFFE')) ) {
- alt7=1;
- }
-
-
- switch (alt7) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:245:26: ~ '\"'
- {
- if ( (input.LA(1)>='\u0000' && input.LA(1)<='!')||(input.LA(1)>='#' && input.LA(1)<='\uFFFE') ) {
- input.consume();
-
- }
- else {
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recover(mse); throw mse;
- }
-
-
- }
- break;
-
- default :
- break loop7;
- }
- } while (true);
-
- match('\"');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end DQ_STRING_LITERAL
-
- // $ANTLR start ID
- public final void mID() throws RecognitionException {
- try {
- int _type = ID;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:246:3: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | DOT_ESCAPED )* )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:246:5: ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | DOT_ESCAPED )*
- {
- if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) {
- input.consume();
-
- }
- else {
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recover(mse); throw mse;
- }
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:246:29: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | DOT_ESCAPED )*
- loop8:
- do {
- int alt8=6;
- switch ( input.LA(1) ) {
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- case 'i':
- case 'j':
- case 'k':
- case 'l':
- case 'm':
- case 'n':
- case 'o':
- case 'p':
- case 'q':
- case 'r':
- case 's':
- case 't':
- case 'u':
- case 'v':
- case 'w':
- case 'x':
- case 'y':
- case 'z':
- {
- alt8=1;
- }
- break;
- case 'A':
- case 'B':
- case 'C':
- case 'D':
- case 'E':
- case 'F':
- case 'G':
- case 'H':
- case 'I':
- case 'J':
- case 'K':
- case 'L':
- case 'M':
- case 'N':
- case 'O':
- case 'P':
- case 'Q':
- case 'R':
- case 'S':
- case 'T':
- case 'U':
- case 'V':
- case 'W':
- case 'X':
- case 'Y':
- case 'Z':
- {
- alt8=2;
- }
- break;
- case '_':
- {
- alt8=3;
- }
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- alt8=4;
- }
- break;
- case '\\':
- {
- alt8=5;
- }
- break;
-
- }
-
- switch (alt8) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:246:30: 'a' .. 'z'
- {
- matchRange('a','z');
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:246:39: 'A' .. 'Z'
- {
- matchRange('A','Z');
-
- }
- break;
- case 3 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:246:48: '_'
- {
- match('_');
-
- }
- break;
- case 4 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:246:52: '0' .. '9'
- {
- matchRange('0','9');
-
- }
- break;
- case 5 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:246:61: DOT_ESCAPED
- {
- mDOT_ESCAPED();
-
- }
- break;
-
- default :
- break loop8;
- }
- } while (true);
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end ID
-
- // $ANTLR start DOT_ESCAPED
- public final void mDOT_ESCAPED() throws RecognitionException {
- try {
- int _type = DOT_ESCAPED;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:247:12: ( '\\\\.' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:247:14: '\\\\.'
- {
- match("\\.");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end DOT_ESCAPED
-
- // $ANTLR start WS
- public final void mWS() throws RecognitionException {
- try {
- int _type = WS;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:248:3: ( ( ' ' | '\\t' | '\\n' | '\\r' )+ )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:248:5: ( ' ' | '\\t' | '\\n' | '\\r' )+
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:248:5: ( ' ' | '\\t' | '\\n' | '\\r' )+
- int cnt9=0;
- loop9:
- do {
- int alt9=2;
- int LA9_0 = input.LA(1);
-
- if ( ((LA9_0>='\t' && LA9_0<='\n')||LA9_0=='\r'||LA9_0==' ') ) {
- alt9=1;
- }
-
-
- switch (alt9) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:
- {
- if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) {
- input.consume();
-
- }
- else {
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recover(mse); throw mse;
- }
-
-
- }
- break;
-
- default :
- if ( cnt9 >= 1 ) break loop9;
- EarlyExitException eee =
- new EarlyExitException(9, input);
- throw eee;
- }
- cnt9++;
- } while (true);
-
- channel=HIDDEN;
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end WS
-
- // $ANTLR start DOLLAR
- public final void mDOLLAR() throws RecognitionException {
- try {
- int _type = DOLLAR;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:249:7: ( '$' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:249:9: '$'
- {
- match('$');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end DOLLAR
-
- // $ANTLR start AT
- public final void mAT() throws RecognitionException {
- try {
- int _type = AT;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:250:3: ( '@' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:250:5: '@'
- {
- match('@');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end AT
-
- // $ANTLR start UPTO
- public final void mUPTO() throws RecognitionException {
- try {
- int _type = UPTO;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:251:5: ( '..' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:251:7: '..'
- {
- match("..");
-
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end UPTO
-
- // $ANTLR start COLON
- public final void mCOLON() throws RecognitionException {
- try {
- int _type = COLON;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:252:6: ( ':' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:252:8: ':'
- {
- match(':');
-
- }
-
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end COLON
-
- // $ANTLR start REAL_LITERAL
- public final void mREAL_LITERAL() throws RecognitionException {
- try {
- int _type = REAL_LITERAL;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:255:14: ( ( '.' ( DECIMAL_DIGIT )+ ( EXPONENT_PART )? ( REAL_TYPE_SUFFIX )? ) | ( ( DECIMAL_DIGIT )+ '.' ( DECIMAL_DIGIT )+ ( EXPONENT_PART )? ( REAL_TYPE_SUFFIX )? ) | ( ( DECIMAL_DIGIT )+ ( EXPONENT_PART ) ( REAL_TYPE_SUFFIX )? ) | ( ( DECIMAL_DIGIT )+ ( REAL_TYPE_SUFFIX ) ) )
- int alt20=4;
- alt20 = dfa20.predict(input);
- switch (alt20) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:256:3: ( '.' ( DECIMAL_DIGIT )+ ( EXPONENT_PART )? ( REAL_TYPE_SUFFIX )? )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:256:3: ( '.' ( DECIMAL_DIGIT )+ ( EXPONENT_PART )? ( REAL_TYPE_SUFFIX )? )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:256:4: '.' ( DECIMAL_DIGIT )+ ( EXPONENT_PART )? ( REAL_TYPE_SUFFIX )?
- {
- match('.');
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:256:8: ( DECIMAL_DIGIT )+
- int cnt10=0;
- loop10:
- do {
- int alt10=2;
- int LA10_0 = input.LA(1);
-
- if ( ((LA10_0>='0' && LA10_0<='9')) ) {
- alt10=1;
- }
-
-
- switch (alt10) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:256:9: DECIMAL_DIGIT
- {
- mDECIMAL_DIGIT();
-
- }
- break;
-
- default :
- if ( cnt10 >= 1 ) break loop10;
- EarlyExitException eee =
- new EarlyExitException(10, input);
- throw eee;
- }
- cnt10++;
- } while (true);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:256:25: ( EXPONENT_PART )?
- int alt11=2;
- int LA11_0 = input.LA(1);
-
- if ( (LA11_0=='E'||LA11_0=='e') ) {
- alt11=1;
- }
- switch (alt11) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:256:26: EXPONENT_PART
- {
- mEXPONENT_PART();
-
- }
- break;
-
- }
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:256:42: ( REAL_TYPE_SUFFIX )?
- int alt12=2;
- int LA12_0 = input.LA(1);
-
- if ( (LA12_0=='D'||LA12_0=='F'||LA12_0=='d'||LA12_0=='f') ) {
- alt12=1;
- }
- switch (alt12) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:256:43: REAL_TYPE_SUFFIX
- {
- mREAL_TYPE_SUFFIX();
-
- }
- break;
-
- }
-
-
- }
-
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:2: ( ( DECIMAL_DIGIT )+ '.' ( DECIMAL_DIGIT )+ ( EXPONENT_PART )? ( REAL_TYPE_SUFFIX )? )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:2: ( ( DECIMAL_DIGIT )+ '.' ( DECIMAL_DIGIT )+ ( EXPONENT_PART )? ( REAL_TYPE_SUFFIX )? )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:3: ( DECIMAL_DIGIT )+ '.' ( DECIMAL_DIGIT )+ ( EXPONENT_PART )? ( REAL_TYPE_SUFFIX )?
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:3: ( DECIMAL_DIGIT )+
- int cnt13=0;
- loop13:
- do {
- int alt13=2;
- int LA13_0 = input.LA(1);
-
- if ( ((LA13_0>='0' && LA13_0<='9')) ) {
- alt13=1;
- }
-
-
- switch (alt13) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:4: DECIMAL_DIGIT
- {
- mDECIMAL_DIGIT();
-
- }
- break;
-
- default :
- if ( cnt13 >= 1 ) break loop13;
- EarlyExitException eee =
- new EarlyExitException(13, input);
- throw eee;
- }
- cnt13++;
- } while (true);
-
- match('.');
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:24: ( DECIMAL_DIGIT )+
- int cnt14=0;
- loop14:
- do {
- int alt14=2;
- int LA14_0 = input.LA(1);
-
- if ( ((LA14_0>='0' && LA14_0<='9')) ) {
- alt14=1;
- }
-
-
- switch (alt14) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:25: DECIMAL_DIGIT
- {
- mDECIMAL_DIGIT();
-
- }
- break;
-
- default :
- if ( cnt14 >= 1 ) break loop14;
- EarlyExitException eee =
- new EarlyExitException(14, input);
- throw eee;
- }
- cnt14++;
- } while (true);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:41: ( EXPONENT_PART )?
- int alt15=2;
- int LA15_0 = input.LA(1);
-
- if ( (LA15_0=='E'||LA15_0=='e') ) {
- alt15=1;
- }
- switch (alt15) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:42: EXPONENT_PART
- {
- mEXPONENT_PART();
-
- }
- break;
-
- }
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:58: ( REAL_TYPE_SUFFIX )?
- int alt16=2;
- int LA16_0 = input.LA(1);
-
- if ( (LA16_0=='D'||LA16_0=='F'||LA16_0=='d'||LA16_0=='f') ) {
- alt16=1;
- }
- switch (alt16) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:257:59: REAL_TYPE_SUFFIX
- {
- mREAL_TYPE_SUFFIX();
-
- }
- break;
-
- }
-
-
- }
-
-
- }
- break;
- case 3 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:258:2: ( ( DECIMAL_DIGIT )+ ( EXPONENT_PART ) ( REAL_TYPE_SUFFIX )? )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:258:2: ( ( DECIMAL_DIGIT )+ ( EXPONENT_PART ) ( REAL_TYPE_SUFFIX )? )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:258:3: ( DECIMAL_DIGIT )+ ( EXPONENT_PART ) ( REAL_TYPE_SUFFIX )?
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:258:3: ( DECIMAL_DIGIT )+
- int cnt17=0;
- loop17:
- do {
- int alt17=2;
- int LA17_0 = input.LA(1);
-
- if ( ((LA17_0>='0' && LA17_0<='9')) ) {
- alt17=1;
- }
-
-
- switch (alt17) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:258:4: DECIMAL_DIGIT
- {
- mDECIMAL_DIGIT();
-
- }
- break;
-
- default :
- if ( cnt17 >= 1 ) break loop17;
- EarlyExitException eee =
- new EarlyExitException(17, input);
- throw eee;
- }
- cnt17++;
- } while (true);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:258:20: ( EXPONENT_PART )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:258:21: EXPONENT_PART
- {
- mEXPONENT_PART();
-
- }
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:258:36: ( REAL_TYPE_SUFFIX )?
- int alt18=2;
- int LA18_0 = input.LA(1);
-
- if ( (LA18_0=='D'||LA18_0=='F'||LA18_0=='d'||LA18_0=='f') ) {
- alt18=1;
- }
- switch (alt18) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:258:37: REAL_TYPE_SUFFIX
- {
- mREAL_TYPE_SUFFIX();
-
- }
- break;
-
- }
-
-
- }
-
-
- }
- break;
- case 4 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:259:2: ( ( DECIMAL_DIGIT )+ ( REAL_TYPE_SUFFIX ) )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:259:2: ( ( DECIMAL_DIGIT )+ ( REAL_TYPE_SUFFIX ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:259:3: ( DECIMAL_DIGIT )+ ( REAL_TYPE_SUFFIX )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:259:3: ( DECIMAL_DIGIT )+
- int cnt19=0;
- loop19:
- do {
- int alt19=2;
- int LA19_0 = input.LA(1);
-
- if ( ((LA19_0>='0' && LA19_0<='9')) ) {
- alt19=1;
- }
-
-
- switch (alt19) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:259:4: DECIMAL_DIGIT
- {
- mDECIMAL_DIGIT();
-
- }
- break;
-
- default :
- if ( cnt19 >= 1 ) break loop19;
- EarlyExitException eee =
- new EarlyExitException(19, input);
- throw eee;
- }
- cnt19++;
- } while (true);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:259:20: ( REAL_TYPE_SUFFIX )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:259:21: REAL_TYPE_SUFFIX
- {
- mREAL_TYPE_SUFFIX();
-
- }
-
-
- }
-
-
- }
- break;
-
- }
- this.type = _type;
- }
- finally {
- }
- }
- // $ANTLR end REAL_LITERAL
-
- // $ANTLR start APOS
- public final void mAPOS() throws RecognitionException {
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:261:15: ( '\\'' '\\'' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:261:17: '\\'' '\\''
- {
- match('\'');
- match('\'');
-
- }
-
- }
- finally {
- }
- }
- // $ANTLR end APOS
-
- // $ANTLR start DECIMAL_DIGIT
- public final void mDECIMAL_DIGIT() throws RecognitionException {
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:262:24: ( '0' .. '9' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:262:26: '0' .. '9'
- {
- matchRange('0','9');
-
- }
-
- }
- finally {
- }
- }
- // $ANTLR end DECIMAL_DIGIT
-
- // $ANTLR start INTEGER_TYPE_SUFFIX
- public final void mINTEGER_TYPE_SUFFIX() throws RecognitionException {
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:263:30: ( ( 'L' | 'l' ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:263:32: ( 'L' | 'l' )
- {
- if ( input.LA(1)=='L'||input.LA(1)=='l' ) {
- input.consume();
-
- }
- else {
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recover(mse); throw mse;
- }
-
-
- }
-
- }
- finally {
- }
- }
- // $ANTLR end INTEGER_TYPE_SUFFIX
-
- // $ANTLR start HEX_DIGIT
- public final void mHEX_DIGIT() throws RecognitionException {
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:264:20: ( '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:
- {
- if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='F')||(input.LA(1)>='a' && input.LA(1)<='f') ) {
- input.consume();
-
- }
- else {
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recover(mse); throw mse;
- }
-
-
- }
-
- }
- finally {
- }
- }
- // $ANTLR end HEX_DIGIT
-
- // $ANTLR start EXPONENT_PART
- public final void mEXPONENT_PART() throws RecognitionException {
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:24: ( 'e' ( SIGN )* ( DECIMAL_DIGIT )+ | 'E' ( SIGN )* ( DECIMAL_DIGIT )+ )
- int alt25=2;
- int LA25_0 = input.LA(1);
-
- if ( (LA25_0=='e') ) {
- alt25=1;
- }
- else if ( (LA25_0=='E') ) {
- alt25=2;
- }
- else {
- NoViableAltException nvae =
- new NoViableAltException("266:10: fragment EXPONENT_PART : ( 'e' ( SIGN )* ( DECIMAL_DIGIT )+ | 'E' ( SIGN )* ( DECIMAL_DIGIT )+ );", 25, 0, input);
-
- throw nvae;
- }
- switch (alt25) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:26: 'e' ( SIGN )* ( DECIMAL_DIGIT )+
- {
- match('e');
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:31: ( SIGN )*
- loop21:
- do {
- int alt21=2;
- int LA21_0 = input.LA(1);
-
- if ( (LA21_0=='+'||LA21_0=='-') ) {
- alt21=1;
- }
-
-
- switch (alt21) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:32: SIGN
- {
- mSIGN();
-
- }
- break;
-
- default :
- break loop21;
- }
- } while (true);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:40: ( DECIMAL_DIGIT )+
- int cnt22=0;
- loop22:
- do {
- int alt22=2;
- int LA22_0 = input.LA(1);
-
- if ( ((LA22_0>='0' && LA22_0<='9')) ) {
- alt22=1;
- }
-
-
- switch (alt22) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:41: DECIMAL_DIGIT
- {
- mDECIMAL_DIGIT();
-
- }
- break;
-
- default :
- if ( cnt22 >= 1 ) break loop22;
- EarlyExitException eee =
- new EarlyExitException(22, input);
- throw eee;
- }
- cnt22++;
- } while (true);
-
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:59: 'E' ( SIGN )* ( DECIMAL_DIGIT )+
- {
- match('E');
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:64: ( SIGN )*
- loop23:
- do {
- int alt23=2;
- int LA23_0 = input.LA(1);
-
- if ( (LA23_0=='+'||LA23_0=='-') ) {
- alt23=1;
- }
-
-
- switch (alt23) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:65: SIGN
- {
- mSIGN();
-
- }
- break;
-
- default :
- break loop23;
- }
- } while (true);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:73: ( DECIMAL_DIGIT )+
- int cnt24=0;
- loop24:
- do {
- int alt24=2;
- int LA24_0 = input.LA(1);
-
- if ( ((LA24_0>='0' && LA24_0<='9')) ) {
- alt24=1;
- }
-
-
- switch (alt24) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:266:74: DECIMAL_DIGIT
- {
- mDECIMAL_DIGIT();
-
- }
- break;
-
- default :
- if ( cnt24 >= 1 ) break loop24;
- EarlyExitException eee =
- new EarlyExitException(24, input);
- throw eee;
- }
- cnt24++;
- } while (true);
-
-
- }
- break;
-
- }
- }
- finally {
- }
- }
- // $ANTLR end EXPONENT_PART
-
- // $ANTLR start SIGN
- public final void mSIGN() throws RecognitionException {
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:267:15: ( '+' | '-' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:
- {
- if ( input.LA(1)=='+'||input.LA(1)=='-' ) {
- input.consume();
-
- }
- else {
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recover(mse); throw mse;
- }
-
-
- }
-
- }
- finally {
- }
- }
- // $ANTLR end SIGN
-
- // $ANTLR start REAL_TYPE_SUFFIX
- public final void mREAL_TYPE_SUFFIX() throws RecognitionException {
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:268:27: ( 'F' | 'f' | 'D' | 'd' )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:
- {
- if ( input.LA(1)=='D'||input.LA(1)=='F'||input.LA(1)=='d'||input.LA(1)=='f' ) {
- input.consume();
-
- }
- else {
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recover(mse); throw mse;
- }
-
-
- }
-
- }
- finally {
- }
- }
- // $ANTLR end REAL_TYPE_SUFFIX
-
- public void mTokens() throws RecognitionException {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:8: ( T77 | INTEGER_LITERAL | HEXADECIMAL_INTEGER_LITERAL | ASSIGN | EQUAL | NOT_EQUAL | LESS_THAN | LESS_THAN_OR_EQUAL | GREATER_THAN | GREATER_THAN_OR_EQUAL | INSTANCEOF | BETWEEN | MATCHES | NULL_LITERAL | SEMI | DOT | COMMA | LPAREN | RPAREN | LCURLY | RCURLY | LBRACKET | RBRACKET | PIPE | AND | OR | FALSE | TRUE | PLUS | MINUS | DIV | STAR | MOD | POWER | BANG | POUND | QMARK | DEFAULT | PROJECT | SELECT | SELECT_FIRST | SELECT_LAST | TYPE | STRING_LITERAL | DQ_STRING_LITERAL | ID | DOT_ESCAPED | WS | DOLLAR | AT | UPTO | COLON | REAL_LITERAL )
- int alt26=53;
- alt26 = dfa26.predict(input);
- switch (alt26) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:10: T77
- {
- mT77();
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:14: INTEGER_LITERAL
- {
- mINTEGER_LITERAL();
-
- }
- break;
- case 3 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:30: HEXADECIMAL_INTEGER_LITERAL
- {
- mHEXADECIMAL_INTEGER_LITERAL();
-
- }
- break;
- case 4 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:58: ASSIGN
- {
- mASSIGN();
-
- }
- break;
- case 5 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:65: EQUAL
- {
- mEQUAL();
-
- }
- break;
- case 6 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:71: NOT_EQUAL
- {
- mNOT_EQUAL();
-
- }
- break;
- case 7 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:81: LESS_THAN
- {
- mLESS_THAN();
-
- }
- break;
- case 8 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:91: LESS_THAN_OR_EQUAL
- {
- mLESS_THAN_OR_EQUAL();
-
- }
- break;
- case 9 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:110: GREATER_THAN
- {
- mGREATER_THAN();
-
- }
- break;
- case 10 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:123: GREATER_THAN_OR_EQUAL
- {
- mGREATER_THAN_OR_EQUAL();
-
- }
- break;
- case 11 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:145: INSTANCEOF
- {
- mINSTANCEOF();
-
- }
- break;
- case 12 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:156: BETWEEN
- {
- mBETWEEN();
-
- }
- break;
- case 13 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:164: MATCHES
- {
- mMATCHES();
-
- }
- break;
- case 14 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:172: NULL_LITERAL
- {
- mNULL_LITERAL();
-
- }
- break;
- case 15 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:185: SEMI
- {
- mSEMI();
-
- }
- break;
- case 16 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:190: DOT
- {
- mDOT();
-
- }
- break;
- case 17 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:194: COMMA
- {
- mCOMMA();
-
- }
- break;
- case 18 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:200: LPAREN
- {
- mLPAREN();
-
- }
- break;
- case 19 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:207: RPAREN
- {
- mRPAREN();
-
- }
- break;
- case 20 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:214: LCURLY
- {
- mLCURLY();
-
- }
- break;
- case 21 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:221: RCURLY
- {
- mRCURLY();
-
- }
- break;
- case 22 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:228: LBRACKET
- {
- mLBRACKET();
-
- }
- break;
- case 23 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:237: RBRACKET
- {
- mRBRACKET();
-
- }
- break;
- case 24 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:246: PIPE
- {
- mPIPE();
-
- }
- break;
- case 25 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:251: AND
- {
- mAND();
-
- }
- break;
- case 26 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:255: OR
- {
- mOR();
-
- }
- break;
- case 27 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:258: FALSE
- {
- mFALSE();
-
- }
- break;
- case 28 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:264: TRUE
- {
- mTRUE();
-
- }
- break;
- case 29 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:269: PLUS
- {
- mPLUS();
-
- }
- break;
- case 30 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:274: MINUS
- {
- mMINUS();
-
- }
- break;
- case 31 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:280: DIV
- {
- mDIV();
-
- }
- break;
- case 32 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:284: STAR
- {
- mSTAR();
-
- }
- break;
- case 33 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:289: MOD
- {
- mMOD();
-
- }
- break;
- case 34 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:293: POWER
- {
- mPOWER();
-
- }
- break;
- case 35 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:299: BANG
- {
- mBANG();
-
- }
- break;
- case 36 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:304: POUND
- {
- mPOUND();
-
- }
- break;
- case 37 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:310: QMARK
- {
- mQMARK();
-
- }
- break;
- case 38 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:316: DEFAULT
- {
- mDEFAULT();
-
- }
- break;
- case 39 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:324: PROJECT
- {
- mPROJECT();
-
- }
- break;
- case 40 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:332: SELECT
- {
- mSELECT();
-
- }
- break;
- case 41 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:339: SELECT_FIRST
- {
- mSELECT_FIRST();
-
- }
- break;
- case 42 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:352: SELECT_LAST
- {
- mSELECT_LAST();
-
- }
- break;
- case 43 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:364: TYPE
- {
- mTYPE();
-
- }
- break;
- case 44 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:369: STRING_LITERAL
- {
- mSTRING_LITERAL();
-
- }
- break;
- case 45 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:384: DQ_STRING_LITERAL
- {
- mDQ_STRING_LITERAL();
-
- }
- break;
- case 46 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:402: ID
- {
- mID();
-
- }
- break;
- case 47 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:405: DOT_ESCAPED
- {
- mDOT_ESCAPED();
-
- }
- break;
- case 48 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:417: WS
- {
- mWS();
-
- }
- break;
- case 49 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:420: DOLLAR
- {
- mDOLLAR();
-
- }
- break;
- case 50 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:427: AT
- {
- mAT();
-
- }
- break;
- case 51 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:430: UPTO
- {
- mUPTO();
-
- }
- break;
- case 52 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:435: COLON
- {
- mCOLON();
-
- }
- break;
- case 53 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:1:441: REAL_LITERAL
- {
- mREAL_LITERAL();
-
- }
- break;
-
- }
-
- }
-
-
- protected DFA20 dfa20 = new DFA20(this);
- protected DFA26 dfa26 = new DFA26(this);
- static final String DFA20_eotS =
- "\6\uffff";
- static final String DFA20_eofS =
- "\6\uffff";
- static final String DFA20_minS =
- "\1\56\1\uffff\1\56\3\uffff";
- static final String DFA20_maxS =
- "\1\71\1\uffff\1\146\3\uffff";
- static final String DFA20_acceptS =
- "\1\uffff\1\1\1\uffff\1\2\1\4\1\3";
- static final String DFA20_specialS =
- "\6\uffff}>";
- static final String[] DFA20_transitionS = {
- "\1\1\1\uffff\12\2",
- "",
- "\1\3\1\uffff\12\2\12\uffff\1\4\1\5\1\4\35\uffff\1\4\1\5\1\4",
- "",
- "",
- ""
- };
-
- static final short[] DFA20_eot = DFA.unpackEncodedString(DFA20_eotS);
- static final short[] DFA20_eof = DFA.unpackEncodedString(DFA20_eofS);
- static final char[] DFA20_min = DFA.unpackEncodedStringToUnsignedChars(DFA20_minS);
- static final char[] DFA20_max = DFA.unpackEncodedStringToUnsignedChars(DFA20_maxS);
- static final short[] DFA20_accept = DFA.unpackEncodedString(DFA20_acceptS);
- static final short[] DFA20_special = DFA.unpackEncodedString(DFA20_specialS);
- static final short[][] DFA20_transition;
-
- static {
- int numStates = DFA20_transitionS.length;
- DFA20_transition = new short[numStates][];
- for (int i=0; i";
- static final String[] DFA26_transitionS = {
- "\2\47\2\uffff\1\47\22\uffff\1\47\1\5\1\44\1\37\1\41\1\35\1\uffff"+
- "\1\43\1\16\1\17\1\34\1\31\1\15\1\32\1\14\1\33\1\2\11\3\1\51"+
- "\1\13\1\6\1\4\1\7\1\40\1\50\23\45\1\42\6\45\1\22\1\46\1\23\1"+
- "\36\1\45\1\uffff\1\25\1\11\3\45\1\27\2\45\1\10\3\45\1\12\1\1"+
- "\1\26\4\45\1\30\6\45\1\20\1\24\1\21",
- "\1\52\17\uffff\1\53",
- "\1\56\1\uffff\12\3\12\uffff\3\56\21\uffff\1\54\13\uffff\3\56"+
- "\21\uffff\1\54",
- "\1\56\1\uffff\12\3\12\uffff\3\56\35\uffff\3\56",
- "\1\57",
- "\1\61\35\uffff\1\62",
- "\1\64",
- "\1\66",
- "\1\70",
- "\1\71",
- "\1\72",
- "",
- "\1\73\1\uffff\12\56",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "\1\75",
- "\1\76",
- "\1\77",
- "\1\100",
- "",
- "",
- "",
- "",
- "",
- "\1\101",
- "",
- "\1\104\33\uffff\1\103",
- "\1\106",
- "\1\110",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "\1\111",
- "\1\112",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "\1\113",
- "\1\114",
- "\1\115",
- "",
- "",
- "\1\116",
- "\12\45\7\uffff\32\45\1\uffff\1\45\2\uffff\1\45\1\uffff\32\45",
- "\1\120",
- "\1\121",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "\12\45\7\uffff\32\45\1\uffff\1\45\2\uffff\1\45\1\uffff\32\45",
- "\1\123",
- "\1\124",
- "\1\125",
- "\1\126",
- "\12\45\7\uffff\32\45\1\uffff\1\45\2\uffff\1\45\1\uffff\32\45",
- "",
- "\1\130",
- "\1\131",
- "",
- "\12\45\7\uffff\32\45\1\uffff\1\45\2\uffff\1\45\1\uffff\32\45",
- "\1\133",
- "\1\134",
- "\1\135",
- "",
- "\1\136",
- "\12\45\7\uffff\32\45\1\uffff\1\45\2\uffff\1\45\1\uffff\32\45",
- "",
- "\1\140",
- "\1\141",
- "\1\142",
- "\12\45\7\uffff\32\45\1\uffff\1\45\2\uffff\1\45\1\uffff\32\45",
- "",
- "\1\144",
- "\1\145",
- "\1\146",
- "",
- "\1\147",
- "\12\45\7\uffff\32\45\1\uffff\1\45\2\uffff\1\45\1\uffff\32\45",
- "\12\45\7\uffff\32\45\1\uffff\1\45\2\uffff\1\45\1\uffff\32\45",
- "\1\152",
- "",
- "",
- "\1\153",
- "\12\45\7\uffff\32\45\1\uffff\1\45\2\uffff\1\45\1\uffff\32\45",
- ""
- };
-
- static final short[] DFA26_eot = DFA.unpackEncodedString(DFA26_eotS);
- static final short[] DFA26_eof = DFA.unpackEncodedString(DFA26_eofS);
- static final char[] DFA26_min = DFA.unpackEncodedStringToUnsignedChars(DFA26_minS);
- static final char[] DFA26_max = DFA.unpackEncodedStringToUnsignedChars(DFA26_maxS);
- static final short[] DFA26_accept = DFA.unpackEncodedString(DFA26_acceptS);
- static final short[] DFA26_special = DFA.unpackEncodedString(DFA26_specialS);
- static final short[][] DFA26_transition;
-
- static {
- int numStates = DFA26_transitionS.length;
- DFA26_transition = new short[numStates][];
- for (int i=0; i", "", "", "", "INTEGER_LITERAL", "EXPRESSION", "QUALIFIED_IDENTIFIER", "PROPERTY_OR_FIELD", "INDEXER", "CONSTRUCTOR", "HOLDER", "NAMED_ARGUMENT", "FUNCTIONREF", "TYPEREF", "VARIABLEREF", "METHOD", "ADD", "SUBTRACT", "NUMBER", "ASSIGN", "DEFAULT", "QMARK", "COLON", "LPAREN", "RPAREN", "OR", "AND", "PLUS", "MINUS", "STAR", "DIV", "MOD", "POWER", "BANG", "DOT", "POUND", "ID", "COMMA", "LBRACKET", "RBRACKET", "PROJECT", "SELECT", "SELECT_FIRST", "SELECT_LAST", "TYPE", "STRING_LITERAL", "DQ_STRING_LITERAL", "NULL_LITERAL", "HEXADECIMAL_INTEGER_LITERAL", "REAL_LITERAL", "TRUE", "FALSE", "DECIMAL_DIGIT", "INTEGER_TYPE_SUFFIX", "HEX_DIGIT", "EQUAL", "NOT_EQUAL", "LESS_THAN", "LESS_THAN_OR_EQUAL", "GREATER_THAN", "GREATER_THAN_OR_EQUAL", "INSTANCEOF", "BETWEEN", "MATCHES", "SEMI", "LCURLY", "RCURLY", "PIPE", "APOS", "DOT_ESCAPED", "WS", "DOLLAR", "AT", "UPTO", "EXPONENT_PART", "REAL_TYPE_SUFFIX", "SIGN", "'new'"
- };
- public static final int SIGN=76;
- public static final int DOLLAR=71;
- public static final int DECIMAL_DIGIT=52;
- public static final int APOS=68;
- public static final int TYPEREF=13;
- public static final int HEXADECIMAL_INTEGER_LITERAL=48;
- public static final int STAR=29;
- public static final int MOD=31;
- public static final int VARIABLEREF=14;
- public static final int AND=26;
- public static final int ID=36;
- public static final int SUBTRACT=17;
- public static final int EOF=-1;
- public static final int UPTO=73;
- public static final int LPAREN=23;
- public static final int TYPE=44;
- public static final int HOLDER=10;
- public static final int AT=72;
- public static final int LBRACKET=38;
- public static final int QUALIFIED_IDENTIFIER=6;
- public static final int RPAREN=24;
- public static final int STRING_LITERAL=45;
- public static final int MATCHES=63;
- public static final int REAL_LITERAL=49;
- public static final int NOT_EQUAL=56;
- public static final int COMMA=37;
- public static final int FUNCTIONREF=12;
- public static final int EQUAL=55;
- public static final int PIPE=67;
- public static final int PLUS=27;
- public static final int RBRACKET=39;
- public static final int DOT=34;
- public static final int SELECT=41;
- public static final int EXPRESSION=5;
- public static final int ADD=16;
- public static final int LESS_THAN_OR_EQUAL=58;
- public static final int GREATER_THAN=59;
- public static final int POUND=35;
- public static final int PROJECT=40;
- public static final int SELECT_LAST=43;
- public static final int DEFAULT=20;
- public static final int NUMBER=18;
- public static final int REAL_TYPE_SUFFIX=75;
- public static final int HEX_DIGIT=54;
- public static final int POWER=32;
- public static final int LCURLY=65;
- public static final int NULL_LITERAL=47;
- public static final int PROPERTY_OR_FIELD=7;
- public static final int BANG=33;
- public static final int INSTANCEOF=61;
- public static final int MINUS=28;
- public static final int SEMI=64;
- public static final int TRUE=50;
- public static final int COLON=22;
- public static final int GREATER_THAN_OR_EQUAL=60;
- public static final int WS=70;
- public static final int DOT_ESCAPED=69;
- public static final int DQ_STRING_LITERAL=46;
- public static final int INTEGER_LITERAL=4;
- public static final int RCURLY=66;
- public static final int INDEXER=8;
- public static final int OR=25;
- public static final int LESS_THAN=57;
- public static final int ASSIGN=19;
- public static final int NAMED_ARGUMENT=11;
- public static final int SELECT_FIRST=42;
- public static final int DIV=30;
- public static final int FALSE=51;
- public static final int EXPONENT_PART=74;
- public static final int BETWEEN=62;
- public static final int INTEGER_TYPE_SUFFIX=53;
- public static final int METHOD=15;
- public static final int CONSTRUCTOR=9;
- public static final int QMARK=21;
-
- public SpringExpressionsParser(TokenStream input) {
- super(input);
- ruleMemo = new HashMap[40+1];
- }
-
- protected TreeAdaptor adaptor = new CommonTreeAdaptor();
-
- public void setTreeAdaptor(TreeAdaptor adaptor) {
- this.adaptor = adaptor;
- }
- public TreeAdaptor getTreeAdaptor() {
- return adaptor;
- }
-
- public String[] getTokenNames() { return tokenNames; }
- public String getGrammarFileName() { return "F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g"; }
-
-
- // For collecting info whilst processing rules that can be used in messages
- protected Stack paraphrase = new Stack();
-
-
- public static class expr_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start expr
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:45:1: expr : expression EOF ;
- public final expr_return expr() throws RecognitionException {
- expr_return retval = new expr_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token EOF2=null;
- expression_return expression1 = null;
-
-
- Object EOF2_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:45:5: ( expression EOF )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:45:7: expression EOF
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_expression_in_expr130);
- expression1=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, expression1.getTree());
- EOF2=(Token)input.LT(1);
- match(input,EOF,FOLLOW_EOF_in_expr132); if (failed) return retval;
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end expr
-
- public static class expression_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start expression
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:47:1: expression : logicalOrExpression ( ( ASSIGN logicalOrExpression ) | ( DEFAULT logicalOrExpression ) | ( QMARK expression COLON expression ) )? ;
- public final expression_return expression() throws RecognitionException {
- expression_return retval = new expression_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token ASSIGN4=null;
- Token DEFAULT6=null;
- Token QMARK8=null;
- Token COLON10=null;
- logicalOrExpression_return logicalOrExpression3 = null;
-
- logicalOrExpression_return logicalOrExpression5 = null;
-
- logicalOrExpression_return logicalOrExpression7 = null;
-
- expression_return expression9 = null;
-
- expression_return expression11 = null;
-
-
- Object ASSIGN4_tree=null;
- Object DEFAULT6_tree=null;
- Object QMARK8_tree=null;
- Object COLON10_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:47:12: ( logicalOrExpression ( ( ASSIGN logicalOrExpression ) | ( DEFAULT logicalOrExpression ) | ( QMARK expression COLON expression ) )? )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:48:5: logicalOrExpression ( ( ASSIGN logicalOrExpression ) | ( DEFAULT logicalOrExpression ) | ( QMARK expression COLON expression ) )?
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_logicalOrExpression_in_expression152);
- logicalOrExpression3=logicalOrExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, logicalOrExpression3.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:49:5: ( ( ASSIGN logicalOrExpression ) | ( DEFAULT logicalOrExpression ) | ( QMARK expression COLON expression ) )?
- int alt1=4;
- switch ( input.LA(1) ) {
- case ASSIGN:
- {
- alt1=1;
- }
- break;
- case DEFAULT:
- {
- alt1=2;
- }
- break;
- case QMARK:
- {
- alt1=3;
- }
- break;
- }
-
- switch (alt1) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:49:7: ( ASSIGN logicalOrExpression )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:49:7: ( ASSIGN logicalOrExpression )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:49:8: ASSIGN logicalOrExpression
- {
- ASSIGN4=(Token)input.LT(1);
- match(input,ASSIGN,FOLLOW_ASSIGN_in_expression161); if (failed) return retval;
- if ( backtracking==0 ) {
- ASSIGN4_tree = (Object)adaptor.create(ASSIGN4);
- root_0 = (Object)adaptor.becomeRoot(ASSIGN4_tree, root_0);
- }
- pushFollow(FOLLOW_logicalOrExpression_in_expression164);
- logicalOrExpression5=logicalOrExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, logicalOrExpression5.getTree());
-
- }
-
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:50:6: ( DEFAULT logicalOrExpression )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:50:6: ( DEFAULT logicalOrExpression )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:50:7: DEFAULT logicalOrExpression
- {
- DEFAULT6=(Token)input.LT(1);
- match(input,DEFAULT,FOLLOW_DEFAULT_in_expression174); if (failed) return retval;
- if ( backtracking==0 ) {
- DEFAULT6_tree = (Object)adaptor.create(DEFAULT6);
- root_0 = (Object)adaptor.becomeRoot(DEFAULT6_tree, root_0);
- }
- pushFollow(FOLLOW_logicalOrExpression_in_expression177);
- logicalOrExpression7=logicalOrExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, logicalOrExpression7.getTree());
-
- }
-
-
- }
- break;
- case 3 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:51:6: ( QMARK expression COLON expression )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:51:6: ( QMARK expression COLON expression )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:51:7: QMARK expression COLON expression
- {
- QMARK8=(Token)input.LT(1);
- match(input,QMARK,FOLLOW_QMARK_in_expression187); if (failed) return retval;
- if ( backtracking==0 ) {
- QMARK8_tree = (Object)adaptor.create(QMARK8);
- root_0 = (Object)adaptor.becomeRoot(QMARK8_tree, root_0);
- }
- pushFollow(FOLLOW_expression_in_expression190);
- expression9=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, expression9.getTree());
- COLON10=(Token)input.LT(1);
- match(input,COLON,FOLLOW_COLON_in_expression192); if (failed) return retval;
- pushFollow(FOLLOW_expression_in_expression195);
- expression11=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, expression11.getTree());
-
- }
-
-
- }
- break;
-
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end expression
-
- public static class parenExpr_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start parenExpr
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:53:1: parenExpr : LPAREN expression RPAREN ;
- public final parenExpr_return parenExpr() throws RecognitionException {
- parenExpr_return retval = new parenExpr_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token LPAREN12=null;
- Token RPAREN14=null;
- expression_return expression13 = null;
-
-
- Object LPAREN12_tree=null;
- Object RPAREN14_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:53:11: ( LPAREN expression RPAREN )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:53:13: LPAREN expression RPAREN
- {
- root_0 = (Object)adaptor.nil();
-
- LPAREN12=(Token)input.LT(1);
- match(input,LPAREN,FOLLOW_LPAREN_in_parenExpr206); if (failed) return retval;
- pushFollow(FOLLOW_expression_in_parenExpr209);
- expression13=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, expression13.getTree());
- RPAREN14=(Token)input.LT(1);
- match(input,RPAREN,FOLLOW_RPAREN_in_parenExpr211); if (failed) return retval;
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end parenExpr
-
- public static class logicalOrExpression_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start logicalOrExpression
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:55:1: logicalOrExpression : logicalAndExpression ( OR logicalAndExpression )* ;
- public final logicalOrExpression_return logicalOrExpression() throws RecognitionException {
- logicalOrExpression_return retval = new logicalOrExpression_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token OR16=null;
- logicalAndExpression_return logicalAndExpression15 = null;
-
- logicalAndExpression_return logicalAndExpression17 = null;
-
-
- Object OR16_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:56:1: ( logicalAndExpression ( OR logicalAndExpression )* )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:56:3: logicalAndExpression ( OR logicalAndExpression )*
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_logicalAndExpression_in_logicalOrExpression222);
- logicalAndExpression15=logicalAndExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, logicalAndExpression15.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:56:24: ( OR logicalAndExpression )*
- loop2:
- do {
- int alt2=2;
- int LA2_0 = input.LA(1);
-
- if ( (LA2_0==OR) ) {
- alt2=1;
- }
-
-
- switch (alt2) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:56:25: OR logicalAndExpression
- {
- OR16=(Token)input.LT(1);
- match(input,OR,FOLLOW_OR_in_logicalOrExpression225); if (failed) return retval;
- if ( backtracking==0 ) {
- OR16_tree = (Object)adaptor.create(OR16);
- root_0 = (Object)adaptor.becomeRoot(OR16_tree, root_0);
- }
- pushFollow(FOLLOW_logicalAndExpression_in_logicalOrExpression228);
- logicalAndExpression17=logicalAndExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, logicalAndExpression17.getTree());
-
- }
- break;
-
- default :
- break loop2;
- }
- } while (true);
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end logicalOrExpression
-
- public static class logicalAndExpression_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start logicalAndExpression
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:58:1: logicalAndExpression : relationalExpression ( AND relationalExpression )* ;
- public final logicalAndExpression_return logicalAndExpression() throws RecognitionException {
- logicalAndExpression_return retval = new logicalAndExpression_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token AND19=null;
- relationalExpression_return relationalExpression18 = null;
-
- relationalExpression_return relationalExpression20 = null;
-
-
- Object AND19_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:59:1: ( relationalExpression ( AND relationalExpression )* )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:59:3: relationalExpression ( AND relationalExpression )*
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_relationalExpression_in_logicalAndExpression263);
- relationalExpression18=relationalExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, relationalExpression18.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:59:24: ( AND relationalExpression )*
- loop3:
- do {
- int alt3=2;
- int LA3_0 = input.LA(1);
-
- if ( (LA3_0==AND) ) {
- alt3=1;
- }
-
-
- switch (alt3) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:59:25: AND relationalExpression
- {
- AND19=(Token)input.LT(1);
- match(input,AND,FOLLOW_AND_in_logicalAndExpression266); if (failed) return retval;
- if ( backtracking==0 ) {
- AND19_tree = (Object)adaptor.create(AND19);
- root_0 = (Object)adaptor.becomeRoot(AND19_tree, root_0);
- }
- pushFollow(FOLLOW_relationalExpression_in_logicalAndExpression269);
- relationalExpression20=relationalExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, relationalExpression20.getTree());
-
- }
- break;
-
- default :
- break loop3;
- }
- } while (true);
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end logicalAndExpression
-
- public static class relationalExpression_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start relationalExpression
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:61:1: relationalExpression : sumExpression ( relationalOperator sumExpression )? ;
- public final relationalExpression_return relationalExpression() throws RecognitionException {
- relationalExpression_return retval = new relationalExpression_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- sumExpression_return sumExpression21 = null;
-
- relationalOperator_return relationalOperator22 = null;
-
- sumExpression_return sumExpression23 = null;
-
-
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:61:22: ( sumExpression ( relationalOperator sumExpression )? )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:61:24: sumExpression ( relationalOperator sumExpression )?
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_sumExpression_in_relationalExpression280);
- sumExpression21=sumExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, sumExpression21.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:61:38: ( relationalOperator sumExpression )?
- int alt4=2;
- int LA4_0 = input.LA(1);
-
- if ( ((LA4_0>=EQUAL && LA4_0<=MATCHES)) ) {
- alt4=1;
- }
- switch (alt4) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:61:39: relationalOperator sumExpression
- {
- pushFollow(FOLLOW_relationalOperator_in_relationalExpression283);
- relationalOperator22=relationalOperator();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) root_0 = (Object)adaptor.becomeRoot(relationalOperator22.getTree(), root_0);
- pushFollow(FOLLOW_sumExpression_in_relationalExpression286);
- sumExpression23=sumExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, sumExpression23.getTree());
-
- }
- break;
-
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end relationalExpression
-
- public static class sumExpression_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start sumExpression
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:63:1: sumExpression : productExpression ( ( PLUS | MINUS ) productExpression )* ;
- public final sumExpression_return sumExpression() throws RecognitionException {
- sumExpression_return retval = new sumExpression_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token PLUS25=null;
- Token MINUS26=null;
- productExpression_return productExpression24 = null;
-
- productExpression_return productExpression27 = null;
-
-
- Object PLUS25_tree=null;
- Object MINUS26_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:64:2: ( productExpression ( ( PLUS | MINUS ) productExpression )* )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:64:4: productExpression ( ( PLUS | MINUS ) productExpression )*
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_productExpression_in_sumExpression297);
- productExpression24=productExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, productExpression24.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:64:22: ( ( PLUS | MINUS ) productExpression )*
- loop6:
- do {
- int alt6=2;
- int LA6_0 = input.LA(1);
-
- if ( ((LA6_0>=PLUS && LA6_0<=MINUS)) ) {
- alt6=1;
- }
-
-
- switch (alt6) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:64:24: ( PLUS | MINUS ) productExpression
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:64:24: ( PLUS | MINUS )
- int alt5=2;
- int LA5_0 = input.LA(1);
-
- if ( (LA5_0==PLUS) ) {
- alt5=1;
- }
- else if ( (LA5_0==MINUS) ) {
- alt5=2;
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("64:24: ( PLUS | MINUS )", 5, 0, input);
-
- throw nvae;
- }
- switch (alt5) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:64:25: PLUS
- {
- PLUS25=(Token)input.LT(1);
- match(input,PLUS,FOLLOW_PLUS_in_sumExpression302); if (failed) return retval;
- if ( backtracking==0 ) {
- PLUS25_tree = (Object)adaptor.create(PLUS25);
- root_0 = (Object)adaptor.becomeRoot(PLUS25_tree, root_0);
- }
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:64:33: MINUS
- {
- MINUS26=(Token)input.LT(1);
- match(input,MINUS,FOLLOW_MINUS_in_sumExpression307); if (failed) return retval;
- if ( backtracking==0 ) {
- MINUS26_tree = (Object)adaptor.create(MINUS26);
- root_0 = (Object)adaptor.becomeRoot(MINUS26_tree, root_0);
- }
-
- }
- break;
-
- }
-
- pushFollow(FOLLOW_productExpression_in_sumExpression311);
- productExpression27=productExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, productExpression27.getTree());
-
- }
- break;
-
- default :
- break loop6;
- }
- } while (true);
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end sumExpression
-
- public static class productExpression_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start productExpression
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:66:1: productExpression : powerExpr ( ( STAR | DIV | MOD ) powerExpr )* ;
- public final productExpression_return productExpression() throws RecognitionException {
- productExpression_return retval = new productExpression_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token STAR29=null;
- Token DIV30=null;
- Token MOD31=null;
- powerExpr_return powerExpr28 = null;
-
- powerExpr_return powerExpr32 = null;
-
-
- Object STAR29_tree=null;
- Object DIV30_tree=null;
- Object MOD31_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:67:2: ( powerExpr ( ( STAR | DIV | MOD ) powerExpr )* )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:67:4: powerExpr ( ( STAR | DIV | MOD ) powerExpr )*
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_powerExpr_in_productExpression322);
- powerExpr28=powerExpr();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, powerExpr28.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:67:14: ( ( STAR | DIV | MOD ) powerExpr )*
- loop8:
- do {
- int alt8=2;
- int LA8_0 = input.LA(1);
-
- if ( ((LA8_0>=STAR && LA8_0<=MOD)) ) {
- alt8=1;
- }
-
-
- switch (alt8) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:67:15: ( STAR | DIV | MOD ) powerExpr
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:67:15: ( STAR | DIV | MOD )
- int alt7=3;
- switch ( input.LA(1) ) {
- case STAR:
- {
- alt7=1;
- }
- break;
- case DIV:
- {
- alt7=2;
- }
- break;
- case MOD:
- {
- alt7=3;
- }
- break;
- default:
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("67:15: ( STAR | DIV | MOD )", 7, 0, input);
-
- throw nvae;
- }
-
- switch (alt7) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:67:16: STAR
- {
- STAR29=(Token)input.LT(1);
- match(input,STAR,FOLLOW_STAR_in_productExpression326); if (failed) return retval;
- if ( backtracking==0 ) {
- STAR29_tree = (Object)adaptor.create(STAR29);
- root_0 = (Object)adaptor.becomeRoot(STAR29_tree, root_0);
- }
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:67:24: DIV
- {
- DIV30=(Token)input.LT(1);
- match(input,DIV,FOLLOW_DIV_in_productExpression331); if (failed) return retval;
- if ( backtracking==0 ) {
- DIV30_tree = (Object)adaptor.create(DIV30);
- root_0 = (Object)adaptor.becomeRoot(DIV30_tree, root_0);
- }
-
- }
- break;
- case 3 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:67:30: MOD
- {
- MOD31=(Token)input.LT(1);
- match(input,MOD,FOLLOW_MOD_in_productExpression335); if (failed) return retval;
- if ( backtracking==0 ) {
- MOD31_tree = (Object)adaptor.create(MOD31);
- root_0 = (Object)adaptor.becomeRoot(MOD31_tree, root_0);
- }
-
- }
- break;
-
- }
-
- pushFollow(FOLLOW_powerExpr_in_productExpression339);
- powerExpr32=powerExpr();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, powerExpr32.getTree());
-
- }
- break;
-
- default :
- break loop8;
- }
- } while (true);
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end productExpression
-
- public static class powerExpr_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start powerExpr
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:69:1: powerExpr : unaryExpression ( POWER unaryExpression )? ;
- public final powerExpr_return powerExpr() throws RecognitionException {
- powerExpr_return retval = new powerExpr_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token POWER34=null;
- unaryExpression_return unaryExpression33 = null;
-
- unaryExpression_return unaryExpression35 = null;
-
-
- Object POWER34_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:69:12: ( unaryExpression ( POWER unaryExpression )? )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:69:14: unaryExpression ( POWER unaryExpression )?
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_unaryExpression_in_powerExpr351);
- unaryExpression33=unaryExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, unaryExpression33.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:69:30: ( POWER unaryExpression )?
- int alt9=2;
- int LA9_0 = input.LA(1);
-
- if ( (LA9_0==POWER) ) {
- alt9=1;
- }
- switch (alt9) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:69:31: POWER unaryExpression
- {
- POWER34=(Token)input.LT(1);
- match(input,POWER,FOLLOW_POWER_in_powerExpr354); if (failed) return retval;
- if ( backtracking==0 ) {
- POWER34_tree = (Object)adaptor.create(POWER34);
- root_0 = (Object)adaptor.becomeRoot(POWER34_tree, root_0);
- }
- pushFollow(FOLLOW_unaryExpression_in_powerExpr357);
- unaryExpression35=unaryExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, unaryExpression35.getTree());
-
- }
- break;
-
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end powerExpr
-
- public static class unaryExpression_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start unaryExpression
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:71:1: unaryExpression : ( ( PLUS | MINUS | BANG ) unaryExpression | primaryExpression );
- public final unaryExpression_return unaryExpression() throws RecognitionException {
- unaryExpression_return retval = new unaryExpression_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token PLUS36=null;
- Token MINUS37=null;
- Token BANG38=null;
- unaryExpression_return unaryExpression39 = null;
-
- primaryExpression_return primaryExpression40 = null;
-
-
- Object PLUS36_tree=null;
- Object MINUS37_tree=null;
- Object BANG38_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:72:2: ( ( PLUS | MINUS | BANG ) unaryExpression | primaryExpression )
- int alt11=2;
- int LA11_0 = input.LA(1);
-
- if ( ((LA11_0>=PLUS && LA11_0<=MINUS)||LA11_0==BANG) ) {
- alt11=1;
- }
- else if ( (LA11_0==INTEGER_LITERAL||LA11_0==LPAREN||(LA11_0>=POUND && LA11_0<=ID)||LA11_0==LBRACKET||(LA11_0>=PROJECT && LA11_0<=FALSE)||LA11_0==77) ) {
- alt11=2;
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("71:1: unaryExpression : ( ( PLUS | MINUS | BANG ) unaryExpression | primaryExpression );", 11, 0, input);
-
- throw nvae;
- }
- switch (alt11) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:72:4: ( PLUS | MINUS | BANG ) unaryExpression
- {
- root_0 = (Object)adaptor.nil();
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:72:4: ( PLUS | MINUS | BANG )
- int alt10=3;
- switch ( input.LA(1) ) {
- case PLUS:
- {
- alt10=1;
- }
- break;
- case MINUS:
- {
- alt10=2;
- }
- break;
- case BANG:
- {
- alt10=3;
- }
- break;
- default:
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("72:4: ( PLUS | MINUS | BANG )", 10, 0, input);
-
- throw nvae;
- }
-
- switch (alt10) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:72:5: PLUS
- {
- PLUS36=(Token)input.LT(1);
- match(input,PLUS,FOLLOW_PLUS_in_unaryExpression371); if (failed) return retval;
- if ( backtracking==0 ) {
- PLUS36_tree = (Object)adaptor.create(PLUS36);
- root_0 = (Object)adaptor.becomeRoot(PLUS36_tree, root_0);
- }
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:72:13: MINUS
- {
- MINUS37=(Token)input.LT(1);
- match(input,MINUS,FOLLOW_MINUS_in_unaryExpression376); if (failed) return retval;
- if ( backtracking==0 ) {
- MINUS37_tree = (Object)adaptor.create(MINUS37);
- root_0 = (Object)adaptor.becomeRoot(MINUS37_tree, root_0);
- }
-
- }
- break;
- case 3 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:72:22: BANG
- {
- BANG38=(Token)input.LT(1);
- match(input,BANG,FOLLOW_BANG_in_unaryExpression381); if (failed) return retval;
- if ( backtracking==0 ) {
- BANG38_tree = (Object)adaptor.create(BANG38);
- root_0 = (Object)adaptor.becomeRoot(BANG38_tree, root_0);
- }
-
- }
- break;
-
- }
-
- pushFollow(FOLLOW_unaryExpression_in_unaryExpression385);
- unaryExpression39=unaryExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, unaryExpression39.getTree());
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:73:4: primaryExpression
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_primaryExpression_in_unaryExpression391);
- primaryExpression40=primaryExpression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, primaryExpression40.getTree());
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end unaryExpression
-
- public static class primaryExpression_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start primaryExpression
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:75:1: primaryExpression : startNode ( node )? -> ^( EXPRESSION startNode ( node )? ) ;
- public final primaryExpression_return primaryExpression() throws RecognitionException {
- primaryExpression_return retval = new primaryExpression_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- startNode_return startNode41 = null;
-
- node_return node42 = null;
-
-
- RewriteRuleSubtreeStream stream_node=new RewriteRuleSubtreeStream(adaptor,"rule node");
- RewriteRuleSubtreeStream stream_startNode=new RewriteRuleSubtreeStream(adaptor,"rule startNode");
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:76:5: ( startNode ( node )? -> ^( EXPRESSION startNode ( node )? ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:76:7: startNode ( node )?
- {
- pushFollow(FOLLOW_startNode_in_primaryExpression405);
- startNode41=startNode();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_startNode.add(startNode41.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:76:17: ( node )?
- int alt12=2;
- int LA12_0 = input.LA(1);
-
- if ( (LA12_0==DOT||LA12_0==LBRACKET) ) {
- alt12=1;
- }
- switch (alt12) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:76:18: node
- {
- pushFollow(FOLLOW_node_in_primaryExpression408);
- node42=node();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_node.add(node42.getTree());
-
- }
- break;
-
- }
-
-
- // AST REWRITE
- // elements: startNode, node
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 76:25: -> ^( EXPRESSION startNode ( node )? )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:76:28: ^( EXPRESSION startNode ( node )? )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(EXPRESSION, "EXPRESSION"), root_1);
-
- adaptor.addChild(root_1, stream_startNode.next());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:76:51: ( node )?
- if ( stream_node.hasNext() ) {
- adaptor.addChild(root_1, stream_node.next());
-
- }
- stream_node.reset();
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end primaryExpression
-
- public static class startNode_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start startNode
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:78:1: startNode : ( parenExpr | methodOrProperty | functionOrVar | indexer | literal | type | constructor | projection | selection | firstSelection | lastSelection );
- public final startNode_return startNode() throws RecognitionException {
- startNode_return retval = new startNode_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- parenExpr_return parenExpr43 = null;
-
- methodOrProperty_return methodOrProperty44 = null;
-
- functionOrVar_return functionOrVar45 = null;
-
- indexer_return indexer46 = null;
-
- literal_return literal47 = null;
-
- type_return type48 = null;
-
- constructor_return constructor49 = null;
-
- projection_return projection50 = null;
-
- selection_return selection51 = null;
-
- firstSelection_return firstSelection52 = null;
-
- lastSelection_return lastSelection53 = null;
-
-
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:79:5: ( parenExpr | methodOrProperty | functionOrVar | indexer | literal | type | constructor | projection | selection | firstSelection | lastSelection )
- int alt13=11;
- switch ( input.LA(1) ) {
- case LPAREN:
- {
- alt13=1;
- }
- break;
- case ID:
- {
- alt13=2;
- }
- break;
- case POUND:
- {
- alt13=3;
- }
- break;
- case LBRACKET:
- {
- alt13=4;
- }
- break;
- case INTEGER_LITERAL:
- case STRING_LITERAL:
- case DQ_STRING_LITERAL:
- case NULL_LITERAL:
- case HEXADECIMAL_INTEGER_LITERAL:
- case REAL_LITERAL:
- case TRUE:
- case FALSE:
- {
- alt13=5;
- }
- break;
- case TYPE:
- {
- alt13=6;
- }
- break;
- case 77:
- {
- alt13=7;
- }
- break;
- case PROJECT:
- {
- alt13=8;
- }
- break;
- case SELECT:
- {
- alt13=9;
- }
- break;
- case SELECT_FIRST:
- {
- alt13=10;
- }
- break;
- case SELECT_LAST:
- {
- alt13=11;
- }
- break;
- default:
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("78:1: startNode : ( parenExpr | methodOrProperty | functionOrVar | indexer | literal | type | constructor | projection | selection | firstSelection | lastSelection );", 13, 0, input);
-
- throw nvae;
- }
-
- switch (alt13) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:80:5: parenExpr
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_parenExpr_in_startNode441);
- parenExpr43=parenExpr();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, parenExpr43.getTree());
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:81:7: methodOrProperty
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_methodOrProperty_in_startNode449);
- methodOrProperty44=methodOrProperty();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, methodOrProperty44.getTree());
-
- }
- break;
- case 3 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:82:7: functionOrVar
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_functionOrVar_in_startNode458);
- functionOrVar45=functionOrVar();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, functionOrVar45.getTree());
-
- }
- break;
- case 4 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:83:7: indexer
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_indexer_in_startNode466);
- indexer46=indexer();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, indexer46.getTree());
-
- }
- break;
- case 5 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:84:7: literal
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_literal_in_startNode474);
- literal47=literal();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, literal47.getTree());
-
- }
- break;
- case 6 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:85:7: type
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_type_in_startNode482);
- type48=type();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, type48.getTree());
-
- }
- break;
- case 7 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:86:7: constructor
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_constructor_in_startNode490);
- constructor49=constructor();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, constructor49.getTree());
-
- }
- break;
- case 8 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:87:7: projection
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_projection_in_startNode498);
- projection50=projection();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, projection50.getTree());
-
- }
- break;
- case 9 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:88:7: selection
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_selection_in_startNode507);
- selection51=selection();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, selection51.getTree());
-
- }
- break;
- case 10 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:89:7: firstSelection
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_firstSelection_in_startNode516);
- firstSelection52=firstSelection();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, firstSelection52.getTree());
-
- }
- break;
- case 11 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:90:7: lastSelection
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_lastSelection_in_startNode524);
- lastSelection53=lastSelection();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, lastSelection53.getTree());
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end startNode
-
- public static class node_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start node
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:93:1: node : ( ( DOT dottedNode ) | nonDottedNode )+ ;
- public final node_return node() throws RecognitionException {
- node_return retval = new node_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token DOT54=null;
- dottedNode_return dottedNode55 = null;
-
- nonDottedNode_return nonDottedNode56 = null;
-
-
- Object DOT54_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:94:2: ( ( ( DOT dottedNode ) | nonDottedNode )+ )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:94:4: ( ( DOT dottedNode ) | nonDottedNode )+
- {
- root_0 = (Object)adaptor.nil();
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:94:4: ( ( DOT dottedNode ) | nonDottedNode )+
- int cnt14=0;
- loop14:
- do {
- int alt14=3;
- int LA14_0 = input.LA(1);
-
- if ( (LA14_0==DOT) ) {
- alt14=1;
- }
- else if ( (LA14_0==LBRACKET) ) {
- alt14=2;
- }
-
-
- switch (alt14) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:94:5: ( DOT dottedNode )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:94:5: ( DOT dottedNode )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:94:6: DOT dottedNode
- {
- DOT54=(Token)input.LT(1);
- match(input,DOT,FOLLOW_DOT_in_node544); if (failed) return retval;
- if ( backtracking==0 ) {
- DOT54_tree = (Object)adaptor.create(DOT54);
- adaptor.addChild(root_0, DOT54_tree);
- }
- pushFollow(FOLLOW_dottedNode_in_node546);
- dottedNode55=dottedNode();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, dottedNode55.getTree());
-
- }
-
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:94:24: nonDottedNode
- {
- pushFollow(FOLLOW_nonDottedNode_in_node551);
- nonDottedNode56=nonDottedNode();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, nonDottedNode56.getTree());
-
- }
- break;
-
- default :
- if ( cnt14 >= 1 ) break loop14;
- if (backtracking>0) {failed=true; return retval;}
- EarlyExitException eee =
- new EarlyExitException(14, input);
- throw eee;
- }
- cnt14++;
- } while (true);
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end node
-
- public static class nonDottedNode_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start nonDottedNode
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:96:1: nonDottedNode : indexer ;
- public final nonDottedNode_return nonDottedNode() throws RecognitionException {
- nonDottedNode_return retval = new nonDottedNode_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- indexer_return indexer57 = null;
-
-
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:97:2: ( indexer )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:97:4: indexer
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_indexer_in_nonDottedNode563);
- indexer57=indexer();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, indexer57.getTree());
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end nonDottedNode
-
- public static class dottedNode_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start dottedNode
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:99:1: dottedNode : ( ( methodOrProperty | functionOrVar | projection | selection | firstSelection | lastSelection ) ) ;
- public final dottedNode_return dottedNode() throws RecognitionException {
- dottedNode_return retval = new dottedNode_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- methodOrProperty_return methodOrProperty58 = null;
-
- functionOrVar_return functionOrVar59 = null;
-
- projection_return projection60 = null;
-
- selection_return selection61 = null;
-
- firstSelection_return firstSelection62 = null;
-
- lastSelection_return lastSelection63 = null;
-
-
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:100:2: ( ( ( methodOrProperty | functionOrVar | projection | selection | firstSelection | lastSelection ) ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:101:2: ( ( methodOrProperty | functionOrVar | projection | selection | firstSelection | lastSelection ) )
- {
- root_0 = (Object)adaptor.nil();
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:101:2: ( ( methodOrProperty | functionOrVar | projection | selection | firstSelection | lastSelection ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:101:3: ( methodOrProperty | functionOrVar | projection | selection | firstSelection | lastSelection )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:101:3: ( methodOrProperty | functionOrVar | projection | selection | firstSelection | lastSelection )
- int alt15=6;
- switch ( input.LA(1) ) {
- case ID:
- {
- alt15=1;
- }
- break;
- case POUND:
- {
- alt15=2;
- }
- break;
- case PROJECT:
- {
- alt15=3;
- }
- break;
- case SELECT:
- {
- alt15=4;
- }
- break;
- case SELECT_FIRST:
- {
- alt15=5;
- }
- break;
- case SELECT_LAST:
- {
- alt15=6;
- }
- break;
- default:
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("101:3: ( methodOrProperty | functionOrVar | projection | selection | firstSelection | lastSelection )", 15, 0, input);
-
- throw nvae;
- }
-
- switch (alt15) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:101:4: methodOrProperty
- {
- pushFollow(FOLLOW_methodOrProperty_in_dottedNode576);
- methodOrProperty58=methodOrProperty();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, methodOrProperty58.getTree());
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:102:4: functionOrVar
- {
- pushFollow(FOLLOW_functionOrVar_in_dottedNode582);
- functionOrVar59=functionOrVar();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, functionOrVar59.getTree());
-
- }
- break;
- case 3 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:103:7: projection
- {
- pushFollow(FOLLOW_projection_in_dottedNode590);
- projection60=projection();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, projection60.getTree());
-
- }
- break;
- case 4 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:104:7: selection
- {
- pushFollow(FOLLOW_selection_in_dottedNode599);
- selection61=selection();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, selection61.getTree());
-
- }
- break;
- case 5 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:105:7: firstSelection
- {
- pushFollow(FOLLOW_firstSelection_in_dottedNode608);
- firstSelection62=firstSelection();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, firstSelection62.getTree());
-
- }
- break;
- case 6 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:106:7: lastSelection
- {
- pushFollow(FOLLOW_lastSelection_in_dottedNode617);
- lastSelection63=lastSelection();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, lastSelection63.getTree());
-
- }
- break;
-
- }
-
-
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end dottedNode
-
- public static class functionOrVar_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start functionOrVar
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:110:1: functionOrVar : ( ( POUND ID LPAREN )=> function | var );
- public final functionOrVar_return functionOrVar() throws RecognitionException {
- functionOrVar_return retval = new functionOrVar_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- function_return function64 = null;
-
- var_return var65 = null;
-
-
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:111:5: ( ( POUND ID LPAREN )=> function | var )
- int alt16=2;
- int LA16_0 = input.LA(1);
-
- if ( (LA16_0==POUND) ) {
- int LA16_1 = input.LA(2);
-
- if ( (LA16_1==ID) ) {
- int LA16_2 = input.LA(3);
-
- if ( (synpred1()) ) {
- alt16=1;
- }
- else if ( (true) ) {
- alt16=2;
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("110:1: functionOrVar : ( ( POUND ID LPAREN )=> function | var );", 16, 2, input);
-
- throw nvae;
- }
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("110:1: functionOrVar : ( ( POUND ID LPAREN )=> function | var );", 16, 1, input);
-
- throw nvae;
- }
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("110:1: functionOrVar : ( ( POUND ID LPAREN )=> function | var );", 16, 0, input);
-
- throw nvae;
- }
- switch (alt16) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:111:7: ( POUND ID LPAREN )=> function
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_function_in_functionOrVar651);
- function64=function();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, function64.getTree());
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:112:7: var
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_var_in_functionOrVar659);
- var65=var();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, var65.getTree());
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end functionOrVar
-
- public static class function_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start function
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:115:1: function : POUND id= ID methodArgs -> ^( FUNCTIONREF[$id] methodArgs ) ;
- public final function_return function() throws RecognitionException {
- function_return retval = new function_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token id=null;
- Token POUND66=null;
- methodArgs_return methodArgs67 = null;
-
-
- Object id_tree=null;
- Object POUND66_tree=null;
- RewriteRuleTokenStream stream_POUND=new RewriteRuleTokenStream(adaptor,"token POUND");
- RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
- RewriteRuleSubtreeStream stream_methodArgs=new RewriteRuleSubtreeStream(adaptor,"rule methodArgs");
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:115:10: ( POUND id= ID methodArgs -> ^( FUNCTIONREF[$id] methodArgs ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:115:12: POUND id= ID methodArgs
- {
- POUND66=(Token)input.LT(1);
- match(input,POUND,FOLLOW_POUND_in_function676); if (failed) return retval;
- if ( backtracking==0 ) stream_POUND.add(POUND66);
-
- id=(Token)input.LT(1);
- match(input,ID,FOLLOW_ID_in_function680); if (failed) return retval;
- if ( backtracking==0 ) stream_ID.add(id);
-
- pushFollow(FOLLOW_methodArgs_in_function682);
- methodArgs67=methodArgs();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_methodArgs.add(methodArgs67.getTree());
-
- // AST REWRITE
- // elements: methodArgs
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 115:35: -> ^( FUNCTIONREF[$id] methodArgs )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:115:38: ^( FUNCTIONREF[$id] methodArgs )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(FUNCTIONREF, id), root_1);
-
- adaptor.addChild(root_1, stream_methodArgs.next());
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end function
-
- public static class var_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start var
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:117:1: var : POUND id= ID -> ^( VARIABLEREF[$id] ) ;
- public final var_return var() throws RecognitionException {
- var_return retval = new var_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token id=null;
- Token POUND68=null;
-
- Object id_tree=null;
- Object POUND68_tree=null;
- RewriteRuleTokenStream stream_POUND=new RewriteRuleTokenStream(adaptor,"token POUND");
- RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:117:5: ( POUND id= ID -> ^( VARIABLEREF[$id] ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:117:7: POUND id= ID
- {
- POUND68=(Token)input.LT(1);
- match(input,POUND,FOLLOW_POUND_in_var703); if (failed) return retval;
- if ( backtracking==0 ) stream_POUND.add(POUND68);
-
- id=(Token)input.LT(1);
- match(input,ID,FOLLOW_ID_in_var707); if (failed) return retval;
- if ( backtracking==0 ) stream_ID.add(id);
-
-
- // AST REWRITE
- // elements:
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 117:19: -> ^( VARIABLEREF[$id] )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:117:22: ^( VARIABLEREF[$id] )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(VARIABLEREF, id), root_1);
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end var
-
- public static class methodOrProperty_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start methodOrProperty
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:120:1: methodOrProperty : ( ( ID LPAREN )=>id= ID methodArgs -> ^( METHOD[$id] methodArgs ) | property );
- public final methodOrProperty_return methodOrProperty() throws RecognitionException {
- methodOrProperty_return retval = new methodOrProperty_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token id=null;
- methodArgs_return methodArgs69 = null;
-
- property_return property70 = null;
-
-
- Object id_tree=null;
- RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
- RewriteRuleSubtreeStream stream_methodArgs=new RewriteRuleSubtreeStream(adaptor,"rule methodArgs");
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:121:2: ( ( ID LPAREN )=>id= ID methodArgs -> ^( METHOD[$id] methodArgs ) | property )
- int alt17=2;
- int LA17_0 = input.LA(1);
-
- if ( (LA17_0==ID) ) {
- int LA17_1 = input.LA(2);
-
- if ( (LA17_1==LPAREN) && (synpred2())) {
- alt17=1;
- }
- else if ( (LA17_1==EOF||(LA17_1>=ASSIGN && LA17_1<=COLON)||(LA17_1>=RPAREN && LA17_1<=POWER)||LA17_1==DOT||(LA17_1>=COMMA && LA17_1<=RBRACKET)||(LA17_1>=EQUAL && LA17_1<=MATCHES)) ) {
- alt17=2;
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("120:1: methodOrProperty : ( ( ID LPAREN )=>id= ID methodArgs -> ^( METHOD[$id] methodArgs ) | property );", 17, 1, input);
-
- throw nvae;
- }
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("120:1: methodOrProperty : ( ( ID LPAREN )=>id= ID methodArgs -> ^( METHOD[$id] methodArgs ) | property );", 17, 0, input);
-
- throw nvae;
- }
- switch (alt17) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:121:4: ( ID LPAREN )=>id= ID methodArgs
- {
- id=(Token)input.LT(1);
- match(input,ID,FOLLOW_ID_in_methodOrProperty735); if (failed) return retval;
- if ( backtracking==0 ) stream_ID.add(id);
-
- pushFollow(FOLLOW_methodArgs_in_methodOrProperty737);
- methodArgs69=methodArgs();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_methodArgs.add(methodArgs69.getTree());
-
- // AST REWRITE
- // elements: methodArgs
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 121:36: -> ^( METHOD[$id] methodArgs )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:121:39: ^( METHOD[$id] methodArgs )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(METHOD, id), root_1);
-
- adaptor.addChild(root_1, stream_methodArgs.next());
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:122:4: property
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_property_in_methodOrProperty751);
- property70=property();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, property70.getTree());
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end methodOrProperty
-
- public static class methodArgs_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start methodArgs
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:128:1: methodArgs : LPAREN ( argument ( COMMA argument )* ( COMMA )? )? RPAREN ;
- public final methodArgs_return methodArgs() throws RecognitionException {
- methodArgs_return retval = new methodArgs_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token LPAREN71=null;
- Token COMMA73=null;
- Token COMMA75=null;
- Token RPAREN76=null;
- argument_return argument72 = null;
-
- argument_return argument74 = null;
-
-
- Object LPAREN71_tree=null;
- Object COMMA73_tree=null;
- Object COMMA75_tree=null;
- Object RPAREN76_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:128:12: ( LPAREN ( argument ( COMMA argument )* ( COMMA )? )? RPAREN )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:128:15: LPAREN ( argument ( COMMA argument )* ( COMMA )? )? RPAREN
- {
- root_0 = (Object)adaptor.nil();
-
- LPAREN71=(Token)input.LT(1);
- match(input,LPAREN,FOLLOW_LPAREN_in_methodArgs766); if (failed) return retval;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:128:23: ( argument ( COMMA argument )* ( COMMA )? )?
- int alt20=2;
- int LA20_0 = input.LA(1);
-
- if ( (LA20_0==INTEGER_LITERAL||LA20_0==LPAREN||(LA20_0>=PLUS && LA20_0<=MINUS)||LA20_0==BANG||(LA20_0>=POUND && LA20_0<=ID)||LA20_0==LBRACKET||(LA20_0>=PROJECT && LA20_0<=FALSE)||LA20_0==77) ) {
- alt20=1;
- }
- switch (alt20) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:128:24: argument ( COMMA argument )* ( COMMA )?
- {
- pushFollow(FOLLOW_argument_in_methodArgs770);
- argument72=argument();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, argument72.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:128:33: ( COMMA argument )*
- loop18:
- do {
- int alt18=2;
- int LA18_0 = input.LA(1);
-
- if ( (LA18_0==COMMA) ) {
- int LA18_1 = input.LA(2);
-
- if ( (LA18_1==INTEGER_LITERAL||LA18_1==LPAREN||(LA18_1>=PLUS && LA18_1<=MINUS)||LA18_1==BANG||(LA18_1>=POUND && LA18_1<=ID)||LA18_1==LBRACKET||(LA18_1>=PROJECT && LA18_1<=FALSE)||LA18_1==77) ) {
- alt18=1;
- }
-
-
- }
-
-
- switch (alt18) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:128:34: COMMA argument
- {
- COMMA73=(Token)input.LT(1);
- match(input,COMMA,FOLLOW_COMMA_in_methodArgs773); if (failed) return retval;
- pushFollow(FOLLOW_argument_in_methodArgs776);
- argument74=argument();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, argument74.getTree());
-
- }
- break;
-
- default :
- break loop18;
- }
- } while (true);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:128:52: ( COMMA )?
- int alt19=2;
- int LA19_0 = input.LA(1);
-
- if ( (LA19_0==COMMA) ) {
- alt19=1;
- }
- switch (alt19) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:128:53: COMMA
- {
- COMMA75=(Token)input.LT(1);
- match(input,COMMA,FOLLOW_COMMA_in_methodArgs781); if (failed) return retval;
-
- }
- break;
-
- }
-
-
- }
- break;
-
- }
-
- RPAREN76=(Token)input.LT(1);
- match(input,RPAREN,FOLLOW_RPAREN_in_methodArgs788); if (failed) return retval;
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end methodArgs
-
- public static class property_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start property
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:133:1: property : id= ID -> ^( PROPERTY_OR_FIELD[$id] ) ;
- public final property_return property() throws RecognitionException {
- property_return retval = new property_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token id=null;
-
- Object id_tree=null;
- RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:133:9: (id= ID -> ^( PROPERTY_OR_FIELD[$id] ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:133:11: id= ID
- {
- id=(Token)input.LT(1);
- match(input,ID,FOLLOW_ID_in_property801); if (failed) return retval;
- if ( backtracking==0 ) stream_ID.add(id);
-
-
- // AST REWRITE
- // elements:
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 133:17: -> ^( PROPERTY_OR_FIELD[$id] )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:133:20: ^( PROPERTY_OR_FIELD[$id] )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(PROPERTY_OR_FIELD, id), root_1);
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end property
-
- public static class indexer_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start indexer
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:136:1: indexer : LBRACKET r1= argument ( COMMA r2= argument )* RBRACKET -> ^( INDEXER $r1 ( $r2)* ) ;
- public final indexer_return indexer() throws RecognitionException {
- indexer_return retval = new indexer_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token LBRACKET77=null;
- Token COMMA78=null;
- Token RBRACKET79=null;
- argument_return r1 = null;
-
- argument_return r2 = null;
-
-
- Object LBRACKET77_tree=null;
- Object COMMA78_tree=null;
- Object RBRACKET79_tree=null;
- RewriteRuleTokenStream stream_LBRACKET=new RewriteRuleTokenStream(adaptor,"token LBRACKET");
- RewriteRuleTokenStream stream_RBRACKET=new RewriteRuleTokenStream(adaptor,"token RBRACKET");
- RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
- RewriteRuleSubtreeStream stream_argument=new RewriteRuleSubtreeStream(adaptor,"rule argument");
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:136:8: ( LBRACKET r1= argument ( COMMA r2= argument )* RBRACKET -> ^( INDEXER $r1 ( $r2)* ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:136:10: LBRACKET r1= argument ( COMMA r2= argument )* RBRACKET
- {
- LBRACKET77=(Token)input.LT(1);
- match(input,LBRACKET,FOLLOW_LBRACKET_in_indexer816); if (failed) return retval;
- if ( backtracking==0 ) stream_LBRACKET.add(LBRACKET77);
-
- pushFollow(FOLLOW_argument_in_indexer820);
- r1=argument();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_argument.add(r1.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:136:31: ( COMMA r2= argument )*
- loop21:
- do {
- int alt21=2;
- int LA21_0 = input.LA(1);
-
- if ( (LA21_0==COMMA) ) {
- alt21=1;
- }
-
-
- switch (alt21) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:136:32: COMMA r2= argument
- {
- COMMA78=(Token)input.LT(1);
- match(input,COMMA,FOLLOW_COMMA_in_indexer823); if (failed) return retval;
- if ( backtracking==0 ) stream_COMMA.add(COMMA78);
-
- pushFollow(FOLLOW_argument_in_indexer827);
- r2=argument();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_argument.add(r2.getTree());
-
- }
- break;
-
- default :
- break loop21;
- }
- } while (true);
-
- RBRACKET79=(Token)input.LT(1);
- match(input,RBRACKET,FOLLOW_RBRACKET_in_indexer831); if (failed) return retval;
- if ( backtracking==0 ) stream_RBRACKET.add(RBRACKET79);
-
-
- // AST REWRITE
- // elements: r1, r2
- // token labels:
- // rule labels: retval, r1, r2
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
- RewriteRuleSubtreeStream stream_r1=new RewriteRuleSubtreeStream(adaptor,"token r1",r1!=null?r1.tree:null);
- RewriteRuleSubtreeStream stream_r2=new RewriteRuleSubtreeStream(adaptor,"token r2",r2!=null?r2.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 136:61: -> ^( INDEXER $r1 ( $r2)* )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:136:64: ^( INDEXER $r1 ( $r2)* )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(INDEXER, "INDEXER"), root_1);
-
- adaptor.addChild(root_1, stream_r1.next());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:136:78: ( $r2)*
- while ( stream_r2.hasNext() ) {
- adaptor.addChild(root_1, stream_r2.next());
-
- }
- stream_r2.reset();
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end indexer
-
- public static class projection_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start projection
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:140:1: projection : PROJECT expression RBRACKET ;
- public final projection_return projection() throws RecognitionException {
- projection_return retval = new projection_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token PROJECT80=null;
- Token RBRACKET82=null;
- expression_return expression81 = null;
-
-
- Object PROJECT80_tree=null;
- Object RBRACKET82_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:140:11: ( PROJECT expression RBRACKET )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:140:13: PROJECT expression RBRACKET
- {
- root_0 = (Object)adaptor.nil();
-
- PROJECT80=(Token)input.LT(1);
- match(input,PROJECT,FOLLOW_PROJECT_in_projection857); if (failed) return retval;
- if ( backtracking==0 ) {
- PROJECT80_tree = (Object)adaptor.create(PROJECT80);
- root_0 = (Object)adaptor.becomeRoot(PROJECT80_tree, root_0);
- }
- pushFollow(FOLLOW_expression_in_projection860);
- expression81=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, expression81.getTree());
- RBRACKET82=(Token)input.LT(1);
- match(input,RBRACKET,FOLLOW_RBRACKET_in_projection862); if (failed) return retval;
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end projection
-
- public static class selection_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start selection
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:142:1: selection : SELECT expression RBRACKET ;
- public final selection_return selection() throws RecognitionException {
- selection_return retval = new selection_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token SELECT83=null;
- Token RBRACKET85=null;
- expression_return expression84 = null;
-
-
- Object SELECT83_tree=null;
- Object RBRACKET85_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:142:10: ( SELECT expression RBRACKET )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:142:12: SELECT expression RBRACKET
- {
- root_0 = (Object)adaptor.nil();
-
- SELECT83=(Token)input.LT(1);
- match(input,SELECT,FOLLOW_SELECT_in_selection870); if (failed) return retval;
- if ( backtracking==0 ) {
- SELECT83_tree = (Object)adaptor.create(SELECT83);
- root_0 = (Object)adaptor.becomeRoot(SELECT83_tree, root_0);
- }
- pushFollow(FOLLOW_expression_in_selection873);
- expression84=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, expression84.getTree());
- RBRACKET85=(Token)input.LT(1);
- match(input,RBRACKET,FOLLOW_RBRACKET_in_selection875); if (failed) return retval;
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end selection
-
- public static class firstSelection_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start firstSelection
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:144:1: firstSelection : SELECT_FIRST expression RBRACKET ;
- public final firstSelection_return firstSelection() throws RecognitionException {
- firstSelection_return retval = new firstSelection_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token SELECT_FIRST86=null;
- Token RBRACKET88=null;
- expression_return expression87 = null;
-
-
- Object SELECT_FIRST86_tree=null;
- Object RBRACKET88_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:144:15: ( SELECT_FIRST expression RBRACKET )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:144:17: SELECT_FIRST expression RBRACKET
- {
- root_0 = (Object)adaptor.nil();
-
- SELECT_FIRST86=(Token)input.LT(1);
- match(input,SELECT_FIRST,FOLLOW_SELECT_FIRST_in_firstSelection883); if (failed) return retval;
- if ( backtracking==0 ) {
- SELECT_FIRST86_tree = (Object)adaptor.create(SELECT_FIRST86);
- root_0 = (Object)adaptor.becomeRoot(SELECT_FIRST86_tree, root_0);
- }
- pushFollow(FOLLOW_expression_in_firstSelection886);
- expression87=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, expression87.getTree());
- RBRACKET88=(Token)input.LT(1);
- match(input,RBRACKET,FOLLOW_RBRACKET_in_firstSelection888); if (failed) return retval;
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end firstSelection
-
- public static class lastSelection_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start lastSelection
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:146:1: lastSelection : SELECT_LAST expression RBRACKET ;
- public final lastSelection_return lastSelection() throws RecognitionException {
- lastSelection_return retval = new lastSelection_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token SELECT_LAST89=null;
- Token RBRACKET91=null;
- expression_return expression90 = null;
-
-
- Object SELECT_LAST89_tree=null;
- Object RBRACKET91_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:146:14: ( SELECT_LAST expression RBRACKET )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:146:16: SELECT_LAST expression RBRACKET
- {
- root_0 = (Object)adaptor.nil();
-
- SELECT_LAST89=(Token)input.LT(1);
- match(input,SELECT_LAST,FOLLOW_SELECT_LAST_in_lastSelection896); if (failed) return retval;
- if ( backtracking==0 ) {
- SELECT_LAST89_tree = (Object)adaptor.create(SELECT_LAST89);
- root_0 = (Object)adaptor.becomeRoot(SELECT_LAST89_tree, root_0);
- }
- pushFollow(FOLLOW_expression_in_lastSelection899);
- expression90=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, expression90.getTree());
- RBRACKET91=(Token)input.LT(1);
- match(input,RBRACKET,FOLLOW_RBRACKET_in_lastSelection901); if (failed) return retval;
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end lastSelection
-
- public static class type_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start type
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:149:1: type : TYPE qualifiedId RPAREN -> ^( TYPEREF qualifiedId ) ;
- public final type_return type() throws RecognitionException {
- type_return retval = new type_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token TYPE92=null;
- Token RPAREN94=null;
- qualifiedId_return qualifiedId93 = null;
-
-
- Object TYPE92_tree=null;
- Object RPAREN94_tree=null;
- RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
- RewriteRuleTokenStream stream_TYPE=new RewriteRuleTokenStream(adaptor,"token TYPE");
- RewriteRuleSubtreeStream stream_qualifiedId=new RewriteRuleSubtreeStream(adaptor,"rule qualifiedId");
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:149:5: ( TYPE qualifiedId RPAREN -> ^( TYPEREF qualifiedId ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:149:7: TYPE qualifiedId RPAREN
- {
- TYPE92=(Token)input.LT(1);
- match(input,TYPE,FOLLOW_TYPE_in_type910); if (failed) return retval;
- if ( backtracking==0 ) stream_TYPE.add(TYPE92);
-
- pushFollow(FOLLOW_qualifiedId_in_type912);
- qualifiedId93=qualifiedId();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_qualifiedId.add(qualifiedId93.getTree());
- RPAREN94=(Token)input.LT(1);
- match(input,RPAREN,FOLLOW_RPAREN_in_type914); if (failed) return retval;
- if ( backtracking==0 ) stream_RPAREN.add(RPAREN94);
-
-
- // AST REWRITE
- // elements: qualifiedId
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 149:31: -> ^( TYPEREF qualifiedId )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:149:34: ^( TYPEREF qualifiedId )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(TYPEREF, "TYPEREF"), root_1);
-
- adaptor.addChild(root_1, stream_qualifiedId.next());
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end type
-
- public static class constructor_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start constructor
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:153:1: constructor : ( 'new' qualifiedId LPAREN )=> 'new' qualifiedId ctorArgs -> ^( CONSTRUCTOR qualifiedId ctorArgs ) ;
- public final constructor_return constructor() throws RecognitionException {
- constructor_return retval = new constructor_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token string_literal95=null;
- qualifiedId_return qualifiedId96 = null;
-
- ctorArgs_return ctorArgs97 = null;
-
-
- Object string_literal95_tree=null;
- RewriteRuleTokenStream stream_77=new RewriteRuleTokenStream(adaptor,"token 77");
- RewriteRuleSubtreeStream stream_qualifiedId=new RewriteRuleSubtreeStream(adaptor,"rule qualifiedId");
- RewriteRuleSubtreeStream stream_ctorArgs=new RewriteRuleSubtreeStream(adaptor,"rule ctorArgs");
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:154:2: ( ( 'new' qualifiedId LPAREN )=> 'new' qualifiedId ctorArgs -> ^( CONSTRUCTOR qualifiedId ctorArgs ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:154:4: ( 'new' qualifiedId LPAREN )=> 'new' qualifiedId ctorArgs
- {
- string_literal95=(Token)input.LT(1);
- match(input,77,FOLLOW_77_in_constructor945); if (failed) return retval;
- if ( backtracking==0 ) stream_77.add(string_literal95);
-
- pushFollow(FOLLOW_qualifiedId_in_constructor947);
- qualifiedId96=qualifiedId();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_qualifiedId.add(qualifiedId96.getTree());
- pushFollow(FOLLOW_ctorArgs_in_constructor949);
- ctorArgs97=ctorArgs();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_ctorArgs.add(ctorArgs97.getTree());
-
- // AST REWRITE
- // elements: ctorArgs, qualifiedId
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 154:61: -> ^( CONSTRUCTOR qualifiedId ctorArgs )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:154:64: ^( CONSTRUCTOR qualifiedId ctorArgs )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(CONSTRUCTOR, "CONSTRUCTOR"), root_1);
-
- adaptor.addChild(root_1, stream_qualifiedId.next());
- adaptor.addChild(root_1, stream_ctorArgs.next());
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end constructor
-
- public static class ctorArgs_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start ctorArgs
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:157:1: ctorArgs : LPAREN ( namedArgument ( COMMA namedArgument )* )? RPAREN ;
- public final ctorArgs_return ctorArgs() throws RecognitionException {
- ctorArgs_return retval = new ctorArgs_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token LPAREN98=null;
- Token COMMA100=null;
- Token RPAREN102=null;
- namedArgument_return namedArgument99 = null;
-
- namedArgument_return namedArgument101 = null;
-
-
- Object LPAREN98_tree=null;
- Object COMMA100_tree=null;
- Object RPAREN102_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:158:2: ( LPAREN ( namedArgument ( COMMA namedArgument )* )? RPAREN )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:158:4: LPAREN ( namedArgument ( COMMA namedArgument )* )? RPAREN
- {
- root_0 = (Object)adaptor.nil();
-
- LPAREN98=(Token)input.LT(1);
- match(input,LPAREN,FOLLOW_LPAREN_in_ctorArgs971); if (failed) return retval;
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:158:12: ( namedArgument ( COMMA namedArgument )* )?
- int alt23=2;
- int LA23_0 = input.LA(1);
-
- if ( (LA23_0==INTEGER_LITERAL||LA23_0==LPAREN||(LA23_0>=PLUS && LA23_0<=MINUS)||LA23_0==BANG||(LA23_0>=POUND && LA23_0<=ID)||LA23_0==LBRACKET||(LA23_0>=PROJECT && LA23_0<=FALSE)||LA23_0==77) ) {
- alt23=1;
- }
- switch (alt23) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:158:13: namedArgument ( COMMA namedArgument )*
- {
- pushFollow(FOLLOW_namedArgument_in_ctorArgs975);
- namedArgument99=namedArgument();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, namedArgument99.getTree());
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:158:27: ( COMMA namedArgument )*
- loop22:
- do {
- int alt22=2;
- int LA22_0 = input.LA(1);
-
- if ( (LA22_0==COMMA) ) {
- alt22=1;
- }
-
-
- switch (alt22) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:158:28: COMMA namedArgument
- {
- COMMA100=(Token)input.LT(1);
- match(input,COMMA,FOLLOW_COMMA_in_ctorArgs978); if (failed) return retval;
- pushFollow(FOLLOW_namedArgument_in_ctorArgs981);
- namedArgument101=namedArgument();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, namedArgument101.getTree());
-
- }
- break;
-
- default :
- break loop22;
- }
- } while (true);
-
-
- }
- break;
-
- }
-
- RPAREN102=(Token)input.LT(1);
- match(input,RPAREN,FOLLOW_RPAREN_in_ctorArgs987); if (failed) return retval;
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end ctorArgs
-
- public static class argument_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start argument
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:160:1: argument : expression ;
- public final argument_return argument() throws RecognitionException {
- argument_return retval = new argument_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- expression_return expression103 = null;
-
-
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:160:10: ( expression )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:160:12: expression
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_expression_in_argument996);
- expression103=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, expression103.getTree());
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end argument
-
- public static class namedArgument_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start namedArgument
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:162:1: namedArgument : ( ( ID ASSIGN )=>id= ID ASSIGN expression -> ^( NAMED_ARGUMENT[$id] expression ) | argument );
- public final namedArgument_return namedArgument() throws RecognitionException {
- namedArgument_return retval = new namedArgument_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token id=null;
- Token ASSIGN104=null;
- expression_return expression105 = null;
-
- argument_return argument106 = null;
-
-
- Object id_tree=null;
- Object ASSIGN104_tree=null;
- RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
- RewriteRuleTokenStream stream_ASSIGN=new RewriteRuleTokenStream(adaptor,"token ASSIGN");
- RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:163:5: ( ( ID ASSIGN )=>id= ID ASSIGN expression -> ^( NAMED_ARGUMENT[$id] expression ) | argument )
- int alt24=2;
- int LA24_0 = input.LA(1);
-
- if ( (LA24_0==ID) ) {
- int LA24_1 = input.LA(2);
-
- if ( (LA24_1==ASSIGN) ) {
- int LA24_21 = input.LA(3);
-
- if ( (synpred4()) ) {
- alt24=1;
- }
- else if ( (true) ) {
- alt24=2;
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("162:1: namedArgument : ( ( ID ASSIGN )=>id= ID ASSIGN expression -> ^( NAMED_ARGUMENT[$id] expression ) | argument );", 24, 21, input);
-
- throw nvae;
- }
- }
- else if ( ((LA24_1>=DEFAULT && LA24_1<=QMARK)||(LA24_1>=LPAREN && LA24_1<=POWER)||LA24_1==DOT||(LA24_1>=COMMA && LA24_1<=LBRACKET)||(LA24_1>=EQUAL && LA24_1<=MATCHES)) ) {
- alt24=2;
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("162:1: namedArgument : ( ( ID ASSIGN )=>id= ID ASSIGN expression -> ^( NAMED_ARGUMENT[$id] expression ) | argument );", 24, 1, input);
-
- throw nvae;
- }
- }
- else if ( (LA24_0==INTEGER_LITERAL||LA24_0==LPAREN||(LA24_0>=PLUS && LA24_0<=MINUS)||LA24_0==BANG||LA24_0==POUND||LA24_0==LBRACKET||(LA24_0>=PROJECT && LA24_0<=FALSE)||LA24_0==77) ) {
- alt24=2;
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("162:1: namedArgument : ( ( ID ASSIGN )=>id= ID ASSIGN expression -> ^( NAMED_ARGUMENT[$id] expression ) | argument );", 24, 0, input);
-
- throw nvae;
- }
- switch (alt24) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:163:7: ( ID ASSIGN )=>id= ID ASSIGN expression
- {
- id=(Token)input.LT(1);
- match(input,ID,FOLLOW_ID_in_namedArgument1019); if (failed) return retval;
- if ( backtracking==0 ) stream_ID.add(id);
-
- ASSIGN104=(Token)input.LT(1);
- match(input,ASSIGN,FOLLOW_ASSIGN_in_namedArgument1021); if (failed) return retval;
- if ( backtracking==0 ) stream_ASSIGN.add(ASSIGN104);
-
- pushFollow(FOLLOW_expression_in_namedArgument1023);
- expression105=expression();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) stream_expression.add(expression105.getTree());
-
- // AST REWRITE
- // elements: expression
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 164:19: -> ^( NAMED_ARGUMENT[$id] expression )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:164:22: ^( NAMED_ARGUMENT[$id] expression )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(NAMED_ARGUMENT, id), root_1);
-
- adaptor.addChild(root_1, stream_expression.next());
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:165:7: argument
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_argument_in_namedArgument1059);
- argument106=argument();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, argument106.getTree());
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end namedArgument
-
- public static class qualifiedId_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start qualifiedId
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:167:1: qualifiedId : ID ( DOT ID )* -> ^( QUALIFIED_IDENTIFIER ( ID )* ) ;
- public final qualifiedId_return qualifiedId() throws RecognitionException {
- qualifiedId_return retval = new qualifiedId_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token ID107=null;
- Token DOT108=null;
- Token ID109=null;
-
- Object ID107_tree=null;
- Object DOT108_tree=null;
- Object ID109_tree=null;
- RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
- RewriteRuleTokenStream stream_DOT=new RewriteRuleTokenStream(adaptor,"token DOT");
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:167:13: ( ID ( DOT ID )* -> ^( QUALIFIED_IDENTIFIER ( ID )* ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:167:15: ID ( DOT ID )*
- {
- ID107=(Token)input.LT(1);
- match(input,ID,FOLLOW_ID_in_qualifiedId1071); if (failed) return retval;
- if ( backtracking==0 ) stream_ID.add(ID107);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:167:18: ( DOT ID )*
- loop25:
- do {
- int alt25=2;
- int LA25_0 = input.LA(1);
-
- if ( (LA25_0==DOT) ) {
- alt25=1;
- }
-
-
- switch (alt25) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:167:19: DOT ID
- {
- DOT108=(Token)input.LT(1);
- match(input,DOT,FOLLOW_DOT_in_qualifiedId1074); if (failed) return retval;
- if ( backtracking==0 ) stream_DOT.add(DOT108);
-
- ID109=(Token)input.LT(1);
- match(input,ID,FOLLOW_ID_in_qualifiedId1076); if (failed) return retval;
- if ( backtracking==0 ) stream_ID.add(ID109);
-
-
- }
- break;
-
- default :
- break loop25;
- }
- } while (true);
-
-
- // AST REWRITE
- // elements: ID
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 167:28: -> ^( QUALIFIED_IDENTIFIER ( ID )* )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:167:31: ^( QUALIFIED_IDENTIFIER ( ID )* )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(QUALIFIED_IDENTIFIER, "QUALIFIED_IDENTIFIER"), root_1);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:167:54: ( ID )*
- while ( stream_ID.hasNext() ) {
- adaptor.addChild(root_1, stream_ID.next());
-
- }
- stream_ID.reset();
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end qualifiedId
-
- public static class contextName_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start contextName
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:169:1: contextName : ID ( DIV ID )* -> ^( QUALIFIED_IDENTIFIER ( ID )* ) ;
- public final contextName_return contextName() throws RecognitionException {
- contextName_return retval = new contextName_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token ID110=null;
- Token DIV111=null;
- Token ID112=null;
-
- Object ID110_tree=null;
- Object DIV111_tree=null;
- Object ID112_tree=null;
- RewriteRuleTokenStream stream_DIV=new RewriteRuleTokenStream(adaptor,"token DIV");
- RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:169:13: ( ID ( DIV ID )* -> ^( QUALIFIED_IDENTIFIER ( ID )* ) )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:169:15: ID ( DIV ID )*
- {
- ID110=(Token)input.LT(1);
- match(input,ID,FOLLOW_ID_in_contextName1095); if (failed) return retval;
- if ( backtracking==0 ) stream_ID.add(ID110);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:169:18: ( DIV ID )*
- loop26:
- do {
- int alt26=2;
- int LA26_0 = input.LA(1);
-
- if ( (LA26_0==DIV) ) {
- alt26=1;
- }
-
-
- switch (alt26) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:169:19: DIV ID
- {
- DIV111=(Token)input.LT(1);
- match(input,DIV,FOLLOW_DIV_in_contextName1098); if (failed) return retval;
- if ( backtracking==0 ) stream_DIV.add(DIV111);
-
- ID112=(Token)input.LT(1);
- match(input,ID,FOLLOW_ID_in_contextName1100); if (failed) return retval;
- if ( backtracking==0 ) stream_ID.add(ID112);
-
-
- }
- break;
-
- default :
- break loop26;
- }
- } while (true);
-
-
- // AST REWRITE
- // elements: ID
- // token labels:
- // rule labels: retval
- // token list labels:
- // rule list labels:
- if ( backtracking==0 ) {
- retval.tree = root_0;
- RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
-
- root_0 = (Object)adaptor.nil();
- // 169:28: -> ^( QUALIFIED_IDENTIFIER ( ID )* )
- {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:169:31: ^( QUALIFIED_IDENTIFIER ( ID )* )
- {
- Object root_1 = (Object)adaptor.nil();
- root_1 = (Object)adaptor.becomeRoot(adaptor.create(QUALIFIED_IDENTIFIER, "QUALIFIED_IDENTIFIER"), root_1);
-
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:169:54: ( ID )*
- while ( stream_ID.hasNext() ) {
- adaptor.addChild(root_1, stream_ID.next());
-
- }
- stream_ID.reset();
-
- adaptor.addChild(root_0, root_1);
- }
-
- }
-
- }
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end contextName
-
- public static class literal_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start literal
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:171:1: literal : ( INTEGER_LITERAL | STRING_LITERAL | DQ_STRING_LITERAL | boolLiteral | NULL_LITERAL | HEXADECIMAL_INTEGER_LITERAL | REAL_LITERAL );
- public final literal_return literal() throws RecognitionException {
- literal_return retval = new literal_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token INTEGER_LITERAL113=null;
- Token STRING_LITERAL114=null;
- Token DQ_STRING_LITERAL115=null;
- Token NULL_LITERAL117=null;
- Token HEXADECIMAL_INTEGER_LITERAL118=null;
- Token REAL_LITERAL119=null;
- boolLiteral_return boolLiteral116 = null;
-
-
- Object INTEGER_LITERAL113_tree=null;
- Object STRING_LITERAL114_tree=null;
- Object DQ_STRING_LITERAL115_tree=null;
- Object NULL_LITERAL117_tree=null;
- Object HEXADECIMAL_INTEGER_LITERAL118_tree=null;
- Object REAL_LITERAL119_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:172:2: ( INTEGER_LITERAL | STRING_LITERAL | DQ_STRING_LITERAL | boolLiteral | NULL_LITERAL | HEXADECIMAL_INTEGER_LITERAL | REAL_LITERAL )
- int alt27=7;
- switch ( input.LA(1) ) {
- case INTEGER_LITERAL:
- {
- alt27=1;
- }
- break;
- case STRING_LITERAL:
- {
- alt27=2;
- }
- break;
- case DQ_STRING_LITERAL:
- {
- alt27=3;
- }
- break;
- case TRUE:
- case FALSE:
- {
- alt27=4;
- }
- break;
- case NULL_LITERAL:
- {
- alt27=5;
- }
- break;
- case HEXADECIMAL_INTEGER_LITERAL:
- {
- alt27=6;
- }
- break;
- case REAL_LITERAL:
- {
- alt27=7;
- }
- break;
- default:
- if (backtracking>0) {failed=true; return retval;}
- NoViableAltException nvae =
- new NoViableAltException("171:1: literal : ( INTEGER_LITERAL | STRING_LITERAL | DQ_STRING_LITERAL | boolLiteral | NULL_LITERAL | HEXADECIMAL_INTEGER_LITERAL | REAL_LITERAL );", 27, 0, input);
-
- throw nvae;
- }
-
- switch (alt27) {
- case 1 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:172:4: INTEGER_LITERAL
- {
- root_0 = (Object)adaptor.nil();
-
- INTEGER_LITERAL113=(Token)input.LT(1);
- match(input,INTEGER_LITERAL,FOLLOW_INTEGER_LITERAL_in_literal1121); if (failed) return retval;
- if ( backtracking==0 ) {
- INTEGER_LITERAL113_tree = (Object)adaptor.create(INTEGER_LITERAL113);
- adaptor.addChild(root_0, INTEGER_LITERAL113_tree);
- }
-
- }
- break;
- case 2 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:173:4: STRING_LITERAL
- {
- root_0 = (Object)adaptor.nil();
-
- STRING_LITERAL114=(Token)input.LT(1);
- match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_literal1127); if (failed) return retval;
- if ( backtracking==0 ) {
- STRING_LITERAL114_tree = (Object)adaptor.create(STRING_LITERAL114);
- adaptor.addChild(root_0, STRING_LITERAL114_tree);
- }
-
- }
- break;
- case 3 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:174:4: DQ_STRING_LITERAL
- {
- root_0 = (Object)adaptor.nil();
-
- DQ_STRING_LITERAL115=(Token)input.LT(1);
- match(input,DQ_STRING_LITERAL,FOLLOW_DQ_STRING_LITERAL_in_literal1132); if (failed) return retval;
- if ( backtracking==0 ) {
- DQ_STRING_LITERAL115_tree = (Object)adaptor.create(DQ_STRING_LITERAL115);
- adaptor.addChild(root_0, DQ_STRING_LITERAL115_tree);
- }
-
- }
- break;
- case 4 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:175:4: boolLiteral
- {
- root_0 = (Object)adaptor.nil();
-
- pushFollow(FOLLOW_boolLiteral_in_literal1137);
- boolLiteral116=boolLiteral();
- _fsp--;
- if (failed) return retval;
- if ( backtracking==0 ) adaptor.addChild(root_0, boolLiteral116.getTree());
-
- }
- break;
- case 5 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:176:4: NULL_LITERAL
- {
- root_0 = (Object)adaptor.nil();
-
- NULL_LITERAL117=(Token)input.LT(1);
- match(input,NULL_LITERAL,FOLLOW_NULL_LITERAL_in_literal1142); if (failed) return retval;
- if ( backtracking==0 ) {
- NULL_LITERAL117_tree = (Object)adaptor.create(NULL_LITERAL117);
- adaptor.addChild(root_0, NULL_LITERAL117_tree);
- }
-
- }
- break;
- case 6 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:177:4: HEXADECIMAL_INTEGER_LITERAL
- {
- root_0 = (Object)adaptor.nil();
-
- HEXADECIMAL_INTEGER_LITERAL118=(Token)input.LT(1);
- match(input,HEXADECIMAL_INTEGER_LITERAL,FOLLOW_HEXADECIMAL_INTEGER_LITERAL_in_literal1147); if (failed) return retval;
- if ( backtracking==0 ) {
- HEXADECIMAL_INTEGER_LITERAL118_tree = (Object)adaptor.create(HEXADECIMAL_INTEGER_LITERAL118);
- adaptor.addChild(root_0, HEXADECIMAL_INTEGER_LITERAL118_tree);
- }
-
- }
- break;
- case 7 :
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:178:4: REAL_LITERAL
- {
- root_0 = (Object)adaptor.nil();
-
- REAL_LITERAL119=(Token)input.LT(1);
- match(input,REAL_LITERAL,FOLLOW_REAL_LITERAL_in_literal1153); if (failed) return retval;
- if ( backtracking==0 ) {
- REAL_LITERAL119_tree = (Object)adaptor.create(REAL_LITERAL119);
- adaptor.addChild(root_0, REAL_LITERAL119_tree);
- }
-
- }
- break;
-
- }
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end literal
-
- public static class boolLiteral_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start boolLiteral
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:181:1: boolLiteral : ( TRUE | FALSE );
- public final boolLiteral_return boolLiteral() throws RecognitionException {
- boolLiteral_return retval = new boolLiteral_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token set120=null;
-
- Object set120_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:181:12: ( TRUE | FALSE )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:
- {
- root_0 = (Object)adaptor.nil();
-
- set120=(Token)input.LT(1);
- if ( (input.LA(1)>=TRUE && input.LA(1)<=FALSE) ) {
- input.consume();
- if ( backtracking==0 ) adaptor.addChild(root_0, adaptor.create(set120));
- errorRecovery=false;failed=false;
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recoverFromMismatchedSet(input,mse,FOLLOW_set_in_boolLiteral0); throw mse;
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end boolLiteral
-
- public static class relationalOperator_return extends ParserRuleReturnScope {
- Object tree;
- public Object getTree() { return tree; }
- };
-
- // $ANTLR start relationalOperator
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:188:1: relationalOperator : ( EQUAL | NOT_EQUAL | LESS_THAN | LESS_THAN_OR_EQUAL | GREATER_THAN | GREATER_THAN_OR_EQUAL | INSTANCEOF | BETWEEN | MATCHES );
- public final relationalOperator_return relationalOperator() throws RecognitionException {
- relationalOperator_return retval = new relationalOperator_return();
- retval.start = input.LT(1);
-
- Object root_0 = null;
-
- Token set121=null;
-
- Object set121_tree=null;
-
- try {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:189:5: ( EQUAL | NOT_EQUAL | LESS_THAN | LESS_THAN_OR_EQUAL | GREATER_THAN | GREATER_THAN_OR_EQUAL | INSTANCEOF | BETWEEN | MATCHES )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:
- {
- root_0 = (Object)adaptor.nil();
-
- set121=(Token)input.LT(1);
- if ( (input.LA(1)>=EQUAL && input.LA(1)<=MATCHES) ) {
- input.consume();
- if ( backtracking==0 ) adaptor.addChild(root_0, adaptor.create(set121));
- errorRecovery=false;failed=false;
- }
- else {
- if (backtracking>0) {failed=true; return retval;}
- MismatchedSetException mse =
- new MismatchedSetException(null,input);
- recoverFromMismatchedSet(input,mse,FOLLOW_set_in_relationalOperator0); throw mse;
- }
-
-
- }
-
- retval.stop = input.LT(-1);
-
- if ( backtracking==0 ) {
- retval.tree = (Object)adaptor.rulePostProcessing(root_0);
- adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
- }
- }
-
- catch(RecognitionException e) {
- reportError(e);
- throw e;
- }
- finally {
- }
- return retval;
- }
- // $ANTLR end relationalOperator
-
- // $ANTLR start synpred1
- public final void synpred1_fragment() throws RecognitionException {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:111:7: ( POUND ID LPAREN )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:111:8: POUND ID LPAREN
- {
- match(input,POUND,FOLLOW_POUND_in_synpred1642); if (failed) return ;
- match(input,ID,FOLLOW_ID_in_synpred1644); if (failed) return ;
- match(input,LPAREN,FOLLOW_LPAREN_in_synpred1646); if (failed) return ;
-
- }
- }
- // $ANTLR end synpred1
-
- // $ANTLR start synpred2
- public final void synpred2_fragment() throws RecognitionException {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:121:4: ( ID LPAREN )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:121:5: ID LPAREN
- {
- match(input,ID,FOLLOW_ID_in_synpred2726); if (failed) return ;
- match(input,LPAREN,FOLLOW_LPAREN_in_synpred2728); if (failed) return ;
-
- }
- }
- // $ANTLR end synpred2
-
- // $ANTLR start synpred4
- public final void synpred4_fragment() throws RecognitionException {
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:163:7: ( ID ASSIGN )
- // F:\\svn\\sfw2\\org.springframework.expression\\src\\main\\java\\org\\springframework\\expression\\spel\\generated\\SpringExpressions.g:163:8: ID ASSIGN
- {
- match(input,ID,FOLLOW_ID_in_synpred41010); if (failed) return ;
- match(input,ASSIGN,FOLLOW_ASSIGN_in_synpred41012); if (failed) return ;
-
- }
- }
- // $ANTLR end synpred4
-
- public final boolean synpred1() {
- backtracking++;
- int start = input.mark();
- try {
- synpred1_fragment(); // can never throw exception
- } catch (RecognitionException re) {
- System.err.println("impossible: "+re);
- }
- boolean success = !failed;
- input.rewind(start);
- backtracking--;
- failed=false;
- return success;
- }
- public final boolean synpred2() {
- backtracking++;
- int start = input.mark();
- try {
- synpred2_fragment(); // can never throw exception
- } catch (RecognitionException re) {
- System.err.println("impossible: "+re);
- }
- boolean success = !failed;
- input.rewind(start);
- backtracking--;
- failed=false;
- return success;
- }
- public final boolean synpred4() {
- backtracking++;
- int start = input.mark();
- try {
- synpred4_fragment(); // can never throw exception
- } catch (RecognitionException re) {
- System.err.println("impossible: "+re);
- }
- boolean success = !failed;
- input.rewind(start);
- backtracking--;
- failed=false;
- return success;
- }
-
-
-
-
- public static final BitSet FOLLOW_expression_in_expr130 = new BitSet(new long[]{0x0000000000000000L});
- public static final BitSet FOLLOW_EOF_in_expr132 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_logicalOrExpression_in_expression152 = new BitSet(new long[]{0x0000000000380002L});
- public static final BitSet FOLLOW_ASSIGN_in_expression161 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_logicalOrExpression_in_expression164 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_DEFAULT_in_expression174 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_logicalOrExpression_in_expression177 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_QMARK_in_expression187 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_expression_in_expression190 = new BitSet(new long[]{0x0000000000400000L});
- public static final BitSet FOLLOW_COLON_in_expression192 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_expression_in_expression195 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_LPAREN_in_parenExpr206 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_expression_in_parenExpr209 = new BitSet(new long[]{0x0000000001000000L});
- public static final BitSet FOLLOW_RPAREN_in_parenExpr211 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_logicalAndExpression_in_logicalOrExpression222 = new BitSet(new long[]{0x0000000002000002L});
- public static final BitSet FOLLOW_OR_in_logicalOrExpression225 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_logicalAndExpression_in_logicalOrExpression228 = new BitSet(new long[]{0x0000000002000002L});
- public static final BitSet FOLLOW_relationalExpression_in_logicalAndExpression263 = new BitSet(new long[]{0x0000000004000002L});
- public static final BitSet FOLLOW_AND_in_logicalAndExpression266 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_relationalExpression_in_logicalAndExpression269 = new BitSet(new long[]{0x0000000004000002L});
- public static final BitSet FOLLOW_sumExpression_in_relationalExpression280 = new BitSet(new long[]{0xFF80000000000002L});
- public static final BitSet FOLLOW_relationalOperator_in_relationalExpression283 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_sumExpression_in_relationalExpression286 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_productExpression_in_sumExpression297 = new BitSet(new long[]{0x0000000018000002L});
- public static final BitSet FOLLOW_PLUS_in_sumExpression302 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_MINUS_in_sumExpression307 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_productExpression_in_sumExpression311 = new BitSet(new long[]{0x0000000018000002L});
- public static final BitSet FOLLOW_powerExpr_in_productExpression322 = new BitSet(new long[]{0x00000000E0000002L});
- public static final BitSet FOLLOW_STAR_in_productExpression326 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_DIV_in_productExpression331 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_MOD_in_productExpression335 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_powerExpr_in_productExpression339 = new BitSet(new long[]{0x00000000E0000002L});
- public static final BitSet FOLLOW_unaryExpression_in_powerExpr351 = new BitSet(new long[]{0x0000000100000002L});
- public static final BitSet FOLLOW_POWER_in_powerExpr354 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_unaryExpression_in_powerExpr357 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_PLUS_in_unaryExpression371 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_MINUS_in_unaryExpression376 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_BANG_in_unaryExpression381 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_unaryExpression_in_unaryExpression385 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_primaryExpression_in_unaryExpression391 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_startNode_in_primaryExpression405 = new BitSet(new long[]{0x0000004400000002L});
- public static final BitSet FOLLOW_node_in_primaryExpression408 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_parenExpr_in_startNode441 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_methodOrProperty_in_startNode449 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_functionOrVar_in_startNode458 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_indexer_in_startNode466 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_literal_in_startNode474 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_type_in_startNode482 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_constructor_in_startNode490 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_projection_in_startNode498 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_selection_in_startNode507 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_firstSelection_in_startNode516 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_lastSelection_in_startNode524 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_DOT_in_node544 = new BitSet(new long[]{0x00000F1800000000L});
- public static final BitSet FOLLOW_dottedNode_in_node546 = new BitSet(new long[]{0x0000004400000002L});
- public static final BitSet FOLLOW_nonDottedNode_in_node551 = new BitSet(new long[]{0x0000004400000002L});
- public static final BitSet FOLLOW_indexer_in_nonDottedNode563 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_methodOrProperty_in_dottedNode576 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_functionOrVar_in_dottedNode582 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_projection_in_dottedNode590 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_selection_in_dottedNode599 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_firstSelection_in_dottedNode608 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_lastSelection_in_dottedNode617 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_function_in_functionOrVar651 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_var_in_functionOrVar659 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_POUND_in_function676 = new BitSet(new long[]{0x0000001000000000L});
- public static final BitSet FOLLOW_ID_in_function680 = new BitSet(new long[]{0x0000000000800000L});
- public static final BitSet FOLLOW_methodArgs_in_function682 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_POUND_in_var703 = new BitSet(new long[]{0x0000001000000000L});
- public static final BitSet FOLLOW_ID_in_var707 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_ID_in_methodOrProperty735 = new BitSet(new long[]{0x0000000000800000L});
- public static final BitSet FOLLOW_methodArgs_in_methodOrProperty737 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_property_in_methodOrProperty751 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_LPAREN_in_methodArgs766 = new BitSet(new long[]{0x000FFF5A19800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_argument_in_methodArgs770 = new BitSet(new long[]{0x0000002001000000L});
- public static final BitSet FOLLOW_COMMA_in_methodArgs773 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_argument_in_methodArgs776 = new BitSet(new long[]{0x0000002001000000L});
- public static final BitSet FOLLOW_COMMA_in_methodArgs781 = new BitSet(new long[]{0x0000000001000000L});
- public static final BitSet FOLLOW_RPAREN_in_methodArgs788 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_ID_in_property801 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_LBRACKET_in_indexer816 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_argument_in_indexer820 = new BitSet(new long[]{0x000000A000000000L});
- public static final BitSet FOLLOW_COMMA_in_indexer823 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_argument_in_indexer827 = new BitSet(new long[]{0x000000A000000000L});
- public static final BitSet FOLLOW_RBRACKET_in_indexer831 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_PROJECT_in_projection857 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_expression_in_projection860 = new BitSet(new long[]{0x0000008000000000L});
- public static final BitSet FOLLOW_RBRACKET_in_projection862 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_SELECT_in_selection870 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_expression_in_selection873 = new BitSet(new long[]{0x0000008000000000L});
- public static final BitSet FOLLOW_RBRACKET_in_selection875 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_SELECT_FIRST_in_firstSelection883 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_expression_in_firstSelection886 = new BitSet(new long[]{0x0000008000000000L});
- public static final BitSet FOLLOW_RBRACKET_in_firstSelection888 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_SELECT_LAST_in_lastSelection896 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_expression_in_lastSelection899 = new BitSet(new long[]{0x0000008000000000L});
- public static final BitSet FOLLOW_RBRACKET_in_lastSelection901 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_TYPE_in_type910 = new BitSet(new long[]{0x0000001000000000L});
- public static final BitSet FOLLOW_qualifiedId_in_type912 = new BitSet(new long[]{0x0000000001000000L});
- public static final BitSet FOLLOW_RPAREN_in_type914 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_77_in_constructor945 = new BitSet(new long[]{0x0000001000000000L});
- public static final BitSet FOLLOW_qualifiedId_in_constructor947 = new BitSet(new long[]{0x0000000000800000L});
- public static final BitSet FOLLOW_ctorArgs_in_constructor949 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_LPAREN_in_ctorArgs971 = new BitSet(new long[]{0x000FFF5A19800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_namedArgument_in_ctorArgs975 = new BitSet(new long[]{0x0000002001000000L});
- public static final BitSet FOLLOW_COMMA_in_ctorArgs978 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_namedArgument_in_ctorArgs981 = new BitSet(new long[]{0x0000002001000000L});
- public static final BitSet FOLLOW_RPAREN_in_ctorArgs987 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_expression_in_argument996 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_ID_in_namedArgument1019 = new BitSet(new long[]{0x0000000000080000L});
- public static final BitSet FOLLOW_ASSIGN_in_namedArgument1021 = new BitSet(new long[]{0x000FFF5A18800010L,0x0000000000002000L});
- public static final BitSet FOLLOW_expression_in_namedArgument1023 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_argument_in_namedArgument1059 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_ID_in_qualifiedId1071 = new BitSet(new long[]{0x0000000400000002L});
- public static final BitSet FOLLOW_DOT_in_qualifiedId1074 = new BitSet(new long[]{0x0000001000000000L});
- public static final BitSet FOLLOW_ID_in_qualifiedId1076 = new BitSet(new long[]{0x0000000400000002L});
- public static final BitSet FOLLOW_ID_in_contextName1095 = new BitSet(new long[]{0x0000000040000002L});
- public static final BitSet FOLLOW_DIV_in_contextName1098 = new BitSet(new long[]{0x0000001000000000L});
- public static final BitSet FOLLOW_ID_in_contextName1100 = new BitSet(new long[]{0x0000000040000002L});
- public static final BitSet FOLLOW_INTEGER_LITERAL_in_literal1121 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_STRING_LITERAL_in_literal1127 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_DQ_STRING_LITERAL_in_literal1132 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_boolLiteral_in_literal1137 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_NULL_LITERAL_in_literal1142 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_HEXADECIMAL_INTEGER_LITERAL_in_literal1147 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_REAL_LITERAL_in_literal1153 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_set_in_boolLiteral0 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_set_in_relationalOperator0 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_POUND_in_synpred1642 = new BitSet(new long[]{0x0000001000000000L});
- public static final BitSet FOLLOW_ID_in_synpred1644 = new BitSet(new long[]{0x0000000000800000L});
- public static final BitSet FOLLOW_LPAREN_in_synpred1646 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_ID_in_synpred2726 = new BitSet(new long[]{0x0000000000800000L});
- public static final BitSet FOLLOW_LPAREN_in_synpred2728 = new BitSet(new long[]{0x0000000000000002L});
- public static final BitSet FOLLOW_ID_in_synpred41010 = new BitSet(new long[]{0x0000000000080000L});
- public static final BitSet FOLLOW_ASSIGN_in_synpred41012 = new BitSet(new long[]{0x0000000000000002L});
-
-}
\ No newline at end of file
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/generated/SpringExpressions__.g b/org.springframework.expression/src/main/java/org/springframework/expression/spel/generated/SpringExpressions__.g
deleted file mode 100644
index e9f39b690b9..00000000000
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/generated/SpringExpressions__.g
+++ /dev/null
@@ -1,142 +0,0 @@
-lexer grammar SpringExpressions;
-options {
- language=Java;
-
-}
-@header {package org.springframework.expression.spel.generated;}
-
-T77 : 'new' ;
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 183
-INTEGER_LITERAL
- : (DECIMAL_DIGIT)+ (INTEGER_TYPE_SUFFIX)?;
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 186
-HEXADECIMAL_INTEGER_LITERAL : ('0x' | '0X') (HEX_DIGIT)+ (INTEGER_TYPE_SUFFIX)?;
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 200
-ASSIGN: '=';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 201
-EQUAL: '==';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 202
-NOT_EQUAL: '!=';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 203
-LESS_THAN: '<';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 204
-LESS_THAN_OR_EQUAL: '<=';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 205
-GREATER_THAN: '>';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 206
-GREATER_THAN_OR_EQUAL: '>=';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 207
-INSTANCEOF: 'instanceof';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 208
-BETWEEN:'between';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 209
-MATCHES:'matches';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 210
-NULL_LITERAL: 'null';
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 212
-SEMI: ';';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 213
-DOT: '.';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 214
-COMMA: ',';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 215
-LPAREN: '(';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 216
-RPAREN: ')';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 217
-LCURLY: '{';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 218
-RCURLY: '}';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 219
-LBRACKET: '[';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 220
-RBRACKET: ']';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 221
-PIPE: '|';
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 223
-AND: 'and';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 224
-OR: 'or';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 225
-FALSE: 'false';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 226
-TRUE: 'true';
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 228
-PLUS: '+';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 229
-MINUS: '-';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 230
-DIV: '/';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 231
-STAR: '*';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 232
-MOD: '%';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 233
-POWER: '^';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 234
-BANG: '!';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 235
-POUND: '#';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 236
-QMARK: '?';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 237
-DEFAULT: '??';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 238
-PROJECT: '![';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 239
-SELECT: '?[';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 240
-SELECT_FIRST: '^[';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 241
-SELECT_LAST: '$[';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 242
-TYPE: 'T(';
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 244
-STRING_LITERAL: '\''! (APOS|~'\'')* '\''!;
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 245
-DQ_STRING_LITERAL: '"'! (~'"')* '"'!;
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 246
-ID: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|DOT_ESCAPED)*;
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 247
-DOT_ESCAPED: '\\.';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 248
-WS: ( ' ' | '\t' | '\n' |'\r')+ { $channel=HIDDEN; } ;
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 249
-DOLLAR: '$';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 250
-AT: '@';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 251
-UPTO: '..';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 252
-COLON: ':';
-
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 255
-REAL_LITERAL :
- ('.' (DECIMAL_DIGIT)+ (EXPONENT_PART)? (REAL_TYPE_SUFFIX)?) |
- ((DECIMAL_DIGIT)+ '.' (DECIMAL_DIGIT)+ (EXPONENT_PART)? (REAL_TYPE_SUFFIX)?) |
- ((DECIMAL_DIGIT)+ (EXPONENT_PART) (REAL_TYPE_SUFFIX)?) |
- ((DECIMAL_DIGIT)+ (REAL_TYPE_SUFFIX));
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 261
-fragment APOS : '\''! '\'';
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 262
-fragment DECIMAL_DIGIT : '0'..'9' ;
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 263
-fragment INTEGER_TYPE_SUFFIX : ( 'L' | 'l' );
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 264
-fragment HEX_DIGIT : '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'A'|'B'|'C'|'D'|'E'|'F'|'a'|'b'|'c'|'d'|'e'|'f';
-
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 266
-fragment EXPONENT_PART : 'e' (SIGN)* (DECIMAL_DIGIT)+ | 'E' (SIGN)* (DECIMAL_DIGIT)+ ;
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 267
-fragment SIGN : '+' | '-' ;
-// $ANTLR src "F:\svn\sfw2\org.springframework.expression\src\main\java\org\springframework\expression\spel\generated\SpringExpressions.g" 268
-fragment REAL_TYPE_SUFFIX : 'F' | 'f' | 'D' | 'd';
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/EmptySpelNode.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/InternalParseException.java
similarity index 51%
rename from org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/EmptySpelNode.java
rename to org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/InternalParseException.java
index 411a1a6dec8..f7fae509bff 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/EmptySpelNode.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/InternalParseException.java
@@ -13,32 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.springframework.expression.spel.standard;
-package org.springframework.expression.spel.ast;
-
-import org.antlr.runtime.Token;
-import org.springframework.expression.TypedValue;
-import org.springframework.expression.spel.ExpressionState;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelParseException;
/**
+ * Wraps a real parse exception. This exception flows to the top parse method and then
+ * the wrapped exception is thrown as the real problem.
+ *
* @author Andy Clement
* @since 3.0
*/
-public class EmptySpelNode extends SpelNodeImpl {
+public class InternalParseException extends RuntimeException {
- public EmptySpelNode(Token payload) {
- super(payload);
+ public InternalParseException(SpelParseException t) {
+ super(t);
}
-
- @Override
- public TypedValue getValueInternal(ExpressionState state) throws SpelException {
- throw new RuntimeException("?");
+
+ public SpelParseException getCause() {
+ return (SpelParseException)super.getCause();
}
-
- @Override
- public String toStringAST() {
- return "";
- }
-
+
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/SpelExpressionParser.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/SpelExpressionParser.java
new file mode 100644
index 00000000000..f2846c15345
--- /dev/null
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/SpelExpressionParser.java
@@ -0,0 +1,745 @@
+/*
+ * Copyright 2008-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.expression.spel.standard;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+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.SpelNode;
+import org.springframework.expression.spel.SpelParseException;
+import org.springframework.expression.spel.ast.Assign;
+import org.springframework.expression.spel.ast.BooleanLiteral;
+import org.springframework.expression.spel.ast.CompoundExpression;
+import org.springframework.expression.spel.ast.ConstructorReference;
+import org.springframework.expression.spel.ast.Elvis;
+import org.springframework.expression.spel.ast.FunctionReference;
+import org.springframework.expression.spel.ast.Identifier;
+import org.springframework.expression.spel.ast.Indexer;
+import org.springframework.expression.spel.ast.Literal;
+import org.springframework.expression.spel.ast.MethodReference;
+import org.springframework.expression.spel.ast.NullLiteral;
+import org.springframework.expression.spel.ast.OpEQ;
+import org.springframework.expression.spel.ast.OpGE;
+import org.springframework.expression.spel.ast.OpGT;
+import org.springframework.expression.spel.ast.OpLE;
+import org.springframework.expression.spel.ast.OpLT;
+import org.springframework.expression.spel.ast.OpNE;
+import org.springframework.expression.spel.ast.OperatorAnd;
+import org.springframework.expression.spel.ast.OperatorDivide;
+import org.springframework.expression.spel.ast.OperatorInstanceof;
+import org.springframework.expression.spel.ast.OperatorMatches;
+import org.springframework.expression.spel.ast.OperatorMinus;
+import org.springframework.expression.spel.ast.OperatorModulus;
+import org.springframework.expression.spel.ast.OperatorMultiply;
+import org.springframework.expression.spel.ast.OperatorNot;
+import org.springframework.expression.spel.ast.OperatorOr;
+import org.springframework.expression.spel.ast.OperatorPlus;
+import org.springframework.expression.spel.ast.OperatorPower;
+import org.springframework.expression.spel.ast.Projection;
+import org.springframework.expression.spel.ast.PropertyOrFieldReference;
+import org.springframework.expression.spel.ast.QualifiedIdentifier;
+import org.springframework.expression.spel.ast.Selection;
+import org.springframework.expression.spel.ast.SpelNodeImpl;
+import org.springframework.expression.spel.ast.StringLiteral;
+import org.springframework.expression.spel.ast.Ternary;
+import org.springframework.expression.spel.ast.TypeReference;
+import org.springframework.expression.spel.ast.VariableReference;
+
+
+/**
+ * Hand written SpEL parser. Instances are reusable.
+ *
+ * @author Andy Clement
+ * @since 3.0
+ */
+public class SpelExpressionParser extends TemplateAwareExpressionParser {
+
+ // The expression being parsed
+ private String expressionString;
+
+ // The token stream constructed from that expression string
+ private List tokenStream;
+
+ // length of a populated token stream
+ private int tokenStreamLength;
+
+ // Current location in the token stream when processing tokens
+ private int tokenStreamPointer;
+
+ // For rules that build nodes, they are stacked here for return
+ private Stack constructedNodes = new Stack();
+
+ public SpelExpressionParser() {
+ }
+
+ public SpelExpression parse(String expressionString) throws ParseException {
+ return doParseExpression(expressionString, null);
+ }
+
+ protected SpelExpression doParseExpression(String expressionString, ParserContext context) throws ParseException {
+ try {
+ Tokenizer tokenizer = new Tokenizer(expressionString);
+ tokenizer.process();
+ this.expressionString = expressionString;
+ tokenStream = tokenizer.getTokens();
+ tokenStreamLength = tokenStream.size();
+ tokenStreamPointer = 0;
+ constructedNodes.clear();
+ SpelNode ast = eatExpression();
+ if (moreTokens()) {
+ throw new SpelParseException(peekToken().startpos,SpelMessages.MORE_INPUT,toString(nextToken()));
+ }
+ assert constructedNodes.isEmpty();
+ return new SpelExpression(expressionString,ast);
+ } catch (InternalParseException ipe) {
+ throw ipe.getCause();
+ }
+ }
+
+ public String toString(Token t) {
+ if (t.getKind().hasPayload()) {
+ return t.stringValue();
+ } else {
+ return t.kind.toString().toLowerCase();
+ }
+ }
+
+ // expression
+ // : logicalOrExpression
+ // ( (ASSIGN^ logicalOrExpression)
+ // | (DEFAULT^ logicalOrExpression)
+ // | (QMARK^ expression COLON! expression))?;
+ private SpelNodeImpl eatExpression() {
+ SpelNodeImpl expr = eatLogicalOrExpression();
+ if (moreTokens()) {
+ Token t = peekToken();
+ if (t.kind==TokenKind.ASSIGN) { // a=b
+ nextToken();
+ SpelNodeImpl assignedValue = eatLogicalOrExpression();
+ return new Assign(toPos(t),expr,assignedValue);
+ } else if (t.kind==TokenKind.ELVIS) { // a?:b (a if it isn't null, otherwise b)
+ nextToken(); // elvis has left the building
+ SpelNodeImpl valueIfNull = eatLogicalOrExpression();
+ return new Elvis(toPos(t),expr,valueIfNull);
+ } else if (t.kind==TokenKind.QMARK) { // a?b:c
+ nextToken();
+ SpelNodeImpl ifTrueExprValue = eatLogicalOrExpression();
+ eatToken(TokenKind.COLON);
+ SpelNodeImpl ifFalseExprValue = eatLogicalOrExpression();
+ return new Ternary(toPos(t),expr,ifTrueExprValue,ifFalseExprValue);
+ }
+ }
+ return expr;
+ }
+
+ //logicalOrExpression : logicalAndExpression (OR^ logicalAndExpression)*;
+ private SpelNodeImpl eatLogicalOrExpression() {
+ SpelNodeImpl expr = eatLogicalAndExpression();
+ while (peekIdentifierToken("or")) {
+ Token t = nextToken();//consume OR
+ SpelNodeImpl expr2 = eatLogicalAndExpression();
+ checkRightOperand(t,expr2);
+ expr = new OperatorOr(toPos(t),expr,expr2);
+ }
+ return expr;
+ }
+
+ private void checkRightOperand(Token token, SpelNodeImpl operandExpression) {
+ if (operandExpression==null) {
+ throw new InternalParseException(new SpelParseException(token.startpos,SpelMessages.RIGHT_OPERAND_PROBLEM));
+ }
+ }
+
+ //logicalAndExpression : relationalExpression (AND^ relationalExpression)*;
+ private SpelNodeImpl eatLogicalAndExpression() {
+ SpelNodeImpl expr = eatRelationalExpression();
+ while (peekIdentifierToken("and")) {
+ Token t = nextToken();// consume 'AND'
+ SpelNodeImpl rightExpr = eatRelationalExpression();
+ checkRightOperand(t,rightExpr);
+ expr = new OperatorAnd(toPos(t),expr,rightExpr);
+ }
+ return expr;
+ }
+
+ //relationalExpression : sumExpression (relationalOperator^ sumExpression)?;
+ private SpelNodeImpl eatRelationalExpression() {
+ SpelNodeImpl expr = eatSumExpression();
+ Token relationalOperatorToken = maybeEatRelationalOperator();
+ if (relationalOperatorToken!=null) {
+ Token t = nextToken();//consume relational operator token
+ SpelNodeImpl expr2 = eatSumExpression();
+ checkRightOperand(t,expr2);
+ if (relationalOperatorToken.isNumericRelationalOperator()) {
+ if (relationalOperatorToken.isGreaterThan()) {
+ return new OpGT(toPos(t),expr,expr2);
+ } else if (relationalOperatorToken.isLessThan()) {
+ return new OpLT(toPos(t),expr,expr2);
+ } else if (relationalOperatorToken.isLessThanOrEqual()) {
+ return new OpLE(toPos(t),expr,expr2);
+ } else if (relationalOperatorToken.isGreaterThanOrEqual()) {
+ return new OpGE(toPos(t),expr,expr2);
+ } else if (relationalOperatorToken.isEquality()) {
+ return new OpEQ(toPos(t),expr,expr2);
+ } else {
+ assert relationalOperatorToken.kind==TokenKind.NE;
+ return new OpNE(toPos(t),expr,expr2);
+ }
+ }
+ if (relationalOperatorToken.kind==TokenKind.INSTANCEOF) {
+ return new OperatorInstanceof(toPos(t),expr,expr2);
+ } else if (relationalOperatorToken.kind==TokenKind.MATCHES) {
+ return new OperatorMatches(toPos(t),expr,expr2);
+ } else {
+ assert relationalOperatorToken.kind==TokenKind.BETWEEN;
+ return new org.springframework.expression.spel.ast.OperatorBetween(toPos(t),expr,expr2);
+ }
+ }
+ return expr;
+ }
+
+ //sumExpression: productExpression ( (PLUS^ | MINUS^) productExpression)*;
+ private SpelNodeImpl eatSumExpression() {
+ SpelNodeImpl expr = eatProductExpression();
+ while (peekToken(TokenKind.PLUS,TokenKind.MINUS)) {
+ Token t = nextToken();//consume PLUS or MINUS
+ SpelNodeImpl rhOperand = eatProductExpression();
+ checkRightOperand(t,rhOperand);
+ if (t.getKind()==TokenKind.PLUS) {
+ expr = new OperatorPlus(toPos(t),expr,rhOperand);
+ } else {
+ expr = new OperatorMinus(toPos(t),expr,rhOperand);
+ }
+ }
+ return expr;
+ }
+
+ //productExpression: powerExpr ((STAR^ | DIV^| MOD^) powerExpr)* ;
+ private SpelNodeImpl eatProductExpression() {
+ SpelNodeImpl expr = eatPowerExpression();
+ while (peekToken(TokenKind.STAR,TokenKind.DIV,TokenKind.MOD)) {
+ Token t = nextToken(); // consume STAR/DIV/MOD
+ SpelNodeImpl expr2 = eatPowerExpression();
+ checkRightOperand(t,expr2);
+ if (t.getKind()==TokenKind.STAR) {
+ expr = new OperatorMultiply(toPos(t),expr,expr2);
+ } else if (t.getKind()==TokenKind.DIV) {
+ expr = new OperatorDivide(toPos(t),expr,expr2);
+ } else {
+ expr = new OperatorModulus(toPos(t),expr,expr2);
+ }
+ }
+ return expr;
+ }
+
+ //powerExpr : unaryExpression (POWER^ unaryExpression)? ;
+ private SpelNodeImpl eatPowerExpression() {
+ SpelNodeImpl expr = eatUnaryExpression();
+ if (peekToken(TokenKind.POWER)) {
+ Token t = nextToken();//consume POWER
+ SpelNodeImpl expr2 = eatUnaryExpression();
+ checkRightOperand(t,expr2);
+ return new OperatorPower(toPos(t),expr, expr2);
+ }
+ return expr;
+ }
+
+ //unaryExpression: (PLUS^ | MINUS^ | BANG^) unaryExpression | primaryExpression ;
+ private SpelNodeImpl eatUnaryExpression() {
+ if (peekToken(TokenKind.PLUS) || peekToken(TokenKind.MINUS) || peekToken(TokenKind.BANG)) {
+ Token t = nextToken();
+ SpelNodeImpl expr = eatUnaryExpression();
+ if (t.kind==TokenKind.BANG) {
+ return new OperatorNot(toPos(t),expr);
+ } else if (t.kind==TokenKind.PLUS) {
+ return new OperatorPlus(toPos(t),expr);
+ } else {
+ assert t.kind==TokenKind.MINUS;
+ return new OperatorMinus(toPos(t),expr);
+ }
+ } else {
+ return eatPrimaryExpression();
+ }
+ }
+
+ //primaryExpression : startNode (node)? -> ^(EXPRESSION startNode (node)?);
+ private SpelNodeImpl eatPrimaryExpression() {
+ List nodes = new ArrayList();
+ SpelNodeImpl start = eatStartNode();
+ nodes.add(start);
+ while (maybeEatNode()) {
+ nodes.add(pop());
+ }
+ if (nodes.size()==1) {
+ return nodes.get(0);
+ } else {
+ return new CompoundExpression(toPos(start.getStartPosition(),nodes.get(nodes.size()-1).getEndPosition()),nodes.toArray(new SpelNodeImpl[nodes.size()]));
+ }
+ }
+
+ private int toPos(int start,int end) {
+ return (start<<16)+end;
+ }
+
+ //node : ((DOT dottedNode) | nonDottedNode)+;
+ private boolean maybeEatNode() {
+ Token t = peekToken();
+ SpelNodeImpl expr = null;
+ if (t!=null && peekToken(TokenKind.DOT,TokenKind.SAFE_NAVI)) {
+ expr = eatDottedNode();
+ } else {
+ expr = maybeEatNonDottedNode();
+ }
+ if (expr==null) {
+ return false;
+ } else {
+ push(expr);
+ return true;
+ }
+ }
+
+ //nonDottedNode: indexer;
+ private SpelNodeImpl maybeEatNonDottedNode() {
+ if (peekToken(TokenKind.LSQUARE)) {
+ if (maybeEatIndexer()) {
+ return pop();
+ }
+ }
+ return null;
+ }
+
+ //dottedNode
+ // : ((methodOrProperty
+ // | functionOrVar
+ // | projection
+ // | selection
+ // | firstSelection
+ // | lastSelection
+ // ))
+ // ;
+ private SpelNodeImpl eatDottedNode() {
+ Token t = nextToken();// it was a '.' or a '?.'
+ //eatToken(TokenKind.DOT);
+ boolean nullSafeNavigation = t.kind==TokenKind.SAFE_NAVI;
+ if (maybeEatMethodOrProperty(nullSafeNavigation) || maybeEatFunctionOrVar() || maybeEatProjection(nullSafeNavigation) || maybeEatSelection(nullSafeNavigation)) {
+ return pop();
+ }
+ throw new InternalParseException(new SpelParseException(expressionString,t.startpos,SpelMessages.UNEXPECTED_DATA_AFTER_DOT,toString(peekToken())));
+ }
+
+// functionOrVar
+// : (POUND ID LPAREN) => function
+// | var
+// ;
+//
+//function : POUND id=ID methodArgs -> ^(FUNCTIONREF[$id] methodArgs);
+//
+//var : POUND id=ID -> ^(VARIABLEREF[$id]);
+
+ private boolean maybeEatFunctionOrVar() {
+ if (!peekToken(TokenKind.HASH)) {
+ return false;
+ }
+ Token t = nextToken();
+ Token functionOrVariableName = eatToken(TokenKind.IDENTIFIER);
+ SpelNodeImpl[] args = maybeEatMethodArgs();
+ if (args==null) {
+ push(new VariableReference(functionOrVariableName.data,toPos(t.startpos,functionOrVariableName.endpos)));
+ return true;
+ } else {
+ push(new FunctionReference(functionOrVariableName.data,toPos(t.startpos,functionOrVariableName.endpos),args));
+ return true;
+ }
+ }
+
+
+ //methodArgs : LPAREN! (argument (COMMA! argument)* (COMMA!)?)? RPAREN!;
+ private SpelNodeImpl[] maybeEatMethodArgs() {
+ if (!peekToken(TokenKind.LPAREN)) {
+ return null;
+ }
+ List args = new ArrayList();
+ consumeArguments(args);
+ eatToken(TokenKind.RPAREN);
+ return args.toArray(new SpelNodeImpl[args.size()]);
+ }
+
+ private void eatConstructorArgs(List accumulatedArguments) {
+ if (!peekToken(TokenKind.LPAREN)) {
+ throw new InternalParseException(new SpelParseException(expressionString,positionOf(peekToken()),SpelMessages.MISSING_CONSTRUCTOR_ARGS));
+ }
+ consumeArguments(accumulatedArguments);
+ eatToken(TokenKind.RPAREN);
+ }
+
+ /**
+ * Used for consuming arguments for either a method or a constructor call
+ */
+ private void consumeArguments(List accumulatedArguments) {
+ int pos = peekToken().startpos;
+ Token next = null;
+ do {
+ nextToken();// consume ( (first time through) or comma (subsequent times)
+ Token t = peekToken();
+ if (t==null) {
+ raiseInternalException(pos,SpelMessages.RUN_OUT_OF_ARGUMENTS);
+ }
+ if (t.kind!=TokenKind.RPAREN) {
+ accumulatedArguments.add(eatExpression());
+ }
+ next = peekToken();
+ } while (next!=null && next.kind==TokenKind.COMMA);
+ if (next==null) {
+ raiseInternalException(pos,SpelMessages.RUN_OUT_OF_ARGUMENTS);
+ }
+ }
+
+ private int positionOf(Token t) {
+ if (t==null) {
+ // if null assume the problem is because the right token was
+ // not found at the end of the expression
+ return expressionString.length();
+ } else {
+ return t.startpos;
+ }
+ }
+
+
+ //startNode
+ // : parenExpr | literal
+ // | type
+ // | methodOrProperty
+ // | functionOrVar
+ // | projection
+ // | selection
+ // | firstSelection
+ // | lastSelection
+ // | indexer
+ // | constructor
+ private SpelNodeImpl eatStartNode() {
+ if (maybeEatLiteral()) {
+ return pop();
+ } else if (maybeEatParenExpression()) {
+ return pop();
+ } else if (maybeEatTypeReference() || maybeEatNullReference() || maybeEatConstructorReference() || maybeEatMethodOrProperty(false) || maybeEatFunctionOrVar()) {
+ return pop();
+ } else if (maybeEatProjection(false) || maybeEatSelection(false) || maybeEatIndexer()) {
+ return pop();
+ } else {
+ return null;
+ }
+ }
+
+
+
+ private boolean maybeEatTypeReference() {
+ if (peekToken(TokenKind.IDENTIFIER)) {
+ Token typeName = peekToken();
+ if (!typeName.stringValue().equals("T")) {
+ return false;
+ }
+ nextToken();
+ eatToken(TokenKind.LPAREN);
+ SpelNodeImpl node = eatPossiblyQualifiedId();
+ // dotted qualified id
+ eatToken(TokenKind.RPAREN);
+ constructedNodes.push(new TypeReference(toPos(typeName),node));
+ return true;
+ }
+ return false;
+ }
+
+ private boolean maybeEatNullReference() {
+ if (peekToken(TokenKind.IDENTIFIER)) {
+ Token nullToken = peekToken();
+ if (!nullToken.stringValue().equals("null")) {
+ return false;
+ }
+ nextToken();
+ constructedNodes.push(new NullLiteral(toPos(nullToken)));
+ return true;
+ }
+ return false;
+ }
+
+ //projection: PROJECT^ expression RCURLY!;
+ private boolean maybeEatProjection(boolean nullSafeNavigation) {
+ Token t = peekToken();
+ if (!peekToken(TokenKind.PROJECT)) {
+ return false;
+ }
+ nextToken();
+ SpelNodeImpl expr = eatExpression();
+ eatToken(TokenKind.RSQUARE);
+ constructedNodes.push(new Projection(nullSafeNavigation, toPos(t),expr));
+ return true;
+ }
+
+ private boolean maybeEatIndexer() {
+ Token t = peekToken();
+ if (!peekToken(TokenKind.LSQUARE)) {
+ return false;
+ }
+ nextToken();
+ SpelNodeImpl expr = eatExpression();
+ eatToken(TokenKind.RSQUARE);
+ constructedNodes.push(new Indexer(toPos(t),expr));
+ return true;
+ }
+
+ private boolean maybeEatSelection(boolean nullSafeNavigation) {
+ Token t = peekToken();
+ if (!peekSelectToken()) {
+ return false;
+ }
+ nextToken();
+ SpelNodeImpl expr = eatExpression();
+ eatToken(TokenKind.RSQUARE);
+ if (t.kind==TokenKind.SELECT_FIRST) {
+ constructedNodes.push(new Selection(nullSafeNavigation,Selection.FIRST,toPos(t),expr));
+ } else if (t.kind==TokenKind.SELECT_LAST) {
+ constructedNodes.push(new Selection(nullSafeNavigation,Selection.LAST,toPos(t),expr));
+ } else {
+ constructedNodes.push(new Selection(nullSafeNavigation,Selection.ALL,toPos(t),expr));
+ }
+ return true;
+ }
+
+ private SpelNodeImpl eatPossiblyQualifiedId() {
+ List qualifiedIdPieces = new ArrayList();
+ Token startnode = eatToken(TokenKind.IDENTIFIER);
+ qualifiedIdPieces.add(new Identifier(startnode.stringValue(),toPos(startnode)));
+ while (peekToken(TokenKind.DOT)) {
+ nextToken();
+ Token node = eatToken(TokenKind.IDENTIFIER);
+ qualifiedIdPieces.add(new Identifier(node.stringValue(),toPos(node)));
+ }
+ return new QualifiedIdentifier(toPos(startnode.startpos,qualifiedIdPieces.get(qualifiedIdPieces.size()-1).getEndPosition()),qualifiedIdPieces.toArray(new SpelNodeImpl[qualifiedIdPieces.size()]));
+ }
+
+ private boolean maybeEatMethodOrProperty(boolean nullSafeNavigation) {
+ if (peekToken(TokenKind.IDENTIFIER)) {
+ Token methodOrPropertyName = nextToken();
+ SpelNodeImpl[] args = maybeEatMethodArgs();
+ if (args==null) {
+ // property
+ push(new PropertyOrFieldReference(nullSafeNavigation, methodOrPropertyName.data,toPos(methodOrPropertyName)));
+ return true;
+ } else {
+ // methodreference
+ push(new MethodReference(nullSafeNavigation, methodOrPropertyName.data,toPos(methodOrPropertyName),args));
+ // TODO what is the end position for a method reference? the name or the last arg?
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //constructor
+// : ('new' qualifiedId LPAREN) => 'new' qualifiedId ctorArgs -> ^(CONSTRUCTOR qualifiedId ctorArgs)
+// ;
+ private boolean maybeEatConstructorReference() {
+ if (peekIdentifierToken("new")) {
+ Token newToken = nextToken();
+ SpelNodeImpl possiblyQualifiedConstructorName = eatPossiblyQualifiedId();
+ List nodes = new ArrayList();
+ nodes.add(possiblyQualifiedConstructorName);
+ eatConstructorArgs(nodes);
+ push(new ConstructorReference(toPos(newToken),nodes.toArray(new SpelNodeImpl[nodes.size()]))); // TODO correct end position?
+ return true;
+ }
+ return false;
+ }
+
+
+ private void push(SpelNodeImpl newNode) {
+ constructedNodes.push(newNode);
+ }
+
+ private SpelNodeImpl pop() {
+ return constructedNodes.pop();
+ }
+
+// literal:
+// INTEGER_LITERAL
+// | boolLiteral
+// | STRING_LITERAL
+
+// | HEXADECIMAL_INTEGER_LITERAL
+// | REAL_LITERAL
+// | DQ_STRING_LITERAL
+// | NULL_LITERAL
+// ;
+ private boolean maybeEatLiteral() {
+ Token t = peekToken();
+ if (t==null) {
+ return false;
+ }
+ if (t.kind==TokenKind.LITERAL_INT) {
+ nextToken();
+ push(Literal.getIntLiteral(t.data, toPos(t), 10));
+ return true;
+ } else if (t.kind==TokenKind.LITERAL_LONG) {
+ nextToken();
+ push(Literal.getLongLiteral(t.data, toPos(t), 10));
+ return true;
+ } else if (t.kind==TokenKind.LITERAL_HEXINT) {
+ nextToken();
+ push(Literal.getIntLiteral(t.data, toPos(t), 16));
+ return true;
+ } else if (t.kind==TokenKind.LITERAL_HEXLONG) {
+ nextToken();
+ push(Literal.getLongLiteral(t.data, toPos(t), 16));
+ return true;
+ } else if (t.kind==TokenKind.LITERAL_REAL) {
+ nextToken();
+ push(Literal.getRealLiteral(t.data, toPos(t),false));
+ return true;
+ } else if (t.kind==TokenKind.LITERAL_REAL_FLOAT) {
+ nextToken();
+ push(Literal.getRealLiteral(t.data, toPos(t), true));
+ return true;
+ } else if (peekIdentifierToken("true")) {
+ nextToken();
+ push(new BooleanLiteral(t.data,toPos(t),true));
+ return true;
+ } else if (peekIdentifierToken("false")) {
+ nextToken();
+ push(new BooleanLiteral(t.data,toPos(t),false));
+ return true;
+ } else if (t.kind==TokenKind.LITERAL_STRING) {
+ nextToken();
+ push(new StringLiteral(t.data,toPos(t),t.data));
+ return true;
+ }
+ return false;
+ }
+
+ private int toPos(Token t) {
+ return (t.startpos<<16)+t.endpos;
+ }
+
+ //parenExpr : LPAREN! expression RPAREN!;
+ private boolean maybeEatParenExpression() {
+ if (peekToken(TokenKind.LPAREN)) {
+ nextToken();
+ SpelNodeImpl expr = eatExpression();
+ eatToken(TokenKind.RPAREN);
+ push(expr);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ // relationalOperator
+ // : EQUAL | NOT_EQUAL | LESS_THAN | LESS_THAN_OR_EQUAL | GREATER_THAN | GREATER_THAN_OR_EQUAL | INSTANCEOF
+ // | BETWEEN | MATCHES
+ private Token maybeEatRelationalOperator() {
+ Token t = peekToken();
+ if (t==null) {
+ return null;
+ }
+ if (t.isNumericRelationalOperator()) {
+ return t;
+ }
+ if (t.isIdentifier()) {
+ String idString = t.stringValue();
+ if (idString.equalsIgnoreCase("instanceof")) {
+ return t.asInstanceOfToken();
+ } else if (idString.equalsIgnoreCase("matches")) {
+ return t.asMatchesToken();
+ } else if (idString.equalsIgnoreCase("between")) {
+ return t.asBetweenToken();
+ }
+ }
+ return null;
+ }
+
+ private Token eatToken(TokenKind expectedKind) {
+ assert moreTokens();
+ Token t = nextToken();
+ if (t==null) {
+ raiseInternalException( expressionString.length(), SpelMessages.OOD);
+ }
+ if (t.kind!=expectedKind) {
+ raiseInternalException(t.startpos,SpelMessages.NOT_EXPECTED_TOKEN, expectedKind.toString().toLowerCase(),t.getKind().toString().toLowerCase());
+ }
+ return t;
+ }
+
+ private boolean peekToken(TokenKind desiredTokenKind) {
+ if (!moreTokens()) return false;
+ Token t = peekToken();
+ return t.kind==desiredTokenKind;
+ }
+
+ private boolean peekToken(TokenKind possible1,TokenKind possible2) {
+ if (!moreTokens()) return false;
+ Token t = peekToken();
+ return t.kind==possible1 || t.kind==possible2;
+ }
+
+ private boolean peekToken(TokenKind possible1,TokenKind possible2, TokenKind possible3) {
+ if (!moreTokens()) return false;
+ Token t = peekToken();
+ return t.kind==possible1 || t.kind==possible2 || t.kind==possible3;
+ }
+
+ private boolean peekIdentifierToken(String identifierString) {
+ if (!moreTokens()) return false;
+ Token t = peekToken();
+ return t.kind==TokenKind.IDENTIFIER && t.stringValue().equalsIgnoreCase(identifierString);
+ }
+
+ private boolean peekSelectToken() {
+ if (!moreTokens()) return false;
+ Token t = peekToken();
+ return t.kind==TokenKind.SELECT || t.kind==TokenKind.SELECT_FIRST || t.kind==TokenKind.SELECT_LAST;
+ }
+
+
+ private boolean moreTokens() {
+ return tokenStreamPointer=tokenStreamLength) {
+ return null;
+ }
+ return tokenStream.get(tokenStreamPointer++);
+ }
+
+ private Token peekToken() {
+ if (tokenStreamPointer>=tokenStreamLength) {
+ return null;
+ }
+ return tokenStream.get(tokenStreamPointer);
+ }
+
+ private void raiseInternalException(int pos, SpelMessages message,Object... inserts) {
+ throw new InternalParseException(new SpelParseException(expressionString,pos,message,inserts));
+ }
+
+}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/Token.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/Token.java
new file mode 100644
index 00000000000..3b89cabac1e
--- /dev/null
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/Token.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.springframework.expression.spel.standard;
+
+/**
+ * Holder for a kind of token, the associated data and its position in the input data stream (start/end).
+ *
+ * @author Andy Clement
+ * @since 3.0
+ */
+class Token {
+
+ TokenKind kind;
+ String data;
+ int startpos; // index of first character
+ int endpos; // index of char after the last character
+
+ /**
+ * Constructor for use when there is no particular data for the token (eg. TRUE or '+')
+ * @param startpos the exact start
+ * @param endpos the index to the last character
+ */
+ Token(TokenKind tokenKind, int startpos, int endpos) {
+ this.kind = tokenKind;
+ this.startpos = startpos;
+ this.endpos = endpos;
+ }
+
+ Token(TokenKind tokenKind, char[] tokenData, int pos, int endpos) {
+ this(tokenKind,pos,endpos);
+ this.data = new String(tokenData);
+ }
+
+
+ public TokenKind getKind() {
+ return kind;
+ }
+
+ public String toString() {
+ StringBuilder s = new StringBuilder();
+ s.append("[").append(kind.toString());
+ if (kind.hasPayload()) {
+ s.append(":").append(data);
+ }
+ s.append("]");
+ s.append("(").append(startpos).append(",").append(endpos).append(")");
+ return s.toString();
+ }
+
+ public boolean isIdentifier() {
+ return kind==TokenKind.IDENTIFIER;
+ }
+
+ public boolean isGreaterThan() {
+ return kind==TokenKind.GT;
+ }
+
+ public boolean isLessThan() {
+ return kind==TokenKind.LT;
+ }
+
+ public boolean isGreaterThanOrEqual() {
+ return kind==TokenKind.GE;
+ }
+
+ public boolean isEquality() {
+ return kind==TokenKind.EQ;
+ }
+
+ public boolean isLessThanOrEqual() {
+ return kind==TokenKind.LE;
+ }
+
+ public boolean isInstanceOf() {
+ return kind==TokenKind.INSTANCEOF;
+ }
+
+ public boolean isNumericRelationalOperator() {
+ return kind==TokenKind.GT || kind==TokenKind.GE || kind==TokenKind.LT || kind==TokenKind.LE || kind==TokenKind.EQ || kind==TokenKind.NE;
+ }
+
+ public String stringValue() {
+ return data;
+ }
+
+ public Token asInstanceOfToken() {
+ return new Token(TokenKind.INSTANCEOF,startpos,endpos);
+ }
+
+ public Token asMatchesToken() {
+ return new Token(TokenKind.MATCHES,startpos,endpos);
+ }
+
+ public Token asBetweenToken() {
+ return new Token(TokenKind.BETWEEN,startpos,endpos);
+ }
+}
\ No newline at end of file
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/TokenKind.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/TokenKind.java
new file mode 100644
index 00000000000..fd73c571e74
--- /dev/null
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/TokenKind.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.springframework.expression.spel.standard;
+
+/**
+ * @author Andy Clement
+ * @since 3.0
+ */
+enum TokenKind {
+ // ordered by priority - operands first
+ LITERAL_INT, LITERAL_LONG, LITERAL_HEXINT, LITERAL_HEXLONG, LITERAL_STRING, LITERAL_REAL, LITERAL_REAL_FLOAT,
+ LPAREN("("), RPAREN(")"), COMMA(","), IDENTIFIER,
+ COLON(":"),HASH("#"),RSQUARE("]"), LSQUARE("["),
+ DOT("."), PLUS("+"), STAR("*"), DIV("/"), BANG("!"), MINUS("-"), SELECT_FIRST("^["), SELECT_LAST("$["), QMARK("?"), PROJECT("!["),
+ GE(">="),GT(">"),LE("<="),LT("<"),EQ("=="),NE("!="),ASSIGN("="), INSTANCEOF("instanceof"), MATCHES("matches"), BETWEEN("between"),
+ SELECT("?["), MOD("%"), POWER("^"), DOLLAR("$"),
+ ELVIS("?:"), SAFE_NAVI("?.");
+ ;
+
+ char[] tokenChars;
+ private boolean hasPayload; // is there more to this token than simply the kind
+
+ private TokenKind(String tokenString) {
+ tokenChars = tokenString.toCharArray();
+ hasPayload = tokenChars.length==0;
+ }
+
+ private TokenKind() {
+ this("");
+ }
+
+ public String toString() {
+ return this.name()+(tokenChars.length!=0?"("+new String(tokenChars)+")":"");
+ }
+
+ public boolean hasPayload() {
+ return hasPayload;
+ }
+}
\ No newline at end of file
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java
new file mode 100644
index 00000000000..249cbe92fb2
--- /dev/null
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java
@@ -0,0 +1,474 @@
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.springframework.expression.spel.standard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.expression.spel.SpelMessages;
+import org.springframework.expression.spel.SpelParseException;
+
+/**
+ * Lex some input data into a stream of tokens that can then be parsed.
+ *
+ * @author Andy Clement
+ * @since 3.0
+ */
+public class Tokenizer {
+
+ String expressionString;
+ char[] toProcess;
+ int pos;
+ int max;
+ List tokens = new ArrayList();
+
+ public Tokenizer(String inputdata) {
+ this.expressionString = inputdata;
+ this.toProcess = (inputdata+"\0").toCharArray();
+ this.max = toProcess.length;
+ this.pos = 0;
+ process();
+ }
+
+ public void process() {
+ while (pos':
+ if (isTwoCharToken(TokenKind.GE)) {
+ pushPairToken(TokenKind.GE);
+ } else {
+ pushCharToken(TokenKind.GT);
+ }
+ break;
+ case '<':
+ if (isTwoCharToken(TokenKind.LE)) {
+ pushPairToken(TokenKind.LE);
+ } else {
+ pushCharToken(TokenKind.LT);
+ }
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ lexNumericLiteral(ch=='0');
+ break;
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ // drift over white space
+ pos++;
+ break;
+ case '\'':
+ lexQuotedStringLiteral();
+ break;
+ case '"':
+ lexDoubleQuotedStringLiteral();
+ break;
+ case 0:
+ // hit sentinel at end of value
+ pos++; // will take us to the end
+ break;
+ default:
+ throw new IllegalStateException("Cannot handle ("+Integer.valueOf(ch)+") '"+ch+"'");
+ }
+ }
+ }
+ }
+
+ public List getTokens() {
+ return tokens;
+ }
+
+
+ // STRING_LITERAL: '\''! (APOS|~'\'')* '\''!;
+ private void lexQuotedStringLiteral() {
+ int start = pos;
+ boolean terminated = false;
+ while (!terminated) {
+ pos++;
+ char ch = toProcess[pos];
+ if (ch=='\'') {
+ // may not be the end if the char after is also a '
+ if (toProcess[pos+1]=='\'') {
+ pos++; // skip over that too, and continue
+ } else {
+ terminated = true;
+ }
+ }
+ if (ch==0) {
+ throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessages.NON_TERMINATING_QUOTED_STRING));
+ }
+ }
+ pos++;
+ tokens.add(new Token(TokenKind.LITERAL_STRING, subarray(start,pos), start, pos));
+ }
+
+ // DQ_STRING_LITERAL: '"'! (~'"')* '"'!;
+ private void lexDoubleQuotedStringLiteral() {
+ int start = pos;
+ boolean terminated = false;
+ while (!terminated) {
+ pos++;
+ char ch = toProcess[pos];
+ if (ch=='"') {
+ terminated = true;
+ }
+ if (ch==0) {
+ throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessages.NON_TERMINATING_DOUBLE_QUOTED_STRING));
+ }
+ }
+ pos++;
+ tokens.add(new Token(TokenKind.LITERAL_STRING, subarray(start,pos), start, pos));
+ }
+
+
+// REAL_LITERAL :
+// ('.' (DECIMAL_DIGIT)+ (EXPONENT_PART)? (REAL_TYPE_SUFFIX)?) |
+// ((DECIMAL_DIGIT)+ '.' (DECIMAL_DIGIT)+ (EXPONENT_PART)? (REAL_TYPE_SUFFIX)?) |
+// ((DECIMAL_DIGIT)+ (EXPONENT_PART) (REAL_TYPE_SUFFIX)?) |
+// ((DECIMAL_DIGIT)+ (REAL_TYPE_SUFFIX));
+// fragment INTEGER_TYPE_SUFFIX : ( 'L' | 'l' );
+// fragment HEX_DIGIT : '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'A'|'B'|'C'|'D'|'E'|'F'|'a'|'b'|'c'|'d'|'e'|'f';
+//
+// fragment EXPONENT_PART : 'e' (SIGN)* (DECIMAL_DIGIT)+ | 'E' (SIGN)* (DECIMAL_DIGIT)+ ;
+// fragment SIGN : '+' | '-' ;
+// fragment REAL_TYPE_SUFFIX : 'F' | 'f' | 'D' | 'd';
+// INTEGER_LITERAL
+// : (DECIMAL_DIGIT)+ (INTEGER_TYPE_SUFFIX)?;
+
+ private void lexNumericLiteral(boolean firstCharIsZero) {
+ boolean isReal = false;
+ int start = pos;
+ char ch = toProcess[pos+1];
+ boolean isHex = ch=='x' || ch=='X';
+
+ // deal with hexadecimal
+ if (firstCharIsZero && isHex) {
+ pos=pos+1;
+ do {
+ pos++;
+ } while (isHexadecimalDigit(toProcess[pos]));
+ if (isChar('L','l')) {
+ pushHexIntToken(subarray(start+2,pos),true, start, pos);
+ pos++;
+ } else {
+ pushHexIntToken(subarray(start+2,pos),false, start, pos);
+ }
+ return;
+ }
+
+ // real numbers must have leading digits
+
+ // Consume first part of number
+ do {
+ pos++;
+ } while (isDigit(toProcess[pos]));
+
+ // a '.' indicates this number is a real
+ ch = toProcess[pos];
+ if (ch=='.') {
+ isReal = true;
+ // carry on consuming digits
+ do {
+ pos++;
+ } while (isDigit(toProcess[pos]));
+ }
+
+ int endOfNumber = pos;
+
+ // Now there may or may not be an exponent
+
+ // 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));
+ }
+ pushIntToken(subarray(start, endOfNumber), true, start, endOfNumber);
+ pos++;
+ } else if (isExponentChar(toProcess[pos])) {
+ isReal = true; // if it wasnt before, it is now
+ pos++;
+ char possibleSign = toProcess[pos];
+ if (isSign(possibleSign)) {
+ pos++;
+ }
+
+ // exponent digits
+ do {
+ pos++;
+ } while (isDigit(toProcess[pos]));
+ boolean isFloat = false;
+ if (isFloatSuffix(toProcess[pos])) {
+ isFloat = true;
+ endOfNumber = ++pos;
+ } else if (isDoubleSuffix(toProcess[pos])) {
+ endOfNumber = ++pos;
+ }
+ pushRealToken(subarray(start,pos), isFloat, start, pos);
+ } else {
+ ch = toProcess[pos];
+ boolean isFloat = false;
+ if (isFloatSuffix(ch)) {
+ isReal = true;
+ isFloat = true;
+ endOfNumber = ++pos;
+ } else if (isDoubleSuffix(ch)) {
+ isReal = true;
+ endOfNumber = ++pos;
+ }
+ if (isReal) {
+ pushRealToken(subarray(start,endOfNumber), isFloat, start, endOfNumber);
+ } else {
+ pushIntToken(subarray(start,endOfNumber), false, start, endOfNumber);
+ }
+ }
+ }
+
+
+ private void lexIdentifier() {
+ int start = pos;
+ do {
+ pos++;
+ } while (isIdentifier(toProcess[pos]));
+ tokens.add(new Token(TokenKind.IDENTIFIER,subarray(start,pos),start,pos));
+ }
+
+ private void pushIntToken(char[] data,boolean isLong, int start, int end) {
+ if (isLong) {
+ tokens.add(new Token(TokenKind.LITERAL_LONG,data, start, end));
+ } else {
+ tokens.add(new Token(TokenKind.LITERAL_INT,data, start, end));
+ }
+ }
+
+ 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)));
+ } else {
+ throw new InternalParseException(new SpelParseException(expressionString,start,SpelMessages.NOT_AN_INTEGER,expressionString.substring(start,end)));
+ }
+ }
+ if (isLong) {
+ tokens.add(new Token(TokenKind.LITERAL_HEXLONG, data, start, end));
+ } else {
+ tokens.add(new Token(TokenKind.LITERAL_HEXINT, data, start, end));
+ }
+ }
+
+ private void pushRealToken(char[] data, boolean isFloat, int start, int end) {
+ if (isFloat) {
+ tokens.add(new Token(TokenKind.LITERAL_REAL_FLOAT, data, start, end));
+ } else {
+ tokens.add(new Token(TokenKind.LITERAL_REAL, data, start, end));
+ }
+ }
+
+ private char[] subarray(int start, int end) {
+ char[] result = new char[end - start];
+ System.arraycopy(toProcess, start, result, 0, end - start);
+ return result;
+ }
+
+ /**
+ * Check if this might be a two character token.
+ */
+ private boolean isTwoCharToken(TokenKind kind) {
+ assert kind.tokenChars.length==2;
+ assert toProcess[pos] == kind.tokenChars[0];
+ return toProcess[pos+1] == kind.tokenChars[1];
+ }
+
+ /**
+ * Push a token of just one character in length.
+ */
+ private void pushCharToken(TokenKind kind) {
+ tokens.add(new Token(kind,pos,pos+1));
+ pos++;
+ }
+
+ /**
+ * Push a token of two characters in length.
+ */
+ private void pushPairToken(TokenKind kind) {
+ tokens.add(new Token(kind,pos,pos+2));
+ pos+=2;
+ }
+
+ // ID: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|DOT_ESCAPED)*;
+ private boolean isIdentifier(char ch) {
+ return isAlphabetic(ch) || isDigit(ch) || ch=='_';
+ }
+
+ private boolean isChar(char a,char b) {
+ char ch = toProcess[pos];
+ return ch==a || ch==b;
+ }
+
+ private boolean isExponentChar(char ch) {
+ return ch=='e' || ch=='E';
+ }
+
+ private boolean isFloatSuffix(char ch) {
+ return ch=='f' || ch=='F';
+ }
+
+ private boolean isDoubleSuffix(char ch) {
+ return ch=='d' || ch=='D';
+ }
+
+ private boolean isSign(char ch) {
+ return ch=='+' || ch=='-';
+ }
+
+ private boolean isDigit(char ch) {
+ if (ch>255) {
+ return false;
+ }
+ return (flags[ch] & IS_DIGIT)!=0;
+ }
+
+ private boolean isAlphabetic(char ch) {
+ if (ch>255) {
+ return false;
+ }
+ return (flags[ch] & IS_ALPHA)!=0;
+ }
+
+ private boolean isHexadecimalDigit(char ch) {
+ if (ch>255) {
+ return false;
+ }
+ return (flags[ch] & IS_HEXDIGIT)!=0;
+ }
+
+ private static final byte flags[] = new byte[256];
+ private static final byte IS_DIGIT=0x01;
+ private static final byte IS_HEXDIGIT=0x02;
+ private static final byte IS_ALPHA=0x04;
+
+ static {
+ for (int ch='0';ch<='9';ch++) {
+ flags[ch]|=IS_DIGIT | IS_HEXDIGIT;
+ }
+ for (int ch='A';ch<='F';ch++) {
+ flags[ch]|= IS_HEXDIGIT;
+ }
+ for (int ch='a';ch<='f';ch++) {
+ flags[ch]|= IS_HEXDIGIT;
+ }
+ for (int ch='A';ch<='Z';ch++) {
+ flags[ch]|= IS_ALPHA;
+ }
+ for (int ch='a';ch<='z';ch++) {
+ flags[ch]|= IS_ALPHA;
+ }
+ }
+
+
+}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/BooleanTypedValue.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/BooleanTypedValue.java
index 75537ca1a44..d12dd5edfd1 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/BooleanTypedValue.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/BooleanTypedValue.java
@@ -16,7 +16,7 @@
package org.springframework.expression.spel.support;
import org.springframework.expression.TypedValue;
-import org.springframework.expression.spel.ast.SpelNodeImpl;
+import org.springframework.expression.spel.ast.CommonTypeDescriptors;
/**
* @author Andy Clement
@@ -28,7 +28,7 @@ public class BooleanTypedValue extends TypedValue {
public static final BooleanTypedValue False = new BooleanTypedValue(false);
private BooleanTypedValue(boolean b) {
- super(b,SpelNodeImpl.BOOLEAN_TYPE_DESCRIPTOR);
+ super(b,CommonTypeDescriptors.BOOLEAN_TYPE_DESCRIPTOR);
}
public static BooleanTypedValue forValue(boolean b) {
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java
index 1828c5814ea..0021c08750a 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java
@@ -22,7 +22,7 @@ import java.util.List;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypeConverter;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -112,7 +112,7 @@ public class ReflectionHelper {
int argCountUpToVarargs = expectedArgTypes.length-1;
for (int i = 0; i < argCountUpToVarargs && match != null; i++) {
Class suppliedArg = suppliedArgTypes[i];
- Class expectedArg = expectedArgTypes[i];
+ Class> expectedArg = expectedArgTypes[i];
if (expectedArg != suppliedArg) {
if (expectedArg.isAssignableFrom(suppliedArg) || ClassUtils.isAssignableValue(expectedArg, suppliedArg)) {
if (match != ArgsMatchKind.REQUIRES_CONVERSION) {
@@ -226,10 +226,10 @@ public class ReflectionHelper {
* @param isVarargs whether parameterTypes relates to a varargs method
* @param converter the converter to use for type conversions
* @param arguments the arguments to convert to the requested parameter types
- * @throws SpelException if there is a problem with conversion
+ * @throws SpelEvaluationException if there is a problem with conversion
*/
public static void convertAllArguments(Class[] parameterTypes, boolean isVarargs, TypeConverter converter,
- Object[] arguments) throws SpelException {
+ Object[] arguments) throws SpelEvaluationException {
Assert.notNull(arguments,"should not be called if nothing to convert");
@@ -248,16 +248,16 @@ public class ReflectionHelper {
try {
if (arguments[i] != null && arguments[i].getClass() != targetType) {
if (converter == null) {
- throw new SpelException(SpelMessages.TYPE_CONVERSION_ERROR, arguments[i].getClass().getName(),targetType);
+ throw new SpelEvaluationException(SpelMessages.TYPE_CONVERSION_ERROR, arguments[i].getClass().getName(),targetType);
}
arguments[i] = converter.convertValue(arguments[i], targetType);
}
} catch (EvaluationException ex) {
// allows for another type converter throwing a different kind of EvaluationException
- if (ex instanceof SpelException) {
- throw (SpelException)ex;
+ if (ex instanceof SpelEvaluationException) {
+ throw (SpelEvaluationException)ex;
} else {
- throw new SpelException(ex, SpelMessages.TYPE_CONVERSION_ERROR,arguments[i].getClass().getName(),targetType);
+ throw new SpelEvaluationException(ex, SpelMessages.TYPE_CONVERSION_ERROR,arguments[i].getClass().getName(),targetType);
}
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java
index 97de92d00d7..bc209ddea56 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java
@@ -24,7 +24,7 @@ import org.springframework.expression.EvaluationException;
import org.springframework.expression.MethodExecutor;
import org.springframework.expression.MethodResolver;
import org.springframework.expression.TypeConverter;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
/**
@@ -88,7 +88,7 @@ public class ReflectiveMethodResolver implements MethodResolver {
}
else if (matchRequiringConversion != null) {
if (multipleOptions) {
- throw new SpelException(SpelMessages.MULTIPLE_POSSIBLE_METHODS, name);
+ throw new SpelEvaluationException(SpelMessages.MULTIPLE_POSSIBLE_METHODS, name);
}
return new ReflectiveMethodExecutor(matchRequiringConversion, argsToConvert);
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeComparator.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeComparator.java
index 200730eabc1..0f1ded846ec 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeComparator.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeComparator.java
@@ -17,7 +17,7 @@
package org.springframework.expression.spel.support;
import org.springframework.expression.TypeComparator;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
/**
@@ -30,7 +30,7 @@ import org.springframework.expression.spel.SpelMessages;
public class StandardTypeComparator implements TypeComparator {
@SuppressWarnings("unchecked")
- public int compare(Object left, Object right) throws SpelException {
+ public int compare(Object left, Object right) throws SpelEvaluationException {
// If one is null, check if the other is
if (left == null) {
return right == null ? 0 : 1;
@@ -65,7 +65,7 @@ public class StandardTypeComparator implements TypeComparator {
return ((Comparable) left).compareTo(right);
}
- throw new SpelException(SpelMessages.NOT_COMPARABLE, left.getClass(), right.getClass());
+ throw new SpelEvaluationException(SpelMessages.NOT_COMPARABLE, left.getClass(), right.getClass());
}
public boolean canCompare(Object left, Object right) {
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeConverter.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeConverter.java
index 23c7b9af27e..97e2ceee7e0 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeConverter.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeConverter.java
@@ -22,7 +22,7 @@ import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultTypeConverter;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypeConverter;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
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 SpelException(cenfe, SpelMessages.TYPE_CONVERSION_ERROR, value.getClass(), typeDescriptor.asString());
+ throw new SpelEvaluationException(cenfe, SpelMessages.TYPE_CONVERSION_ERROR, value.getClass(), typeDescriptor.asString());
}
catch (ConvertException ce) {
- throw new SpelException(ce, SpelMessages.TYPE_CONVERSION_ERROR, value.getClass(), typeDescriptor.asString());
+ throw new SpelEvaluationException(ce, SpelMessages.TYPE_CONVERSION_ERROR, value.getClass(), typeDescriptor.asString());
}
}
diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java
index 7dd6ce5f950..df104096f6d 100644
--- a/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java
+++ b/org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java
@@ -22,7 +22,7 @@ import java.util.List;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypeLocator;
-import org.springframework.expression.spel.SpelException;
+import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessages;
import org.springframework.util.ClassUtils;
@@ -76,7 +76,7 @@ public class StandardTypeLocator implements TypeLocator {
// might be a different prefix
}
}
- throw new SpelException(SpelMessages.TYPE_NOT_FOUND, typename);
+ throw new SpelEvaluationException(SpelMessages.TYPE_NOT_FOUND, typename);
}
/**
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java
index f6ddbeb4362..f074add3fae 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java
@@ -16,6 +16,8 @@
package org.springframework.expression.spel;
+import org.junit.Test;
+
/**
* Tests the evaluation of real boolean expressions, these use AND, OR, NOT, TRUE, FALSE
*
@@ -23,14 +25,17 @@ package org.springframework.expression.spel;
*/
public class BooleanExpressionTests extends ExpressionTestCase {
+ @Test
public void testBooleanTrue() {
evaluate("true", Boolean.TRUE, Boolean.class);
}
+ @Test
public void testBooleanFalse() {
evaluate("false", Boolean.FALSE, Boolean.class);
}
+ @Test
public void testOr() {
evaluate("false or false", Boolean.FALSE, Boolean.class);
evaluate("false or true", Boolean.TRUE, Boolean.class);
@@ -38,6 +43,7 @@ public class BooleanExpressionTests extends ExpressionTestCase {
evaluate("true or true", Boolean.TRUE, Boolean.class);
}
+ @Test
public void testAnd() {
evaluate("false and false", Boolean.FALSE, Boolean.class);
evaluate("false and true", Boolean.FALSE, Boolean.class);
@@ -45,23 +51,27 @@ public class BooleanExpressionTests extends ExpressionTestCase {
evaluate("true and true", Boolean.TRUE, Boolean.class);
}
+ @Test
public void testNot() {
evaluate("!false", Boolean.TRUE, Boolean.class);
evaluate("!true", Boolean.FALSE, Boolean.class);
}
+ @Test
public void testCombinations01() {
evaluate("false and false or true", Boolean.TRUE, Boolean.class);
evaluate("true and false or true", Boolean.TRUE, Boolean.class);
evaluate("true and false or false", Boolean.FALSE, Boolean.class);
}
+ @Test
public void testWritability() {
evaluate("true and true", Boolean.TRUE, Boolean.class, false);
evaluate("true or true", Boolean.TRUE, Boolean.class, false);
evaluate("!false", Boolean.TRUE, Boolean.class, false);
}
+ @Test
public void testBooleanErrors01() {
evaluateAndCheckError("1.0 or false", SpelMessages.TYPE_CONVERSION_ERROR, 0);
evaluateAndCheckError("false or 39.4", SpelMessages.TYPE_CONVERSION_ERROR, 9);
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java
index ab2ecd72f44..fb4419ddf94 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java
@@ -16,6 +16,8 @@
package org.springframework.expression.spel;
+import org.junit.Test;
+
/**
* Tests invocation of constructors.
*
@@ -23,14 +25,17 @@ package org.springframework.expression.spel;
*/
public class ConstructorInvocationTests extends ExpressionTestCase {
+ @Test
public void testTypeConstructors() {
evaluate("new String('hello world')", "hello world", String.class);
}
+ @Test
public void testNonExistentType() {
- evaluateAndCheckError("new FooBar()",SpelMessages.PROBLEM_LOCATING_CONSTRUCTOR);
+ evaluateAndCheckError("new FooBar()",SpelMessages.CONSTRUCTOR_INVOCATION_PROBLEM);
}
+ @Test
public void testVarargsInvocation01() {
// Calling 'Fruit(String... strings)'
evaluate("new org.springframework.expression.spel.testresources.Fruit('a','b','c').stringscount()", 3, Integer.class);
@@ -41,6 +46,7 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
evaluate("new org.springframework.expression.spel.testresources.Fruit(1,'a',3.0d).stringscount()", 3, Integer.class); // first and last need conversion
}
+ @Test
public void testVarargsInvocation02() {
// Calling 'Fruit(int i, String... strings)' - returns int+length_of_strings
evaluate("new org.springframework.expression.spel.testresources.Fruit(5,'a','b','c').stringscount()", 8, Integer.class);
@@ -56,6 +62,7 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
* These tests are attempting to call constructors where we need to widen or convert the argument in order to
* satisfy a suitable constructor.
*/
+ @Test
public void testWidening01() {
// widening of int 3 to double 3 is OK
evaluate("new Double(3)", 3.0d, Double.class);
@@ -63,6 +70,7 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
evaluate("new Long(3)", 3L, Long.class);
}
+ @Test
public void testArgumentConversion01() {
// Closest ctor will be new String(String) and converter supports Double>String
evaluate("new String(3.0d)", "3.0", String.class);
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/DefaultComparatorUnitTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/DefaultComparatorUnitTests.java
index 2a201dbb10c..98f1ff8a9be 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/DefaultComparatorUnitTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/DefaultComparatorUnitTests.java
@@ -15,8 +15,9 @@
*/
package org.springframework.expression.spel;
-import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.junit.Test;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypeComparator;
import org.springframework.expression.spel.support.StandardTypeComparator;
@@ -26,59 +27,63 @@ import org.springframework.expression.spel.support.StandardTypeComparator;
*
* @author Andy Clement
*/
-public class DefaultComparatorUnitTests extends TestCase {
+public class DefaultComparatorUnitTests {
+ @Test
public void testPrimitives() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
// primitive int
- assertTrue(comparator.compare(1, 2) < 0);
- assertTrue(comparator.compare(1, 1) == 0);
- assertTrue(comparator.compare(2, 1) > 0);
+ Assert.assertTrue(comparator.compare(1, 2) < 0);
+ Assert.assertTrue(comparator.compare(1, 1) == 0);
+ Assert.assertTrue(comparator.compare(2, 1) > 0);
- assertTrue(comparator.compare(1.0d, 2) < 0);
- assertTrue(comparator.compare(1.0d, 1) == 0);
- assertTrue(comparator.compare(2.0d, 1) > 0);
+ Assert.assertTrue(comparator.compare(1.0d, 2) < 0);
+ Assert.assertTrue(comparator.compare(1.0d, 1) == 0);
+ Assert.assertTrue(comparator.compare(2.0d, 1) > 0);
- assertTrue(comparator.compare(1.0f, 2) < 0);
- assertTrue(comparator.compare(1.0f, 1) == 0);
- assertTrue(comparator.compare(2.0f, 1) > 0);
+ Assert.assertTrue(comparator.compare(1.0f, 2) < 0);
+ Assert.assertTrue(comparator.compare(1.0f, 1) == 0);
+ Assert.assertTrue(comparator.compare(2.0f, 1) > 0);
- assertTrue(comparator.compare(1L, 2) < 0);
- assertTrue(comparator.compare(1L, 1) == 0);
- assertTrue(comparator.compare(2L, 1) > 0);
+ Assert.assertTrue(comparator.compare(1L, 2) < 0);
+ Assert.assertTrue(comparator.compare(1L, 1) == 0);
+ Assert.assertTrue(comparator.compare(2L, 1) > 0);
- assertTrue(comparator.compare(1, 2L) < 0);
- assertTrue(comparator.compare(1, 1L) == 0);
- assertTrue(comparator.compare(2, 1L) > 0);
+ Assert.assertTrue(comparator.compare(1, 2L) < 0);
+ Assert.assertTrue(comparator.compare(1, 1L) == 0);
+ Assert.assertTrue(comparator.compare(2, 1L) > 0);
- assertTrue(comparator.compare(1L, 2L) < 0);
- assertTrue(comparator.compare(1L, 1L) == 0);
- assertTrue(comparator.compare(2L, 1L) > 0);
+ Assert.assertTrue(comparator.compare(1L, 2L) < 0);
+ Assert.assertTrue(comparator.compare(1L, 1L) == 0);
+ Assert.assertTrue(comparator.compare(2L, 1L) > 0);
}
+ @Test
public void testNulls() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
- assertTrue(comparator.compare(null,"abc")>0);
- assertTrue(comparator.compare(null,null)==0);
- assertTrue(comparator.compare("abc",null)<0);
+ Assert.assertTrue(comparator.compare(null,"abc")>0);
+ Assert.assertTrue(comparator.compare(null,null)==0);
+ Assert.assertTrue(comparator.compare("abc",null)<0);
}
+ @Test
public void testObjects() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
- assertTrue(comparator.compare("a","a")==0);
- assertTrue(comparator.compare("a","b")<0);
- assertTrue(comparator.compare("b","a")>0);
+ Assert.assertTrue(comparator.compare("a","a")==0);
+ Assert.assertTrue(comparator.compare("a","b")<0);
+ Assert.assertTrue(comparator.compare("b","a")>0);
}
+ @Test
public void testCanCompare() throws EvaluationException {
TypeComparator comparator = new StandardTypeComparator();
- assertTrue(comparator.canCompare(null,1));
- assertTrue(comparator.canCompare(1,null));
+ Assert.assertTrue(comparator.canCompare(null,1));
+ Assert.assertTrue(comparator.canCompare(1,null));
- assertTrue(comparator.canCompare(2,1));
- assertTrue(comparator.canCompare("abc","def"));
- assertTrue(comparator.canCompare("abc",3));
- assertFalse(comparator.canCompare(String.class,3));
+ Assert.assertTrue(comparator.canCompare(2,1));
+ Assert.assertTrue(comparator.canCompare("abc","def"));
+ Assert.assertTrue(comparator.canCompare("abc",3));
+ Assert.assertFalse(comparator.canCompare(String.class,3));
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java
index 8cbdd1fecb8..325c3a9134e 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java
@@ -16,9 +16,14 @@
package org.springframework.expression.spel;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
+import org.springframework.expression.ParseException;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.support.StandardTypeLocator;
@@ -29,68 +34,95 @@ import org.springframework.expression.spel.support.StandardTypeLocator;
*/
public class EvaluationTests extends ExpressionTestCase {
+ @Test
+ public void testElvis01() {
+ evaluate("'Andy'?:'Dave'","Andy",String.class);
+ evaluate("null?:'Dave'","Dave",String.class);
+ }
+
+ @Test
+ public void testSafeNavigation() {
+ evaluate("null?.null?.null",null,null);
+ }
+
+ @Test
public void testRelOperatorGT01() {
evaluate("3 > 6", "false", Boolean.class);
}
+ @Test
public void testRelOperatorLT01() {
evaluate("3 < 6", "true", Boolean.class);
}
+ @Test
public void testRelOperatorLE01() {
evaluate("3 <= 6", "true", Boolean.class);
}
+ @Test
public void testRelOperatorGE01() {
evaluate("3 >= 6", "false", Boolean.class);
}
+ @Test
public void testRelOperatorGE02() {
evaluate("3 >= 3", "true", Boolean.class);
}
- public void testRelOperatorsIs01() {
+ @Test
+ public void testRelOperatorsInstanceof01() {
evaluate("'xyz' instanceof T(int)", "false", Boolean.class);
}
- public void testRelOperatorsIs04() {
+ @Test
+ public void testRelOperatorsInstanceof04() {
evaluate("null instanceof T(String)", "false", Boolean.class);
}
- public void testRelOperatorsIs05() {
+ @Test
+ public void testRelOperatorsInstanceof05() {
evaluate("null instanceof T(Integer)", "false", Boolean.class);
}
- public void testRelOperatorsIs06() {
+ @Test
+ public void testRelOperatorsInstanceof06() {
evaluateAndCheckError("'A' instanceof null", SpelMessages.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND, 15, "null");
}
+ @Test
public void testRelOperatorsMatches01() {
evaluate("'5.0067' matches '^-?\\d+(\\.\\d{2})?$'", "false", Boolean.class);
}
+ @Test
public void testRelOperatorsMatches02() {
evaluate("'5.00' matches '^-?\\d+(\\.\\d{2})?$'", "true", Boolean.class);
}
+ @Test
public void testRelOperatorsMatches03() {
evaluateAndCheckError("null matches '^.*$'", SpelMessages.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);
}
+ @Test
public void testRelOperatorsMatches05() {
evaluate("27 matches '^.*2.*$'", true, Boolean.class); // conversion int>string
}
// mixing operators
+ @Test
public void testMixingOperators01() {
evaluate("true and 5>3", "true", Boolean.class);
}
// property access
+ @Test
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
@@ -99,121 +131,157 @@ public class EvaluationTests extends ExpressionTestCase {
}
// nested properties
+ @Test
public void testPropertiesNested01() {
evaluate("placeOfBirth.city", "SmilJan", String.class, true);
}
+ @Test
public void testPropertiesNested02() {
evaluate("placeOfBirth.doubleIt(12)", "24", Integer.class);
}
+
+ @Test
+ public void testPropertiesNested03() throws ParseException {
+ try {
+ new SpelExpressionParser().parse("placeOfBirth.23");
+ Assert.fail();
+ } catch (SpelParseException spe) {
+ Assert.assertEquals(spe.getMessageUnformatted(), SpelMessages.UNEXPECTED_DATA_AFTER_DOT);
+ Assert.assertEquals("23", spe.getInserts()[0]);
+ }
+ }
// methods
+ @Test
public void testMethods01() {
evaluate("echo(12)", "12", String.class);
}
+ @Test
public void testMethods02() {
evaluate("echo(name)", "Nikola Tesla", String.class);
}
// constructors
+ @Test
public void testConstructorInvocation01() {
evaluate("new String('hello')", "hello", String.class);
}
+ @Test
public void testConstructorInvocation05() {
evaluate("new java.lang.String('foobar')", "foobar", String.class);
}
+ @Test
public void testConstructorInvocation06() throws Exception {
// repeated evaluation to drive use of cached executor
SpelExpression expr = (SpelExpression)parser.parseExpression("new String('wibble')");
String newString = expr.getValue(String.class);
- assertEquals("wibble",newString);
+ Assert.assertEquals("wibble",newString);
newString = expr.getValue(String.class);
- assertEquals("wibble",newString);
+ Assert.assertEquals("wibble",newString);
// not writable
- assertFalse(expr.isWritable(new StandardEvaluationContext()));
+ Assert.assertFalse(expr.isWritable(new StandardEvaluationContext()));
// ast
- assertEquals("new String('wibble')",expr.toStringAST());
+ Assert.assertEquals("new String('wibble')",expr.toStringAST());
}
// unary expressions
+ @Test
public void testUnaryMinus01() {
evaluate("-5", "-5", Integer.class);
}
+ @Test
public void testUnaryPlus01() {
evaluate("+5", "5", Integer.class);
}
+ @Test
public void testUnaryNot01() {
evaluate("!true", "false", Boolean.class);
}
+
// assignment
+ @Test
public void testAssignmentToVariables01() {
evaluate("#var1='value1'", "value1", String.class);
}
+ @Test
public void testTernaryOperator01() {
evaluate("2>4?1:2",2,Integer.class);
}
+ @Test
public void testTernaryOperator02() {
evaluate("'abc'=='abc'?1:2",1,Integer.class);
}
+ @Test
public void testTernaryOperator03() {
evaluateAndCheckError("'hello'?1:2", SpelMessages.TYPE_CONVERSION_ERROR); // cannot convert String to boolean
}
+ @Test
public void testTernaryOperator04() throws Exception {
Expression expr = parser.parseExpression("1>2?3:4");
- assertFalse(expr.isWritable(eContext));
+ Assert.assertFalse(expr.isWritable(eContext));
}
+ @Test
public void testIndexer03() {
evaluate("'christian'[8]", "n", String.class);
}
+ @Test
public void testIndexerError() {
evaluateAndCheckError("new org.springframework.expression.spel.testresources.Inventor().inventions[1]",SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
}
+ @Test
public void testStaticRef02() {
evaluate("T(java.awt.Color).green.getRGB()!=0", "true", Boolean.class);
}
// variables and functions
+ @Test
public void testVariableAccess01() {
evaluate("#answer", "42", Integer.class, true);
}
+ @Test
public void testFunctionAccess01() {
evaluate("#reverseInt(1,2,3)", "int[3]{3,2,1}", int[].class);
}
+ @Test
public void testFunctionAccess02() {
evaluate("#reverseString('hello')", "olleh", String.class);
}
// type references
+ @Test
public void testTypeReferences01() {
evaluate("T(java.lang.String)", "class java.lang.String", Class.class);
}
+ @Test
public void testTypeReferencesAndQualifiedIdentifierCaching() throws Exception {
SpelExpression expr = (SpelExpression)parser.parseExpression("T(java.lang.String)");
- assertFalse(expr.isWritable(new StandardEvaluationContext()));
- assertEquals("T(java.lang.String)",expr.toStringAST());
- assertEquals(String.class,expr.getValue(Class.class));
+ Assert.assertFalse(expr.isWritable(new StandardEvaluationContext()));
+ Assert.assertEquals("T(java.lang.String)",expr.toStringAST());
+ Assert.assertEquals(String.class,expr.getValue(Class.class));
// use cached QualifiedIdentifier:
- assertEquals("T(java.lang.String)",expr.toStringAST());
- assertEquals(String.class,expr.getValue(Class.class));
+ Assert.assertEquals("T(java.lang.String)",expr.toStringAST());
+ Assert.assertEquals(String.class,expr.getValue(Class.class));
}
+ @Test
public void testTypeReferencesPrimitive() {
evaluate("T(int)", "int", Class.class);
evaluate("T(byte)", "byte", Class.class);
@@ -225,14 +293,17 @@ public class EvaluationTests extends ExpressionTestCase {
evaluate("T(float)", "float", Class.class);
}
+ @Test
public void testTypeReferences02() {
evaluate("T(String)", "class java.lang.String", Class.class);
}
+ @Test
public void testStringType() {
evaluateAndAskForReturnType("getPlaceOfBirth().getCity()", "SmilJan", String.class);
}
+ @Test
public void testNumbers01() {
evaluateAndAskForReturnType("3*4+5", 17, Integer.class);
evaluateAndAskForReturnType("3*4+5", 17L, Long.class);
@@ -242,39 +313,43 @@ public class EvaluationTests extends ExpressionTestCase {
}
+ @Test
public void testAdvancedNumerics() throws Exception {
int twentyFour = parser.parseExpression("2.0 * 3e0 * 4").getValue(Integer.class);
- assertEquals(24,twentyFour);
+ Assert.assertEquals(24,twentyFour);
double one = parser.parseExpression("8.0 / 5e0 % 2").getValue(Double.class);
- assertEquals(1.6d,one);
+ Assert.assertEquals(1.6d,one);
int o = parser.parseExpression("8.0 / 5e0 % 2").getValue(Integer.class);
- assertEquals(1,o);
+ Assert.assertEquals(1,o);
int sixteen = parser.parseExpression("-2 ^ 4").getValue(Integer.class);
- assertEquals(16,sixteen);
+ Assert.assertEquals(16,sixteen);
int minusFortyFive = parser.parseExpression("1+2-3*8^2/2/2").getValue(Integer.class);
- assertEquals(-45,minusFortyFive);
+ Assert.assertEquals(-45,minusFortyFive);
}
+ @Test
public void testComparison() throws Exception {
EvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
boolean trueValue = parser.parseExpression("T(java.util.Date) == Birthdate.Class").getValue(context, Boolean.class);
- assertTrue(trueValue);
+ Assert.assertTrue(trueValue);
}
+ @Test
public void testResolvingList() throws Exception {
StandardEvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
try {
- assertFalse(parser.parseExpression("T(List)!=null").getValue(context, Boolean.class));
- fail("should have failed to find List");
+ Assert.assertFalse(parser.parseExpression("T(List)!=null").getValue(context, Boolean.class));
+ Assert.fail("should have failed to find List");
} catch (EvaluationException ee) {
// success - List not found
}
((StandardTypeLocator)context.getTypeLocator()).registerImport("java.util");
- assertTrue(parser.parseExpression("T(List)!=null").getValue(context, Boolean.class));
+ Assert.assertTrue(parser.parseExpression("T(List)!=null").getValue(context, Boolean.class));
}
+ @Test
public void testResolvingString() throws Exception {
Class stringClass = parser.parseExpression("T(String)").getValue(Class.class);
- assertEquals(String.class,stringClass);
+ Assert.assertEquals(String.class,stringClass);
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java
index ab6ce9f4815..540035e38fb 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java
@@ -23,6 +23,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
@@ -31,9 +34,11 @@ import org.springframework.expression.Expression;
import org.springframework.expression.ParseException;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
+///CLOVER:OFF
+
/**
* Testcases showing the common scenarios/use-cases for picking up the expression language support.
* The first test shows very basic usage, just drop it in and go. By 'standard infrastructure', it means:
@@ -60,10 +65,11 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
/**
* Scenario: using the standard infrastructure and running simple expression evaluation.
*/
+ @Test
public void testScenario_UsingStandardInfrastructure() {
try {
// Create a parser
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
// Parse an expression
Expression expr = parser.parseExpression("new String('hello world')");
// Evaluate it using a 'standard' context
@@ -71,23 +77,24 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
// They are reusable
value = expr.getValue();
- assertEquals("hello world", value);
- assertEquals(String.class, value.getClass());
+ Assert.assertEquals("hello world", value);
+ Assert.assertEquals(String.class, value.getClass());
} catch (EvaluationException ee) {
ee.printStackTrace();
- fail("Unexpected Exception: " + ee.getMessage());
+ Assert.fail("Unexpected Exception: " + ee.getMessage());
} catch (ParseException pe) {
pe.printStackTrace();
- fail("Unexpected Exception: " + pe.getMessage());
+ Assert.fail("Unexpected Exception: " + pe.getMessage());
}
}
/**
* Scenario: using the standard context but adding your own variables
*/
+ @Test
public void testScenario_DefiningVariablesThatWillBeAccessibleInExpressions() throws Exception {
// Create a parser
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.setVariable("favouriteColour","blue");
@@ -97,16 +104,16 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
Expression expr = parser.parseExpression("#favouriteColour");
Object value = expr.getValue(ctx);
- assertEquals("blue", value);
+ Assert.assertEquals("blue", value);
expr = parser.parseExpression("#primes.get(1)");
value = expr.getValue(ctx);
- assertEquals(3, value);
+ Assert.assertEquals(3, value);
// all prime numbers > 10 from the list (using selection ?{...})
expr = parser.parseExpression("#primes.?[#this>10]");
value = expr.getValue(ctx);
- assertEquals("[11, 13, 17]", value.toString());
+ Assert.assertEquals("[11, 13, 17]", value.toString());
}
@@ -120,9 +127,10 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
/**
* Scenario: using your own root context object
*/
+ @Test
public void testScenario_UsingADifferentRootContextObject() throws Exception {
// Create a parser
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
StandardEvaluationContext ctx = new StandardEvaluationContext();
@@ -134,30 +142,30 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
// read it, set it, read it again
Expression expr = parser.parseExpression("str");
Object value = expr.getValue(ctx);
- assertEquals("wibble", value);
+ Assert.assertEquals("wibble", value);
expr = parser.parseExpression("str");
expr.setValue(ctx, "wobble");
expr = parser.parseExpression("str");
value = expr.getValue(ctx);
- assertEquals("wobble", value);
+ Assert.assertEquals("wobble", value);
// or using assignment within the expression
expr = parser.parseExpression("str='wabble'");
value = expr.getValue(ctx);
expr = parser.parseExpression("str");
value = expr.getValue(ctx);
- assertEquals("wabble", value);
+ Assert.assertEquals("wabble", value);
// private property will be accessed through getter()
expr = parser.parseExpression("property");
value = expr.getValue(ctx);
- assertEquals(42, value);
+ Assert.assertEquals(42, value);
// ... and set through setter
expr = parser.parseExpression("property=4");
value = expr.getValue(ctx);
expr = parser.parseExpression("property");
value = expr.getValue(ctx);
- assertEquals(4,value);
+ Assert.assertEquals(4,value);
}
public static String repeat(String s) { return s+s; }
@@ -165,66 +173,69 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
/**
* Scenario: using your own java methods and calling them from the expression
*/
+ @Test
public void testScenario_RegisteringJavaMethodsAsFunctionsAndCallingThem() throws SecurityException, NoSuchMethodException {
try {
// Create a parser
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.registerFunction("repeat",ExpressionLanguageScenarioTests.class.getDeclaredMethod("repeat",String.class));
Expression expr = parser.parseExpression("#repeat('hello')");
Object value = expr.getValue(ctx);
- assertEquals("hellohello", value);
+ Assert.assertEquals("hellohello", value);
} catch (EvaluationException ee) {
ee.printStackTrace();
- fail("Unexpected Exception: " + ee.getMessage());
+ Assert.fail("Unexpected Exception: " + ee.getMessage());
} catch (ParseException pe) {
pe.printStackTrace();
- fail("Unexpected Exception: " + pe.getMessage());
+ Assert.fail("Unexpected Exception: " + pe.getMessage());
}
}
/**
* Scenario: add a property resolver that will get called in the resolver chain, this one only supports reading.
*/
+ @Test
public void testScenario_AddingYourOwnPropertyResolvers_1() throws Exception {
// Create a parser
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.addPropertyAccessor(new FruitColourAccessor());
Expression expr = parser.parseExpression("orange");
Object value = expr.getValue(ctx);
- assertEquals(Color.orange, value);
+ Assert.assertEquals(Color.orange, value);
try {
expr.setValue(ctx, Color.blue);
- fail("Should not be allowed to set oranges to be blue !");
- } catch (SpelException ee) {
- assertEquals(ee.getMessageUnformatted(), SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
+ 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);
}
}
+ @Test
public void testScenario_AddingYourOwnPropertyResolvers_2() throws Exception {
// Create a parser
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
// Use the standard evaluation context
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.addPropertyAccessor(new VegetableColourAccessor());
Expression expr = parser.parseExpression("pea");
Object value = expr.getValue(ctx);
- assertEquals(Color.green, value);
+ Assert.assertEquals(Color.green, value);
try {
expr.setValue(ctx, Color.blue);
- fail("Should not be allowed to set peas to be blue !");
+ Assert.fail("Should not be allowed to set peas to be blue !");
}
- catch (SpelException ee) {
- assertEquals(ee.getMessageUnformatted(), SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
+ catch (SpelEvaluationException ee) {
+ Assert.assertEquals(ee.getMessageUnformatted(), SpelMessages.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java
index d8e198f2b20..d74cfbcc217 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java
@@ -18,6 +18,9 @@ package org.springframework.expression.spel;
import java.util.HashMap;
import java.util.Map;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
@@ -34,204 +37,218 @@ import org.springframework.expression.spel.testresources.Inventor;
*/
public class ExpressionStateTests extends ExpressionTestCase {
+ @Test
public void testConstruction() {
EvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
ExpressionState state = new ExpressionState(context);
- assertEquals(context,state.getEvaluationContext());
+ Assert.assertEquals(context,state.getEvaluationContext());
}
// Local variables are in variable scopes which come and go during evaluation. Normal variables are
// accessible through the evaluation context
+ @Test
public void testLocalVariables() {
ExpressionState state = getState();
Object value = state.lookupLocalVariable("foo");
- assertNull(value);
+ Assert.assertNull(value);
state.setLocalVariable("foo",34);
value = state.lookupLocalVariable("foo");
- assertEquals(34,value);
+ Assert.assertEquals(34,value);
state.setLocalVariable("foo",null);
value = state.lookupLocalVariable("foo");
- assertEquals(null,value);
+ Assert.assertEquals(null,value);
}
+ @Test
public void testVariables() {
ExpressionState state = getState();
TypedValue typedValue = state.lookupVariable("foo");
- assertEquals(TypedValue.NULL_TYPED_VALUE,typedValue);
+ Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,typedValue);
state.setVariable("foo",34);
typedValue = state.lookupVariable("foo");
- assertEquals(34,typedValue.getValue());
- assertEquals(Integer.class,typedValue.getTypeDescriptor().getType());
+ Assert.assertEquals(34,typedValue.getValue());
+ Assert.assertEquals(Integer.class,typedValue.getTypeDescriptor().getType());
state.setVariable("foo","abc");
typedValue = state.lookupVariable("foo");
- assertEquals("abc",typedValue.getValue());
- assertEquals(String.class,typedValue.getTypeDescriptor().getType());
+ Assert.assertEquals("abc",typedValue.getValue());
+ Assert.assertEquals(String.class,typedValue.getTypeDescriptor().getType());
}
+ @Test
public void testNoVariableInteference() {
ExpressionState state = getState();
TypedValue typedValue = state.lookupVariable("foo");
- assertEquals(TypedValue.NULL_TYPED_VALUE,typedValue);
+ Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,typedValue);
state.setLocalVariable("foo",34);
typedValue = state.lookupVariable("foo");
- assertEquals(TypedValue.NULL_TYPED_VALUE,typedValue);
+ Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,typedValue);
state.setVariable("goo","hello");
- assertNull(state.lookupLocalVariable("goo"));
+ Assert.assertNull(state.lookupLocalVariable("goo"));
}
+ @Test
public void testLocalVariableNestedScopes() {
ExpressionState state = getState();
- assertEquals(null,state.lookupLocalVariable("foo"));
+ Assert.assertEquals(null,state.lookupLocalVariable("foo"));
state.setLocalVariable("foo",12);
- assertEquals(12,state.lookupLocalVariable("foo"));
+ Assert.assertEquals(12,state.lookupLocalVariable("foo"));
state.enterScope(null);
- assertEquals(12,state.lookupLocalVariable("foo")); // found in upper scope
+ Assert.assertEquals(12,state.lookupLocalVariable("foo")); // found in upper scope
state.setLocalVariable("foo","abc");
- assertEquals("abc",state.lookupLocalVariable("foo")); // found in nested scope
+ Assert.assertEquals("abc",state.lookupLocalVariable("foo")); // found in nested scope
state.exitScope();
- assertEquals(12,state.lookupLocalVariable("foo")); // found in nested scope
+ Assert.assertEquals(12,state.lookupLocalVariable("foo")); // found in nested scope
}
+ @Test
public void testRootContextObject() {
ExpressionState state = getState();
- assertEquals(Inventor.class,state.getRootContextObject().getValue().getClass());
+ Assert.assertEquals(Inventor.class,state.getRootContextObject().getValue().getClass());
state.getEvaluationContext().setRootObject(null);
- assertEquals(null,state.getRootContextObject().getValue());
+ Assert.assertEquals(null,state.getRootContextObject().getValue());
state = new ExpressionState(new StandardEvaluationContext());
- assertEquals(TypedValue.NULL_TYPED_VALUE,state.getRootContextObject());
+ Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,state.getRootContextObject());
((StandardEvaluationContext)state.getEvaluationContext()).setRootObject(null,TypeDescriptor.NULL);
- assertEquals(null,state.getRootContextObject().getValue());
+ Assert.assertEquals(null,state.getRootContextObject().getValue());
}
+ @Test
public void testActiveContextObject() {
ExpressionState state = getState();
- assertEquals(state.getRootContextObject().getValue(),state.getActiveContextObject().getValue());
+ Assert.assertEquals(state.getRootContextObject().getValue(),state.getActiveContextObject().getValue());
state.pushActiveContextObject(new TypedValue(34));
- assertEquals(34,state.getActiveContextObject().getValue());
+ Assert.assertEquals(34,state.getActiveContextObject().getValue());
state.pushActiveContextObject(new TypedValue("hello"));
- assertEquals("hello",state.getActiveContextObject().getValue());
+ Assert.assertEquals("hello",state.getActiveContextObject().getValue());
state.popActiveContextObject();
- assertEquals(34,state.getActiveContextObject().getValue());
+ Assert.assertEquals(34,state.getActiveContextObject().getValue());
state.popActiveContextObject();
- assertEquals(state.getRootContextObject().getValue(),state.getActiveContextObject().getValue());
+ Assert.assertEquals(state.getRootContextObject().getValue(),state.getActiveContextObject().getValue());
state = new ExpressionState(new StandardEvaluationContext());
- assertEquals(TypedValue.NULL_TYPED_VALUE,state.getActiveContextObject());
+ Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,state.getActiveContextObject());
}
+ @Test
public void testPopulatedNestedScopes() {
ExpressionState state = getState();
- assertNull(state.lookupLocalVariable("foo"));
+ Assert.assertNull(state.lookupLocalVariable("foo"));
state.enterScope("foo",34);
- assertEquals(34,state.lookupLocalVariable("foo"));
+ Assert.assertEquals(34,state.lookupLocalVariable("foo"));
state.enterScope(null);
state.setLocalVariable("foo",12);
- assertEquals(12,state.lookupLocalVariable("foo"));
+ Assert.assertEquals(12,state.lookupLocalVariable("foo"));
state.exitScope();
- assertEquals(34,state.lookupLocalVariable("foo"));
+ Assert.assertEquals(34,state.lookupLocalVariable("foo"));
state.exitScope();
- assertNull(state.lookupLocalVariable("goo"));
+ Assert.assertNull(state.lookupLocalVariable("goo"));
}
+ @Test
public void testPopulatedNestedScopesMap() {
ExpressionState state = getState();
- assertNull(state.lookupLocalVariable("foo"));
- assertNull(state.lookupLocalVariable("goo"));
+ Assert.assertNull(state.lookupLocalVariable("foo"));
+ Assert.assertNull(state.lookupLocalVariable("goo"));
Map m = new HashMap();
m.put("foo",34);
m.put("goo","abc");
state.enterScope(m);
- assertEquals(34,state.lookupLocalVariable("foo"));
- assertEquals("abc",state.lookupLocalVariable("goo"));
+ Assert.assertEquals(34,state.lookupLocalVariable("foo"));
+ Assert.assertEquals("abc",state.lookupLocalVariable("goo"));
state.enterScope(null);
state.setLocalVariable("foo",12);
- assertEquals(12,state.lookupLocalVariable("foo"));
- assertEquals("abc",state.lookupLocalVariable("goo"));
+ Assert.assertEquals(12,state.lookupLocalVariable("foo"));
+ Assert.assertEquals("abc",state.lookupLocalVariable("goo"));
state.exitScope();
state.exitScope();
- assertNull(state.lookupLocalVariable("foo"));
- assertNull(state.lookupLocalVariable("goo"));
+ Assert.assertNull(state.lookupLocalVariable("foo"));
+ Assert.assertNull(state.lookupLocalVariable("goo"));
}
+ @Test
public void testOperators() throws Exception {
ExpressionState state = getState();
try {
state.operate(Operation.ADD,1,2);
- fail("should have failed");
+ Assert.fail("should have failed");
} catch (EvaluationException ee) {
- SpelException sEx = (SpelException)ee;
- assertEquals(SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageUnformatted());
+ SpelEvaluationException sEx = (SpelEvaluationException)ee;
+ Assert.assertEquals(SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageUnformatted());
}
try {
state.operate(Operation.ADD,null,null);
- fail("should have failed");
+ Assert.fail("should have failed");
} catch (EvaluationException ee) {
- SpelException sEx = (SpelException)ee;
- assertEquals(SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageUnformatted());
+ SpelEvaluationException sEx = (SpelEvaluationException)ee;
+ Assert.assertEquals(SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageUnformatted());
}
}
+ @Test
public void testComparator() {
ExpressionState state = getState();
- assertEquals(state.getEvaluationContext().getTypeComparator(),state.getTypeComparator());
+ Assert.assertEquals(state.getEvaluationContext().getTypeComparator(),state.getTypeComparator());
}
+ @Test
public void testTypeLocator() throws EvaluationException {
ExpressionState state = getState();
- assertNotNull(state.getEvaluationContext().getTypeLocator());
- assertEquals(Integer.class,state.findType("java.lang.Integer"));
+ Assert.assertNotNull(state.getEvaluationContext().getTypeLocator());
+ Assert.assertEquals(Integer.class,state.findType("java.lang.Integer"));
try {
state.findType("someMadeUpName");
- fail("Should have failed to find it");
+ Assert.fail("Should have failed to find it");
} catch (EvaluationException ee) {
- SpelException sEx = (SpelException)ee;
- assertEquals(SpelMessages.TYPE_NOT_FOUND,sEx.getMessageUnformatted());
+ SpelEvaluationException sEx = (SpelEvaluationException)ee;
+ Assert.assertEquals(SpelMessages.TYPE_NOT_FOUND,sEx.getMessageUnformatted());
}
}
+ @Test
public void testTypeConversion() throws EvaluationException {
ExpressionState state = getState();
String s = (String)state.convertValue(34,TypeDescriptor.valueOf(String.class));
- assertEquals("34",s);
+ Assert.assertEquals("34",s);
s = (String)state.convertValue(new TypedValue(34),TypeDescriptor.valueOf(String.class));
- assertEquals("34",s);
+ Assert.assertEquals("34",s);
}
+ @Test
public void testPropertyAccessors() {
ExpressionState state = getState();
- assertEquals(state.getEvaluationContext().getPropertyAccessors(),state.getPropertyAccessors());
+ Assert.assertEquals(state.getEvaluationContext().getPropertyAccessors(),state.getPropertyAccessors());
}
/**
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestCase.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestCase.java
index d2830fe5586..b04ab93f65f 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestCase.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestCase.java
@@ -19,28 +19,27 @@ package org.springframework.expression.spel;
import java.util.Arrays;
import java.util.List;
-import junit.framework.TestCase;
+import junit.framework.Assert;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
+import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParseException;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
-///CLOVER:OFF
/**
* Common superclass for expression tests.
*
* @author Andy Clement
*/
-public abstract class ExpressionTestCase extends TestCase {
+public abstract class ExpressionTestCase {
private final static boolean DEBUG = false;
protected final static boolean SHOULD_BE_WRITABLE = true;
protected final static boolean SHOULD_NOT_BE_WRITABLE = false;
- protected final static SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ protected final static ExpressionParser parser = SpelExpressionParserFactory.getParser();
protected final static StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
/**
@@ -54,13 +53,13 @@ public abstract class ExpressionTestCase extends TestCase {
try {
Expression expr = parser.parseExpression(expression);
if (expr == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
}
// Class> expressionType = expr.getValueType();
- // assertEquals("Type of the expression is not as expected. Should be '"+expectedResultType+"' but is
+ // Assert.assertEquals("Type of the expression is not as expected. Should be '"+expectedResultType+"' but is
// '"+expressionType+"'",
// expectedResultType,expressionType);
@@ -71,12 +70,12 @@ public abstract class ExpressionTestCase extends TestCase {
if (expectedValue == null) {
return; // no point doing other checks
}
- assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
+ Assert.assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
null);
}
Class> resultType = value.getClass();
- assertEquals("Type of the actual result was not as expected. Expected '" + expectedResultType
+ Assert.assertEquals("Type of the actual result was not as expected. Expected '" + expectedResultType
+ "' but result was of type '" + resultType + "'", expectedResultType, resultType);
// .equals/* isAssignableFrom */(resultType), truers);
@@ -84,17 +83,17 @@ public abstract class ExpressionTestCase extends TestCase {
// in the above expression...
if (expectedValue instanceof String) {
- assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
+ Assert.assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
ExpressionTestCase.stringValueOf(value));
} else {
- assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
+ Assert.assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
}
} catch (EvaluationException ee) {
ee.printStackTrace();
- fail("Unexpected Exception: " + ee.getMessage());
+ Assert.fail("Unexpected Exception: " + ee.getMessage());
} catch (ParseException pe) {
pe.printStackTrace();
- fail("Unexpected Exception: " + pe.getMessage());
+ Assert.fail("Unexpected Exception: " + pe.getMessage());
}
}
@@ -102,13 +101,13 @@ public abstract class ExpressionTestCase extends TestCase {
try {
Expression expr = parser.parseExpression(expression);
if (expr == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
}
// Class> expressionType = expr.getValueType();
- // assertEquals("Type of the expression is not as expected. Should be '"+expectedResultType+"' but is
+ // Assert.assertEquals("Type of the expression is not as expected. Should be '"+expectedResultType+"' but is
// '"+expressionType+"'",
// expectedResultType,expressionType);
@@ -116,23 +115,23 @@ public abstract class ExpressionTestCase extends TestCase {
if (value == null) {
if (expectedValue == null)
return; // no point doing other checks
- assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
+ Assert.assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
null);
}
Class> resultType = value.getClass();
- assertEquals("Type of the actual result was not as expected. Expected '" + expectedResultType
+ Assert.assertEquals("Type of the actual result was not as expected. Expected '" + expectedResultType
+ "' but result was of type '" + resultType + "'", expectedResultType, resultType);
// .equals/* isAssignableFrom */(resultType), truers);
- assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
+ Assert.assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
// isAssignableFrom would allow some room for compatibility
// in the above expression...
} catch (EvaluationException ee) {
- SpelException ex = (SpelException) ee;
+ SpelEvaluationException ex = (SpelEvaluationException) ee;
ex.printStackTrace();
- fail("Unexpected EvaluationException: " + ex.getMessage());
+ Assert.fail("Unexpected EvaluationException: " + ex.getMessage());
} catch (ParseException pe) {
- fail("Unexpected ParseException: " + pe.getMessage());
+ Assert.fail("Unexpected ParseException: " + pe.getMessage());
}
}
@@ -151,7 +150,7 @@ public abstract class ExpressionTestCase extends TestCase {
try {
Expression e = parser.parseExpression(expression);
if (e == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, e);
@@ -161,19 +160,19 @@ public abstract class ExpressionTestCase extends TestCase {
if (expectedValue == null)
return; // no point doing other
// checks
- assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
+ Assert.assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
null);
}
Class extends Object> resultType = value.getClass();
if (expectedValue instanceof String) {
- assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
+ Assert.assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
ExpressionTestCase.stringValueOf(value));
} else {
- assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
+ Assert.assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
}
-// assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
+// Assert.assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
// ExpressionTestCase.stringValueOf(value));
- assertEquals("Type of the result was not as expected. Expected '" + expectedClassOfResult
+ Assert.assertEquals("Type of the result was not as expected. Expected '" + expectedClassOfResult
+ "' but result was of type '" + resultType + "'", expectedClassOfResult
.equals/* isAssignableFrom */(resultType), true);
// TODO isAssignableFrom would allow some room for compatibility
@@ -182,16 +181,16 @@ public abstract class ExpressionTestCase extends TestCase {
boolean isWritable = e.isWritable(eContext);
if (isWritable != shouldBeWritable) {
if (shouldBeWritable)
- fail("Expected the expression to be writable but it is not");
+ Assert.fail("Expected the expression to be writable but it is not");
else
- fail("Expected the expression to be readonly but it is not");
+ Assert.fail("Expected the expression to be readonly but it is not");
}
} catch (EvaluationException ee) {
ee.printStackTrace();
- fail("Unexpected Exception: " + ee.getMessage());
+ Assert.fail("Unexpected Exception: " + ee.getMessage());
} catch (ParseException pe) {
pe.printStackTrace();
- fail("Unexpected Exception: " + pe.getMessage());
+ Assert.fail("Unexpected Exception: " + pe.getMessage());
}
}
@@ -222,7 +221,7 @@ public abstract class ExpressionTestCase extends TestCase {
try {
Expression expr = parser.parseExpression(expression);
if (expr == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
if (expectedReturnType != null) {
@SuppressWarnings("unused")
@@ -231,18 +230,18 @@ public abstract class ExpressionTestCase extends TestCase {
@SuppressWarnings("unused")
Object value = expr.getValue(eContext);
}
- fail("Should have failed with message " + expectedMessage);
+ Assert.fail("Should have failed with message " + expectedMessage);
} catch (EvaluationException ee) {
- SpelException ex = (SpelException) ee;
+ SpelEvaluationException ex = (SpelEvaluationException) ee;
if (ex.getMessageUnformatted() != expectedMessage) {
- System.out.println(ex.getMessage());
+// System.out.println(ex.getMessage());
ex.printStackTrace();
- assertEquals("Failed to get expected message", expectedMessage, ex.getMessageUnformatted());
+ Assert.assertEquals("Failed to get expected message", expectedMessage, ex.getMessageUnformatted());
}
if (otherProperties != null && otherProperties.length != 0) {
// first one is expected position of the error within the string
int pos = ((Integer) otherProperties[0]).intValue();
- assertEquals("Did not get correct position reported in error ", pos, ex.getPosition());
+ Assert.assertEquals("Did not get correct position reported in error ", pos, ex.getPosition());
if (otherProperties.length > 1) {
// Check inserts match
Object[] inserts = ex.getInserts();
@@ -251,25 +250,25 @@ public abstract class ExpressionTestCase extends TestCase {
}
if (inserts.length < otherProperties.length - 1) {
ex.printStackTrace();
- fail("Cannot check " + (otherProperties.length - 1)
+ Assert.fail("Cannot check " + (otherProperties.length - 1)
+ " properties of the exception, it only has " + inserts.length + " inserts");
}
for (int i = 1; i < otherProperties.length; i++) {
if (otherProperties[i] == null) {
if (inserts[i - 1] != null) {
ex.printStackTrace();
- fail("Insert does not match, expected 'null' but insert value was '" + inserts[i - 1]
+ Assert.fail("Insert does not match, expected 'null' but insert value was '" + inserts[i - 1]
+ "'");
}
} else if (inserts[i - 1] == null) {
if (otherProperties[i] != null) {
ex.printStackTrace();
- fail("Insert does not match, expected '" + otherProperties[i]
+ Assert.fail("Insert does not match, expected '" + otherProperties[i]
+ "' but insert value was 'null'");
}
} else if (!inserts[i - 1].equals(otherProperties[i])) {
ex.printStackTrace();
- fail("Insert does not match, expected '" + otherProperties[i] + "' but insert value was '"
+ Assert.fail("Insert does not match, expected '" + otherProperties[i] + "' but insert value was '"
+ inserts[i - 1] + "'");
}
}
@@ -277,7 +276,7 @@ public abstract class ExpressionTestCase extends TestCase {
}
} catch (ParseException pe) {
pe.printStackTrace();
- fail("Unexpected Exception: " + pe.getMessage());
+ Assert.fail("Unexpected Exception: " + pe.getMessage());
}
}
@@ -293,26 +292,29 @@ public abstract class ExpressionTestCase extends TestCase {
try {
Expression expr = parser.parseExpression(expression);
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
- fail("Parsing should have failed!");
+ Assert.fail("Parsing should have failed!");
} catch (ParseException pe) {
- Throwable t = pe.getCause();
- if (t == null) {
- fail("ParseException caught with no defined cause");
- }
- if (!(t instanceof SpelException)) {
- t.printStackTrace();
- fail("Cause of parse exception is not a SpelException");
- }
- SpelException ex = (SpelException) t;
+// pe.printStackTrace();
+// Throwable t = pe.getCause();
+// if (t == null) {
+// Assert.fail("ParseException caught with no defined cause");
+// }
+// if (!(t instanceof SpelEvaluationException)) {
+// t.printStackTrace();
+// Assert.fail("Cause of parse exception is not a SpelException");
+// }
+// SpelEvaluationException ex = (SpelEvaluationException) t;
+// pe.printStackTrace();
+ SpelParseException ex = (SpelParseException)pe;
if (ex.getMessageUnformatted() != expectedMessage) {
- System.out.println(ex.getMessage());
+// System.out.println(ex.getMessage());
ex.printStackTrace();
- assertEquals("Failed to get expected message", expectedMessage, ex.getMessageUnformatted());
+ Assert.assertEquals("Failed to get expected message", expectedMessage, ex.getMessageUnformatted());
}
if (otherProperties != null && otherProperties.length != 0) {
// first one is expected position of the error within the string
int pos = ((Integer) otherProperties[0]).intValue();
- assertEquals("Did not get correct position reported in error ", pos, ex.getPosition());
+ Assert.assertEquals("Did not get correct position reported in error ", pos, ex.getPosition());
if (otherProperties.length > 1) {
// Check inserts match
Object[] inserts = ex.getInserts();
@@ -321,13 +323,13 @@ public abstract class ExpressionTestCase extends TestCase {
}
if (inserts.length < otherProperties.length - 1) {
ex.printStackTrace();
- fail("Cannot check " + (otherProperties.length - 1)
+ Assert.fail("Cannot check " + (otherProperties.length - 1)
+ " properties of the exception, it only has " + inserts.length + " inserts");
}
for (int i = 1; i < otherProperties.length; i++) {
if (!inserts[i - 1].equals(otherProperties[i])) {
ex.printStackTrace();
- fail("Insert does not match, expected '" + otherProperties[i] + "' but insert value was '"
+ Assert.fail("Insert does not match, expected '" + otherProperties[i] + "' but insert value was '"
+ inserts[i - 1] + "'");
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestsUsingCoreConversionService.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestsUsingCoreConversionService.java
index 76fa7ef3505..f000dfa64ca 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestsUsingCoreConversionService.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestsUsingCoreConversionService.java
@@ -19,6 +19,10 @@ package org.springframework.expression.spel;
import java.util.ArrayList;
import java.util.List;
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultTypeConverter;
import org.springframework.core.convert.support.GenericTypeConverter;
@@ -48,43 +52,45 @@ public class ExpressionTestsUsingCoreConversionService extends ExpressionTestCas
listOfInteger.add(6);
}
+ @Before
public void setUp() throws Exception {
- super.setUp();
- typeDescriptorForListOfString = new TypeDescriptor(ExpressionTestsUsingCoreConversionService.class.getDeclaredField("listOfString"));
- typeDescriptorForListOfInteger = new TypeDescriptor(ExpressionTestsUsingCoreConversionService.class.getDeclaredField("listOfInteger"));
+ ExpressionTestsUsingCoreConversionService.typeDescriptorForListOfString = new TypeDescriptor(ExpressionTestsUsingCoreConversionService.class.getDeclaredField("listOfString"));
+ ExpressionTestsUsingCoreConversionService.typeDescriptorForListOfInteger = new TypeDescriptor(ExpressionTestsUsingCoreConversionService.class.getDeclaredField("listOfInteger"));
}
/**
* Test the service can convert what we are about to use in the expression evaluation tests.
*/
+ @Test
public void testConversionsAvailable() throws Exception {
TypeConvertorUsingConversionService tcs = new TypeConvertorUsingConversionService();
// ArrayList containing List to List
Class> clazz = typeDescriptorForListOfString.getElementType();
- assertEquals(String.class,clazz);
+ Assert.assertEquals(String.class,clazz);
List l = (List) tcs.convertValue(listOfInteger, typeDescriptorForListOfString);
- assertNotNull(l);
+ Assert.assertNotNull(l);
// ArrayList containing List to List
clazz = typeDescriptorForListOfInteger.getElementType();
- assertEquals(Integer.class,clazz);
+ Assert.assertEquals(Integer.class,clazz);
l = (List) tcs.convertValue(listOfString, typeDescriptorForListOfString);
- assertNotNull(l);
+ Assert.assertNotNull(l);
}
+ @Test
public void testSetParameterizedList() throws Exception {
StandardEvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
Expression e = parser.parseExpression("listOfInteger.size()");
- assertEquals(0,e.getValue(context,Integer.class).intValue());
+ Assert.assertEquals(0,e.getValue(context,Integer.class).intValue());
context.setTypeConverter(new TypeConvertorUsingConversionService());
// Assign a List to the List field - the component elements should be converted
parser.parseExpression("listOfInteger").setValue(context,listOfString);
- assertEquals(3,e.getValue(context,Integer.class).intValue()); // size now 3
+ Assert.assertEquals(3,e.getValue(context,Integer.class).intValue()); // size now 3
Class clazz = parser.parseExpression("listOfInteger[1].getClass()").getValue(context,Class.class); // element type correctly Integer
- assertEquals(Integer.class,clazz);
+ Assert.assertEquals(Integer.class,clazz);
}
@@ -103,7 +109,7 @@ public class ExpressionTestsUsingCoreConversionService extends ExpressionTestCas
return this.service.canConvert(sourceType, typeDescriptor);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("cast")
public T convertValue(Object value, Class targetType) throws EvaluationException {
return (T) this.service.convert(value,TypeDescriptor.valueOf(targetType));
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/HelperTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/HelperTests.java
index 3726656c30c..7b295b09bec 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/HelperTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/HelperTests.java
@@ -20,11 +20,17 @@ import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.ParseException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ast.FormatHelper;
import org.springframework.expression.spel.support.ReflectionHelper;
+import org.springframework.expression.spel.support.ReflectivePropertyResolver;
+import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.support.StandardTypeConverter;
import org.springframework.expression.spel.support.ReflectionHelper.ArgsMatchKind;
@@ -35,20 +41,23 @@ import org.springframework.expression.spel.support.ReflectionHelper.ArgsMatchKin
*/
public class HelperTests extends ExpressionTestCase {
+ @Test
public void testFormatHelperForClassName() {
- assertEquals("java.lang.String",FormatHelper.formatClassNameForMessage(String.class));
- assertEquals("java.lang.String[]",FormatHelper.formatClassNameForMessage(new String[1].getClass()));
- assertEquals("int[]",FormatHelper.formatClassNameForMessage(new int[1].getClass()));
- assertEquals("int[][]",FormatHelper.formatClassNameForMessage(new int[1][2].getClass()));
- assertEquals("null",FormatHelper.formatClassNameForMessage(null));
+ Assert.assertEquals("java.lang.String",FormatHelper.formatClassNameForMessage(String.class));
+ Assert.assertEquals("java.lang.String[]",FormatHelper.formatClassNameForMessage(new String[1].getClass()));
+ Assert.assertEquals("int[]",FormatHelper.formatClassNameForMessage(new int[1].getClass()));
+ Assert.assertEquals("int[][]",FormatHelper.formatClassNameForMessage(new int[1][2].getClass()));
+ Assert.assertEquals("null",FormatHelper.formatClassNameForMessage(null));
}
+ @Test
public void testFormatHelperForMethod() {
- assertEquals("foo(java.lang.String)",FormatHelper.formatMethodForMessage("foo", String.class));
- assertEquals("goo(java.lang.String,int[])",FormatHelper.formatMethodForMessage("goo", String.class,new int[1].getClass()));
- assertEquals("boo()",FormatHelper.formatMethodForMessage("boo"));
+ Assert.assertEquals("foo(java.lang.String)",FormatHelper.formatMethodForMessage("foo", String.class));
+ Assert.assertEquals("goo(java.lang.String,int[])",FormatHelper.formatMethodForMessage("goo", String.class,new int[1].getClass()));
+ Assert.assertEquals("boo()",FormatHelper.formatMethodForMessage("boo"));
}
+ @Test
public void testUtilities() throws ParseException {
SpelExpression expr = (SpelExpression)parser.parseExpression("3+4+5+6+7-2");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -75,16 +84,18 @@ public class HelperTests extends ExpressionTestCase {
// CompoundExpression value:2
// IntLiteral value:2
// ===> Expression '3+4+5+6+7-2' - AST end
- assertTrue(s.indexOf("===> Expression '3+4+5+6+7-2' - AST start")!=-1);
- assertTrue(s.indexOf(" OperatorPlus value:((((3 + 4) + 5) + 6) + 7) #children:2")!=-1);
+ Assert.assertTrue(s.indexOf("===> Expression '3+4+5+6+7-2' - AST start")!=-1);
+ Assert.assertTrue(s.indexOf(" OperatorPlus value:((((3 + 4) + 5) + 6) + 7) #children:2")!=-1);
}
+ @Test
public void testTypedValue() {
TypedValue tValue = new TypedValue("hello");
- assertEquals(String.class,tValue.getTypeDescriptor().getType());
- assertEquals("TypedValue: hello of type java.lang.String",tValue.toString());
+ Assert.assertEquals(String.class,tValue.getTypeDescriptor().getType());
+ Assert.assertEquals("TypedValue: hello of type java.lang.String",tValue.toString());
}
+ @Test
public void testReflectionHelperCompareArguments_ExactMatching() {
StandardTypeConverter typeConverter = new StandardTypeConverter();
@@ -95,6 +106,7 @@ public class HelperTests extends ExpressionTestCase {
checkMatch(new Class[]{String.class,Integer.class},new Class[]{String.class,Integer.class},typeConverter,ArgsMatchKind.EXACT);
}
+ @Test
public void testReflectionHelperCompareArguments_CloseMatching() {
StandardTypeConverter typeConverter = new StandardTypeConverter();
@@ -108,6 +120,7 @@ public class HelperTests extends ExpressionTestCase {
checkMatch(new Class[]{String.class,Sub.class},new Class[]{String.class,Super.class},typeConverter,ArgsMatchKind.CLOSE);
}
+ @Test
public void testReflectionHelperCompareArguments_RequiresConversionMatching() {
// TODO these are failing - for investigation
StandardTypeConverter typeConverter = new StandardTypeConverter();
@@ -125,6 +138,7 @@ public class HelperTests extends ExpressionTestCase {
checkMatch(new Class[]{Integer.TYPE,Sub.class,Boolean.TYPE},new Class[]{Integer.class, Super.class,Boolean.class},typeConverter,ArgsMatchKind.REQUIRES_CONVERSION,0,2);
}
+ @Test
public void testReflectionHelperCompareArguments_NotAMatch() {
StandardTypeConverter typeConverter = new StandardTypeConverter();
@@ -132,6 +146,7 @@ public class HelperTests extends ExpressionTestCase {
checkMatch(new Class[]{Super.class,String.class},new Class[]{Sub.class,String.class},typeConverter,null);
}
+ @Test
public void testReflectionHelperCompareArguments_Varargs_ExactMatching() {
StandardTypeConverter tc = new StandardTypeConverter();
Class> stringArrayClass = new String[0].getClass();
@@ -184,6 +199,7 @@ public class HelperTests extends ExpressionTestCase {
// what happens on (Integer,String) passed to (Integer[]) ?
}
+ @Test
public void testConvertArguments() throws Exception {
StandardTypeConverter tc = new StandardTypeConverter();
@@ -206,8 +222,9 @@ public class HelperTests extends ExpressionTestCase {
args = new Object[]{3,false,3.0d};
ReflectionHelper.convertArguments(new Class[]{String.class,String[].class}, true, tc, new int[]{0,1,2}, args);
checkArguments(args, "3","false","3.0");
-}
+ }
+ @Test
public void testConvertArguments2() throws EvaluationException {
StandardTypeConverter tc = new StandardTypeConverter();
@@ -230,9 +247,9 @@ public class HelperTests extends ExpressionTestCase {
args = new Object[]{3,false,3.0f};
try {
ReflectionHelper.convertAllArguments(new Class[]{String.class,String[].class}, true, null, args);
- fail("Should have failed because no converter supplied");
- } catch (SpelException se) {
- assertEquals(SpelMessages.TYPE_CONVERSION_ERROR,se.getMessageUnformatted());
+ Assert.fail("Should have failed because no converter supplied");
+ } catch (SpelEvaluationException se) {
+ Assert.assertEquals(SpelMessages.TYPE_CONVERSION_ERROR,se.getMessageUnformatted());
}
// null value
@@ -241,21 +258,78 @@ public class HelperTests extends ExpressionTestCase {
checkArguments(args,"3",null,"3.0");
}
-
+ @Test
public void testSetupArguments() {
Object[] newArray = ReflectionHelper.setupArgumentsForVarargsInvocation(new Class[]{new String[0].getClass()},"a","b","c");
- assertEquals(1,newArray.length);
+ Assert.assertEquals(1,newArray.length);
Object firstParam = newArray[0];
- assertEquals(String.class,firstParam.getClass().getComponentType());
+ Assert.assertEquals(String.class,firstParam.getClass().getComponentType());
Object[] firstParamArray = (Object[])firstParam;
- assertEquals(3,firstParamArray.length);
- assertEquals("a",firstParamArray[0]);
- assertEquals("b",firstParamArray[1]);
- assertEquals("c",firstParamArray[2]);
+ Assert.assertEquals(3,firstParamArray.length);
+ Assert.assertEquals("a",firstParamArray[0]);
+ Assert.assertEquals("b",firstParamArray[1]);
+ Assert.assertEquals("c",firstParamArray[2]);
}
+
+ @Test
+ public void testReflectivePropertyResolver() throws Exception {
+ ReflectivePropertyResolver rpr = new ReflectivePropertyResolver();
+ Tester t = new Tester();
+ t.setProperty("hello");
+ EvaluationContext ctx = new StandardEvaluationContext(t);
+ Assert.assertTrue(rpr.canRead(ctx, t, "property"));
+ Assert.assertEquals("hello",rpr.read(ctx, t, "property").getValue());
+ Assert.assertEquals("hello",rpr.read(ctx, t, "property").getValue()); // cached accessor used
+
+ Assert.assertTrue(rpr.canRead(ctx, t, "field"));
+ Assert.assertEquals(3,rpr.read(ctx, t, "field").getValue());
+ Assert.assertEquals(3,rpr.read(ctx, t, "field").getValue()); // cached accessor used
+
+ Assert.assertTrue(rpr.canWrite(ctx, t, "property"));
+ rpr.write(ctx, t, "property","goodbye");
+ rpr.write(ctx, t, "property","goodbye"); // cached accessor used
+
+ Assert.assertTrue(rpr.canWrite(ctx, t, "field"));
+ rpr.write(ctx, t, "field",12);
+ rpr.write(ctx, t, "field",12);
+
+ // Attempted write as first activity on this field and property to drive testing
+ // of populating type descriptor cache
+ rpr.write(ctx,t,"field2",3);
+ rpr.write(ctx, t, "property2","doodoo");
+ Assert.assertEquals(3,rpr.read(ctx,t,"field2").getValue());
+
+ // Attempted read as first activity on this field and property (no canRead before them)
+ Assert.assertEquals(0,rpr.read(ctx,t,"field3").getValue());
+ Assert.assertEquals("doodoo",rpr.read(ctx,t,"property3").getValue());
+
+ // Access through is method
+// Assert.assertEquals(0,rpr.read(ctx,t,"field3").getValue());
+ Assert.assertEquals(false,rpr.read(ctx,t,"property4").getValue());
+ Assert.assertTrue(rpr.canRead(ctx,t,"property4"));
+ }
+
// test classes
+ static class Tester {
+ String property;
+ public int field = 3;
+ public int field2;
+ public int field3 = 0;
+ String property2;
+ String property3 = "doodoo";
+ boolean property4 = false;
+
+ public String getProperty() { return property; }
+ public void setProperty(String value) { property = value; }
+
+ public void setProperty2(String value) { property2 = value; }
+
+ public String getProperty3() { return property3; }
+
+ public boolean isProperty4() { return property4; }
+ }
static class Super {
}
@@ -273,25 +347,25 @@ public class HelperTests extends ExpressionTestCase {
private void checkMatch(Class[] inputTypes, Class[] expectedTypes, StandardTypeConverter typeConverter,ArgsMatchKind expectedMatchKind,int... argsForConversion) {
ReflectionHelper.ArgumentsMatchInfo matchInfo = ReflectionHelper.compareArguments(expectedTypes, inputTypes, typeConverter);
if (expectedMatchKind==null) {
- assertNull("Did not expect them to match in any way", matchInfo);
+ Assert.assertNull("Did not expect them to match in any way", matchInfo);
} else {
- assertNotNull("Should not be a null match", matchInfo);
+ Assert.assertNotNull("Should not be a null match", matchInfo);
}
if (expectedMatchKind==ArgsMatchKind.EXACT) {
- assertTrue(matchInfo.isExactMatch());
- assertNull(matchInfo.argsRequiringConversion);
+ Assert.assertTrue(matchInfo.isExactMatch());
+ Assert.assertNull(matchInfo.argsRequiringConversion);
} else if (expectedMatchKind==ArgsMatchKind.CLOSE) {
- assertTrue(matchInfo.isCloseMatch());
- assertNull(matchInfo.argsRequiringConversion);
+ Assert.assertTrue(matchInfo.isCloseMatch());
+ Assert.assertNull(matchInfo.argsRequiringConversion);
} else if (expectedMatchKind==ArgsMatchKind.REQUIRES_CONVERSION) {
- assertTrue("expected to be a match requiring conversion, but was "+matchInfo,matchInfo.isMatchRequiringConversion());
+ Assert.assertTrue("expected to be a match requiring conversion, but was "+matchInfo,matchInfo.isMatchRequiringConversion());
if (argsForConversion==null) {
- fail("there are arguments that need conversion");
+ Assert.fail("there are arguments that need conversion");
}
- assertEquals("The array of args that need conversion is different length to that expected",argsForConversion.length, matchInfo.argsRequiringConversion.length);
+ Assert.assertEquals("The array of args that need conversion is different length to that expected",argsForConversion.length, matchInfo.argsRequiringConversion.length);
for (int a=0;a5?value:null]", "[null, null, null, null, null, six, seven, eight, nine, ten]", ArrayList.class);
}
+ @Test
public void testProjection05() {
evaluateAndCheckError("'abc'.![true]", SpelMessages.PROJECTION_NOT_SUPPORTED_ON_TYPE);
}
+ @Test
public void testProjection06() throws Exception {
SpelExpression expr = (SpelExpression)parser.parseExpression("'abc'.![true]");
- assertEquals("'abc'.![true]",expr.toStringAST());
- assertFalse(expr.isWritable(new StandardEvaluationContext()));
+ Assert.assertEquals("'abc'.![true]",expr.toStringAST());
+ Assert.assertFalse(expr.isWritable(new StandardEvaluationContext()));
}
// SELECTION
+ @Test
public void testSelection02() {
evaluate("testMap.keySet().?[#this matches '.*o.*']", "[monday]", ArrayList.class);
evaluate("testMap.keySet().?[#this matches '.*r.*'].contains('saturday')", "true", Boolean.class);
evaluate("testMap.keySet().?[#this matches '.*r.*'].size()", "3", Integer.class);
}
+ @Test
public void testSelectionError_NonBooleanSelectionCriteria() {
evaluateAndCheckError("listOfNumbersUpToTen.?['nonboolean']",
SpelMessages.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);
}
+ @Test
public void testSelection03() {
evaluate("mapOfNumbersUpToTen.?[key>5].size()", "5", Integer.class);
// evaluate("listOfNumbersUpToTen.?{#this>5}", "5", ArrayList.class);
}
+ @Test
public void testSelection04() {
evaluateAndCheckError("mapOfNumbersUpToTen.?['hello'].size()",SpelMessages.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);
}
+ @Test
public void testSelectionFirst01() {
evaluate("listOfNumbersUpToTen.^[#isEven(#this) == 'y']", "2", Integer.class);
}
+ @Test
public void testSelectionFirst02() {
evaluate("mapOfNumbersUpToTen.^[key>5].size()", "1", Integer.class);
}
+ @Test
public void testSelectionLast01() {
evaluate("listOfNumbersUpToTen.$[#isEven(#this) == 'y']", "10", Integer.class);
}
+ @Test
public void testSelectionLast02() {
evaluate("mapOfNumbersUpToTen.$[key>5].size()", "1", Integer.class);
}
+ @Test
public void testSelectionAST() throws Exception {
SpelExpression expr = (SpelExpression)parser.parseExpression("'abc'.^[true]");
- assertEquals("'abc'.^[true]",expr.toStringAST());
- assertFalse(expr.isWritable(new StandardEvaluationContext()));
+ Assert.assertEquals("'abc'.^[true]",expr.toStringAST());
+ Assert.assertFalse(expr.isWritable(new StandardEvaluationContext()));
expr = (SpelExpression)parser.parseExpression("'abc'.?[true]");
- assertEquals("'abc'.?[true]",expr.toStringAST());
- assertFalse(expr.isWritable(new StandardEvaluationContext()));
+ Assert.assertEquals("'abc'.?[true]",expr.toStringAST());
+ Assert.assertFalse(expr.isWritable(new StandardEvaluationContext()));
expr = (SpelExpression)parser.parseExpression("'abc'.$[true]");
- assertEquals("'abc'.$[true]",expr.toStringAST());
- assertFalse(expr.isWritable(new StandardEvaluationContext()));
+ Assert.assertEquals("'abc'.$[true]",expr.toStringAST());
+ Assert.assertFalse(expr.isWritable(new StandardEvaluationContext()));
}
// Constructor invocation
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/LiteralExpressionTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/LiteralExpressionTests.java
index 3c5ae20f339..caa9e13ce4f 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/LiteralExpressionTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/LiteralExpressionTests.java
@@ -16,8 +16,9 @@
package org.springframework.expression.spel;
-import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.junit.Test;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.common.LiteralExpression;
@@ -26,8 +27,9 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
/**
* @author Andy Clement
*/
-public class LiteralExpressionTests extends TestCase {
+public class LiteralExpressionTests {
+ @Test
public void testGetValue() throws Exception {
LiteralExpression lEx = new LiteralExpression("somevalue");
checkString("somevalue", lEx.getValue());
@@ -35,34 +37,36 @@ public class LiteralExpressionTests extends TestCase {
EvaluationContext ctx = new StandardEvaluationContext();
checkString("somevalue", lEx.getValue(ctx));
checkString("somevalue", lEx.getValue(ctx, String.class));
- assertEquals("somevalue", lEx.getExpressionString());
- assertFalse(lEx.isWritable(new StandardEvaluationContext()));
+ Assert.assertEquals("somevalue", lEx.getExpressionString());
+ Assert.assertFalse(lEx.isWritable(new StandardEvaluationContext()));
}
+ @Test
public void testSetValue() {
try {
LiteralExpression lEx = new LiteralExpression("somevalue");
lEx.setValue(new StandardEvaluationContext(), "flibble");
- fail("Should have got an exception that the value cannot be set");
+ Assert.fail("Should have got an exception that the value cannot be set");
}
catch (EvaluationException ee) {
// success, not allowed - whilst here, check the expression value in the exception
- assertEquals(ee.getExpressionString(), "somevalue");
+ Assert.assertEquals(ee.getExpressionString(), "somevalue");
}
}
+ @Test
public void testGetValueType() throws Exception {
LiteralExpression lEx = new LiteralExpression("somevalue");
- assertEquals(String.class, lEx.getValueType());
- assertEquals(String.class, lEx.getValueType(new StandardEvaluationContext()));
+ Assert.assertEquals(String.class, lEx.getValueType());
+ Assert.assertEquals(String.class, lEx.getValueType(new StandardEvaluationContext()));
}
private void checkString(String expectedString, Object value) {
if (!(value instanceof String)) {
- fail("Result was not a string, it was of type " + value.getClass() + " (value=" + value + ")");
+ Assert.fail("Result was not a string, it was of type " + value.getClass() + " (value=" + value + ")");
}
if (!((String) value).equals(expectedString)) {
- fail("Did not get expected result. Should have been '" + expectedString + "' but was '" + value + "'");
+ Assert.fail("Did not get expected result. Should have been '" + expectedString + "' but was '" + value + "'");
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/LiteralTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/LiteralTests.java
index fa6799aa494..f0c06bf3956 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/LiteralTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/LiteralTests.java
@@ -16,6 +16,9 @@
package org.springframework.expression.spel;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.spel.support.StandardEvaluationContext;
/**
@@ -25,47 +28,58 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*/
public class LiteralTests extends ExpressionTestCase {
+ @Test
public void testLiteralBoolean01() {
evaluate("false", "false", Boolean.class);
}
+ @Test
public void testLiteralBoolean02() {
evaluate("true", "true", Boolean.class);
}
+ @Test
public void testLiteralInteger01() {
evaluate("1", "1", Integer.class);
}
+ @Test
public void testLiteralInteger02() {
evaluate("1415", "1415", Integer.class);
}
+ @Test
public void testLiteralString01() {
evaluate("'Hello World'", "Hello World", String.class);
}
+ @Test
public void testLiteralString02() {
evaluate("'joe bloggs'", "joe bloggs", String.class);
}
+ @Test
public void testLiteralString03() {
evaluate("'hello'", "hello", String.class);
}
+ @Test
public void testLiteralString04() {
evaluate("'Tony''s Pizza'", "Tony's Pizza", String.class);
evaluate("'Tony\\r''s Pizza'", "Tony\\r's Pizza", String.class);
}
+ @Test
public void testLiteralString05() {
evaluate("\"Hello World\"", "Hello World", String.class);
}
+ @Test
public void testLiteralString06() {
evaluate("\"Hello ' World\"", "Hello ' World", String.class);
}
+ @Test
public void testHexIntLiteral01() {
evaluate("0x7FFFF", "524287", Integer.class);
evaluate("0x7FFFFL", 524287L, Long.class);
@@ -73,18 +87,21 @@ public class LiteralTests extends ExpressionTestCase {
evaluate("0X7FFFFl", 524287L, Long.class);
}
+ @Test
public void testLongIntLiteral01() {
evaluate("0xCAFEBABEL", 3405691582L, Long.class);
}
+ @Test
public void testLongIntInteractions01() {
evaluate("0x20 * 2L", 64L, Long.class);
// 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, -1);
+ evaluateAndCheckError("0x1220 * 0xffffffffL", Integer.class, SpelMessages.TYPE_CONVERSION_ERROR, 0);
}
+ @Test
public void testSignedIntLiterals() {
evaluate("-1", -1, Integer.class);
evaluate("-0xa", -10, Integer.class);
@@ -92,6 +109,7 @@ public class LiteralTests extends ExpressionTestCase {
evaluate("-0x20l", -32L, Long.class);
}
+ @Test
public void testLiteralReal01_CreatingDoubles() {
evaluate("1.25", 1.25d, Double.class);
evaluate("2.99", 2.99d, Double.class);
@@ -104,46 +122,51 @@ public class LiteralTests extends ExpressionTestCase {
evaluate("-3.141D", -3.141d, Double.class);
}
+ @Test
public void testLiteralReal02_CreatingFloats() {
// For now, everything becomes a double...
evaluate("1.25f", 1.25d, Double.class);
- evaluate("2.99f", 2.99d, Double.class);
- evaluate("-3.141f", -3.141d, Double.class);
+ evaluate("2.5f", 2.5d, Double.class);
+ evaluate("-3.5f", -3.5d, Double.class);
evaluate("1.25F", 1.25d, Double.class);
- evaluate("2.99F", 2.99d, Double.class);
- evaluate("-3.141F", -3.141d, Double.class);
+ evaluate("2.5F", 2.5d, Double.class);
+ evaluate("-3.5F", -3.5d, Double.class);
}
+ @Test
public void testLiteralReal03_UsingExponents() {
evaluate("6.0221415E+23", "6.0221415E23", Double.class);
evaluate("6.0221415e+23", "6.0221415E23", Double.class);
evaluate("6.0221415E+23d", "6.0221415E23", Double.class);
evaluate("6.0221415e+23D", "6.0221415E23", Double.class);
- evaluate("6.0221415E+23f", "6.0221415E23", Double.class);
- evaluate("6.0221415e+23F", "6.0221415E23", Double.class);
+ evaluate("6E2f", 600.0d, Double.class);
}
+ @Test
public void testLiteralReal04_BadExpressions() {
- parseAndCheckError("6.1e23e22", SpelMessages.PARSE_PROBLEM, 6, "mismatched input 'e22' expecting EOF");
- parseAndCheckError("6.1f23e22", SpelMessages.PARSE_PROBLEM, 4, "mismatched input '23e22' expecting EOF");
+ parseAndCheckError("6.1e23e22", SpelMessages.MORE_INPUT, 6, "e22");
+ parseAndCheckError("6.1f23e22", SpelMessages.MORE_INPUT, 4, "23e22");
}
+ @Test
public void testLiteralNull01() {
evaluate("null", null, null);
}
+ @Test
public void testConversions() {
// getting the expression type to be what we want - either:
evaluate("new Integer(37).byteValue()", (byte) 37, Byte.class); // calling byteValue() on Integer.class
evaluateAndAskForReturnType("new Integer(37)", (byte) 37, Byte.class); // relying on registered type converters
}
+ @Test
public void testNotWritable() throws Exception {
SpelExpression expr = (SpelExpression)parser.parseExpression("37");
- assertFalse(expr.isWritable(new StandardEvaluationContext()));
+ Assert.assertFalse(expr.isWritable(new StandardEvaluationContext()));
expr = (SpelExpression)parser.parseExpression("37L");
- assertFalse(expr.isWritable(new StandardEvaluationContext()));
+ Assert.assertFalse(expr.isWritable(new StandardEvaluationContext()));
expr = (SpelExpression)parser.parseExpression("true");
- assertFalse(expr.isWritable(new StandardEvaluationContext()));
+ Assert.assertFalse(expr.isWritable(new StandardEvaluationContext()));
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java
index 7ed32854487..57acec5d79b 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java
@@ -18,13 +18,17 @@ package org.springframework.expression.spel;
import java.util.Map;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
+import org.springframework.expression.ExpressionParser;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
import org.springframework.expression.spel.ast.CommonTypeDescriptors;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
/**
@@ -34,32 +38,36 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*/
public class MapAccessTests extends ExpressionTestCase {
+ @Test
public void testSimpleMapAccess01() {
evaluate("testMap.get('monday')", "montag", String.class);
}
+ @Test
public void testMapAccessThroughIndexer() {
evaluate("testMap['monday']", "montag", String.class);
}
+ @Test
public void testCustomMapAccessor() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = TestScenarioCreator.getTestEvaluationContext();
ctx.addPropertyAccessor(new MapAccessor());
Expression expr = parser.parseExpression("testMap.monday");
Object value = expr.getValue(ctx, String.class);
- assertEquals("montag", value);
+ Assert.assertEquals("montag", value);
}
+ @Test
public void testVariableMapAccess() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = TestScenarioCreator.getTestEvaluationContext();
ctx.setVariable("day", "saturday");
Expression expr = parser.parseExpression("testMap[#day]");
Object value = expr.getValue(ctx, String.class);
- assertEquals("samstag", value);
+ Assert.assertEquals("samstag", value);
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java
index 51b772a2135..e5fc59c474d 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java
@@ -16,14 +16,16 @@
package org.springframework.expression.spel;
+import org.junit.Test;
+
/**
* Tests invocation of methods.
*
* @author Andy Clement
*/
-@SuppressWarnings("unused")
public class MethodInvocationTests extends ExpressionTestCase {
+ @Test
public void testSimpleAccess01() {
evaluate("getPlaceOfBirth().getCity()", "SmilJan", String.class);
}
@@ -39,6 +41,7 @@ public class MethodInvocationTests extends ExpressionTestCase {
// evaluate("new int[]{4,3,2,1,2,3}.distinct().count()", 4, Integer.class);
// }
+ @Test
public void testStringClass() {
evaluate("new java.lang.String('hello').charAt(2)", 'l', Character.class);
evaluate("new java.lang.String('hello').charAt(2).equals('l'.charAt(0))", true, Boolean.class);
@@ -46,11 +49,13 @@ public class MethodInvocationTests extends ExpressionTestCase {
evaluate("' abcba '.trim()", "abcba", String.class);
}
+ @Test
public void testNonExistentMethods() {
// name is ok but madeup() does not exist
evaluateAndCheckError("name.madeup()", SpelMessages.METHOD_NOT_FOUND, 5);
}
+ @Test
public void testWidening01() {
// widening of int 3 to double 3 is OK
evaluate("new Double(3.0d).compareTo(8)", -1, Integer.class);
@@ -58,12 +63,14 @@ public class MethodInvocationTests extends ExpressionTestCase {
evaluate("new Double(3.0d).compareTo(2)", 1, Integer.class);
}
+ @Test
public void testArgumentConversion01() {
// Rely on Double>String conversion for calling startsWith()
evaluate("new String('hello 2.0 to you').startsWith(7.0d)", false, Boolean.class);
evaluate("new String('7.0 foobar').startsWith(7.0d)", true, Boolean.class);
}
+ @Test
public void testVarargsInvocation01() {
// Calling 'public int aVarargsMethod(String... strings)'
evaluate("aVarargsMethod('a','b','c')", 3, Integer.class);
@@ -75,6 +82,7 @@ public class MethodInvocationTests extends ExpressionTestCase {
// evaluate("aVarargsMethod(new String[]{'a','b','c'})", 3, Integer.class);
}
+ @Test
public void testVarargsInvocation02() {
// Calling 'public int aVarargsMethod2(int i, String... strings)' - returns int+length_of_strings
evaluate("aVarargsMethod2(5,'a','b','c')", 8, Integer.class);
@@ -86,6 +94,7 @@ public class MethodInvocationTests extends ExpressionTestCase {
// evaluate("aVarargsMethod2(8,new String[]{'a','b','c'})", 11, Integer.class);
}
+ @Test
public void testInvocationOnNullContextObject() {
evaluateAndCheckError("null.toString()",SpelMessages.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED);
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java
index 675f4c25e7d..103dd9db3c1 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java
@@ -16,6 +16,9 @@
package org.springframework.expression.spel;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Operation;
import org.springframework.expression.OperatorOverloader;
@@ -49,6 +52,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);
@@ -57,9 +61,9 @@ public class OperatorOverloaderTests extends ExpressionTestCase {
eContext.setOperatorOverloader(new StringAndBooleanAddition());
SpelExpression expr = (SpelExpression)parser.parseExpression("'abc'+true");
- assertEquals("abctrue",expr.getValue(eContext));
+ Assert.assertEquals("abctrue",expr.getValue(eContext));
expr = (SpelExpression)parser.parseExpression("'abc'-true");
- assertEquals("abc",expr.getValue(eContext));
+ Assert.assertEquals("abc",expr.getValue(eContext));
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/OperatorTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/OperatorTests.java
index 0ee30bf34f0..b1c0925338b 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/OperatorTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/OperatorTests.java
@@ -16,6 +16,9 @@
package org.springframework.expression.spel;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.spel.ast.Operator;
/**
@@ -25,14 +28,17 @@ import org.springframework.expression.spel.ast.Operator;
*/
public class OperatorTests extends ExpressionTestCase {
+ @Test
public void testIntegerLiteral() {
evaluate("3", 3, Integer.class);
}
+ @Test
public void testRealLiteral() {
evaluate("3.5", 3.5d, Double.class);
}
+ @Test
public void testLessThan() {
evaluate("3 < 5", true, Boolean.class);
evaluate("5 < 3", false, Boolean.class);
@@ -44,6 +50,7 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("'def' < 'abc'",false,Boolean.class);
}
+ @Test
public void testLessThanOrEqual() {
evaluate("3 <= 5", true, Boolean.class);
evaluate("5 <= 3", false, Boolean.class);
@@ -59,6 +66,7 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("'abc' <= 'abc'",true,Boolean.class);
}
+ @Test
public void testEqual() {
evaluate("3 == 5", false, Boolean.class);
evaluate("5 == 3", false, Boolean.class);
@@ -68,6 +76,7 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("'abc' == null", false, Boolean.class);
}
+ @Test
public void testNotEqual() {
evaluate("3 != 5", true, Boolean.class);
evaluate("5 != 3", true, Boolean.class);
@@ -76,6 +85,7 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("3.0f != 3.0f", false, Boolean.class);
}
+ @Test
public void testGreaterThanOrEqual() {
evaluate("3 >= 5", false, Boolean.class);
evaluate("5 >= 3", true, Boolean.class);
@@ -92,6 +102,7 @@ public class OperatorTests extends ExpressionTestCase {
}
+ @Test
public void testGreaterThan() {
evaluate("3 > 5", false, Boolean.class);
evaluate("5 > 3", true, Boolean.class);
@@ -103,18 +114,29 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("'def' > 'abc'",true,Boolean.class);
}
+ @Test
public void testMultiplyStringInt() {
evaluate("'a' * 5", "aaaaa", String.class);
}
+ @Test
public void testMultiplyDoubleDoubleGivesDouble() {
evaluate("3.0d * 5.0d", 15.0d, Double.class);
}
+ @Test
public void testMathOperatorAdd02() {
evaluate("'hello' + ' ' + 'world'", "hello world", String.class);
}
+
+ @Test
+ public void testMathOperatorsInChains() {
+ evaluate("1+2+3",6,Integer.class);
+ evaluate("2*3*4",24,Integer.class);
+ evaluate("12-1-2",9,Integer.class);
+ }
+ @Test
public void testIntegerArithmetic() {
evaluate("2 + 4", "6", Integer.class);
evaluate("5 - 4", "1", Integer.class);
@@ -125,6 +147,7 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("3 % 2", 1, Integer.class);
}
+ @Test
public void testPlus() throws Exception {
evaluate("7 + 2", "9", Integer.class);
evaluate("3.0f + 5.0f", 8.0d, Double.class);
@@ -136,9 +159,9 @@ public class OperatorTests extends ExpressionTestCase {
// AST:
SpelExpression expr = (SpelExpression)parser.parseExpression("+3");
- assertEquals("+3",expr.toStringAST());
+ Assert.assertEquals("+3",expr.toStringAST());
expr = (SpelExpression)parser.parseExpression("2+3");
- assertEquals("(2 + 3)",expr.toStringAST());
+ Assert.assertEquals("(2 + 3)",expr.toStringAST());
// use as a unary operator
evaluate("+5d",5d,Double.class);
@@ -153,15 +176,16 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("5 + new Integer('37')",42,Integer.class);
}
+ @Test
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);
SpelExpression expr = (SpelExpression)parser.parseExpression("-3");
- assertEquals("-3",expr.toStringAST());
+ Assert.assertEquals("-3",expr.toStringAST());
expr = (SpelExpression)parser.parseExpression("2-3");
- assertEquals("(2 - 3)",expr.toStringAST());
+ Assert.assertEquals("(2 - 3)",expr.toStringAST());
evaluate("-5d",-5d,Double.class);
evaluate("-5L",-5L,Long.class);
@@ -169,28 +193,33 @@ public class OperatorTests extends ExpressionTestCase {
evaluateAndCheckError("-'abc'",SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
}
+ @Test
public void testModulus() {
evaluate("3%2",1,Integer.class);
evaluate("3L%2L",1L,Long.class);
- evaluate("3.0d%2.0d",1d,Double.class);
- evaluate("5.0f % 3.1f", 1.9d, Double.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);
}
+ @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);
}
+ @Test
public void testMathOperatorDivide_ConvertToDouble() {
evaluateAndAskForReturnType("8/4", new Double(2.0), Double.class);
}
+ @Test
public void testMathOperatorDivide04_ConvertToFloat() {
evaluateAndAskForReturnType("8/4", new Float(2.0), Float.class);
}
+ @Test
public void testDoubles() {
evaluate("3.0d == 5.0d", false, Boolean.class);
evaluate("3.0d == 3.0d", true, Boolean.class);
@@ -203,49 +232,52 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("6.0d % 3.5d", 2.5d, Double.class);
}
+ @Test
public void testOperatorNames() throws Exception {
Operator node = getOperatorNode((SpelExpression)parser.parseExpression("1==3"));
- assertEquals("==",node.getOperatorName());
+ Assert.assertEquals("==",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("1!=3"));
- assertEquals("!=",node.getOperatorName());
+ Assert.assertEquals("!=",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3/3"));
- assertEquals("/",node.getOperatorName());
+ Assert.assertEquals("/",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3+3"));
- assertEquals("+",node.getOperatorName());
+ Assert.assertEquals("+",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3-3"));
- assertEquals("-",node.getOperatorName());
+ Assert.assertEquals("-",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3<4"));
- assertEquals("<",node.getOperatorName());
+ Assert.assertEquals("<",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3<=4"));
- assertEquals("<=",node.getOperatorName());
+ Assert.assertEquals("<=",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3*4"));
- assertEquals("*",node.getOperatorName());
+ Assert.assertEquals("*",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3%4"));
- assertEquals("%",node.getOperatorName());
+ Assert.assertEquals("%",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3>=4"));
- assertEquals(">=",node.getOperatorName());
+ Assert.assertEquals(">=",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3 between 4"));
- assertEquals("between",node.getOperatorName());
+ Assert.assertEquals("between",node.getOperatorName());
node = getOperatorNode((SpelExpression)parser.parseExpression("3 ^ 4"));
- assertEquals("^",node.getOperatorName());
+ Assert.assertEquals("^",node.getOperatorName());
}
+ @Test
public void testOperatorOverloading() {
evaluateAndCheckError("'a' * '2'", SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
evaluateAndCheckError("'a' ^ '2'", SpelMessages.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
}
+ @Test
public void testPower() {
evaluate("3^2",9,Integer.class);
evaluate("3.0d^2.0d",9.0d,Double.class);
@@ -253,14 +285,16 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("(2^32)^2",9223372036854775807L,Long.class);
}
+ @Test
public void testMixedOperands_FloatsAndDoubles() {
evaluate("3.0d + 5.0f", 8.0d, Double.class);
evaluate("3.0D - 5.0f", -2.0d, Double.class);
evaluate("3.0f * 5.0d", 15.0d, Double.class);
evaluate("3.0f / 5.0D", 0.6d, Double.class);
- evaluate("5.0D % 3.1f", 1.9d, Double.class);
+ evaluate("5.0D % 3f", 2.0d, Double.class);
}
+ @Test
public void testMixedOperands_DoublesAndInts() {
evaluate("3.0d + 5", 8.0d, Double.class);
evaluate("3.0D - 5", -2.0d, Double.class);
@@ -271,6 +305,7 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("5.5D % 3", 2.5, Double.class);
}
+ @Test
public void testStrings() {
evaluate("'abc' == 'abc'",true,Boolean.class);
evaluate("'abc' == 'def'",false,Boolean.class);
@@ -278,6 +313,7 @@ public class OperatorTests extends ExpressionTestCase {
evaluate("'abc' != 'def'",true,Boolean.class);
}
+ @Test
public void testLongs() {
evaluate("3L == 4L", false, Boolean.class);
evaluate("3L == 3L", true, Boolean.class);
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ParserErrorMessagesTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ParserErrorMessagesTests.java
index 2e57a380337..73ed21ee953 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ParserErrorMessagesTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ParserErrorMessagesTests.java
@@ -16,15 +16,16 @@
package org.springframework.expression.spel;
+import org.junit.Test;
+
/**
* Tests the messages and exceptions that come out for badly formed expressions
*
* @author Andy Clement
*/
public class ParserErrorMessagesTests extends ExpressionTestCase {
- // TODO extract expected insert messages into constants (just in case of changes)?
- // TODO review poor messages, marked // POOR below
+ @Test
public void testBrokenExpression01() {
// will not fit into an int, needs L suffix
parseAndCheckError("0xCAFEBABE", SpelMessages.NOT_AN_INTEGER);
@@ -32,26 +33,30 @@ public class ParserErrorMessagesTests extends ExpressionTestCase {
parseAndCheckError("0xCAFEBABECAFEBABEL", SpelMessages.NOT_A_LONG);
}
+ @Test
public void testBrokenExpression02() {
// rogue 'G' on the end
- parseAndCheckError("0xB0BG", SpelMessages.PARSE_PROBLEM, 5, "mismatched input 'G' expecting EOF");
+ parseAndCheckError("0xB0BG", SpelMessages.MORE_INPUT, 5, "G");
}
+ @Test
public void testBrokenExpression04() {
// missing right operand
- parseAndCheckError("true or ", SpelMessages.PARSE_PROBLEM, -1, "no viable alternative at input ''"); // POOR
+ parseAndCheckError("true or ", SpelMessages.RIGHT_OPERAND_PROBLEM, 5);
}
+ @Test
public void testBrokenExpression05() {
// missing right operand
- parseAndCheckError("1 + ", SpelMessages.PARSE_PROBLEM, -1, "no viable alternative at input ''"); // POOR
+ parseAndCheckError("1 + ", SpelMessages.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.PARSE_PROBLEM, 18,
- "mismatched input ''a'' expecting ID"); // POOR
+ parseAndCheckError("null instanceof T('a')", SpelMessages.NOT_EXPECTED_TOKEN, 18,
+ "identifier","literal_string");
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ParsingTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ParsingTests.java
index 29a1354c5c5..5e0aea44f6d 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ParsingTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ParsingTests.java
@@ -16,10 +16,11 @@
package org.springframework.expression.spel;
-import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.junit.Test;
import org.springframework.expression.ParseException;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
/**
* Parse some expressions and check we get the AST we expect. Rather than inspecting each node in the AST, we ask it to
@@ -27,105 +28,129 @@ import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
*
* @author Andy Clement
*/
-public class ParsingTests extends TestCase {
+public class ParsingTests {
- private SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ private SpelExpressionParser parser = new SpelExpressionParser();
// literals
+ @Test
public void testLiteralBoolean01() {
parseCheck("false");
}
+ @Test
public void testLiteralLong01() {
parseCheck("37L", "37");
}
+ @Test
public void testLiteralBoolean02() {
parseCheck("true");
}
+ @Test
public void testLiteralBoolean03() {
parseCheck("!true");
}
+ @Test
public void testLiteralInteger01() {
parseCheck("1");
}
+ @Test
public void testLiteralInteger02() {
parseCheck("1415");
}
+ @Test
public void testLiteralString01() {
parseCheck("'hello'");
}
+ @Test
public void testLiteralString02() {
parseCheck("'joe bloggs'");
}
+ @Test
public void testLiteralString03() {
parseCheck("'Tony''s Pizza'", "'Tony's Pizza'");
}
+ @Test
public void testLiteralReal01() {
parseCheck("6.0221415E+23", "6.0221415E23");
}
+ @Test
public void testLiteralHex01() {
parseCheck("0x7FFFFFFF", "2147483647");
}
+ @Test
public void testLiteralDate01() {
parseCheck("date('1974/08/24')");
}
+ @Test
public void testLiteralDate02() {
parseCheck("date('19740824T131030','yyyyMMddTHHmmss')");
}
+ @Test
public void testLiteralNull01() {
parseCheck("null");
}
// boolean operators
+ @Test
public void testBooleanOperatorsOr01() {
parseCheck("false or false", "(false or false)");
}
+ @Test
public void testBooleanOperatorsOr02() {
parseCheck("false or true", "(false or true)");
}
+ @Test
public void testBooleanOperatorsOr03() {
parseCheck("true or false", "(true or false)");
}
+ @Test
public void testBooleanOperatorsOr04() {
parseCheck("true or false", "(true or false)");
}
+ @Test
public void testBooleanOperatorsMix01() {
parseCheck("false or true and false", "(false or (true and false))");
}
// relational operators
+ @Test
public void testRelOperatorsGT01() {
parseCheck("3>6", "(3 > 6)");
}
+ @Test
public void testRelOperatorsLT01() {
parseCheck("3<6", "(3 < 6)");
}
+ @Test
public void testRelOperatorsLE01() {
parseCheck("3<=6", "(3 <= 6)");
}
+ @Test
public void testRelOperatorsGE01() {
parseCheck("3>=6", "(3 >= 6)");
}
+ @Test
public void testRelOperatorsGE02() {
parseCheck("3>=3", "(3 >= 3)");
}
@@ -142,6 +167,7 @@ public class ParsingTests extends TestCase {
// parseCheck("'efg' between {'abc', 'xyz'}", "('efg' between {'abc','xyz'})");
// }// true
+ @Test
public void testRelOperatorsIs01() {
parseCheck("'xyz' instanceof int", "('xyz' instanceof int)");
}// false
@@ -150,44 +176,54 @@ public class ParsingTests extends TestCase {
// parseCheck("{1, 2, 3, 4, 5} instanceof List", "({1,2,3,4,5} instanceof List)");
// }// true
+ @Test
public void testRelOperatorsMatches01() {
parseCheck("'5.0067' matches '^-?\\d+(\\.\\d{2})?$'", "('5.0067' matches '^-?\\d+(\\.\\d{2})?$')");
}// false
+ @Test
public void testRelOperatorsMatches02() {
parseCheck("'5.00' matches '^-?\\d+(\\.\\d{2})?$'", "('5.00' matches '^-?\\d+(\\.\\d{2})?$')");
}// true
// mathematical operators
+ @Test
public void testMathOperatorsAdd01() {
parseCheck("2+4", "(2 + 4)");
}
+ @Test
public void testMathOperatorsAdd02() {
parseCheck("'a'+'b'", "('a' + 'b')");
}
+ @Test
public void testMathOperatorsAdd03() {
parseCheck("'hello'+' '+'world'", "(('hello' + ' ') + 'world')");
}
+ @Test
public void testMathOperatorsSubtract01() {
parseCheck("5-4", "(5 - 4)");
}
+ @Test
public void testMathOperatorsMultiply01() {
parseCheck("7*4", "(7 * 4)");
}
+ @Test
public void testMathOperatorsDivide01() {
parseCheck("8/4", "(8 / 4)");
}
+ @Test
public void testMathOperatorModulus01() {
parseCheck("7 % 4", "(7 % 4)");
}
// mixed operators
+ @Test
public void testMixedOperators01() {
parseCheck("true and 5>3", "(true and (5 > 3))");
}
@@ -239,14 +275,17 @@ public class ParsingTests extends TestCase {
// }// normalized to '.' for separator in QualifiedIdentifier
// properties
+ @Test
public void testProperties01() {
parseCheck("name");
}
+ @Test
public void testProperties02() {
parseCheck("placeofbirth.CitY");
}
+ @Test
public void testProperties03() {
parseCheck("a.b.c.d.e");
}
@@ -278,19 +317,23 @@ public class ParsingTests extends TestCase {
// }
// methods
+ @Test
public void testMethods01() {
parseCheck("echo(12)");
}
+ @Test
public void testMethods02() {
parseCheck("echo(name)");
}
+ @Test
public void testMethods03() {
parseCheck("age.doubleItAndAdd(12)");
}
// constructors
+ @Test
public void testConstructors01() {
parseCheck("new String('hello')");
}
@@ -309,14 +352,17 @@ public class ParsingTests extends TestCase {
// }
// variables and functions
+ @Test
public void testVariables01() {
parseCheck("#foo");
}
+ @Test
public void testFunctions01() {
parseCheck("#fn(1,2,3)");
}
+ @Test
public void testFunctions02() {
parseCheck("#fn('hello')");
}
@@ -342,6 +388,7 @@ public class ParsingTests extends TestCase {
// }
// assignment
+ @Test
public void testAssignmentToVariables01() {
parseCheck("#var1='value1'");
}
@@ -349,6 +396,7 @@ public class ParsingTests extends TestCase {
// ternary operator
+ @Test
public void testTernaryOperator01() {
parseCheck("1>2?3:4","(1 > 2) ? 3 : 4");
}
@@ -369,10 +417,12 @@ public class ParsingTests extends TestCase {
// } // 120
// Type references
+ @Test
public void testTypeReferences01() {
parseCheck("T(java.lang.String)");
}
+ @Test
public void testTypeReferences02() {
parseCheck("T(String)");
}
@@ -401,12 +451,12 @@ public class ParsingTests extends TestCase {
SpelUtilities.printAbstractSyntaxTree(System.err, e);
}
if (e == null) {
- fail("Parsed exception was null");
+ Assert.fail("Parsed exception was null");
}
- assertEquals("String form of AST does not match expected output", expectedStringFormOfAST, e.toStringAST());
+ Assert.assertEquals("String form of AST does not match expected output", expectedStringFormOfAST, e.toStringAST());
} catch (ParseException ee) {
ee.printStackTrace();
- fail("Unexpected Exception: " + ee.getMessage());
+ Assert.fail("Unexpected Exception: " + ee.getMessage());
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java
index a31fdfacef4..58fd9fab9d2 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java
@@ -16,27 +16,31 @@
package org.springframework.expression.spel;
-import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.junit.Test;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
+import org.springframework.expression.ExpressionParser;
+
+///CLOVER:OFF
/**
* Tests the evaluation of real expressions in a real context.
*
* @author Andy Clement
*/
-public class PerformanceTests extends TestCase {
+public class PerformanceTests {
public static final int ITERATIONS = 10000;
public static final boolean report = true;
- private static SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ private static ExpressionParser parser = SpelExpressionParserFactory.getParser();
private static EvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
private static final boolean DEBUG = false;
+ @Test
public void testPerformanceOfPropertyAccess() throws Exception {
long starttime = 0;
long endtime = 0;
@@ -45,18 +49,18 @@ public class PerformanceTests extends TestCase {
for (int i = 0; i < ITERATIONS; i++) {
Expression expr = parser.parseExpression("placeOfBirth.city");
if (expr == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
- Object value = expr.getValue(eContext);
+ expr.getValue(eContext);
}
starttime = System.currentTimeMillis();
for (int i = 0; i < ITERATIONS; i++) {
Expression expr = parser.parseExpression("placeOfBirth.city");
if (expr == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
- Object value = expr.getValue(eContext);
+ expr.getValue(eContext);
}
endtime = System.currentTimeMillis();
long freshParseTime = endtime - starttime;
@@ -66,11 +70,11 @@ public class PerformanceTests extends TestCase {
Expression expr = parser.parseExpression("placeOfBirth.city");
if (expr == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
starttime = System.currentTimeMillis();
for (int i = 0; i < ITERATIONS; i++) {
- Object value = expr.getValue(eContext);
+ expr.getValue(eContext);
}
endtime = System.currentTimeMillis();
long reuseTime = endtime - starttime;
@@ -80,7 +84,7 @@ public class PerformanceTests extends TestCase {
if (reuseTime > freshParseTime) {
System.out.println("Fresh parse every time, ITERATIONS iterations = " + freshParseTime + "ms");
System.out.println("Reuse SpelExpression, ITERATIONS iterations = " + reuseTime + "ms");
- fail("Should have been quicker to reuse!");
+ Assert.fail("Should have been quicker to reuse!");
}
}
@@ -92,18 +96,18 @@ public class PerformanceTests extends TestCase {
for (int i = 0; i < ITERATIONS; i++) {
Expression expr = parser.parseExpression("getPlaceOfBirth().getCity()");
if (expr == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
- Object value = expr.getValue(eContext);
+ expr.getValue(eContext);
}
starttime = System.currentTimeMillis();
for (int i = 0; i < ITERATIONS; i++) {
Expression expr = parser.parseExpression("getPlaceOfBirth().getCity()");
if (expr == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
- Object value = expr.getValue(eContext);
+ expr.getValue(eContext);
}
endtime = System.currentTimeMillis();
long freshParseTime = endtime - starttime;
@@ -113,11 +117,11 @@ public class PerformanceTests extends TestCase {
Expression expr = parser.parseExpression("getPlaceOfBirth().getCity()");
if (expr == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
starttime = System.currentTimeMillis();
for (int i = 0; i < ITERATIONS; i++) {
- Object value = expr.getValue(eContext);
+ expr.getValue(eContext);
}
endtime = System.currentTimeMillis();
long reuseTime = endtime - starttime;
@@ -128,7 +132,7 @@ public class PerformanceTests extends TestCase {
if (reuseTime > freshParseTime) {
System.out.println("Fresh parse every time, ITERATIONS iterations = " + freshParseTime + "ms");
System.out.println("Reuse SpelExpression, ITERATIONS iterations = " + reuseTime + "ms");
- fail("Should have been quicker to reuse!");
+ Assert.fail("Should have been quicker to reuse!");
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java
index a796b46f459..9872e340ec8 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java
@@ -16,16 +16,21 @@
package org.springframework.expression.spel;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
import org.springframework.expression.spel.ast.CommonTypeDescriptors;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
+///CLOVER:OFF
+
/**
* Tests accessing of properties.
*
@@ -33,18 +38,22 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*/
public class PropertyAccessTests extends ExpressionTestCase {
+ @Test
public void testSimpleAccess01() {
evaluate("name", "Nikola Tesla", String.class);
}
+ @Test
public void testSimpleAccess02() {
evaluate("placeOfBirth.city", "SmilJan", String.class);
}
+ @Test
public void testSimpleAccess03() {
evaluate("stringArrayOfThreeItems.length", "3", Integer.class);
}
+ @Test
public void testNonExistentPropertiesAndMethods() {
// madeup does not exist as a property
evaluateAndCheckError("madeup", SpelMessages.PROPERTY_OR_FIELD_NOT_READABLE, 0);
@@ -57,36 +66,38 @@ public class PropertyAccessTests extends ExpressionTestCase {
* The standard reflection resolver cannot find properties on null objects but some
* supplied resolver might be able to - so null shouldn't crash the reflection resolver.
*/
+ @Test
public void testAccessingOnNullObject() throws Exception {
SpelExpression expr = (SpelExpression)parser.parseExpression("madeup");
EvaluationContext context = new StandardEvaluationContext(null);
try {
expr.getValue(context);
- fail("Should have failed - default property resolver cannot resolve on null");
+ 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);
}
- assertFalse(expr.isWritable(context));
+ Assert.assertFalse(expr.isWritable(context));
try {
expr.setValue(context,"abc");
- fail("Should have failed - default property resolver cannot resolve on null");
+ 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);
}
}
private void checkException(Exception e, SpelMessages expectedMessage) {
- if (e instanceof SpelException) {
- SpelMessages sm = ((SpelException)e).getMessageUnformatted();
- assertEquals("Expected exception type did not occur",expectedMessage,sm);
+ if (e instanceof SpelEvaluationException) {
+ SpelMessages sm = ((SpelEvaluationException)e).getMessageUnformatted();
+ Assert.assertEquals("Expected exception type did not occur",expectedMessage,sm);
} else {
- fail("Should be a SpelException "+e);
+ Assert.fail("Should be a SpelException "+e);
}
}
+ @Test
// Adding a new property accessor just for a particular type
public void testAddingSpecificPropertyAccessor() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
// Even though this property accessor is added after the reflection one, it specifically
@@ -95,22 +106,22 @@ public class PropertyAccessTests extends ExpressionTestCase {
ctx.addPropertyAccessor(new StringyPropertyAccessor());
Expression expr = parser.parseExpression("new String('hello').flibbles");
Integer i = expr.getValue(ctx, Integer.class);
- assertEquals((int) i, 7);
+ Assert.assertEquals((int) i, 7);
// The reflection one will be used for other properties...
expr = parser.parseExpression("new String('hello').CASE_INSENSITIVE_ORDER");
Object o = expr.getValue(ctx);
- assertNotNull(o);
+ Assert.assertNotNull(o);
expr = parser.parseExpression("new String('hello').flibbles");
expr.setValue(ctx, 99);
i = expr.getValue(ctx, Integer.class);
- assertEquals((int) i, 99);
+ Assert.assertEquals((int) i, 99);
// Cannot set it to a string value
try {
expr.setValue(ctx, "not allowed");
- fail("Should not have been allowed");
+ Assert.fail("Should not have been allowed");
} catch (EvaluationException e) {
// success - message will be: EL1063E:(pos 20): A problem occurred whilst attempting to set the property
// 'flibbles': 'Cannot set flibbles to an object of type 'class java.lang.String''
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java
index f6ef4865f1a..f5b87036d41 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java
@@ -18,6 +18,9 @@ package org.springframework.expression.spel;
import java.lang.reflect.Method;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
@@ -29,7 +32,7 @@ import org.springframework.expression.MethodResolver;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypeConverter;
import org.springframework.expression.TypedValue;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.ReflectionHelper;
import org.springframework.expression.spel.support.StandardEvaluationContext;
@@ -41,28 +44,30 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*/
public class ScenariosForSpringSecurity extends ExpressionTestCase {
+ @Test
public void testScenario01_Roles() throws Exception {
try {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
Expression expr = parser.parseExpression("hasAnyRole('MANAGER','TELLER')");
ctx.setRootObject(new Person("Ben"));
Boolean value = expr.getValue(ctx,Boolean.class);
- assertFalse(value);
+ Assert.assertFalse(value);
ctx.setRootObject(new Manager("Luke"));
value = expr.getValue(ctx,Boolean.class);
- assertTrue(value);
+ Assert.assertTrue(value);
} catch (EvaluationException ee) {
ee.printStackTrace();
- fail("Unexpected SpelException: " + ee.getMessage());
+ Assert.fail("Unexpected SpelException: " + ee.getMessage());
}
}
+ @Test
public void testScenario02_ComparingNames() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.addPropertyAccessor(new SecurityPrincipalAccessor());
@@ -73,11 +78,11 @@ public class ScenariosForSpringSecurity extends ExpressionTestCase {
ctx.setRootObject(new Person("Andy"));
Boolean value = expr.getValue(ctx,Boolean.class);
- assertTrue(value);
+ Assert.assertTrue(value);
ctx.setRootObject(new Person("Christian"));
value = expr.getValue(ctx,Boolean.class);
- assertFalse(value);
+ Assert.assertFalse(value);
// (2) Or register an accessor that can understand 'p' and return the right person
expr = parser.parseExpression("p.name == principal.name");
@@ -88,15 +93,16 @@ public class ScenariosForSpringSecurity extends ExpressionTestCase {
pAccessor.setPerson(new Person("Andy"));
value = expr.getValue(ctx,Boolean.class);
- assertTrue(value);
+ Assert.assertTrue(value);
pAccessor.setPerson(new Person("Christian"));
value = expr.getValue(ctx,Boolean.class);
- assertFalse(value);
+ Assert.assertFalse(value);
}
+ @Test
public void testScenario03_Arithmetic() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
// Might be better with a as a variable although it would work as a property too...
@@ -108,17 +114,18 @@ public class ScenariosForSpringSecurity extends ExpressionTestCase {
ctx.setVariable("a",1.0d); // referenced as #a in the expression
ctx.setRootObject(new Supervisor("Ben")); // so non-qualified references 'hasRole()' 'hasIpAddress()' are invoked against it
value = expr.getValue(ctx,Boolean.class);
- assertTrue(value);
+ Assert.assertTrue(value);
ctx.setRootObject(new Manager("Luke"));
ctx.setVariable("a",1.043d);
value = expr.getValue(ctx,Boolean.class);
- assertFalse(value);
+ Assert.assertFalse(value);
}
// Here i'm going to change which hasRole() executes and make it one of my own Java methods
+ @Test
public void testScenario04_ControllingWhichMethodsRun() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.setRootObject(new Supervisor("Ben")); // so non-qualified references 'hasRole()' 'hasIpAddress()' are invoked against it);
@@ -133,7 +140,7 @@ public class ScenariosForSpringSecurity extends ExpressionTestCase {
ctx.setVariable("a",1.0d); // referenced as #a in the expression
value = expr.getValue(ctx,Boolean.class);
- assertTrue(value);
+ Assert.assertTrue(value);
// ctx.setRootObject(new Manager("Luke"));
// ctx.setVariable("a",1.043d);
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/SetValueTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/SetValueTests.java
index 1eda33ddd7b..0b5cad4de3a 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/SetValueTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/SetValueTests.java
@@ -20,6 +20,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
import org.springframework.expression.ParseException;
@@ -37,22 +40,27 @@ public class SetValueTests extends ExpressionTestCase {
private final static boolean DEBUG = false;
+ @Test
public void testSetProperty() {
setValue("wonNobelPrize", true);
}
+ @Test
public void testSetNestedProperty() {
setValue("placeOfBirth.city", "Wien");
}
+ @Test
public void testSetArrayElementValue() {
setValue("inventions[0]", "Just the telephone");
}
+ @Test
public void testSetElementOfNull() {
setValueExpectError("new org.springframework.expression.spel.testresources.Inventor().inventions[1]",SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
}
+ @Test
public void testSetArrayElementValueAllPrimitiveTypes() {
setValue("arrayContainer.ints[1]", 3);
setValue("arrayContainer.floats[1]", 3.0f);
@@ -64,6 +72,7 @@ public class SetValueTests extends ExpressionTestCase {
setValue("arrayContainer.chars[1]", (char) 3);
}
+ @Test
public void testSetArrayElementValueAllPrimitiveTypesErrors() {
// none of these sets are possible due to (expected) conversion problems
setValueExpectError("arrayContainer.ints[1]", "wibble");
@@ -76,62 +85,74 @@ public class SetValueTests extends ExpressionTestCase {
setValueExpectError("arrayContainer.chars[1]", "NaC");
}
+ @Test
public void testSetArrayElementNestedValue() {
setValue("placesLived[0].city", "Wien");
}
+ @Test
public void testSetListElementValue() {
setValue("placesLivedList[0]", new PlaceOfBirth("Wien"));
}
- public void testSetGenericListElementValueTypeCoersionFail() {
+ @Test
+ public void testSetGenericListElementValueTypeCoersionfail() {
// no type converter registered for String > PlaceOfBirth
setValueExpectError("placesLivedList[0]", "Wien");
}
+ @Test
public void testSetGenericListElementValueTypeCoersionOK() {
setValue("booleanList[0]", "true", Boolean.TRUE);
}
+ @Test
public void testSetListElementNestedValue() {
setValue("placesLived[0].city", "Wien");
}
+ @Test
public void testSetArrayElementInvalidIndex() {
setValueExpectError("placesLived[23]", "Wien");
setValueExpectError("placesLivedList[23]", "Wien");
}
+ @Test
public void testSetMapElements() {
setValue("testMap['montag']","lundi");
}
+ @Test
public void testIndexingIntoUnsupportedType() {
setValueExpectError("'hello'[3]", 'p');
}
+ @Test
public void testSetPropertyTypeCoersion() {
setValue("publicBoolean", "true", Boolean.TRUE);
}
+ @Test
public void testSetPropertyTypeCoersionThroughSetter() {
setValue("SomeProperty", "true", Boolean.TRUE);
}
+ @Test
public void testAssign() throws Exception {
StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
Expression e = parse("publicName='Andy'");
- assertFalse(e.isWritable(eContext));
- assertEquals("Andy",e.getValue(eContext));
+ Assert.assertFalse(e.isWritable(eContext));
+ Assert.assertEquals("Andy",e.getValue(eContext));
}
/*
* Testing the coercion of both the keys and the values to the correct type
*/
+ @Test
public void testSetGenericMapElementRequiresCoercion() throws Exception {
StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
Expression e = parse("mapOfStringToBoolean[42]");
- assertNull(e.getValue(eContext));
+ Assert.assertNull(e.getValue(eContext));
// Key should be coerced to string representation of 42
e.setValue(eContext, "true");
@@ -139,18 +160,18 @@ public class SetValueTests extends ExpressionTestCase {
// All keys should be strings
Set ks = parse("mapOfStringToBoolean.keySet()").getValue(eContext,Set.class);
for (Object o: ks) {
- assertEquals(String.class,o.getClass());
+ Assert.assertEquals(String.class,o.getClass());
}
// All values should be booleans
Collection vs = parse("mapOfStringToBoolean.values()").getValue(eContext,Collection.class);
for (Object o: vs) {
- assertEquals(Boolean.class,o.getClass());
+ Assert.assertEquals(Boolean.class,o.getClass());
}
// One final test check coercion on the key for a map lookup
Object o = e.getValue(eContext);
- assertEquals(Boolean.TRUE,o);
+ Assert.assertEquals(Boolean.TRUE,o);
}
@@ -165,17 +186,17 @@ public class SetValueTests extends ExpressionTestCase {
try {
Expression e = parser.parseExpression(expression);
if (e == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, e);
}
StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext();
e.setValue(lContext, value);
- fail("expected an error");
+ Assert.fail("expected an error");
} catch (ParseException pe) {
pe.printStackTrace();
- fail("Unexpected Exception: " + pe.getMessage());
+ Assert.fail("Unexpected Exception: " + pe.getMessage());
} catch (EvaluationException ee) {
// success!
}
@@ -185,21 +206,21 @@ public class SetValueTests extends ExpressionTestCase {
try {
Expression e = parser.parseExpression(expression);
if (e == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, e);
}
StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext();
- assertTrue("Expression is not writeable but should be", e.isWritable(lContext));
+ Assert.assertTrue("Expression is not writeable but should be", e.isWritable(lContext));
e.setValue(lContext, value);
- assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext));
+ Assert.assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext));
} catch (EvaluationException ee) {
ee.printStackTrace();
- fail("Unexpected Exception: " + ee.getMessage());
+ Assert.fail("Unexpected Exception: " + ee.getMessage());
} catch (ParseException pe) {
pe.printStackTrace();
- fail("Unexpected Exception: " + pe.getMessage());
+ Assert.fail("Unexpected Exception: " + pe.getMessage());
}
}
@@ -211,26 +232,26 @@ public class SetValueTests extends ExpressionTestCase {
try {
Expression e = parser.parseExpression(expression);
if (e == null) {
- fail("Parser returned null for expression");
+ Assert.fail("Parser returned null for expression");
}
if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, e);
}
StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext();
- assertTrue("Expression is not writeable but should be", e.isWritable(lContext));
+ Assert.assertTrue("Expression is not writeable but should be", e.isWritable(lContext));
e.setValue(lContext, value);
Object a = expectedValue;
Object b = e.getValue(lContext);
if (!a.equals(b)) {
- fail("Not the same: ["+a+"] type="+a.getClass()+" ["+b+"] type="+b.getClass());
-// assertEquals("Retrieved value was not equal to set value", expectedValue, e.getValue(lContext));
+ Assert.fail("Not the same: ["+a+"] type="+a.getClass()+" ["+b+"] type="+b.getClass());
+// Assert.assertEquals("Retrieved value was not equal to set value", expectedValue, e.getValue(lContext));
}
} catch (EvaluationException ee) {
ee.printStackTrace();
- fail("Unexpected Exception: " + ee.getMessage());
+ Assert.fail("Unexpected Exception: " + ee.getMessage());
} catch (ParseException pe) {
pe.printStackTrace();
- fail("Unexpected Exception: " + pe.getMessage());
+ Assert.fail("Unexpected Exception: " + pe.getMessage());
}
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java
index 2dae04724da..93e0a4750b5 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java
@@ -24,11 +24,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParserContext;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.testresources.Inventor;
import org.springframework.expression.spel.testresources.PlaceOfBirth;
@@ -68,6 +71,7 @@ public class SpelDocumentationTests extends ExpressionTestCase {
public Inventor[] Members = new Inventor[1];
public List Members2 = new ArrayList();
public Map officers = new HashMap();
+ @SuppressWarnings("unchecked")
IEEE() {
officers.put("president",pupin);
List linv = new ArrayList();
@@ -85,18 +89,22 @@ public class SpelDocumentationTests extends ExpressionTestCase {
public void setName(String n) { this.name = n; }
}
+ @Test
public void testMethodInvocation() {
evaluate("'Hello World'.concat('!')","Hello World!",String.class);
}
+ @Test
public void testBeanPropertyAccess() {
evaluate("new String('Hello World'.bytes)","Hello World",String.class);
}
+ @Test
public void testArrayLengthAccess() {
evaluate("'Hello World'.bytes.length",11,Integer.class);
}
+ @Test
public void testRootObject() throws Exception {
GregorianCalendar c = new GregorianCalendar();
c.set(1856, 7, 9);
@@ -104,65 +112,70 @@ public class SpelDocumentationTests extends ExpressionTestCase {
// The constructor arguments are name, birthday, and nationaltiy.
Inventor tesla = new Inventor("Nikola Tesla", c.getTime(), "Serbian");
- ExpressionParser parser = new SpelAntlrExpressionParser();
+ ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("name");
EvaluationContext context = new StandardEvaluationContext();
context.setRootObject(tesla);
String name = (String) exp.getValue(context);
- assertEquals("Nikola Tesla",name);
+ Assert.assertEquals("Nikola Tesla",name);
}
+ @Test
public void testEqualityCheck() throws Exception {
- ExpressionParser parser = new SpelAntlrExpressionParser();
+ ExpressionParser parser = new SpelExpressionParser();
EvaluationContext context = new StandardEvaluationContext();
context.setRootObject(tesla);
Expression exp = parser.parseExpression("name == 'Nikola Tesla'");
boolean isEqual = exp.getValue(context, Boolean.class); // evaluates to true
- assertTrue(isEqual);
+ Assert.assertTrue(isEqual);
}
// Section 7.4.1
+ @Test
public void testXMLBasedConfig() {
evaluate("(T(java.lang.Math).random() * 100.0 )>0",true,Boolean.class);
}
// Section 7.5
+ @Test
public void testLiterals() throws Exception {
- ExpressionParser parser = new SpelAntlrExpressionParser();
+ ExpressionParser parser = new SpelExpressionParser();
String helloWorld = (String) parser.parseExpression("'Hello World'").getValue(); // evals to "Hello World"
- assertEquals("Hello World",helloWorld);
+ Assert.assertEquals("Hello World",helloWorld);
double avogadrosNumber = (Double) parser.parseExpression("6.0221415E+23").getValue();
- assertEquals(6.0221415E+23,avogadrosNumber);
+ Assert.assertEquals(6.0221415E+23,avogadrosNumber);
int maxValue = (Integer) parser.parseExpression("0x7FFFFFFF").getValue(); // evals to 2147483647
- assertEquals(Integer.MAX_VALUE,maxValue);
+ Assert.assertEquals(Integer.MAX_VALUE,maxValue);
boolean trueValue = (Boolean) parser.parseExpression("true").getValue();
- assertTrue(trueValue);
+ Assert.assertTrue(trueValue);
Object nullValue = parser.parseExpression("null").getValue();
- assertNull(nullValue);
+ Assert.assertNull(nullValue);
}
+ @Test
public void testPropertyAccess() throws Exception {
EvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
int year = (Integer) parser.parseExpression("Birthdate.Year + 1900").getValue(context); // 1856
- assertEquals(1856,year);
+ Assert.assertEquals(1856,year);
String city = (String) parser.parseExpression("placeOfBirth.City").getValue(context);
- assertEquals("SmilJan",city);
+ Assert.assertEquals("SmilJan",city);
}
+ @Test
public void testPropertyNavigation() throws Exception {
- ExpressionParser parser = new SpelAntlrExpressionParser();
+ ExpressionParser parser = new SpelExpressionParser();
// Inventions Array
StandardEvaluationContext teslaContext = TestScenarioCreator.getTestEvaluationContext();
@@ -170,7 +183,7 @@ public class SpelDocumentationTests extends ExpressionTestCase {
// evaluates to "Induction motor"
String invention = parser.parseExpression("inventions[3]").getValue(teslaContext, String.class);
- assertEquals("Induction motor",invention);
+ Assert.assertEquals("Induction motor",invention);
// Members List
StandardEvaluationContext societyContext = new StandardEvaluationContext();
@@ -180,15 +193,16 @@ public class SpelDocumentationTests extends ExpressionTestCase {
// evaluates to "Nikola Tesla"
String name = parser.parseExpression("Members[0].Name").getValue(societyContext, String.class);
- assertEquals("Nikola Tesla",name);
+ Assert.assertEquals("Nikola Tesla",name);
// List and Array navigation
// evaluates to "Wireless communication"
invention = parser.parseExpression("Members[0].Inventions[6]").getValue(societyContext, String.class);
- assertEquals("Wireless communication",invention);
+ Assert.assertEquals("Wireless communication",invention);
}
+ @Test
public void testDictionaryAccess() throws Exception {
StandardEvaluationContext societyContext = new StandardEvaluationContext();
societyContext.setRootObject(new IEEE());
@@ -200,7 +214,7 @@ public class SpelDocumentationTests extends ExpressionTestCase {
// setting values
Inventor i = parser.parseExpression("officers['advisors'][0]").getValue(societyContext,Inventor.class);
- assertEquals("Nikola Tesla",i.getName());
+ Assert.assertEquals("Nikola Tesla",i.getName());
parser.parseExpression("officers['advisors'][0].PlaceOfBirth.Country").setValue(societyContext, "Croatia");
@@ -208,48 +222,52 @@ public class SpelDocumentationTests extends ExpressionTestCase {
// 7.5.3
+ @Test
public void testMethodInvocation2() throws Exception {
// string literal, evaluates to "bc"
String c = parser.parseExpression("'abc'.substring(1, 3)").getValue(String.class);
- assertEquals("bc",c);
+ Assert.assertEquals("bc",c);
StandardEvaluationContext societyContext = new StandardEvaluationContext();
societyContext.setRootObject(new IEEE());
// evaluates to true
boolean isMember = parser.parseExpression("isMember('Mihajlo Pupin')").getValue(societyContext, Boolean.class);
- assertTrue(isMember);
+ Assert.assertTrue(isMember);
}
// 7.5.4.1
+ @Test
public void testRelationalOperators() throws Exception {
boolean result = parser.parseExpression("2 == 2").getValue(Boolean.class);
- assertTrue(result);
+ Assert.assertTrue(result);
// evaluates to false
result = parser.parseExpression("2 < -5.0").getValue(Boolean.class);
- assertFalse(result);
+ Assert.assertFalse(result);
// evaluates to true
result = parser.parseExpression("'black' < 'block'").getValue(Boolean.class);
- assertTrue(result);
+ Assert.assertTrue(result);
}
+ @Test
public void testOtherOperators() throws Exception {
// evaluates to false
boolean falseValue = parser.parseExpression("'xyz' instanceof T(int)").getValue(Boolean.class);
- assertFalse(falseValue);
+ Assert.assertFalse(falseValue);
// evaluates to true
boolean trueValue = parser.parseExpression("'5.00' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean.class);
- assertTrue(trueValue);
+ Assert.assertTrue(trueValue);
//evaluates to false
falseValue = parser.parseExpression("'5.0067' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean.class);
- assertFalse(falseValue);
+ Assert.assertFalse(falseValue);
}
// 7.5.4.2
+ @Test
public void testLogicalOperators() throws Exception {
StandardEvaluationContext societyContext = new StandardEvaluationContext();
@@ -259,7 +277,7 @@ public class SpelDocumentationTests extends ExpressionTestCase {
// evaluates to false
boolean falseValue = parser.parseExpression("true and false").getValue(Boolean.class);
- assertFalse(falseValue);
+ Assert.assertFalse(falseValue);
// evaluates to true
String expression = "isMember('Nikola Tesla') and isMember('Mihajlo Pupin')";
boolean trueValue = parser.parseExpression(expression).getValue(societyContext, Boolean.class);
@@ -268,71 +286,73 @@ public class SpelDocumentationTests extends ExpressionTestCase {
// evaluates to true
trueValue = parser.parseExpression("true or false").getValue(Boolean.class);
- assertTrue(trueValue);
+ Assert.assertTrue(trueValue);
// evaluates to true
expression = "isMember('Nikola Tesla') or isMember('Albert Einstien')";
trueValue = parser.parseExpression(expression).getValue(societyContext, Boolean.class);
- assertTrue(trueValue);
+ Assert.assertTrue(trueValue);
// -- NOT --
// evaluates to false
falseValue = parser.parseExpression("!true").getValue(Boolean.class);
- assertFalse(falseValue);
+ Assert.assertFalse(falseValue);
// -- AND and NOT --
expression = "isMember('Nikola Tesla') and !isMember('Mihajlo Pupin')";
falseValue = parser.parseExpression(expression).getValue(societyContext, Boolean.class);
- assertFalse(falseValue);
+ Assert.assertFalse(falseValue);
}
// 7.5.4.3
+ @Test
public void testNumericalOperators() throws Exception {
// Addition
int two = parser.parseExpression("1 + 1").getValue(Integer.class); // 2
- assertEquals(2,two);
+ Assert.assertEquals(2,two);
String testString = parser.parseExpression("'test' + ' ' + 'string'").getValue(String.class); // 'test string'
- assertEquals("test string",testString);
+ Assert.assertEquals("test string",testString);
// Subtraction
int four = parser.parseExpression("1 - -3").getValue(Integer.class); // 4
- assertEquals(4,four);
+ Assert.assertEquals(4,four);
double d = parser.parseExpression("1000.00 - 1e4").getValue(Double.class); // -9000
- assertEquals(-9000.0d,d);
+ Assert.assertEquals(-9000.0d,d);
// Multiplication
int six = parser.parseExpression("-2 * -3").getValue(Integer.class); // 6
- assertEquals(6,six);
+ Assert.assertEquals(6,six);
double twentyFour = parser.parseExpression("2.0 * 3e0 * 4").getValue(Double.class); // 24.0
- assertEquals(24.0d,twentyFour);
+ Assert.assertEquals(24.0d,twentyFour);
// Division
int minusTwo = parser.parseExpression("6 / -3").getValue(Integer.class); // -2
- assertEquals(-2,minusTwo);
+ Assert.assertEquals(-2,minusTwo);
double one = parser.parseExpression("8.0 / 4e0 / 2").getValue(Double.class); // 1.0
- assertEquals(1.0d,one);
+ Assert.assertEquals(1.0d,one);
// Modulus
int three = parser.parseExpression("7 % 4").getValue(Integer.class); // 3
- assertEquals(3,three);
+ Assert.assertEquals(3,three);
int oneInt = parser.parseExpression("8 / 5 % 2").getValue(Integer.class); // 1
- assertEquals(1,oneInt);
+ Assert.assertEquals(1,oneInt);
// Operator precedence
int minusTwentyOne = parser.parseExpression("1+2-3*8").getValue(Integer.class); // -21
- assertEquals(-21,minusTwentyOne);
+ Assert.assertEquals(-21,minusTwentyOne);
}
// 7.5.5
+ @Test
public void testAssignment() throws Exception {
Inventor inventor = new Inventor();
StandardEvaluationContext inventorContext = new StandardEvaluationContext();
@@ -340,37 +360,40 @@ public class SpelDocumentationTests extends ExpressionTestCase {
parser.parseExpression("foo").setValue(inventorContext, "Alexander Seovic2");
- assertEquals("Alexander Seovic2",parser.parseExpression("foo").getValue(inventorContext,String.class));
+ Assert.assertEquals("Alexander Seovic2",parser.parseExpression("foo").getValue(inventorContext,String.class));
// alternatively
String aleks = parser.parseExpression("foo = 'Alexandar Seovic'").getValue(inventorContext, String.class);
- assertEquals("Alexandar Seovic",parser.parseExpression("foo").getValue(inventorContext,String.class));
- assertEquals("Alexandar Seovic",aleks);
+ Assert.assertEquals("Alexandar Seovic",parser.parseExpression("foo").getValue(inventorContext,String.class));
+ Assert.assertEquals("Alexandar Seovic",aleks);
}
// 7.5.6
+ @Test
public void testTypes() throws Exception {
Class dateClass = parser.parseExpression("T(java.util.Date)").getValue(Class.class);
- assertEquals(Date.class,dateClass);
+ Assert.assertEquals(Date.class,dateClass);
boolean trueValue = parser.parseExpression("T(java.math.RoundingMode).CEILING < T(java.math.RoundingMode).FLOOR").getValue(Boolean.class);
- assertTrue(trueValue);
+ Assert.assertTrue(trueValue);
}
// 7.5.7
+ @Test
public void testConstructors() throws Exception {
StandardEvaluationContext societyContext = new StandardEvaluationContext();
societyContext.setRootObject(new IEEE());
Inventor einstein =
parser.parseExpression("new org.springframework.expression.spel.testresources.Inventor('Albert Einstein',new java.util.Date(), 'German')").getValue(Inventor.class);
- assertEquals("Albert Einstein", einstein.getName());
+ Assert.assertEquals("Albert Einstein", einstein.getName());
//create new inventor instance within add method of List
parser.parseExpression("Members2.add(new org.springframework.expression.spel.testresources.Inventor('Albert Einstein', 'German'))").getValue(societyContext);
}
// 7.5.8
+ @Test
public void testVariables() throws Exception {
Inventor tesla = new Inventor("Nikola Tesla", "Serbian");
StandardEvaluationContext context = new StandardEvaluationContext();
@@ -380,42 +403,46 @@ public class SpelDocumentationTests extends ExpressionTestCase {
parser.parseExpression("foo = #newName").getValue(context);
- assertEquals("Mike Tesla",tesla.getFoo());
+ Assert.assertEquals("Mike Tesla",tesla.getFoo());
}
+ @SuppressWarnings("unchecked")
+ @Test
public void testSpecialVariables() throws Exception {
// create an array of integers
List primes = new ArrayList();
primes.addAll(Arrays.asList(2,3,5,7,11,13,17));
// create parser and set variable 'primes' as the array of integers
- ExpressionParser parser = new SpelAntlrExpressionParser();
+ ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
context.setVariable("primes",primes);
// all prime numbers > 10 from the list (using selection ?{...})
List primesGreaterThanTen = (List) parser.parseExpression("#primes.?[#this>10]").getValue(context);
- assertEquals("[11, 13, 17]",primesGreaterThanTen.toString());
+ Assert.assertEquals("[11, 13, 17]",primesGreaterThanTen.toString());
}
// 7.5.9
+ @Test
public void testFunctions() throws Exception {
- ExpressionParser parser = new SpelAntlrExpressionParser();
+ ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
context.registerFunction("reverseString",
StringUtils.class.getDeclaredMethod("reverseString", new Class[] { String.class }));
String helloWorldReversed = parser.parseExpression("#reverseString('hello world')").getValue(context, String.class);
- assertEquals("dlrow olleh",helloWorldReversed);
+ Assert.assertEquals("dlrow olleh",helloWorldReversed);
}
// 7.5.10
+ @Test
public void testTernary() throws Exception {
String falseString = parser.parseExpression("false ? 'trueExp' : 'falseExp'").getValue(String.class);
- assertEquals("falseExp",falseString);
+ Assert.assertEquals("falseExp",falseString);
StandardEvaluationContext societyContext = new StandardEvaluationContext();
societyContext.setRootObject(new IEEE());
@@ -428,26 +455,29 @@ public class SpelDocumentationTests extends ExpressionTestCase {
"+ Name + ' Society' : #queryName + ' is not a member of the ' + Name + ' Society'";
String queryResultString = parser.parseExpression(expression).getValue(societyContext, String.class);
- assertEquals("Nikola Tesla is a member of the IEEE Society",queryResultString);
+ Assert.assertEquals("Nikola Tesla is a member of the IEEE Society",queryResultString);
// queryResultString = "Nikola Tesla is a member of the IEEE Society"
}
// 7.5.11
+ @SuppressWarnings("unchecked")
+ @Test
public void testSelection() throws Exception {
StandardEvaluationContext societyContext = new StandardEvaluationContext();
societyContext.setRootObject(new IEEE());
List list = (List) parser.parseExpression("Members2.?[nationality == 'Serbian']").getValue(societyContext);
- assertEquals(1,list.size());
- assertEquals("Nikola Tesla",list.get(0).getName());
+ Assert.assertEquals(1,list.size());
+ Assert.assertEquals("Nikola Tesla",list.get(0).getName());
}
// 7.5.12
+ @Test
public void testTemplating() throws Exception {
String randomPhrase =
parser.parseExpression("random number is ${T(java.lang.Math).random()}", new TemplatedParserContext()).getValue(String.class);
- assertTrue(randomPhrase.startsWith("random number"));
+ Assert.assertTrue(randomPhrase.startsWith("random number"));
}
static class TemplatedParserContext implements ParserContext {
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/SpringEL300Tests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/SpringEL300Tests.java
index 1233bad4e4b..2829b26f46f 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/SpringEL300Tests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/SpringEL300Tests.java
@@ -16,12 +16,15 @@
package org.springframework.expression.spel;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ParserContext;
import org.springframework.expression.PropertyAccessor;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.ReflectivePropertyResolver;
/**
@@ -31,10 +34,12 @@ import org.springframework.expression.spel.support.ReflectivePropertyResolver;
*/
public class SpringEL300Tests extends ExpressionTestCase {
+ @Test
public void testNPE_SPR5661() {
evaluate("joinThreeStrings('a',null,'c')", "anullc", String.class);
}
+ @Test
public void testNPE_SPR5673() throws Exception {
ParserContext hashes = TemplateExpressionParsingTests.HASH_DELIMITED_PARSER_CONTEXT;
ParserContext dollars = TemplateExpressionParsingTests.DEFAULT_TEMPLATE_PARSER_CONTEXT;
@@ -69,20 +74,21 @@ public class SpringEL300Tests extends ExpressionTestCase {
checkTemplateParsingError("Hello ${","No ending suffix '}' for expression starting at character 6: ${");
}
+ @Test
public void testAccessingNullPropertyViaReflection_SPR5663() throws AccessException {
PropertyAccessor propertyAccessor = new ReflectivePropertyResolver();
EvaluationContext context = TestScenarioCreator.getTestEvaluationContext();
- assertFalse(propertyAccessor.canRead(context, null, "abc"));
- assertFalse(propertyAccessor.canWrite(context, null, "abc"));
+ Assert.assertFalse(propertyAccessor.canRead(context, null, "abc"));
+ Assert.assertFalse(propertyAccessor.canWrite(context, null, "abc"));
try {
propertyAccessor.read(context, null, "abc");
- fail("Should have failed with an AccessException");
+ Assert.fail("Should have failed with an AccessException");
} catch (AccessException ae) {
// success
}
try {
propertyAccessor.write(context, null, "abc","foo");
- fail("Should have failed with an AccessException");
+ Assert.fail("Should have failed with an AccessException");
} catch (AccessException ae) {
// success
}
@@ -96,9 +102,9 @@ public class SpringEL300Tests extends ExpressionTestCase {
}
private void checkTemplateParsing(String expression, ParserContext context, String expectedValue) throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
Expression expr = parser.parseExpression(expression,context);
- assertEquals(expectedValue,expr.getValue(TestScenarioCreator.getTestEvaluationContext()));
+ Assert.assertEquals(expectedValue,expr.getValue(TestScenarioCreator.getTestEvaluationContext()));
}
private void checkTemplateParsingError(String expression,String expectedMessage) throws Exception {
@@ -106,15 +112,15 @@ public class SpringEL300Tests extends ExpressionTestCase {
}
private void checkTemplateParsingError(String expression,ParserContext context, String expectedMessage) throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
try {
parser.parseExpression(expression,context);
- fail("Should have failed");
+ Assert.fail("Should have failed");
} catch (Exception e) {
if (!e.getMessage().equals(expectedMessage)) {
e.printStackTrace();
}
- assertEquals(expectedMessage,e.getMessage());
+ Assert.assertEquals(expectedMessage,e.getMessage());
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java
index 4df457ce492..ca37282c514 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java
@@ -17,8 +17,9 @@ package org.springframework.expression.spel;
import java.util.List;
-import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.junit.Test;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.spel.support.StandardTypeLocator;
@@ -27,31 +28,32 @@ import org.springframework.expression.spel.support.StandardTypeLocator;
*
* @author Andy Clement
*/
-public class StandardTypeLocatorTests extends TestCase {
+public class StandardTypeLocatorTests {
+ @Test
public void testImports() throws EvaluationException {
StandardTypeLocator locator = new StandardTypeLocator();
- assertEquals(Integer.class,locator.findType("java.lang.Integer"));
- assertEquals(String.class,locator.findType("java.lang.String"));
+ Assert.assertEquals(Integer.class,locator.findType("java.lang.Integer"));
+ Assert.assertEquals(String.class,locator.findType("java.lang.String"));
List prefixes = locator.getImportPrefixes();
- assertEquals(1,prefixes.size());
- assertTrue(prefixes.contains("java.lang"));
- assertFalse(prefixes.contains("java.util"));
+ Assert.assertEquals(1,prefixes.size());
+ Assert.assertTrue(prefixes.contains("java.lang"));
+ Assert.assertFalse(prefixes.contains("java.util"));
- assertEquals(Boolean.class,locator.findType("Boolean"));
+ Assert.assertEquals(Boolean.class,locator.findType("Boolean"));
// currently does not know about java.util by default
// assertEquals(java.util.List.class,locator.findType("List"));
try {
locator.findType("URL");
- fail("Should have failed");
+ Assert.fail("Should have failed");
} catch (EvaluationException ee) {
- SpelException sEx = (SpelException)ee;
- assertEquals(SpelMessages.TYPE_NOT_FOUND,sEx.getMessageUnformatted());
+ SpelEvaluationException sEx = (SpelEvaluationException)ee;
+ Assert.assertEquals(SpelMessages.TYPE_NOT_FOUND,sEx.getMessageUnformatted());
}
locator.registerImport("java.net");
- assertEquals(java.net.URL.class,locator.findType("URL"));
+ Assert.assertEquals(java.net.URL.class,locator.findType("URL"));
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/TemplateExpressionParsingTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/TemplateExpressionParsingTests.java
index 8f78d224219..318a62882ab 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/TemplateExpressionParsingTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/TemplateExpressionParsingTests.java
@@ -16,12 +16,16 @@
package org.springframework.expression.spel;
+import junit.framework.Assert;
+
+import org.junit.Test;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ParseException;
import org.springframework.expression.ParserContext;
import org.springframework.expression.common.CompositeStringExpression;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
+import org.springframework.expression.common.TemplateParserContext;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
/**
@@ -54,144 +58,162 @@ public class TemplateExpressionParsingTests extends ExpressionTestCase {
}
};
+ @Test
+
public void testParsingSimpleTemplateExpression01() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
Expression expr = parser.parseExpression("hello ${'world'}", DEFAULT_TEMPLATE_PARSER_CONTEXT);
Object o = expr.getValue();
- assertEquals("hello world", o.toString());
+ Assert.assertEquals("hello world", o.toString());
}
+ @Test
public void testParsingSimpleTemplateExpression02() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
Expression expr = parser.parseExpression("hello ${'to'} you", DEFAULT_TEMPLATE_PARSER_CONTEXT);
Object o = expr.getValue();
- assertEquals("hello to you", o.toString());
+ Assert.assertEquals("hello to you", o.toString());
}
+ @Test
public void testParsingSimpleTemplateExpression03() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
Expression expr = parser.parseExpression("The quick ${'brown'} fox jumped over the ${'lazy'} dog",
DEFAULT_TEMPLATE_PARSER_CONTEXT);
Object o = expr.getValue();
- assertEquals("The quick brown fox jumped over the lazy dog", o.toString());
+ Assert.assertEquals("The quick brown fox jumped over the lazy dog", o.toString());
}
+ @Test
public void testParsingSimpleTemplateExpression04() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
Expression expr = parser.parseExpression("${'hello'} world", DEFAULT_TEMPLATE_PARSER_CONTEXT);
Object o = expr.getValue();
- assertEquals("hello world", o.toString());
+ Assert.assertEquals("hello world", o.toString());
expr = parser.parseExpression("", DEFAULT_TEMPLATE_PARSER_CONTEXT);
o = expr.getValue();
- assertEquals("", o.toString());
+ Assert.assertEquals("", o.toString());
expr = parser.parseExpression("abc", DEFAULT_TEMPLATE_PARSER_CONTEXT);
o = expr.getValue();
- assertEquals("abc", o.toString());
+ Assert.assertEquals("abc", o.toString());
}
+ @Test
public void testCompositeStringExpression() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
Expression ex = parser.parseExpression("hello ${'world'}", DEFAULT_TEMPLATE_PARSER_CONTEXT);
checkString("hello world", ex.getValue());
checkString("hello world", ex.getValue(String.class));
EvaluationContext ctx = new StandardEvaluationContext();
checkString("hello world", ex.getValue(ctx));
checkString("hello world", ex.getValue(ctx, String.class));
- assertEquals("hello ${'world'}", ex.getExpressionString());
- assertFalse(ex.isWritable(new StandardEvaluationContext()));
+ Assert.assertEquals("hello ${'world'}", ex.getExpressionString());
+ Assert.assertFalse(ex.isWritable(new StandardEvaluationContext()));
}
+ @Test
public void testNestedExpressions() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
// treat the nested ${..} as a part of the expression
Expression ex = parser.parseExpression("hello ${listOfNumbersUpToTen.$[#this<5]} world",DEFAULT_TEMPLATE_PARSER_CONTEXT);
String s = ex.getValue(TestScenarioCreator.getTestEvaluationContext(),String.class);
- assertEquals("hello 4 world",s);
+ Assert.assertEquals("hello 4 world",s);
// not a useful expression but tests nested expression syntax that clashes with template prefix/suffix
ex = parser.parseExpression("hello ${listOfNumbersUpToTen.$[#root.listOfNumbersUpToTen.$[#this%2==1]==3]} world",DEFAULT_TEMPLATE_PARSER_CONTEXT);
- assertEquals(CompositeStringExpression.class,ex.getClass());
+ Assert.assertEquals(CompositeStringExpression.class,ex.getClass());
CompositeStringExpression cse = (CompositeStringExpression)ex;
Expression[] exprs = cse.getExpressions();
- assertEquals(3,exprs.length);
- assertEquals("listOfNumbersUpToTen.$[#root.listOfNumbersUpToTen.$[#this%2==1]==3]",exprs[1].getExpressionString());
+ Assert.assertEquals(3,exprs.length);
+ Assert.assertEquals("listOfNumbersUpToTen.$[#root.listOfNumbersUpToTen.$[#this%2==1]==3]",exprs[1].getExpressionString());
s = ex.getValue(TestScenarioCreator.getTestEvaluationContext(),String.class);
- assertEquals("hello world",s);
+ Assert.assertEquals("hello world",s);
ex = parser.parseExpression("hello ${listOfNumbersUpToTen.$[#this<5]} ${listOfNumbersUpToTen.$[#this>5]} world",DEFAULT_TEMPLATE_PARSER_CONTEXT);
s = ex.getValue(TestScenarioCreator.getTestEvaluationContext(),String.class);
- assertEquals("hello 4 10 world",s);
+ Assert.assertEquals("hello 4 10 world",s);
try {
ex = parser.parseExpression("hello ${listOfNumbersUpToTen.$[#this<5]} ${listOfNumbersUpToTen.$[#this>5] world",DEFAULT_TEMPLATE_PARSER_CONTEXT);
- fail("Should have failed");
+ Assert.fail("Should have failed");
} catch (ParseException pe) {
- assertEquals("No ending suffix '}' for expression starting at character 41: ${listOfNumbersUpToTen.$[#this>5] world",pe.getMessage());
+ Assert.assertEquals("No ending suffix '}' for expression starting at character 41: ${listOfNumbersUpToTen.$[#this>5] world",pe.getMessage());
}
try {
ex = parser.parseExpression("hello ${listOfNumbersUpToTen.$[#root.listOfNumbersUpToTen.$[#this%2==1==3]} world",DEFAULT_TEMPLATE_PARSER_CONTEXT);
- fail("Should have failed");
+ Assert.fail("Should have failed");
} catch (ParseException pe) {
- assertEquals("Found closing '}' at position 74 but most recent opening is '[' at position 30",pe.getMessage());
+ Assert.assertEquals("Found closing '}' at position 74 but most recent opening is '[' at position 30",pe.getMessage());
}
}
+ @Test
+
public void testClashingWithSuffixes() throws Exception {
// Just wanting to use the prefix or suffix within the template:
Expression ex = parser.parseExpression("hello ${3+4} world",DEFAULT_TEMPLATE_PARSER_CONTEXT);
String s = ex.getValue(TestScenarioCreator.getTestEvaluationContext(),String.class);
- assertEquals("hello 7 world",s);
+ Assert.assertEquals("hello 7 world",s);
ex = parser.parseExpression("hello ${3+4} wo${'${'}rld",DEFAULT_TEMPLATE_PARSER_CONTEXT);
s = ex.getValue(TestScenarioCreator.getTestEvaluationContext(),String.class);
- assertEquals("hello 7 wo${rld",s);
+ Assert.assertEquals("hello 7 wo${rld",s);
ex = parser.parseExpression("hello ${3+4} wo}rld",DEFAULT_TEMPLATE_PARSER_CONTEXT);
s = ex.getValue(TestScenarioCreator.getTestEvaluationContext(),String.class);
- assertEquals("hello 7 wo}rld",s);
+ Assert.assertEquals("hello 7 wo}rld",s);
}
+ @Test
public void testParsingNormalExpressionThroughTemplateParser() throws Exception {
Expression expr = parser.parseExpression("1+2+3");
- assertEquals(6,expr.getValue());
+ Assert.assertEquals(6,expr.getValue());
expr = parser.parseExpression("1+2+3",null);
- assertEquals(6,expr.getValue());
+ Assert.assertEquals(6,expr.getValue());
}
+ @Test
public void testErrorCases() throws Exception {
try {
parser.parseExpression("hello ${'world'", DEFAULT_TEMPLATE_PARSER_CONTEXT);
- fail("Should have failed");
+ Assert.fail("Should have failed");
} catch (ParseException pe) {
- assertEquals("No ending suffix '}' for expression starting at character 6: ${'world'",pe.getMessage());
- assertEquals("hello ${'world'",pe.getExpressionString());
+ Assert.assertEquals("No ending suffix '}' for expression starting at character 6: ${'world'",pe.getMessage());
+ Assert.assertEquals("hello ${'world'",pe.getExpressionString());
}
try {
parser.parseExpression("hello ${'wibble'${'world'}", DEFAULT_TEMPLATE_PARSER_CONTEXT);
- fail("Should have failed");
+ Assert.fail("Should have failed");
} catch (ParseException pe) {
- assertEquals("No ending suffix '}' for expression starting at character 6: ${'wibble'${'world'}",pe.getMessage());
+ Assert.assertEquals("No ending suffix '}' for expression starting at character 6: ${'wibble'${'world'}",pe.getMessage());
}
try {
parser.parseExpression("hello ${} world", DEFAULT_TEMPLATE_PARSER_CONTEXT);
- fail("Should have failed");
+ Assert.fail("Should have failed");
} catch (ParseException pe) {
- assertEquals("No expression defined within delimiter '${}' at character 6",pe.getMessage());
+ Assert.assertEquals("No expression defined within delimiter '${}' at character 6",pe.getMessage());
}
}
-
+ @Test
+ public void testTemplateParserContext() {
+ TemplateParserContext tpc = new TemplateParserContext("abc","def");
+ Assert.assertEquals("abc", tpc.getExpressionPrefix());
+ Assert.assertEquals("def", tpc.getExpressionSuffix());
+ Assert.assertTrue(tpc.isTemplate());
+ }
+
// ---
private void checkString(String expectedString, Object value) {
if (!(value instanceof String)) {
- fail("Result was not a string, it was of type " + value.getClass() + " (value=" + value + ")");
+ Assert.fail("Result was not a string, it was of type " + value.getClass() + " (value=" + value + ")");
}
if (!value.equals(expectedString)) {
- fail("Did not get expected result. Should have been '" + expectedString + "' but was '" + value + "'");
+ Assert.fail("Did not get expected result. Should have been '" + expectedString + "' but was '" + value + "'");
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java
index bb8f4216a03..c5969c79304 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java
@@ -16,7 +16,10 @@
package org.springframework.expression.spel;
-import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser;
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
@@ -27,27 +30,32 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*/
public class VariableAndFunctionTests extends ExpressionTestCase {
+ @Test
public void testVariableAccess01() {
evaluate("#answer", "42", Integer.class, SHOULD_BE_WRITABLE);
evaluate("#answer / 2", 21, Integer.class, SHOULD_NOT_BE_WRITABLE);
}
+ @Test
public void testVariableAccess_WellKnownVariables() {
evaluate("#this.getName()","Nikola Tesla",String.class);
evaluate("#root.getName()","Nikola Tesla",String.class);
}
+ @Test
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, 1, 1, 3);
+ evaluateAndCheckError("#reverseInt(1)", SpelMessages.INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION, 0, 1, 3);
}
+ @Test
public void testFunctionAccess02() {
evaluate("#reverseString('hello')", "olleh", String.class);
evaluate("#reverseString(37)", "73", String.class); // requires type conversion of 37 to '37'
}
+ @Test
public void testCallVarargsFunction() {
evaluate("#varargsFunctionReverseStringsAndMerge('a','b','c')", "cba", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge('a')", "a", String.class);
@@ -61,18 +69,19 @@ public class VariableAndFunctionTests extends ExpressionTestCase {
evaluate("#varargsFunctionReverseStringsAndMerge2(5,25)", "525", String.class);
}
+ @Test
public void testCallingIllegalFunctions() throws Exception {
- SpelAntlrExpressionParser parser = new SpelAntlrExpressionParser();
+ SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.setVariable("notStatic", this.getClass().getMethod("nonStatic"));
try {
@SuppressWarnings("unused")
Object v = parser.parseExpression("#notStatic()").getValue(ctx);
- fail("Should have failed with exception - cannot call non static method that way");
- } catch (SpelException se) {
+ 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) {
se.printStackTrace();
- fail("Should have failed a message about the function needing to be static, not: "
+ Assert.fail("Should have failed a message about the function needing to be static, not: "
+ se.getMessageUnformatted());
}
}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java
new file mode 100644
index 00000000000..1f926f891ce
--- /dev/null
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java
@@ -0,0 +1,358 @@
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.springframework.expression.spel.standard;
+import junit.framework.Assert;
+
+import org.junit.Test;
+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.SpelNode;
+import org.springframework.expression.spel.SpelParseException;
+import org.springframework.expression.spel.ast.OperatorAnd;
+import org.springframework.expression.spel.ast.OperatorOr;
+
+
+public class SpelParserTests {
+
+ @Test
+ public void theMostBasic() throws EvaluationException,ParseException {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ SpelExpression expr = parser.parse("2");
+ Assert.assertNotNull(expr);
+ Assert.assertNotNull(expr.getAST());
+ Assert.assertEquals(2,expr.getValue());
+ Assert.assertEquals(Integer.class,expr.getValueType());
+ }
+
+ @Test
+ public void whitespace() throws EvaluationException,ParseException {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ SpelExpression expr = parser.parse("2 + 3");
+ Assert.assertEquals(5,expr.getValue());
+ expr = parser.parse("2 + 3");
+ Assert.assertEquals(5,expr.getValue());
+ expr = parser.parse("2\n+ 3");
+ Assert.assertEquals(5,expr.getValue());
+ expr = parser.parse("2\r\n+\t3");
+ Assert.assertEquals(5,expr.getValue());
+ }
+
+ @Test
+ public void arithmeticPlus1() throws EvaluationException,ParseException {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ SpelExpression expr = parser.parse("2+2");
+ Assert.assertNotNull(expr);
+ Assert.assertNotNull(expr.getAST());
+ Assert.assertEquals(4,expr.getValue());
+ }
+
+ @Test
+ public void arithmeticPlus2() throws EvaluationException,ParseException {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ SpelExpression expr = parser.parse("37+41");
+ Assert.assertEquals(78,expr.getValue());
+ }
+
+ @Test
+ public void arithmeticMultiply1() throws EvaluationException,ParseException {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ SpelExpression expr = parser.parse("2*3");
+ Assert.assertNotNull(expr);
+ Assert.assertNotNull(expr.getAST());
+// printAst(expr.getAST(),0);
+ Assert.assertEquals(6,expr.getValue());
+ }
+
+ @Test
+ public void arithmeticPrecedence1() throws EvaluationException,ParseException {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ SpelExpression expr = parser.parse("2*3+5");
+ Assert.assertEquals(11,expr.getValue());
+ }
+
+ @Test
+ public void generalExpressions() throws Exception {
+ try {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ parser.parse("new String[3]");
+ Assert.fail();
+ } catch (ParseException e) {
+ Assert.assertTrue(e instanceof SpelParseException);
+ SpelParseException spe = (SpelParseException)e;
+ Assert.assertEquals(SpelMessages.MISSING_CONSTRUCTOR_ARGS,spe.getMessageUnformatted());
+ Assert.assertEquals(10,spe.getPosition());
+ }
+ try {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ parser.parse("new String");
+ Assert.fail();
+ } catch (ParseException e) {
+ Assert.assertTrue(e instanceof SpelParseException);
+ SpelParseException spe = (SpelParseException)e;
+ Assert.assertEquals(SpelMessages.MISSING_CONSTRUCTOR_ARGS,spe.getMessageUnformatted());
+ Assert.assertEquals(10,spe.getPosition());
+ }
+ try {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ parser.parse("new String(3,");
+ Assert.fail();
+ } catch (ParseException e) {
+ Assert.assertTrue(e instanceof SpelParseException);
+ SpelParseException spe = (SpelParseException)e;
+ Assert.assertEquals(SpelMessages.RUN_OUT_OF_ARGUMENTS,spe.getMessageUnformatted());
+ Assert.assertEquals(10,spe.getPosition());
+ }
+ try {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ parser.parse("new String(3");
+ Assert.fail();
+ } catch (ParseException e) {
+ Assert.assertTrue(e instanceof SpelParseException);
+ SpelParseException spe = (SpelParseException)e;
+ Assert.assertEquals(SpelMessages.RUN_OUT_OF_ARGUMENTS,spe.getMessageUnformatted());
+ Assert.assertEquals(10,spe.getPosition());
+ }
+ try {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ parser.parse("new String(");
+ Assert.fail();
+ } catch (ParseException e) {
+ Assert.assertTrue(e instanceof SpelParseException);
+ SpelParseException spe = (SpelParseException)e;
+ Assert.assertEquals(SpelMessages.RUN_OUT_OF_ARGUMENTS,spe.getMessageUnformatted());
+ Assert.assertEquals(10,spe.getPosition());
+ }
+ try {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ parser.parse("\"abc");
+ Assert.fail();
+ } catch (ParseException e) {
+ Assert.assertTrue(e instanceof SpelParseException);
+ SpelParseException spe = (SpelParseException)e;
+ Assert.assertEquals(SpelMessages.NON_TERMINATING_DOUBLE_QUOTED_STRING,spe.getMessageUnformatted());
+ Assert.assertEquals(0,spe.getPosition());
+ }
+ try {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ parser.parse("'abc");
+ Assert.fail();
+ } catch (ParseException e) {
+ Assert.assertTrue(e instanceof SpelParseException);
+ SpelParseException spe = (SpelParseException)e;
+ Assert.assertEquals(SpelMessages.NON_TERMINATING_QUOTED_STRING,spe.getMessageUnformatted());
+ Assert.assertEquals(0,spe.getPosition());
+ }
+
+ }
+
+ @Test
+ public void arithmeticPrecedence2() throws EvaluationException,ParseException {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ SpelExpression expr = parser.parse("2+3*5");
+ Assert.assertEquals(17,expr.getValue());
+ }
+
+ @Test
+ public void arithmeticPrecedence3() throws EvaluationException,ParseException {
+ SpelExpression expr = new SpelExpressionParser().parse("3+10/2");
+ Assert.assertEquals(8,expr.getValue());
+ }
+
+ @Test
+ public void arithmeticPrecedence4() throws EvaluationException,ParseException {
+ SpelExpression expr = new SpelExpressionParser().parse("10/2+3");
+ Assert.assertEquals(8,expr.getValue());
+ }
+
+ @Test
+ public void arithmeticPrecedence5() throws EvaluationException,ParseException {
+ SpelExpression expr = new SpelExpressionParser().parse("(4+10)/2");
+ Assert.assertEquals(7,expr.getValue());
+ }
+
+ @Test
+ public void arithmeticPrecedence6() throws EvaluationException,ParseException {
+ SpelExpression expr = new SpelExpressionParser().parse("(3+2)*2");
+ Assert.assertEquals(10,expr.getValue());
+ }
+
+ @Test
+ public void booleanOperators() throws EvaluationException,ParseException {
+ SpelExpression expr = new SpelExpressionParser().parse("true");
+ Assert.assertEquals(Boolean.TRUE,expr.getValue(Boolean.class));
+ expr = new SpelExpressionParser().parse("false");
+ Assert.assertEquals(Boolean.FALSE,expr.getValue(Boolean.class));
+ expr = new SpelExpressionParser().parse("false and false");
+ Assert.assertEquals(Boolean.FALSE,expr.getValue(Boolean.class));
+ expr = new SpelExpressionParser().parse("true and (true or false)");
+ Assert.assertEquals(Boolean.TRUE,expr.getValue(Boolean.class));
+ expr = new SpelExpressionParser().parse("true and true or false");
+ Assert.assertEquals(Boolean.TRUE,expr.getValue(Boolean.class));
+ expr = new SpelExpressionParser().parse("!true");
+ Assert.assertEquals(Boolean.FALSE,expr.getValue(Boolean.class));
+ expr = new SpelExpressionParser().parse("!(false or true)");
+ Assert.assertEquals(Boolean.FALSE,expr.getValue(Boolean.class));
+ }
+
+ @Test
+ public void testStringLiterals() throws EvaluationException,ParseException {
+ SpelExpression expr = new SpelExpressionParser().parse("'howdy'");
+ Assert.assertEquals("howdy",expr.getValue());
+ expr = new SpelExpressionParser().parse("'hello '' world'");
+ Assert.assertEquals("hello ' world",expr.getValue());
+ }
+
+ @Test
+ public void testStringLiterals2() throws EvaluationException,ParseException {
+ SpelExpression expr = new SpelExpressionParser().parse("'howdy'.substring(0,2)");
+ Assert.assertEquals("ho",expr.getValue());
+ }
+
+ @Test
+ public void testPositionalInformation() throws EvaluationException, ParseException {
+ SpelExpression expr = new SpelExpressionParser().parse("true and true or false");
+ SpelNode rootAst = expr.getAST();
+ OperatorOr operatorOr = (OperatorOr)rootAst;
+ OperatorAnd operatorAnd = (OperatorAnd)operatorOr.getLeftOperand();
+ SpelNode rightOrOperand = operatorOr.getRightOperand();
+
+ // check position for final 'false'
+ Assert.assertEquals(17, rightOrOperand.getStartPosition());
+ Assert.assertEquals(22, rightOrOperand.getEndPosition());
+
+ // check position for first 'true'
+ Assert.assertEquals(0, operatorAnd.getLeftOperand().getStartPosition());
+ Assert.assertEquals(4, operatorAnd.getLeftOperand().getEndPosition());
+
+ // check position for second 'true'
+ Assert.assertEquals(9, operatorAnd.getRightOperand().getStartPosition());
+ Assert.assertEquals(13, operatorAnd.getRightOperand().getEndPosition());
+
+ // check position for OperatorAnd
+ Assert.assertEquals(5, operatorAnd.getStartPosition());
+ Assert.assertEquals(8, operatorAnd.getEndPosition());
+
+ // check position for OperatorOr
+ Assert.assertEquals(14, operatorOr.getStartPosition());
+ Assert.assertEquals(16, operatorOr.getEndPosition());
+ }
+
+ @Test
+ public void testTokenKind() {
+ TokenKind tk = TokenKind.BANG;
+ Assert.assertFalse(tk.hasPayload());
+ Assert.assertEquals("BANG(!)",tk.toString());
+
+ tk = TokenKind.MINUS;
+ Assert.assertFalse(tk.hasPayload());
+ Assert.assertEquals("MINUS(-)",tk.toString());
+
+ tk = TokenKind.LITERAL_STRING;
+ Assert.assertEquals("LITERAL_STRING",tk.toString());
+ Assert.assertTrue(tk.hasPayload());
+ }
+
+ @Test
+ public void testToken() {
+ Token token = new Token(TokenKind.BANG,0,3);
+ Assert.assertEquals(TokenKind.BANG,token.kind);
+ Assert.assertEquals(0,token.startpos);
+ Assert.assertEquals(3,token.endpos);
+ Assert.assertEquals("[BANG(!)](0,3)",token.toString());
+
+ token = new Token(TokenKind.LITERAL_STRING,"abc".toCharArray(),0,3);
+ Assert.assertEquals(TokenKind.LITERAL_STRING,token.kind);
+ Assert.assertEquals(0,token.startpos);
+ Assert.assertEquals(3,token.endpos);
+ Assert.assertEquals("[LITERAL_STRING:abc](0,3)",token.toString());
+ }
+
+ @Test
+ public void testExceptions() {
+ ExpressionException exprEx = new ExpressionException("test");
+ Assert.assertEquals("test", exprEx.getMessage());
+ Assert.assertEquals("test", exprEx.toDetailedString());
+
+ exprEx = new ExpressionException("wibble","test");
+ Assert.assertEquals("test", exprEx.getMessage());
+ Assert.assertEquals("Expression 'wibble': test", exprEx.toDetailedString());
+
+ exprEx = new ExpressionException("wibble",3, "test");
+ Assert.assertEquals("test", exprEx.getMessage());
+ Assert.assertEquals("Expression 'wibble' @ 3: test", exprEx.toDetailedString());
+ }
+
+ @Test
+ public void testNumerics() {
+ checkNumber("2",2,Integer.class);
+ checkNumber("22",22,Integer.class);
+ checkNumber("+22",22,Integer.class);
+ checkNumber("-22",-22,Integer.class);
+
+ checkNumber("2L",2L,Long.class);
+ checkNumber("22l",22L,Long.class);
+
+ checkNumber("0x1",1,Integer.class);
+ checkNumber("0x1L",1L,Long.class);
+ checkNumber("0xa",10,Integer.class);
+ checkNumber("0xAL",10L,Long.class);
+
+ checkNumberError("0x",SpelMessages.NOT_AN_INTEGER);
+ checkNumberError("0xL",SpelMessages.NOT_A_LONG);
+
+ checkNumberError(".324",SpelMessages.UNEXPECTED_DATA_AFTER_DOT);
+
+ checkNumberError("3.4L",SpelMessages.REAL_CANNOT_BE_LONG);
+
+ // Number is parsed as a float, but immediately promoted to a double
+ checkNumber("3.5f",3.5d,Double.class);
+
+ checkNumber("1.2e3", 1.2e3d, Double.class);
+ checkNumber("1.2e+3", 1.2e3d, Double.class);
+ checkNumber("1.2e-3", 1.2e-3d, Double.class);
+ checkNumber("1.2e3", 1.2e3d, Double.class);
+ checkNumber("1.e+3", 1.e3d, Double.class);
+ checkNumber("1e+3", 1e3d, Double.class);
+ }
+
+ private void checkNumber(String expression, Object value, Class> type) {
+ try {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ SpelExpression expr = parser.parse(expression);
+ Object o = expr.getValue();
+ Assert.assertEquals(value,o);
+ Assert.assertEquals(type,o.getClass());
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ private void checkNumberError(String expression, SpelMessages expectedMessage) {
+ try {
+ SpelExpressionParser parser = new SpelExpressionParser();
+ parser.parse(expression);
+ Assert.fail();
+ } catch (ParseException e) {
+ Assert.assertTrue(e instanceof SpelParseException);
+ SpelParseException spe = (SpelParseException)e;
+ Assert.assertEquals(expectedMessage,spe.getMessageUnformatted());
+ }
+ }
+}
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/support/StandardComponentsTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/support/StandardComponentsTests.java
new file mode 100644
index 00000000000..c1c670b3a54
--- /dev/null
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/support/StandardComponentsTests.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.springframework.expression.spel.support;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.core.convert.support.DefaultTypeConverter;
+import org.springframework.expression.EvaluationException;
+import org.springframework.expression.Operation;
+import org.springframework.expression.OperatorOverloader;
+import org.springframework.expression.TypeComparator;
+import org.springframework.expression.TypeConverter;
+import org.springframework.expression.TypeLocator;
+
+public class StandardComponentsTests {
+
+ @Test
+ public void testStandardEvaluationContext() {
+ StandardEvaluationContext context = new StandardEvaluationContext();
+ Assert.assertNotNull(context.getTypeComparator());
+
+ TypeComparator tc = new StandardTypeComparator();
+ context.setTypeComparator(tc);
+ Assert.assertEquals(tc,context.getTypeComparator());
+
+ TypeLocator tl = new StandardTypeLocator();
+ context.setTypeLocator(tl);
+ Assert.assertEquals(tl,context.getTypeLocator());
+ }
+
+ @Test
+ public void testStandardOperatorOverloader() throws EvaluationException {
+ OperatorOverloader oo = new StandardOperatorOverloader();
+ Assert.assertFalse(oo.overridesOperation(Operation.ADD, null, null));
+ try {
+ oo.operate(Operation.ADD, 2, 3);
+ Assert.fail("should have failed");
+ } catch (EvaluationException e) {
+ // success
+ }
+ }
+
+ @Test
+ public void testStandardTypeLocator() {
+ StandardTypeLocator tl = new StandardTypeLocator();
+ List prefixes = tl.getImportPrefixes();
+ Assert.assertEquals(1,prefixes.size());
+ tl.registerImport("java.util");
+ prefixes = tl.getImportPrefixes();
+ Assert.assertEquals(2,prefixes.size());
+ tl.removeImport("java.util");
+ prefixes = tl.getImportPrefixes();
+ Assert.assertEquals(1,prefixes.size());
+ }
+
+ @Test
+ public void testStandardTypeConverter() throws EvaluationException {
+ TypeConverter tc = new StandardTypeConverter(new DefaultTypeConverter());
+ tc.convertValue(3,Double.class);
+ }
+
+
+}
+
diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/testresources/ArrayContainer.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/testresources/ArrayContainer.java
index 169d66327f8..fa6d62f444c 100644
--- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/testresources/ArrayContainer.java
+++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/testresources/ArrayContainer.java
@@ -1,7 +1,19 @@
-/**
- *
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-package org.springframework.expression.spel.testresources;
+ package org.springframework.expression.spel.testresources;
/**
* Hold the various kinds of primitive array for access through the test evaluation context.