Author: sebb
Date: Fri Dec 2 22:12:42 2011
New Revision: 1209727
URL: http://svn.apache.org/viewvc?rev=1209727&view=rev
Log:
Binary compatibilty fixes
Modified:
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/Interpreter.java
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java
Modified:
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/Interpreter.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/Interpreter.java?rev=1209727&r1=1209726&r2=1209727&view=diff
==============================================================================
---
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/Interpreter.java
(original)
+++
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/Interpreter.java
Fri Dec 2 22:12:42 2011
@@ -27,6 +27,8 @@ import java.util.Set;
import org.apache.commons.jexl2.parser.SimpleNode;
import org.apache.commons.logging.Log;
+import org.apache.commons.jexl2.parser.ASTFloatLiteral;
+import org.apache.commons.jexl2.parser.ASTIntegerLiteral;
import org.apache.commons.jexl2.parser.JexlNode;
import org.apache.commons.jexl2.parser.ASTAdditiveNode;
import org.apache.commons.jexl2.parser.ASTAdditiveOperator;
@@ -103,9 +105,9 @@ public class Interpreter implements Pars
protected Map<String, Object> functors;
/** The context to store/retrieve variables. */
protected final JexlContext context;
- /** Strict interpreter flag. Do not modify; will be made final in a later
version. */
+ /** Strict interpreter flag. Do not modify; will be made final/private in
a later version. */
protected boolean strict;
- /** Silent intepreter flag. Do not modify; will be made final in a later
version. */
+ /** Silent intepreter flag. Do not modify; will be made final/private in
a later version. */
protected boolean silent;
/** Cache executors. */
protected final boolean cache;
@@ -879,6 +881,22 @@ public class Interpreter implements Pars
}
}
+ /**
+ * @deprecated Do not use
+ */
+ @Deprecated
+ public Object visit(ASTFloatLiteral node, Object data) {
+ throw new UnsupportedOperationException("Method should not be called;
only present for API compatibiltiy");
+ }
+
+ /**
+ * @deprecated Do not use
+ */
+ @Deprecated
+ public Object visit(ASTIntegerLiteral node, Object data) {
+ throw new UnsupportedOperationException("Method should not be called;
only present for API compatibiltiy");
+ }
+
/** {@inheritDoc} */
public Object visit(ASTVar node, Object data) {
return visit((ASTIdentifier) node, data);
Modified:
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java?rev=1209727&r1=1209726&r2=1209727&view=diff
==============================================================================
---
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
(original)
+++
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
Fri Dec 2 22:12:42 2011
@@ -57,9 +57,10 @@ public class JexlArithmetic {
* @since 2.1
*/
protected static final int BIGD_SCALE = -1;
- /** Whether this JexlArithmetic instance behaves in strict or lenient
mode. */
- /** @deprecated : will become final in next version. */
- protected boolean strict;
+ /** Whether this JexlArithmetic instance behaves in strict or lenient mode.
+ * May be made final in a later version.
+ */
+ private volatile boolean strict;
/**
* The big decimal math context.
* @since 2.1
@@ -98,10 +99,11 @@ public class JexlArithmetic {
* null is used as an operand.
* <p>This method is <em>not</em> thread safe; it may be called as an
optional step by the JexlEngine
* in its initialization code before expression creation &
evaluation.</p>
+ * @see JexlEngine#setLenient
* @see JexlEngine#setSilent
* @see JexlEngine#setDebug
* @param flag true means no JexlException will occur, false allows them
- * @deprecated as of 2.1
+ * @deprecated as of 2.1 - may be removed in a later release
*/
@Deprecated
void setLenient(boolean flag) {
Modified:
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java?rev=1209727&r1=1209726&r2=1209727&view=diff
==============================================================================
---
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java
(original)
+++
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlEngine.java
Fri Dec 2 22:12:42 2011
@@ -154,23 +154,22 @@ public class JexlEngine {
* Whether expressions evaluated by this engine will throw exceptions
(false) or
* return null (true) on errors. Default is false.
*/
- protected boolean silent = false;
- /**
- * Whether this engine is in lenient or strict mode; if unspecified, use
the arithmetic lenient property.
- * Provision for version after 2.1.
- */
- // protected Boolean strict = null;
+ // TODO could this be private?
+ protected volatile boolean silent = false;
/**
* Whether error messages will carry debugging information.
*/
- protected boolean debug = true;
+ // TODO could this be private?
+ protected volatile boolean debug = true;
/**
* The map of 'prefix:function' to object implementing the functions.
*/
+ // TODO this could probably be private; is it threadsafe?
protected Map<String, Object> functions = Collections.emptyMap();
/**
* The expression cache.
*/
+ // TODO is this thread-safe? Could it be made private?
protected SoftCache<String, ASTJexlScript> cache = null;
/**
* The default cache load factor.
@@ -279,11 +278,11 @@ public class JexlEngine {
/**
* Sets whether this engine considers unknown variables, methods and
constructors as errors or evaluates them
- * as null.
+ * as null or zero.
* <p>This method is <em>not</em> thread safe; it should be called as an
optional step of the JexlEngine
* initialization code before expression creation & evaluation.</p>
- * <p>After 2.1, you will need a JexlThreadedArithmetic instance for this
call to also modify the JexlArithmetic
- * leniency behavior.</p>
+ * <p>As of 2.1, you can use a JexlThreadedArithmetic instance to allow
the JexlArithmetic
+ * leniency behavior to be independently specified per thread, whilst
still using a single engine.</p>
* @see JexlEngine#setSilent
* @see JexlEngine#setDebug
* @param flag true means no JexlException will occur, false allows them
@@ -293,24 +292,23 @@ public class JexlEngine {
if (arithmetic instanceof JexlThreadedArithmetic) {
JexlThreadedArithmetic.setLenient(Boolean.valueOf(flag));
} else {
- //strict = flag ? Boolean.FALSE : Boolean.TRUE;
this.arithmetic.setLenient(flag);
}
}
/**
* Checks whether this engine considers unknown variables, methods and
constructors as errors.
- * <p>If not explicitly set, the arithmetic leniency value applies.</p>
* @return true if lenient, false if strict
*/
public boolean isLenient() {
- //return strict == null ? arithmetic.isLenient() :
!strict.booleanValue();
- return this.arithmetic.isLenient();
+ return arithmetic.isLenient();
}
/**
* Sets whether this engine behaves in strict or lenient mode.
* Equivalent to setLenient(!flag).
+ * <p>This method is <em>not</em> thread safe; it should be called as an
optional step of the JexlEngine
+ * initialization code before expression creation & evaluation.</p>
* @param flag true for strict, false for lenient
* @since 2.1
*/
@@ -459,6 +457,26 @@ public class JexlEngine {
* This method parses the script which validates the syntax.
*
* @param scriptText A String containing valid JEXL syntax
+ * @param info An info structure to carry debugging information if needed
+ * @return A {@link Script} which can be executed using a {@link
JexlContext}.
+ * @throws JexlException if there is a problem parsing the script.
+ * @deprecated Use {@link #createScript(String, JexlInfo, String[])}
+ */
+ @Deprecated
+ public Script createScript(String scriptText, JexlInfo info) {
+ if (scriptText == null) {
+ throw new NullPointerException("scriptText is null");
+ }
+ // Parse the expression
+ ASTJexlScript tree = parse(scriptText, info);
+ return createScript(tree, scriptText);
+ }
+
+ /**
+ * Creates a Script from a String containing valid JEXL syntax.
+ * This method parses the script which validates the syntax.
+ *
+ * @param scriptText A String containing valid JEXL syntax
* @param names the script parameter names
* @return A {@link Script} which can be executed using a {@link
JexlContext}.
* @throws JexlException if there is a problem parsing the script.
@@ -1187,6 +1205,19 @@ public class JexlEngine {
* Parses an expression.
* @param expression the expression to parse
* @param info debug information structure
+ * @return the parsed tree
+ * @throws JexlException if any error occured during parsing
+ * @deprecated Use {@link #parse(CharSequence, JexlInfo, Scope)} instead
+ */
+ @Deprecated
+ protected ASTJexlScript parse(CharSequence expression, JexlInfo info) {
+ return parse(expression, info, null);
+ }
+
+ /**
+ * Parses an expression.
+ * @param expression the expression to parse
+ * @param info debug information structure
* @param frame the script frame to use
* @return the parsed tree
* @throws JexlException if any error occured during parsing
Modified:
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java?rev=1209727&r1=1209726&r2=1209727&view=diff
==============================================================================
---
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java
(original)
+++
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/UnifiedJEXL.java
Fri Dec 2 22:12:42 2011
@@ -276,10 +276,11 @@ public final class UnifiedJEXL {
/**
* Formats this expression, adding its source string representation in
* comments if available: 'expression /*= source *\/'' .
+ * <b>Note:</b> do not override; will be made final in a future
release.
* @return the formatted expression string
*/
@Override
- public final String toString() {
+ public String toString() {
StringBuilder strb = new StringBuilder();
asString(strb);
if (source != this) {
@@ -343,11 +344,12 @@ public final class UnifiedJEXL {
* <p>
* If the underlying JEXL engine is silent, errors will be logged
through its logger as warning.
* </p>
+ * <b>Note:</b> do not override; will be made final in a future
release.
* @param context the context to use for immediate expression
evaluations
* @return an expression or null if an error occurs and the {@link
JexlEngine} is running in silent mode
* @throws UnifiedJEXL.Exception if an error occurs and the {@link
JexlEngine} is not in silent mode
*/
- public final Expression prepare(JexlContext context) {
+ public Expression prepare(JexlContext context) {
try {
Interpreter interpreter = new Interpreter(jexl, context,
!jexl.isLenient(), jexl.isSilent());
if (context instanceof TemplateContext) {
@@ -369,12 +371,13 @@ public final class UnifiedJEXL {
* <p>
* If the underlying JEXL engine is silent, errors will be logged
through its logger as warning.
* </p>
+ * <b>Note:</b> do not override; will be made final in a future
release.
* @param context the variable context
* @return the result of this expression evaluation or null if an
error occurs and the {@link JexlEngine} is
* running in silent mode
* @throws UnifiedJEXL.Exception if an error occurs and the {@link
JexlEngine} is not silent
*/
- public final Object evaluate(JexlContext context) {
+ public Object evaluate(JexlContext context) {
try {
Interpreter interpreter = new Interpreter(jexl, context,
!jexl.isLenient(), jexl.isSilent());
if (context instanceof TemplateContext) {