This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
The following commit(s) were added to refs/heads/master by this push: new 9bfab54 Remove trailing whitespace. 9bfab54 is described below commit 9bfab54c4a2d5a99b89f2a07d5f5ca8b575a983b Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Feb 28 09:36:05 2021 -0500 Remove trailing whitespace. --- .../org/apache/commons/jexl3/JexlArithmetic.java | 24 +++---- .../java/org/apache/commons/jexl3/JexlBuilder.java | 38 +++++------ .../java/org/apache/commons/jexl3/JexlContext.java | 10 +-- .../org/apache/commons/jexl3/JexlFeatures.java | 14 ++-- .../java/org/apache/commons/jexl3/JexlInfo.java | 22 +++---- .../java/org/apache/commons/jexl3/JexlOptions.java | 50 +++++++-------- .../java/org/apache/commons/jexl3/MapContext.java | 2 +- .../org/apache/commons/jexl3/internal/Engine.java | 18 +++--- .../apache/commons/jexl3/internal/Interpreter.java | 16 ++--- .../commons/jexl3/internal/InterpreterBase.java | 48 +++++++------- .../apache/commons/jexl3/internal/Operators.java | 4 +- .../org/apache/commons/jexl3/internal/Script.java | 6 +- .../commons/jexl3/internal/TemplateDebugger.java | 6 +- .../internal/introspection/AbstractExecutor.java | 2 +- .../internal/introspection/ConstructorMethod.java | 2 +- .../internal/introspection/DuckGetExecutor.java | 2 +- .../internal/introspection/DuckSetExecutor.java | 2 +- .../jexl3/internal/introspection/IndexedType.java | 4 +- .../commons/jexl3/introspection/JexlMethod.java | 6 +- .../jexl3/introspection/JexlPropertyGet.java | 6 +- .../jexl3/introspection/JexlPropertySet.java | 6 +- .../commons/jexl3/parser/ASTForeachStatement.java | 2 +- .../apache/commons/jexl3/parser/ASTIdentifier.java | 22 +++---- .../apache/commons/jexl3/parser/ASTJexlScript.java | 6 +- .../jexl3/parser/ASTNamespaceIdentifier.java | 4 +- .../commons/jexl3/parser/JexlLexicalNode.java | 8 +-- .../org/apache/commons/jexl3/parser/JexlNode.java | 10 +-- .../apache/commons/jexl3/parser/JexlParser.java | 10 +-- .../apache/commons/jexl3/parser/StringParser.java | 4 +- .../commons/jexl3/scripting/JexlScriptEngine.java | 22 +++---- .../org/apache/commons/jexl3/scripting/Main.java | 4 +- .../org/apache/commons/jexl3/AnnotationTest.java | 12 ++-- .../org/apache/commons/jexl3/AntishCallTest.java | 18 +++--- .../org/apache/commons/jexl3/ArithmeticTest.java | 12 ++-- .../java/org/apache/commons/jexl3/CacheTest.java | 2 +- .../java/org/apache/commons/jexl3/CaptureLog.java | 6 +- .../org/apache/commons/jexl3/ClassCreator.java | 8 +-- .../org/apache/commons/jexl3/ClassCreatorTest.java | 56 ++++++++-------- .../apache/commons/jexl3/ContextNamespaceTest.java | 12 ++-- .../java/org/apache/commons/jexl3/DoWhileTest.java | 32 +++++----- .../org/apache/commons/jexl3/Issues200Test.java | 4 +- .../org/apache/commons/jexl3/Issues300Test.java | 38 +++++------ .../java/org/apache/commons/jexl3/JXLTTest.java | 74 +++++++++++----------- .../org/apache/commons/jexl3/JexlEvalContext.java | 4 +- .../org/apache/commons/jexl3/JexlTestCase.java | 4 +- .../java/org/apache/commons/jexl3/LexicalTest.java | 58 ++++++++--------- .../java/org/apache/commons/jexl3/MethodTest.java | 20 +++--- .../java/org/apache/commons/jexl3/PragmaTest.java | 8 +-- .../apache/commons/jexl3/ScriptCallableTest.java | 8 +-- .../java/org/apache/commons/jexl3/ScriptTest.java | 4 +- .../commons/jexl3/SynchronizedArithmetic.java | 4 +- .../java/org/apache/commons/jexl3/VarTest.java | 36 +++++------ .../commons/jexl3/introspection/SandboxTest.java | 18 +++--- .../apache/commons/jexl3/parser/ParserTest.java | 2 +- 54 files changed, 410 insertions(+), 410 deletions(-) diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java index 474f624..7645ae5 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java +++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java @@ -83,10 +83,10 @@ public class JexlArithmetic { /** The big decimal scale. */ private final int mathScale; - + /** The dynamic constructor. */ private final Constructor<? extends JexlArithmetic> ctor; - + /** * Creates a JexlArithmetic. * <p>If you derive your own arithmetic, implement the @@ -118,7 +118,7 @@ public class JexlArithmetic { } this.ctor = actor; } - + /** * Apply options to this arithmetic which eventually may create another instance. * @see #createWithOptions(boolean, java.math.MathContext, int) @@ -145,7 +145,7 @@ public class JexlArithmetic { } return this; } - + /** * Apply options to this arithmetic which eventually may create another instance. * @see #createWithOptions(boolean, java.math.MathContext, int) @@ -177,7 +177,7 @@ public class JexlArithmetic { } return this; } - + /** * Apply options to this arithmetic which eventually may create another instance. * @see #createWithOptions(boolean, java.math.MathContext, int) @@ -636,7 +636,7 @@ public class JexlArithmetic { } return bigd; } - + /** * Replace all numbers in an arguments array with the smallest type that will fit. * @@ -661,7 +661,7 @@ public class JexlArithmetic { } return narrowed; } - + /** * Given a long, attempt to narrow it to an int. * <p>Narrowing will only occur if no operand is a Long. @@ -677,7 +677,7 @@ public class JexlArithmetic { return r; } } - + /** * Checks if value class is a number that can be represented exactly in a long. * @@ -875,7 +875,7 @@ public class JexlArithmetic { && (((y != 0) && (r / y != x)) || (x == Long.MIN_VALUE && y == -1))); } - + /** * Multiply the left value by the right. * @@ -1022,7 +1022,7 @@ public class JexlArithmetic { if (val == null) { controlNullOperand(); return null; - } + } if (val instanceof Short) { return ((Short) val).intValue(); } @@ -1162,7 +1162,7 @@ public class JexlArithmetic { public Boolean isEmpty(final Object object) { return isEmpty(object, object == null); } - + /** * Check for emptiness of various types: Number, Collection, Array, Map, String. * @@ -1200,7 +1200,7 @@ public class JexlArithmetic { public Integer size(final Object object) { return size(object, object == null? 0 : 1); } - + /** * Calculate the <code>size</code> of various types: Collection, Array, Map, String. * diff --git a/src/main/java/org/apache/commons/jexl3/JexlBuilder.java b/src/main/java/org/apache/commons/jexl3/JexlBuilder.java index cd018c1..c00c8c1 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlBuilder.java +++ b/src/main/java/org/apache/commons/jexl3/JexlBuilder.java @@ -75,10 +75,10 @@ public class JexlBuilder { /** Whether error messages will carry debugging information. */ private Boolean debug = null; - + /** Whether interrupt throws JexlException.Cancel. */ private Boolean cancellable = null; - + /** The options. */ private final JexlOptions options = new JexlOptions(); @@ -266,7 +266,7 @@ public class JexlBuilder { public Charset charset() { return charset; } - + /** * Sets whether the engine will resolve antish variable names. * @@ -277,16 +277,16 @@ public class JexlBuilder { options.setAntish(flag); return this; } - + /** @return whether antish resolution is enabled */ public boolean antish() { return options.isAntish(); } - + /** * Sets whether the engine is in lexical mode. * - * @param flag true means lexical function scope is in effect, false implies non-lexical scoping + * @param flag true means lexical function scope is in effect, false implies non-lexical scoping * @return this builder * @since 3.2 */ @@ -294,16 +294,16 @@ public class JexlBuilder { options.setLexical(flag); return this; } - + /** @return whether lexical scope is enabled */ public boolean lexical() { return options.isLexical(); } - + /** * Sets whether the engine is in lexical shading mode. * - * @param flag true means lexical shading is in effect, false implies no lexical shading + * @param flag true means lexical shading is in effect, false implies no lexical shading * @return this builder * @since 3.2 */ @@ -311,12 +311,12 @@ public class JexlBuilder { options.setLexicalShade(flag); return this; } - + /** @return whether lexical shading is enabled */ public boolean lexicalShade() { return options.isLexicalShade(); } - + /** * Sets whether the engine will throw JexlException during evaluation when an error is triggered. * @@ -417,10 +417,10 @@ public class JexlBuilder { public JexlBuilder collectAll(final boolean flag) { return collectMode(flag? 1 : 0); } - + /** * Experimental collector mode setter. - * + * * @param mode 0 or 1 as equivalents to false and true, other values are experimental * @return this builder * @since 3.2 @@ -428,18 +428,18 @@ public class JexlBuilder { public JexlBuilder collectMode(final int mode) { this.collectMode = mode; return this; - } - - /** - * @return true if variable collection follows strict syntactic rule + } + + /** + * @return true if variable collection follows strict syntactic rule * @since 3.2 */ public boolean collectAll() { return this.collectMode != 0; } - /** - * @return 0 if variable collection follows strict syntactic rule + /** + * @return 0 if variable collection follows strict syntactic rule * @since 3.2 */ public int collectMode() { diff --git a/src/main/java/org/apache/commons/jexl3/JexlContext.java b/src/main/java/org/apache/commons/jexl3/JexlContext.java index 2f8371b..658a8f8 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlContext.java +++ b/src/main/java/org/apache/commons/jexl3/JexlContext.java @@ -134,7 +134,7 @@ public interface JexlContext { * <p>All annotations are processed through this method; the statement 'call' is to be performed within * the processAnnotation method. The implementation <em>must</em> perform the call explicitly. * <p>The arguments and the statement <em>must not</em> be referenced or cached for longer than the duration - * of the processAnnotation call. + * of the processAnnotation call. * * @param name the annotation name * @param args the arguments of the annotation, evaluated as arguments of this call @@ -144,7 +144,7 @@ public interface JexlContext { */ Object processAnnotation(String name, Object[] args, Callable<Object> statement) throws Exception; } - + /** * A marker interface of the JexlContext that exposes runtime evaluation options. * @since 3.2 @@ -161,7 +161,7 @@ public interface JexlContext { */ JexlOptions getEngineOptions(); } - + /** * A marker interface of the JexlContext that processes pragmas. * It is called by the engine before interpreter creation; as a marker of @@ -177,7 +177,7 @@ public interface JexlContext { */ void processPragma(String key, Object value); } - + /** * A marker interface of the JexlContext sharing a cancelling flag. * <p>A script running in a thread can thus be notified through this reference @@ -188,7 +188,7 @@ public interface JexlContext { */ interface CancellationHandle { /** - * @return a cancelable boolean used by the interpreter + * @return a cancelable boolean used by the interpreter */ AtomicBoolean getCancellation(); } diff --git a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java index ecceca4..dc79c75 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java +++ b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java @@ -30,7 +30,7 @@ import java.util.Objects; * <li>Registers: register syntax (#number), used internally for {g,s}etProperty * <li>Reserved Names: a set of reserved variable names that can not be used as local variable (or parameter) names * <li>Global Side Effect : assigning/modifying values on global variables (=, += , -=, ...) - * <li>Lexical: lexical scope, prevents redefining local variables + * <li>Lexical: lexical scope, prevents redefining local variables * <li>Lexical Shade: local variables shade globals, prevents confusing a global variable with a local one * <li>Side Effect : assigning/modifying values on any variables or left-value * <li>Constant Array Reference: ensures array references only use constants;they should be statically solvable. @@ -480,20 +480,20 @@ public final class JexlFeatures { /** * Sets whether syntactic lexical mode is enabled. * - * @param flag true means syntactic lexical function scope is in effect, false implies non-lexical scoping + * @param flag true means syntactic lexical function scope is in effect, false implies non-lexical scoping * @return this features instance */ public JexlFeatures lexical(final boolean flag) { setFeature(LEXICAL, flag); return this; } - - + + /** @return whether lexical scope feature is enabled */ public boolean isLexical() { return getFeature(LEXICAL); } - + /** * Sets whether syntactic lexical shade is enabled. * @@ -507,8 +507,8 @@ public final class JexlFeatures { } return this; } - - + + /** @return whether lexical shade feature is enabled */ public boolean isLexicalShade() { return getFeature(LEXICAL_SHADE); diff --git a/src/main/java/org/apache/commons/jexl3/JexlInfo.java b/src/main/java/org/apache/commons/jexl3/JexlInfo.java index 58b97c3..7799442 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlInfo.java +++ b/src/main/java/org/apache/commons/jexl3/JexlInfo.java @@ -24,7 +24,7 @@ import org.apache.commons.jexl3.internal.Script; * debugging information reporting. */ public class JexlInfo { - + /** line number. */ private final int line; @@ -65,7 +65,7 @@ public class JexlInfo { /** * Create info. - * + * * @param source source name * @param l line number * @param c column number @@ -75,7 +75,7 @@ public class JexlInfo { line = l; column = c; } - + /** * Create an information structure for dynamic set/get/invoke/new. * <p>This gathers the class, method and line number of the first calling method @@ -109,7 +109,7 @@ public class JexlInfo { /** * Creates info reusing the name. - * + * * @param l the line * @param c the column * @return a new info instance @@ -120,7 +120,7 @@ public class JexlInfo { /** * The copy constructor. - * + * * @param copy the instance to copy */ protected JexlInfo(final JexlInfo copy) { @@ -131,7 +131,7 @@ public class JexlInfo { /** * Formats this info in the form 'name@line:column'. - * + * * @return the formatted info */ @Override @@ -160,7 +160,7 @@ public class JexlInfo { /** * Gets the file/script/url name. - * + * * @return template name */ public final String getName() { @@ -169,7 +169,7 @@ public class JexlInfo { /** * Gets the line number. - * + * * @return line number. */ public final int getLine() { @@ -178,20 +178,20 @@ public class JexlInfo { /** * Gets the column number. - * + * * @return the column. */ public final int getColumn() { return column; } - + /** * @return this instance or a copy without any decorations */ public JexlInfo detach() { return this; } - + /** * Gets the info from a script. * @param script the script diff --git a/src/main/java/org/apache/commons/jexl3/JexlOptions.java b/src/main/java/org/apache/commons/jexl3/JexlOptions.java index 62666b9..7b8de6e 100644 --- a/src/main/java/org/apache/commons/jexl3/JexlOptions.java +++ b/src/main/java/org/apache/commons/jexl3/JexlOptions.java @@ -93,12 +93,12 @@ public final class JexlOptions { private static boolean isSet(final int ordinal, final int mask) { return (mask & 1 << ordinal) != 0; } - + /** * Default ctor. */ public JexlOptions() {} - + /** * Sets the default (static, shared) option flags. * <p> @@ -107,21 +107,21 @@ public final class JexlOptions { * <p>A '+flag' or 'flag' will set the option named 'flag' as true, '-flag' set as false. * The possible flag names are: * cancellable, strict, silent, safe, lexical, antish, lexicalShade - * <p>Calling JexlBuilder.setDefaultOptions("+safe") once before JEXL engine creation + * <p>Calling JexlBuilder.setDefaultOptions("+safe") once before JEXL engine creation * may ease validating JEXL3.2 in your environment. - * @param flags the flags to set + * @param flags the flags to set */ public static void setDefaultFlags(final String...flags) { DEFAULT = parseFlags(DEFAULT, flags); } - + /** * Parses flags by name. * <p>A '+flag' or 'flag' will set flag as true, '-flag' set as false. * The possible flag names are: * cancellable, strict, silent, safe, lexical, antish, lexicalShade * @param mask the initial mask state - * @param flags the flags to set + * @param flags the flags to set * @return the flag mask updated */ public static int parseFlags(int mask, final String...flags) { @@ -146,7 +146,7 @@ public final class JexlOptions { } return mask; } - + /** * Sets this option flags using the +/- syntax. * @param opts the option flags @@ -154,7 +154,7 @@ public final class JexlOptions { public void setFlags(final String[] opts) { flags = parseFlags(flags, opts); } - + /** * The MathContext instance used for +,-,/,*,% operations on big decimals. * @return the math context @@ -178,7 +178,7 @@ public final class JexlOptions { public boolean isAntish() { return isSet(ANTISH, flags); } - + /** * Checks whether evaluation will throw JexlException.Cancel (true) or * return null (false) if interrupted. @@ -197,12 +197,12 @@ public final class JexlOptions { public boolean isLexical() { return isSet(LEXICAL, flags); } - + /** * Checks whether local variables shade global ones. * <p>After a symbol is defined as local, dereferencing it outside its * scope will trigger an error instead of seeking a global variable of the - * same name. To further reduce potential naming ambiguity errors, + * same name. To further reduce potential naming ambiguity errors, * global variables (ie non local) must be declared to be assigned (@link JexlContext#has(String) ) * when this flag is on; attempting to set an undeclared global variables will * raise an error. @@ -211,7 +211,7 @@ public final class JexlOptions { public boolean isLexicalShade() { return isSet(SHADE, flags); } - + /** * Checks whether the engine considers null in navigation expression as * errors during evaluation.. @@ -247,9 +247,9 @@ public final class JexlOptions { public boolean isStrictArithmetic() { return strictArithmetic; } - + /** - * Sets whether the engine will attempt solving antish variable names from + * Sets whether the engine will attempt solving antish variable names from * context. * @param flag true if antish variables are solved, false otherwise */ @@ -265,7 +265,7 @@ public final class JexlOptions { public void setCancellable(final boolean flag) { flags = set(CANCELLABLE, flags, flag); } - + /** * Sets whether the engine uses a strict block lexical scope during * evaluation. @@ -273,8 +273,8 @@ public final class JexlOptions { */ public void setLexical(final boolean flag) { flags = set(LEXICAL, flags, flag); - } - + } + /** * Sets whether the engine strictly shades global variables. * Local symbols shade globals after definition and creating global @@ -312,7 +312,7 @@ public final class JexlOptions { */ public void setSafe(final boolean flag) { flags = set(SAFE, flags, flag); - } + } /** * Sets whether the engine will throw a {@link JexlException} when an error @@ -349,20 +349,20 @@ public final class JexlOptions { public void setSharedInstance(final boolean flag) { flags = set(SHARED, flags, flag); } - + /** * @return false if a copy of these options is used during execution, - * true if those can potentially be modified + * true if those can potentially be modified */ public boolean isSharedInstance() { return isSet(SHARED, flags); } - + /** * Set options from engine. * @param jexl the engine * @return this instance - */ + */ public JexlOptions set(final JexlEngine jexl) { if (jexl instanceof Engine) { ((Engine) jexl).optionsSet(this); @@ -383,7 +383,7 @@ public final class JexlOptions { namespaces = src.namespaces; return this; } - + /** * Gets the optional map of namespaces. * @return the map of namespaces, may be empty, not null @@ -399,7 +399,7 @@ public final class JexlOptions { public void setNamespaces(final Map<String, Object> ns) { this.namespaces = ns == null? Collections.emptyMap() : ns; } - + /** * Creates a copy of this instance. * @return a copy @@ -407,5 +407,5 @@ public final class JexlOptions { public JexlOptions copy() { return new JexlOptions().set(this); } - + } \ No newline at end of file diff --git a/src/main/java/org/apache/commons/jexl3/MapContext.java b/src/main/java/org/apache/commons/jexl3/MapContext.java index c3bbccc..4088588 100644 --- a/src/main/java/org/apache/commons/jexl3/MapContext.java +++ b/src/main/java/org/apache/commons/jexl3/MapContext.java @@ -40,7 +40,7 @@ public class MapContext implements JexlContext { /** * Creates a MapContext wrapping an existing user provided map. - * + * * @param vars the variable map */ public MapContext(final Map<String, Object> vars) { diff --git a/src/main/java/org/apache/commons/jexl3/internal/Engine.java b/src/main/java/org/apache/commons/jexl3/internal/Engine.java index 41f7e90..f372f98 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Engine.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Engine.java @@ -302,7 +302,7 @@ public class Engine extends JexlEngine { public Charset getCharset() { return charset; } - + /** * Solves an optional option. * @param conf the option as configured, may be null @@ -313,7 +313,7 @@ public class Engine extends JexlEngine { private static <T> T option(final T conf, final T def) { return conf == null? def : conf; } - + /** * Extracts the engine evaluation options from context if available, the engine * options otherwise. @@ -354,7 +354,7 @@ public class Engine extends JexlEngine { * @return the options */ protected JexlOptions options(final ASTJexlScript script, final JexlContext context) { - final JexlOptions opts = options(context); + final JexlOptions opts = options(context); if (opts != options) { // when feature lexical, try hard to run lexical if (scriptFeatures.isLexical()) { @@ -370,7 +370,7 @@ public class Engine extends JexlEngine { } return opts; } - + /** * Processes a script pragmas. * <p>Only called from options(...) @@ -419,7 +419,7 @@ public class Engine extends JexlEngine { } } } - + /** * Sets options from this engine options. * @param opts the options to set @@ -431,7 +431,7 @@ public class Engine extends JexlEngine { } return opts; } - + @Override public TemplateEngine createJxltEngine(final boolean noScript, final int cacheSize, final char immediate, final char deferred) { return new TemplateEngine(this, noScript, cacheSize, immediate, deferred); @@ -443,7 +443,7 @@ public class Engine extends JexlEngine { cache.clear(); } } - + /** * Creates an interpreter. * @param context a JexlContext; if null, the empty context is used instead. @@ -455,7 +455,7 @@ public class Engine extends JexlEngine { return new Interpreter(this, opts, context, frame); } - + @Override public Script createExpression(final JexlInfo info, final String expression) { return createScript(expressionFeatures, info, expression, null); @@ -682,7 +682,7 @@ public class Engine extends JexlEngine { private JexlNode root = null; /** * Whether constant array-access is considered equivalent to dot-access; - * if so, > 1 means collect any constant (set,map,...) instead of just + * if so, > 1 means collect any constant (set,map,...) instead of just * strings and numbers. */ private int mode = 1; diff --git a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java index d37120f..f8e9410 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java @@ -123,7 +123,7 @@ public class Interpreter extends InterpreterBase { protected final Frame frame; /** Block micro-frames. */ protected LexicalFrame block = null; - + /** * The thread local interpreter. */ @@ -707,7 +707,7 @@ public class Interpreter extends InterpreterBase { if (lexical && cnt++ > 0) { // clean up but remain current block.pop(); - // unlikely to fail + // unlikely to fail if (loopSymbol && !defineVariable((ASTVar) loopVariable, locals)) { return redefinedVariable(node, loopVariable.getName()); } @@ -988,7 +988,7 @@ public class Interpreter extends InterpreterBase { return true; } } - + /** * Runs a node. * @param node the node @@ -1003,7 +1003,7 @@ public class Interpreter extends InterpreterBase { block = block.pop(); } } - + /** * Runs a closure. * @param closure the closure @@ -1314,7 +1314,7 @@ public class Interpreter extends InterpreterBase { if (!defineVariable((ASTVar) var, block)) { return redefinedVariable(var, var.getName()); } - } else if (options.isLexicalShade() && var.isShaded()) { + } else if (options.isLexicalShade() && var.isShaded()) { return undefinedVariable(var, var.getName()); } } @@ -1850,14 +1850,14 @@ public class Interpreter extends InterpreterBase { return xreturn; } } - + /** * @return whether the statement has been processed */ public boolean isProcessed() { return processed; } - + /** * @return the actual statement. */ @@ -1865,7 +1865,7 @@ public class Interpreter extends InterpreterBase { return stmt; } } - + /** * Processes an annotated statement. * @param stmt the statement diff --git a/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java b/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java index 29e12f4..85f3145 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java +++ b/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java @@ -77,7 +77,7 @@ public abstract class InterpreterBase extends ParserVisitor { protected final Map<String, Object> functions; /** The map of dynamically creates namespaces, NamespaceFunctor or duck-types of those. */ protected Map<String, Object> functors; - + /** * Creates an interpreter base. * @param engine the engine creating this interpreter @@ -113,7 +113,7 @@ public abstract class InterpreterBase extends ParserVisitor { this.functors = null; this.operators = new Operators(this); } - + /** * Copy constructor. * @param ii the base to copy @@ -133,7 +133,7 @@ public abstract class InterpreterBase extends ParserVisitor { functions = ii.functions; functors = ii.functors; } - + /** * Attempt to call close() if supported. * <p>This is used when dealing with auto-closeable (duck-like) objects @@ -151,7 +151,7 @@ public abstract class InterpreterBase extends ParserVisitor { } } } - + /** * Resolves a namespace, eventually allocating an instance using context as constructor argument. * <p> @@ -270,7 +270,7 @@ public abstract class InterpreterBase extends ParserVisitor { } return frame.defineSymbol(symbol, var.isCaptured()); } - + /** * Checks whether a variable is defined. * <p>The var may be either a local variable declared in the frame and @@ -291,7 +291,7 @@ public abstract class InterpreterBase extends ParserVisitor { } return context.has(name); } - + /** * Gets a value of a defined local variable or from the context. * @param frame the local frame @@ -331,7 +331,7 @@ public abstract class InterpreterBase extends ParserVisitor { * Sets a variable in the global context. * <p>If interpretation applies lexical shade, the variable must exist (ie * the context has(...) method returns true) otherwise an error occurs. - * @param node the node + * @param node the node * @param name the variable name * @param value the variable value */ @@ -345,7 +345,7 @@ public abstract class InterpreterBase extends ParserVisitor { throw new JexlException(node, "context is readonly", xsupport); } } - + /** * Whether this interpreter is currently evaluating with a strict engine flag. * @return true if strict engine, false otherwise @@ -353,7 +353,7 @@ public abstract class InterpreterBase extends ParserVisitor { protected boolean isStrictEngine() { return options.isStrict(); } - + /** * Whether this interpreter ignores null in navigation expression as errors. * @return true if safe, false otherwise @@ -369,7 +369,7 @@ public abstract class InterpreterBase extends ParserVisitor { protected boolean isSilent() { return options.isSilent(); } - + /** * @return true if interrupt throws a JexlException.Cancel. */ @@ -407,7 +407,7 @@ public abstract class InterpreterBase extends ParserVisitor { protected Object unsolvableVariable(final JexlNode node, final String var, final boolean undef) { return variableError(node, var, undef? VariableIssue.UNDEFINED : VariableIssue.NULLVALUE); } - + /** * Triggered when a variable is lexically known as undefined. * @param node the node where the error originated from @@ -417,24 +417,24 @@ public abstract class InterpreterBase extends ParserVisitor { protected Object undefinedVariable(final JexlNode node, final String var) { return variableError(node, var, VariableIssue.UNDEFINED); } - + /** * Triggered when a variable is lexically known as being redefined. * @param node the node where the error originated from * @param var the variable name * @return throws JexlException if strict and not silent, null otherwise - */ + */ protected Object redefinedVariable(final JexlNode node, final String var) { return variableError(node, var, VariableIssue.REDEFINED); } - + /** * Triggered when a variable generates an issue. * @param node the node where the error originated from * @param var the variable name * @param issue the issue type * @return throws JexlException if strict and not silent, null otherwise - */ + */ protected Object variableError(final JexlNode node, final String var, final VariableIssue issue) { if (isStrictEngine() && !node.isTernaryProtected()) { throw new JexlException.Variable(node, var, issue); @@ -452,7 +452,7 @@ public abstract class InterpreterBase extends ParserVisitor { protected Object unsolvableMethod(final JexlNode node, final String method) { return unsolvableMethod(node, method, null); } - + /** * Triggered when a method can not be resolved. * @param node the node where the error originated from @@ -485,7 +485,7 @@ public abstract class InterpreterBase extends ParserVisitor { } return null; } - + /** * Checks whether a reference child node holds a local variable reference. * @param node the reference node @@ -497,7 +497,7 @@ public abstract class InterpreterBase extends ParserVisitor { && node.jjtGetChild(which) instanceof ASTIdentifier && ((ASTIdentifier) node.jjtGetChild(which)).getSymbol() >= 0); } - + /** * Checks whether a reference child node holds a function call. * @param node the reference node @@ -507,7 +507,7 @@ public abstract class InterpreterBase extends ParserVisitor { return (node.jjtGetNumChildren() > 0 && node.jjtGetChild(0) instanceof ASTFunctionNode); } - + /** * Pretty-prints a failing property (de)reference. * <p>Used by calls to unsolvableProperty(...).</p> @@ -534,7 +534,7 @@ public abstract class InterpreterBase extends ParserVisitor { } return stringifyPropertyValue(node); } - + /** * Pretty-prints a failing property value (de)reference. * <p>Used by calls to unsolvableProperty(...).</p> @@ -620,7 +620,7 @@ public abstract class InterpreterBase extends ParserVisitor { throw new JexlException.Cancel(node); } } - + /** * Concatenate arguments in call(...). * <p>When target == context, we are dealing with a global namespace function call @@ -672,7 +672,7 @@ public abstract class InterpreterBase extends ParserVisitor { } return nargv; } - + /** * Optionally narrows an argument for a function call. * @param narrow whether narrowing should occur @@ -751,7 +751,7 @@ public abstract class InterpreterBase extends ParserVisitor { return me.tryInvoke(name, ii.context, ii.functionArguments(target, narrow, args)); } } - + /** * A ctor that needs a context as 1st argument. */ @@ -770,7 +770,7 @@ public abstract class InterpreterBase extends ParserVisitor { return me.tryInvoke(name, target, ii.callArguments(ii.context, narrow, args)); } } - + /** * Helping dispatch function calls. */ diff --git a/src/main/java/org/apache/commons/jexl3/internal/Operators.java b/src/main/java/org/apache/commons/jexl3/internal/Operators.java index c81fc0e..caa02d1 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Operators.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Operators.java @@ -72,7 +72,7 @@ public class Operators { } return false; } - + /** * Checks whether a method is a JexlArithmetic method. * @param vm the JexlMethod (may be null) @@ -85,7 +85,7 @@ public class Operators { } return false; } - + /** * Attempts to call an operator. * <p> diff --git a/src/main/java/org/apache/commons/jexl3/internal/Script.java b/src/main/java/org/apache/commons/jexl3/internal/Script.java index 129a033..fea8ef2 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/Script.java +++ b/src/main/java/org/apache/commons/jexl3/internal/Script.java @@ -99,7 +99,7 @@ public class Script implements JexlScript, JexlExpression { protected Frame createFrame(final Object[] args) { return script.createFrame(args); } - + /** * Creates this script interpreter. * @param context the context @@ -219,14 +219,14 @@ public class Script implements JexlScript, JexlExpression { public String[] getLocalVariables() { return script.getLocalVariables(); } - + /** * @return the info */ public JexlInfo getInfo() { return script.jexlInfo(); } - + /** * @return the script features */ diff --git a/src/main/java/org/apache/commons/jexl3/internal/TemplateDebugger.java b/src/main/java/org/apache/commons/jexl3/internal/TemplateDebugger.java index 6008aa8..c7dfd7e 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/TemplateDebugger.java +++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateDebugger.java @@ -54,7 +54,7 @@ public class TemplateDebugger extends Debugger { exprs = null; script = null; } - + /** * Position the debugger on the root of a template expression. * @param je the expression @@ -203,7 +203,7 @@ public class TemplateDebugger extends Debugger { } } } - + /** * Insert \n when needed. */ @@ -222,7 +222,7 @@ public class TemplateDebugger extends Debugger { } } } - + /** * Visit a template expression. * @param expr the constant expression diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/AbstractExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/AbstractExecutor.java index 06f660b..46bd725 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/AbstractExecutor.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/AbstractExecutor.java @@ -73,7 +73,7 @@ abstract class AbstractExecutor { static Object[] makeArgs(final Object... args) { return args; } - + /** * Gets the class of an object or Object if null. * @param instance the instance diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/ConstructorMethod.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/ConstructorMethod.java index 16bc4c3..2a2feff 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/ConstructorMethod.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/ConstructorMethod.java @@ -117,5 +117,5 @@ public final class ConstructorMethod implements JexlMethod { public Class<?> getReturnType() { return ctor.getDeclaringClass(); } - + } diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/DuckGetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/DuckGetExecutor.java index c1e067a..ca267d5 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/DuckGetExecutor.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/DuckGetExecutor.java @@ -83,7 +83,7 @@ public final class DuckGetExecutor extends AbstractExecutor.Get { return TRY_FAILED;// fail } catch (final InvocationTargetException xinvoke) { throw JexlException.tryFailed(xinvoke); // throw - } + } } return TRY_FAILED; } diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/DuckSetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/DuckSetExecutor.java index b7f32d3..a7b35f4 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/DuckSetExecutor.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/DuckSetExecutor.java @@ -102,7 +102,7 @@ public final class DuckSetExecutor extends AbstractExecutor.Set { return TRY_FAILED;// fail } catch (final InvocationTargetException xinvoke) { throw JexlException.tryFailed(xinvoke); // throw - } + } } return TRY_FAILED; } diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/IndexedType.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/IndexedType.java index 1245451..e0a1493 100644 --- a/src/main/java/org/apache/commons/jexl3/internal/introspection/IndexedType.java +++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/IndexedType.java @@ -87,7 +87,7 @@ public final class IndexedType implements JexlPropertyGet { this.type = theType; this.container = theContainer; } - + /** * Gets the property container name. * @return the container name @@ -103,7 +103,7 @@ public final class IndexedType implements JexlPropertyGet { public Class<?> getContainerClass() { return type.clazz; } - + /** * Gets a property from this indexed container. * @param key the property key diff --git a/src/main/java/org/apache/commons/jexl3/introspection/JexlMethod.java b/src/main/java/org/apache/commons/jexl3/introspection/JexlMethod.java index 1ff6878..5cf4bb0 100644 --- a/src/main/java/org/apache/commons/jexl3/introspection/JexlMethod.java +++ b/src/main/java/org/apache/commons/jexl3/introspection/JexlMethod.java @@ -43,7 +43,7 @@ public interface JexlMethod { * Attempts to reuse this JexlMethod, checking that it is compatible with * the actual set of arguments. * Related to isCacheable since this method is often used with cached JexlMethod instances. - * + * * @param name the method name * @param obj the object to invoke the method upon * @param params the method arguments @@ -57,7 +57,7 @@ public interface JexlMethod { /** * Checks whether a tryInvoke return value indicates a failure or not. * <p>Usage is : <code>Object r = tryInvoke(...); if (tryFailed(r) {...} else {...}</code> - * + * * @param rval the value returned by tryInvoke * @return true if tryInvoke failed, false otherwise */ @@ -73,7 +73,7 @@ public interface JexlMethod { /** * returns the return type of the method invoked. - * + * * @return return type */ Class<?> getReturnType(); diff --git a/src/main/java/org/apache/commons/jexl3/introspection/JexlPropertyGet.java b/src/main/java/org/apache/commons/jexl3/introspection/JexlPropertyGet.java index 9eb9fb0..ea47853 100644 --- a/src/main/java/org/apache/commons/jexl3/introspection/JexlPropertyGet.java +++ b/src/main/java/org/apache/commons/jexl3/introspection/JexlPropertyGet.java @@ -25,7 +25,7 @@ import org.apache.commons.jexl3.JexlException; * <code> * ${foo.bar} * </code> - * + * * @since 1.0 */ public interface JexlPropertyGet { @@ -41,7 +41,7 @@ public interface JexlPropertyGet { /** * Attempts to reuse this JexlPropertyGet, checking that it is compatible with * the actual set of arguments. - * + * * @param obj the object to invoke the property get upon * @param key the property key to get * @return the result of the method invocation that should be checked by tryFailed to determine if it succeeded @@ -53,7 +53,7 @@ public interface JexlPropertyGet { /** * Checks whether a tryInvoke failed or not. - * + * * @param rval the value returned by tryInvoke * @return true if tryInvoke failed, false otherwise */ diff --git a/src/main/java/org/apache/commons/jexl3/introspection/JexlPropertySet.java b/src/main/java/org/apache/commons/jexl3/introspection/JexlPropertySet.java index a57464a..bb63963 100644 --- a/src/main/java/org/apache/commons/jexl3/introspection/JexlPropertySet.java +++ b/src/main/java/org/apache/commons/jexl3/introspection/JexlPropertySet.java @@ -25,7 +25,7 @@ import org.apache.commons.jexl3.JexlException; * <code> * ${foo.bar = "hello"} * </code> - * + * * @since 1.0 */ public interface JexlPropertySet { @@ -42,7 +42,7 @@ public interface JexlPropertySet { /** * Attempts to reuse this JexlPropertySet, checking that it is compatible with * the actual set of arguments. - * + * * @param obj the object to invoke the the get upon * @param key the property key to get * @param value the property value to set @@ -55,7 +55,7 @@ public interface JexlPropertySet { /** * Checks whether a tryInvoke failed or not. - * + * * @param rval the value returned by tryInvoke * @return true if tryInvoke failed, false otherwise */ diff --git a/src/main/java/org/apache/commons/jexl3/parser/ASTForeachStatement.java b/src/main/java/org/apache/commons/jexl3/parser/ASTForeachStatement.java index 4520a81..a82357c 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/ASTForeachStatement.java +++ b/src/main/java/org/apache/commons/jexl3/parser/ASTForeachStatement.java @@ -20,7 +20,7 @@ package org.apache.commons.jexl3.parser; * Declares a for each loop. */ public class ASTForeachStatement extends JexlLexicalNode { - + public ASTForeachStatement(final int id) { super(id); } diff --git a/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java b/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java index 2d03d3c..427078f 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java +++ b/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java @@ -23,7 +23,7 @@ public class ASTIdentifier extends JexlNode { protected String name = null; protected int symbol = -1; protected int flags = 0; - + /** The redefined variable flag. */ private static final int REDEFINED = 0; /** The shaded variable flag. */ @@ -55,11 +55,11 @@ public class ASTIdentifier extends JexlNode { symbol = r; name = identifier; } - + public int getSymbol() { return symbol; } - + /** * Sets the value of a flag in a mask. * @param ordinal the flag ordinal @@ -80,35 +80,35 @@ public class ASTIdentifier extends JexlNode { private static boolean isSet(final int ordinal, final int mask) { return (mask & 1 << ordinal) != 0; } - + public void setRedefined(final boolean f) { flags = set(REDEFINED, flags, f); } - + public boolean isRedefined() { return isSet(REDEFINED, flags); } - + public void setShaded(final boolean f) { flags = set(SHADED, flags, f); } - + public boolean isShaded() { return isSet(SHADED, flags); } - + public void setCaptured(final boolean f) { flags = set(CAPTURED, flags, f); } - + public boolean isCaptured() { return isSet(CAPTURED, flags); } - + public String getName() { return name; } - + public String getNamespace() { return null; } diff --git a/src/main/java/org/apache/commons/jexl3/parser/ASTJexlScript.java b/src/main/java/org/apache/commons/jexl3/parser/ASTJexlScript.java index 38beed6..54c734a 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/ASTJexlScript.java +++ b/src/main/java/org/apache/commons/jexl3/parser/ASTJexlScript.java @@ -39,7 +39,7 @@ public class ASTJexlScript extends JexlLexicalNode { public ASTJexlScript(final Parser p, final int id) { super(p, id); } - + /** * Consider script with no parameters that return lambda as parametric-scripts. * @return the script @@ -58,7 +58,7 @@ public class ASTJexlScript extends JexlLexicalNode { public Object jjtAccept(final ParserVisitor visitor, final Object data) { return visitor.visit(this, data); } - + /** * Sets this script pragmas. * @param thePragmas the pragmas @@ -118,7 +118,7 @@ public class ASTJexlScript extends JexlLexicalNode { public Frame createFrame(final Frame caller, final Object... values) { return scope != null? scope.createFrame(caller, values) : null; } - + /** * Creates an array of arguments by copying values up to the number of parameters. * @param values the argument values diff --git a/src/main/java/org/apache/commons/jexl3/parser/ASTNamespaceIdentifier.java b/src/main/java/org/apache/commons/jexl3/parser/ASTNamespaceIdentifier.java index 7809774..02a6d10 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/ASTNamespaceIdentifier.java +++ b/src/main/java/org/apache/commons/jexl3/parser/ASTNamespaceIdentifier.java @@ -21,11 +21,11 @@ package org.apache.commons.jexl3.parser; */ public class ASTNamespaceIdentifier extends ASTIdentifier { private String namespace; - + public ASTNamespaceIdentifier(final int id) { super(id); } - + @Override public String getNamespace() { return namespace; diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlLexicalNode.java b/src/main/java/org/apache/commons/jexl3/parser/JexlLexicalNode.java index 2bf03a9..8d1a5f1 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/JexlLexicalNode.java +++ b/src/main/java/org/apache/commons/jexl3/parser/JexlLexicalNode.java @@ -24,7 +24,7 @@ import org.apache.commons.jexl3.internal.LexicalScope; */ public class JexlLexicalNode extends JexlNode implements JexlParser.LexicalUnit { private LexicalScope locals = null; - + public JexlLexicalNode(final int id) { super(id); } @@ -32,7 +32,7 @@ public class JexlLexicalNode extends JexlNode implements JexlParser.LexicalUnit public JexlLexicalNode(final Parser p, final int id) { super(p, id); } - + @Override public boolean declareSymbol(final int symbol) { if (locals == null) { @@ -40,7 +40,7 @@ public class JexlLexicalNode extends JexlNode implements JexlParser.LexicalUnit } return locals.addSymbol(symbol); } - + @Override public int getSymbolCount() { return locals == null? 0 : locals.getSymbolCount(); @@ -49,7 +49,7 @@ public class JexlLexicalNode extends JexlNode implements JexlParser.LexicalUnit @Override public boolean hasSymbol(final int symbol) { return locals != null && locals.hasSymbol(symbol); - } + } @Override public LexicalScope getLexicalScope() { diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java b/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java index f2458d3..5ce6751 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java +++ b/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java @@ -246,7 +246,7 @@ public abstract class JexlNode extends SimpleNode { } return false; } - + /** * Check if a null evaluated expression is protected by a ternary expression. * <p> @@ -272,7 +272,7 @@ public abstract class JexlNode extends SimpleNode { node = walk; } return false; - } + } /** * An info bound to its node. @@ -288,16 +288,16 @@ public abstract class JexlNode extends SimpleNode { public Info(final JexlNode jnode) { this(jnode, jnode.jexlInfo()); } - + /** * Copy ctor. * @param jnode the node - * @param info the + * @param info the */ public Info(final JexlNode jnode, final JexlInfo info) { this(jnode, info.getName(), info.getLine(), info.getColumn()); } - + /** * Full detail ctor. * @param jnode the node diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java index 2a3b17b..45fd1b2 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java +++ b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java @@ -102,12 +102,12 @@ public abstract class JexlParser extends StringParser { * @return true if declared, false otherwise */ boolean hasSymbol(int symbol); - + /** * @return the number of local variables declared in this unit */ int getSymbolCount(); - + LexicalScope getLexicalScope(); } @@ -257,7 +257,7 @@ public abstract class JexlParser extends StringParser { } } } - + /** * Checks if a symbol is defined in lexical scopes. * <p>This works with with parsed scripts in template resolution only. @@ -282,7 +282,7 @@ public abstract class JexlParser extends StringParser { } return false; } - + /** * Checks whether an identifier is a local variable or argument, ie a symbol, stored in a register. * @param identifier the identifier @@ -585,7 +585,7 @@ public abstract class JexlParser extends StringParser { // unlikely but safe throw xparse != null ? xparse : new JexlException.Parsing(xinfo, msg); } - + /** * Pick the most significant token for error reporting. * @param tokens the tokens to choose from diff --git a/src/main/java/org/apache/commons/jexl3/parser/StringParser.java b/src/main/java/org/apache/commons/jexl3/parser/StringParser.java index f86c8dd..0754896 100644 --- a/src/main/java/org/apache/commons/jexl3/parser/StringParser.java +++ b/src/main/java/org/apache/commons/jexl3/parser/StringParser.java @@ -225,7 +225,7 @@ public class StringParser { strb.append(delim); return strb.toString(); } - + /** * Remove escape char ('\') from an identifier. * @param str the identifier escaped string, ie with a backslash before space, quote, double-quote and backslash @@ -242,7 +242,7 @@ public class StringParser { if (strb == null) { strb = new StringBuilder(last); strb.append(str.substring(0, n)); - } + } } else if (strb != null) { strb.append(c); } diff --git a/src/main/java/org/apache/commons/jexl3/scripting/JexlScriptEngine.java b/src/main/java/org/apache/commons/jexl3/scripting/JexlScriptEngine.java index 414bd41..cea77db 100644 --- a/src/main/java/org/apache/commons/jexl3/scripting/JexlScriptEngine.java +++ b/src/main/java/org/apache/commons/jexl3/scripting/JexlScriptEngine.java @@ -58,7 +58,7 @@ import org.apache.commons.logging.LogFactory; * See * <a href="http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html">Java Scripting API</a> * Javadoc. - * + * * @since 2.0 */ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable { @@ -99,7 +99,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable * Those properties are always bound to the default engine scope context. * * <p>The following properties are defined:</p> - * + * * <ul> * <li>in - refers to the engine scope reader that defaults to reading System.err</li> * <li>out - refers the engine scope writer that defaults to writing in System.out</li> @@ -117,7 +117,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable * <p>Although this allows to manipulate various engine flags (lenient, debug, cache...) * for <strong>all</strong> JexlScriptEngine instances, you probably should only do so * if you are in strict control and sole user of the JEXL scripting feature.</p> - * + * * @return the shared underlying JEXL engine */ public JexlEngine getEngine() { @@ -126,7 +126,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable /** * Gives access to the engine scope output writer (defaults to System.out). - * + * * @return the engine output writer */ public PrintWriter getOut() { @@ -142,7 +142,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable /** * Gives access to the engine scope error writer (defaults to System.err). - * + * * @return the engine error writer */ public PrintWriter getErr() { @@ -158,7 +158,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable /** * Gives access to the engine scope input reader (defaults to System.in). - * + * * @return the engine input reader */ public Reader getIn() { @@ -167,7 +167,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable /** * Gives access to System class. - * + * * @return System.class */ public Class<System> getSystem() { @@ -176,7 +176,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable /** * Gives access to the engine logger. - * + * * @return the JexlScriptEngine logger */ public Log getLogger() { @@ -262,7 +262,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable /** * Read from a reader into a local buffer and return a String with * the contents of the reader. - * + * * @param scriptReader to be read. * @return the contents of the reader as a String. * @throws ScriptException on any error reading the reader. @@ -320,7 +320,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable /** * Creates a context wrapper. - * + * * @param theContext the engine context. */ private JexlContextWrapper (final ScriptContext theContext){ @@ -365,7 +365,7 @@ public class JexlScriptEngine extends AbstractScriptEngine implements Compilable /** * Creates an instance. - * + * * @param theScript to wrap */ private JexlCompiledScript(final JexlScript theScript) { diff --git a/src/main/java/org/apache/commons/jexl3/scripting/Main.java b/src/main/java/org/apache/commons/jexl3/scripting/Main.java index 1cf4f85..9e26acb 100644 --- a/src/main/java/org/apache/commons/jexl3/scripting/Main.java +++ b/src/main/java/org/apache/commons/jexl3/scripting/Main.java @@ -28,14 +28,14 @@ import javax.script.ScriptException; /** * Test application for JexlScriptEngine (JSR-223 implementation). - * + * * @since 2.0 */ public class Main { /** * Reads an input. - * + * * @param charset the charset or null for default charset * @param fileName the file name or null for stdin * @return the reader diff --git a/src/test/java/org/apache/commons/jexl3/AnnotationTest.java b/src/test/java/org/apache/commons/jexl3/AnnotationTest.java index 2d8cd17..10d6e18 100644 --- a/src/test/java/org/apache/commons/jexl3/AnnotationTest.java +++ b/src/test/java/org/apache/commons/jexl3/AnnotationTest.java @@ -36,7 +36,7 @@ public class AnnotationTest extends JexlTestCase { public final static int NUM_THREADS = 10; public final static int NUM_ITERATIONS = 1000; - + public AnnotationTest() { super("AnnotationTest"); } @@ -222,7 +222,7 @@ public class AnnotationTest extends JexlTestCase { Assert.assertEquals(1, jc.getCount()); Assert.assertTrue(jc.getNames().contains("synchronized")); } - + @Test public void testHoistingStatement() throws Exception { final AnnotationContext jc = new AnnotationContext(); @@ -232,7 +232,7 @@ public class AnnotationTest extends JexlTestCase { Assert.assertEquals(1, jc.getCount()); Assert.assertTrue(jc.getNames().contains("synchronized")); } - + @Test public void testOneArg() throws Exception { final AnnotationContext jc = new AnnotationContext(); @@ -313,7 +313,7 @@ public class AnnotationTest extends JexlTestCase { Assert.assertEquals(0, log.count("warn")); } } - + /** * A counter whose inc method will misbehave if not mutex-ed. */ @@ -355,11 +355,11 @@ public class AnnotationTest extends JexlTestCase { Assert.assertEquals(NUM_THREADS * NUM_ITERATIONS, syncCounter.getValue()); } } - } + } @Test /** - * A base test to ensure synchronized makes a difference. + * A base test to ensure synchronized makes a difference. */ public void testSynchronized() throws InterruptedException { final TestRunner tr = new TestRunner(); diff --git a/src/test/java/org/apache/commons/jexl3/AntishCallTest.java b/src/test/java/org/apache/commons/jexl3/AntishCallTest.java index c11be20..f85e53f 100644 --- a/src/test/java/org/apache/commons/jexl3/AntishCallTest.java +++ b/src/test/java/org/apache/commons/jexl3/AntishCallTest.java @@ -170,7 +170,7 @@ public class AntishCallTest extends JexlTestCase { final Object o2 = check2.execute(jc); Assert.assertEquals("Result is not 4321", new java.math.BigInteger("4321"), o2); } - + // JEXL-300 @Test public void testSafeAnt() throws Exception { @@ -179,12 +179,12 @@ public class AntishCallTest extends JexlTestCase { ctxt.set("x.y.z", 42); JexlScript script; Object result; - + script = JEXL.createScript("x.y.z"); result = script.execute(ctxt); Assert.assertEquals(42, result); Assert.assertEquals(42, ctxt.get("x.y.z")); - + options.setAntish(false); try { result = script.execute(ctxt); @@ -196,12 +196,12 @@ public class AntishCallTest extends JexlTestCase { } finally { options.setAntish(true); } - + result = null; script = JEXL.createScript("x?.y?.z"); result = script.execute(ctxt); Assert.assertNull(result); // safe navigation, null - + result = null; script = JEXL.createScript("x?.y?.z = 3"); try { @@ -210,7 +210,7 @@ public class AntishCallTest extends JexlTestCase { } catch(final JexlException xjexl) { Assert.assertNull(result); } - + result = null; script = JEXL.createScript("x.y?.z"); try { @@ -219,7 +219,7 @@ public class AntishCallTest extends JexlTestCase { } catch(final JexlException xjexl) { Assert.assertNull(result); } - + result = null; script = JEXL.createScript("x.y?.z = 3"); try { @@ -227,8 +227,8 @@ public class AntishCallTest extends JexlTestCase { Assert.fail("not antish assign"); } catch(final JexlException xjexl) { Assert.assertNull(result); - } - + } + result = null; script = JEXL.createScript("x.`'y'`.z = 3"); try { diff --git a/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java b/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java index 0ae9699..aadbd78 100644 --- a/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java +++ b/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java @@ -128,8 +128,8 @@ public class ArithmeticTest extends JexlTestCase { asserter.assertExpression("right * left", new BigInteger("12")); asserter.assertExpression("right / left", new BigInteger("3")); asserter.assertExpression("right % left", new BigInteger("0")); - } - + } + @Test public void testOverflows() throws Exception { asserter.assertExpression("1 + 2147483647", Long.valueOf("2147483648")); @@ -1169,7 +1169,7 @@ public class ArithmeticTest extends JexlTestCase { public XmlArithmetic(final boolean astrict) { super(astrict); } - + public XmlArithmetic(final boolean astrict, final MathContext bigdContext, final int bigdScale) { super(astrict, bigdContext, bigdScale); } @@ -1198,12 +1198,12 @@ public class ArithmeticTest extends JexlTestCase { final JexlScript e1 = jexl.createScript("empty(x)", "x"); final JexlScript s0 = jexl.createScript("x.size()", "x"); final JexlScript s1 = jexl.createScript("size(x)", "x"); - + empty = (Boolean) e1.execute(null, (Object) null); Assert.assertTrue(empty); size = (Integer) s1.execute(null, (Object) null); Assert.assertEquals(0, size); - + try { final Object xx = e0.execute(null, (Object) null); Assert.assertNull(xx); @@ -1222,7 +1222,7 @@ public class ArithmeticTest extends JexlTestCase { Assert.assertNull(x0); final Object x1 = s0.execute(ctxt, (Object) null); Assert.assertNull(x1); - + xml = getDocument("<node info='123'/>"); x = xml.getLastChild(); empty = (Boolean) e0.execute(null, x); diff --git a/src/test/java/org/apache/commons/jexl3/CacheTest.java b/src/test/java/org/apache/commons/jexl3/CacheTest.java index b638f5e..173fc82 100644 --- a/src/test/java/org/apache/commons/jexl3/CacheTest.java +++ b/src/test/java/org/apache/commons/jexl3/CacheTest.java @@ -41,7 +41,7 @@ public class CacheTest extends JexlTestCase { 0, 0, 3, 3, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 3, 3, 0 }; - + public CacheTest() { super("CacheTest", null); } diff --git a/src/test/java/org/apache/commons/jexl3/CaptureLog.java b/src/test/java/org/apache/commons/jexl3/CaptureLog.java index 08a2a37..227c7ae 100644 --- a/src/test/java/org/apache/commons/jexl3/CaptureLog.java +++ b/src/test/java/org/apache/commons/jexl3/CaptureLog.java @@ -29,11 +29,11 @@ public class CaptureLog implements Log { final StackTraceElement[] stack = new Exception().fillInStackTrace().getStackTrace(); return stack[2]; } - + public CaptureLog() { this("org.apache.commons.jexl3"); } - + public CaptureLog(final String name) { //super(name); } @@ -51,7 +51,7 @@ public class CaptureLog implements Log { } return count; } - + //@Override public boolean isEnabledFor(final int /*Priority*/ p) { return true; diff --git a/src/test/java/org/apache/commons/jexl3/ClassCreator.java b/src/test/java/org/apache/commons/jexl3/ClassCreator.java index 2d700b3..50705e9 100644 --- a/src/test/java/org/apache/commons/jexl3/ClassCreator.java +++ b/src/test/java/org/apache/commons/jexl3/ClassCreator.java @@ -98,7 +98,7 @@ public class ClassCreator { public String getClassName() { return GEN_CLASS + className; } - + public Class<?> getClassInstance() throws Exception { return getClassLoader().loadClass(getClassName()); } @@ -130,12 +130,12 @@ public class ClassCreator { return clazz; } throw new Exception("failed to validate foo" + seed); - } - + } + Object newInstance(final Class<?> clazz, final JexlContext ctxt) throws Exception { return clazz.getConstructor(JexlContext.class).newInstance(ctxt); } - + void generate(final boolean ftor) throws Exception { final FileWriter aWriter = new FileWriter(new File(packageDir, sourceName), false); aWriter.write("package "); diff --git a/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java b/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java index fe6cbae..f778fae 100644 --- a/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java +++ b/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java @@ -116,12 +116,12 @@ public class ClassCreatorTest extends JexlTestCase { Assert.assertEquals("foo1", foo1.getSimpleName()); cctor.clear(); } - + @Test public void testFunctorOne() throws Exception { final JexlContext ctxt = new MapContext(); ctxt.set("value", 1000); - + // create a class foo1 with a ctor whose body gets a value // from the context to initialize its value final ClassCreator cctor = new ClassCreator(jexl, base); @@ -134,14 +134,14 @@ public class ClassCreatorTest extends JexlTestCase { Assert.assertEquals(foo1, result.getClass()); jexl.setClassLoader(cctor.getClassLoader()); cctor.clear(); - + // check we can invoke that ctor using its name or class final JexlScript script = jexl.createScript("(c)->{ new(c).value; }"); result = script.execute(ctxt, foo1); Assert.assertEquals(1010, result); result = script.execute(ctxt, foo1.getName()); Assert.assertEquals(1010, result); - + // re-create foo1 with a different body! cctor.setSeed(1); cctor.setCtorBody("value = (Integer) ctxt.get(\"value\") + 99;"); @@ -154,15 +154,15 @@ public class ClassCreatorTest extends JexlTestCase { // drum rolll.... jexl.setClassLoader(foo1.getClassLoader()); result = script.execute(ctxt, foo1.getName()); - // tada! + // tada! Assert.assertEquals(1099, result); result = script.execute(ctxt, foo1); Assert.assertEquals(1099, result); } - + public static class NsTest implements JexlContext.NamespaceFunctor { private final String className; - + public NsTest(final String cls) { className = cls; } @@ -171,27 +171,27 @@ public class ClassCreatorTest extends JexlTestCase { final JexlEngine jexl = JexlEngine.getThreadEngine(); return jexl.newInstance(className, context); } - + } - + @Test public void testFunctor2Name() throws Exception { functorTwo(ClassCreator.GEN_CLASS + "foo2"); } - + @Test public void testFunctor2Class() throws Exception { functorTwo(new NsTest(ClassCreator.GEN_CLASS + "foo2")); } - + void functorTwo(final Object nstest) throws Exception { - // create jexl2 with a 'test' namespace + // create jexl2 with a 'test' namespace final Map<String, Object> ns = new HashMap<String, Object>(); ns.put("test", nstest); final JexlEngine jexl2 = new JexlBuilder().namespaces(ns).create(); final JexlContext ctxt = new MapContext(); ctxt.set("value", 1000); - + // inject 'foo2' as test namespace functor class final ClassCreator cctor = new ClassCreator(jexl, base); cctor.setSeed(2); @@ -203,12 +203,12 @@ public class ClassCreatorTest extends JexlTestCase { Assert.assertEquals(foo1, result.getClass()); jexl2.setClassLoader(cctor.getClassLoader()); cctor.clear(); - + // check the namespace functor behavior final JexlScript script = jexl2.createScript("test:getValue()"); result = script.execute(ctxt, foo1.getName()); Assert.assertEquals(1010, result); - + // change the body cctor.setSeed(2); cctor.setCtorBody("value = (Integer) ctxt.get(\"value\") + 99;"); @@ -221,15 +221,15 @@ public class ClassCreatorTest extends JexlTestCase { // drum rolll.... jexl2.setClassLoader(foo1.getClassLoader()); result = script.execute(ctxt, foo1.getName()); - // tada! + // tada! Assert.assertEquals(1099, result); } - + @Test public void testFunctorThree() throws Exception { final JexlContext ctxt = new MapContext(); ctxt.set("value", 1000); - + final ClassCreator cctor = new ClassCreator(jexl, base); cctor.setSeed(2); cctor.setCtorBody("value = (Integer) ctxt.get(\"value\") + 10;"); @@ -240,15 +240,15 @@ public class ClassCreatorTest extends JexlTestCase { Assert.assertEquals(foo1, result.getClass()); jexl.setClassLoader(cctor.getClassLoader()); cctor.clear(); - + final Map<String, Object> ns = new HashMap<String, Object>(); ns.put("test", foo1); final JexlEngine jexl2 = new JexlBuilder().namespaces(ns).create(); - + final JexlScript script = jexl2.createScript("test:getValue()"); result = script.execute(ctxt, foo1.getName()); Assert.assertEquals(1010, result); - + cctor.setSeed(2); cctor.setCtorBody("value = (Integer) ctxt.get(\"value\") + 99;"); final Class<?> foo11 = cctor.createClass(true); @@ -260,10 +260,10 @@ public class ClassCreatorTest extends JexlTestCase { // drum rolll.... jexl2.setClassLoader(foo1.getClassLoader()); result = script.execute(ctxt, foo1.getName()); - // tada! + // tada! Assert.assertEquals(1099, result); } - + @Test public void testMany() throws Exception { // abort test if class creator can not run @@ -384,23 +384,23 @@ public class ClassCreatorTest extends JexlTestCase { r = s.execute(null, TwoCtors.class, 100f); Assert.assertEquals(-100, r); } - + public static class ContextualCtor { int value = -1; - + public ContextualCtor(final JexlContext ctxt) { value = (Integer) ctxt.get("value"); } - + public ContextualCtor(final JexlContext ctxt, final int v) { value = (Integer) ctxt.get("value") + v; } - + public int getValue() { return value; } } - + @Test public void testContextualCtor() throws Exception { final MapContext ctxt = new MapContext(); diff --git a/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java b/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java index 2569542..09ca169 100644 --- a/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java +++ b/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java @@ -34,15 +34,15 @@ public class ContextNamespaceTest extends JexlTestCase { */ public static class Taxes { private final double vat; - + public Taxes(final TaxesContext ctxt) { vat = ctxt.getVAT(); - } - + } + public Taxes(final double d) { vat = d; } - + public double vat(final double n) { return (n * vat) / 100.; } @@ -84,7 +84,7 @@ public class ContextNamespaceTest extends JexlTestCase { final Object result = staxes.execute(context); Assert.assertEquals(186., result); } - + @Test public void testNamespacePragma() throws Exception { final JexlEngine jexl = new JexlBuilder().create(); @@ -98,7 +98,7 @@ public class ContextNamespaceTest extends JexlTestCase { Assert.assertEquals(372., result); } - + @Test public void testNamespacePragmaString() throws Exception { final JexlEngine jexl = new JexlBuilder().create(); diff --git a/src/test/java/org/apache/commons/jexl3/DoWhileTest.java b/src/test/java/org/apache/commons/jexl3/DoWhileTest.java index 370606b..3756529 100644 --- a/src/test/java/org/apache/commons/jexl3/DoWhileTest.java +++ b/src/test/java/org/apache/commons/jexl3/DoWhileTest.java @@ -40,7 +40,7 @@ public class DoWhileTest extends JexlTestCase { e = JEXL.createScript("do {} while (false); 23"); o = e.execute(jc); Assert.assertEquals(23, o); - + } @Test @@ -52,12 +52,12 @@ public class DoWhileTest extends JexlTestCase { Object o = e.execute(jc); Assert.assertEquals(10, o); Assert.assertEquals(10, jc.get("x")); - + e = JEXL.createScript("var x = 0; do x += 1; while (x < 23)"); o = e.execute(jc); Assert.assertEquals(23, o); - - + + jc.set("x", 1); e = JEXL.createScript("do x += 1; while (x < 23); return 42;"); o = e.execute(jc); @@ -77,7 +77,7 @@ public class DoWhileTest extends JexlTestCase { Assert.assertEquals("x is wrong", new Integer(10), jc.get("x")); Assert.assertEquals("y is wrong", new Integer(512), jc.get("y")); } - + @Test public void testForEachBreakInsideFunction() throws Exception { try { @@ -88,7 +88,7 @@ public class DoWhileTest extends JexlTestCase { Assert.assertTrue(str.contains("break")); } } - + @Test public void testForEachContinueInsideFunction() throws Exception { try { @@ -99,42 +99,42 @@ public class DoWhileTest extends JexlTestCase { Assert.assertTrue(str.contains("continue")); } } - + @Test public void testForEachLambda() throws Exception { final JexlScript e = JEXL.createScript("(x)->{ for (i : 1..2) { continue; var y = function() { 42; } break; } }"); Assert.assertNotNull(e); } - + @Test public void testEmptyBody() throws Exception { final JexlScript e = JEXL.createScript("var i = 0; do ; while((i+=1) < 10); i"); final JexlContext jc = new MapContext(); final Object o = e.execute(jc); - Assert.assertEquals(10, o); + Assert.assertEquals(10, o); } - + @Test public void testEmptyStmtBody() throws Exception { final JexlScript e = JEXL.createScript("var i = 0; do {} while((i+=1) < 10); i"); final JexlContext jc = new MapContext(); final Object o = e.execute(jc); - Assert.assertEquals(10, o); - } - + Assert.assertEquals(10, o); + } + @Test public void testWhileEmptyBody() throws Exception { final JexlScript e = JEXL.createScript("var i = 0; while((i+=1) < 10); i"); final JexlContext jc = new MapContext(); final Object o = e.execute(jc); - Assert.assertEquals(10, o); + Assert.assertEquals(10, o); } - + @Test public void testWhileEmptyStmtBody() throws Exception { final JexlScript e = JEXL.createScript("var i = 0; while((i+=1) < 10) {}; i"); final JexlContext jc = new MapContext(); final Object o = e.execute(jc); - Assert.assertEquals(10, o); + Assert.assertEquals(10, o); } } diff --git a/src/test/java/org/apache/commons/jexl3/Issues200Test.java b/src/test/java/org/apache/commons/jexl3/Issues200Test.java index c4db522..df4309b 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues200Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues200Test.java @@ -595,7 +595,7 @@ public class Issues200Test extends JexlTestCase { Assert.assertTrue(sxs.contains("jvm")); } } - + @Test public void test275a() throws Exception { final JexlContext ctxt = new MapContext(); @@ -657,7 +657,7 @@ public class Issues200Test extends JexlTestCase { Assert.fail("should not have thrown" + xvar); } } - + @Test public void test278() throws Exception { final String[] srcs = new String[]{ diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java index 6898f66..68e73cd 100644 --- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java +++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java @@ -378,19 +378,19 @@ public class Issues300Test { Assert.assertEquals(ctls[i], output); } } - + public static class User322 { public String getName() { return "user322"; } } - + public static class Session322 { public User322 getUser() { return new User322(); } } - + @Test public void test322b() throws Exception { final MapContext ctxt = new MapContext(); @@ -401,26 +401,26 @@ public class Issues300Test { JxltEngine.Template template; String output; template = jxlt.createTemplate("$$", new StringReader(src)); - + ctxt.set("session", new Session322()); strw = new StringWriter(); template.evaluate(ctxt, strw); output = strw.toString(); Assert.assertEquals("L'utilisateur user322 s'est connecte", output); - + ctxt.set("session.user", new User322()); strw = new StringWriter(); template.evaluate(ctxt, strw); output = strw.toString(); Assert.assertEquals("L'utilisateur user322 s'est connecte", output); - + ctxt.set("session.user.name", "user322"); strw = new StringWriter(); template.evaluate(ctxt, strw); output = strw.toString(); Assert.assertEquals("L'utilisateur user322 s'est connecte", output); } - + @Test public void test323() throws Exception { final JexlEngine jexl = new JexlBuilder().safe(false).create(); @@ -428,37 +428,37 @@ public class Issues300Test { final JexlContext jc = new MapContext(vars); JexlScript script; Object result; - + // nothing in context, ex try { script = jexl.createScript("a.n.t.variable"); - result = script.execute(jc); + result = script.execute(jc); Assert.fail("a.n.t.variable is undefined!"); } catch(final JexlException.Variable xvar) { Assert.assertTrue(xvar.toString().contains("a.n.t")); } - + // defined and null jc.set("a.n.t.variable", null); script = jexl.createScript("a.n.t.variable"); result = script.execute(jc); Assert.assertNull(result); - + // defined and null, dereference jc.set("a.n.t", null); try { script = jexl.createScript("a.n.t[0].variable"); - result = script.execute(jc); + result = script.execute(jc); Assert.fail("a.n.t is null!"); } catch(final JexlException.Variable xvar) { Assert.assertTrue(xvar.toString().contains("a.n.t")); } - + // undefined, dereference vars.remove("a.n.t"); try { script = jexl.createScript("a.n.t[0].variable"); - result = script.execute(jc); + result = script.execute(jc); Assert.fail("a.n.t is undefined!"); } catch(final JexlException.Variable xvar) { Assert.assertTrue(xvar.toString().contains("a.n.t")); @@ -468,7 +468,7 @@ public class Issues300Test { vars.put("a.n.t", inner); try { script = jexl.createScript("a.n.t[0].variable"); - result = script.execute(jc); + result = script.execute(jc); Assert.fail("a.n.t is null!"); } catch(final JexlException.Property xprop) { Assert.assertTrue(xprop.toString().contains("0")); @@ -477,14 +477,14 @@ public class Issues300Test { inner.add(42); try { script = jexl.createScript("a.n.t[0].variable"); - result = script.execute(jc); + result = script.execute(jc); Assert.fail("a.n.t is null!"); } catch(final JexlException.Property xprop) { Assert.assertTrue(xprop.toString().contains("variable")); } - + } - + @Test public void test324() throws Exception { final JexlEngine jexl = new JexlBuilder().create(); @@ -529,7 +529,7 @@ public class Issues300Test { result = script.execute(jc, map, "42"); Assert.assertEquals(42, result); } - + @Test public void test330() throws Exception { final JexlEngine jexl = new JexlBuilder().create(); diff --git a/src/test/java/org/apache/commons/jexl3/JXLTTest.java b/src/test/java/org/apache/commons/jexl3/JXLTTest.java index 88ebbb8..2598bc3 100644 --- a/src/test/java/org/apache/commons/jexl3/JXLTTest.java +++ b/src/test/java/org/apache/commons/jexl3/JXLTTest.java @@ -49,14 +49,14 @@ public class JXLTTest extends JexlTestCase { private final JexlBuilder BUILDER; private final JexlEngine ENGINE; private final JxltEngine JXLT; - + public JXLTTest(final JexlBuilder builder) { super("JXLTTest"); BUILDER = builder; ENGINE = BUILDER.create(); JXLT = ENGINE.createJxltEngine(); } - + @Parameterized.Parameters public static List<JexlBuilder> engines() { @@ -72,7 +72,7 @@ public class JXLTTest extends JexlTestCase { .cache(128).strict(true), }); } - + @Before @Override public void setUp() throws Exception { @@ -87,7 +87,7 @@ public class JXLTTest extends JexlTestCase { debuggerCheck(ENGINE); super.tearDown(); } - + private boolean isLexicalShade() { JexlOptions options = context.getEngineOptions(); if (options.isLexicalShade()) { @@ -584,17 +584,17 @@ public class JXLTTest extends JexlTestCase { Assert.assertNotNull(refactored); Assert.assertEquals(test42, refactored); } - + @Test public void testInheritedDebugger() throws Exception { final String src = "if ($A) { $B + 1; } else { $C - 2 }"; final JexlEngine jexl = JXLT.getEngine(); final JexlScript script = jexl.createScript(src); - + final Debugger sd = new Debugger(); final String rscript = sd.debug(script)? sd.toString() : null; Assert.assertNotNull(rscript); - + final TemplateDebugger td = new TemplateDebugger(); final String refactored = td.debug(script)? td.toString() : null; Assert.assertNotNull(refactored); @@ -768,7 +768,7 @@ public class JXLTTest extends JexlTestCase { final Object value = ENGINE.createScript(expr).execute(context); Assert.assertEquals(expr, "H\"ello \nHenrib", value); } - + @Test public void testInterpolationLvsG2() throws Exception { if (isLexicalShade()) { @@ -806,11 +806,11 @@ public class JXLTTest extends JexlTestCase { t.evaluate(context, strw); final String output = strw.toString(); Assert.assertTrue(output.contains("table1") && output.contains("table2")); - } + } public static class Executor311 { private final String name; - + public Executor311(final String name) { this.name = name; } @@ -827,15 +827,15 @@ public class JXLTTest extends JexlTestCase { return script.execute(JexlEngine.getThreadContext(), actuals); } } - - public static class Context311 extends MapContext + + public static class Context311 extends MapContext implements JexlContext.OptionsHandle, JexlContext.ThreadLocal { private JexlOptions options = null; - + public void setOptions(final JexlOptions o) { options = o; } - + public Executor311 exec(final String name) { return new Executor311(name); } @@ -844,13 +844,13 @@ public class JXLTTest extends JexlTestCase { public JexlOptions getEngineOptions() { return options; } - + JexlOptions newOptions() { options = new JexlOptions(); return options; } } - + @Test public void test311a() throws Exception { final JexlContext ctx = null; @@ -878,7 +878,7 @@ public class JXLTTest extends JexlTestCase { final String output = strw.toString(); Assert.assertEquals("<p>Universe 42</p>\n", output); } - + @Test public void test311c() throws Exception { final Context311 ctx311 = new Context311(); @@ -893,7 +893,7 @@ public class JXLTTest extends JexlTestCase { final String output = strw.toString(); Assert.assertEquals("<p>Universe 42</p>\n", output); } - + @Test public void test311d() throws Exception { final Context311 ctx311 = new Context311(); @@ -908,7 +908,7 @@ public class JXLTTest extends JexlTestCase { final String output = strw.toString(); Assert.assertEquals("<p>Universe 42</p>\n", output); } - + @Test public void test311e() throws Exception { final Context311 ctx311 = new Context311(); @@ -920,8 +920,8 @@ public class JXLTTest extends JexlTestCase { final JexlScript script = JEXL.createScript(rpt); final String output = script.execute(ctx311, 42).toString(); Assert.assertEquals("<p>Universe 42</p>", output); - } - + } + @Test public void test311f() throws Exception { final Context311 ctx311 = new Context311(); @@ -934,7 +934,7 @@ public class JXLTTest extends JexlTestCase { final String output = script.execute(ctx311, 42).toString(); Assert.assertEquals("<p>Universe 42</p>", output); } - + @Test public void test311g() throws Exception { final Context311 ctx311 = new Context311(); @@ -946,8 +946,8 @@ public class JXLTTest extends JexlTestCase { final JexlScript script = JEXL.createScript(rpt); final String output = script.execute(ctx311, "4", "2").toString(); Assert.assertEquals("<p>Universe 42</p>", output); - } - + } + @Test public void test311h() throws Exception { final Context311 ctx311 = new Context311(); @@ -956,8 +956,8 @@ public class JXLTTest extends JexlTestCase { final JexlScript script = JEXL.createScript(rpt, "a", "b"); final String output = script.execute(ctx311, "4", "2").toString(); Assert.assertEquals("<p>Universe 42</p>", output); - } - + } + @Test public void test311i() throws Exception { final JexlContext ctx311 = new Context311(); @@ -971,28 +971,28 @@ public class JXLTTest extends JexlTestCase { final String output = strw.toString(); Assert.assertEquals("<p>Universe 42</p>\n", output); } - + @Test public void test315() throws Exception { String s315; StringWriter strw; JxltEngine.Template t315; String output; - + s315 = "<report/>$"; t315 = JXLT.createTemplate("$$", new StringReader(s315)); strw = new StringWriter(); t315.evaluate(context, strw); output = strw.toString(); Assert.assertEquals(s315, output); - + s315 = "<foo/>#"; t315 = JXLT.createTemplate("$$", new StringReader(s315)); strw = new StringWriter(); t315.evaluate(context, strw); output = strw.toString(); Assert.assertEquals(s315, output); - + s315 = "<bar/>\\"; t315 = JXLT.createTemplate("$$", new StringReader(s315)); strw = new StringWriter(); @@ -1000,7 +1000,7 @@ public class JXLTTest extends JexlTestCase { output = strw.toString(); Assert.assertEquals(s315, output); } - + // define mode pro50 static final JexlOptions MODE_PRO50 = new JexlOptions(); static { @@ -1034,7 +1034,7 @@ public class JXLTTest extends JexlTestCase { return options; } } - + @Test public void testLexicalTemplate() throws Exception { final JexlOptions opts = new JexlOptions(); @@ -1049,15 +1049,15 @@ public class JXLTTest extends JexlTestCase { + " ${$options.lexical?'+':'-'}lexical" + " ${$options.lexicalShade?'+':'-'}lexicalShade" + " ${$options.safe?'+':'-'}safe"; - + final JxltEngine.Template tmplt0 = JXLT.createTemplate("$$", new StringReader(src0)); final Writer strw0 = new StringWriter(); tmplt0.evaluate(ctxt, strw0); final String output0 = strw0.toString(); Assert.assertEquals( "-strict -cancellable -lexical -lexicalShade +safe", output0); - + final String src = "$$ #pragma script.mode pro50\n" + src0; - + final JxltEngine.Template tmplt = JXLT.createTemplate("$$", new StringReader(src)); final Writer strw = new StringWriter(); tmplt.evaluate(ctxt, strw); @@ -1088,7 +1088,7 @@ public class JXLTTest extends JexlTestCase { Assert.assertFalse(xvar.isUndefined()); } } - + @Test public void testTemplateOutOfScope() throws Exception { final JexlOptions opts = new JexlOptions(); @@ -1130,7 +1130,7 @@ public class JXLTTest extends JexlTestCase { Assert.assertTrue(xany.getMessage().contains("tab")); } } - + @Test public void testCommentedTemplate0() throws Exception { final JexlContext ctxt = new MapContext(); diff --git a/src/test/java/org/apache/commons/jexl3/JexlEvalContext.java b/src/test/java/org/apache/commons/jexl3/JexlEvalContext.java index 65e61f4..0a39dc7 100644 --- a/src/test/java/org/apache/commons/jexl3/JexlEvalContext.java +++ b/src/test/java/org/apache/commons/jexl3/JexlEvalContext.java @@ -32,7 +32,7 @@ public class JexlEvalContext implements /** The variables.*/ private final JexlContext vars; /** The namespace. */ - private final JexlContext.NamespaceResolver ns; + private final JexlContext.NamespaceResolver ns; /** The options. */ private final JexlOptions options = new JexlOptions(); @@ -43,7 +43,7 @@ public class JexlEvalContext implements public JexlEvalContext() { this(EMPTY_MAP); } - + /** * Creates an evaluation environment wrapping an existing user provided vars. * <p>The supplied vars should be null only in derived classes that override the get/set/has methods. diff --git a/src/test/java/org/apache/commons/jexl3/JexlTestCase.java b/src/test/java/org/apache/commons/jexl3/JexlTestCase.java index 7fb5f50..7683d6a 100644 --- a/src/test/java/org/apache/commons/jexl3/JexlTestCase.java +++ b/src/test/java/org/apache/commons/jexl3/JexlTestCase.java @@ -61,11 +61,11 @@ public class JexlTestCase { public void tearDown() throws Exception { debuggerCheck(JEXL); } - + static JexlEngine createEngine() { return new JexlBuilder().create(); } - + public static JexlEngine createEngine(final boolean lenient) { return new JexlBuilder().arithmetic(new JexlArithmetic(!lenient)).cache(128).create(); } diff --git a/src/test/java/org/apache/commons/jexl3/LexicalTest.java b/src/test/java/org/apache/commons/jexl3/LexicalTest.java index 8f1f256..deff63c 100644 --- a/src/test/java/org/apache/commons/jexl3/LexicalTest.java +++ b/src/test/java/org/apache/commons/jexl3/LexicalTest.java @@ -286,7 +286,7 @@ public class LexicalTest { final String ctl = "<report>\n\n3\n</report>\n"; Assert.assertEquals(ctl, output); } - + public static class DebugContext extends MapContext { public DebugContext() { } @@ -310,7 +310,7 @@ public class LexicalTest { Assert.fail(ww); } } - + @Test public void testLexical6a() throws Exception { final String str = "i = 0; { var i = 32; }; i"; @@ -319,7 +319,7 @@ public class LexicalTest { final JexlContext ctxt = new MapContext(); final Object o = e.execute(ctxt); Assert.assertEquals(0, o); - } + } @Test public void testLexical6b() throws Exception { @@ -358,7 +358,7 @@ public class LexicalTest { Assert.assertNotNull(xany); } } - + @Test public void testPragmaOptions() throws Exception { // same as 6d but using a pragma @@ -374,7 +374,7 @@ public class LexicalTest { Assert.assertNotNull(xany); } } - + @Test public void testPragmaNoop() throws Exception { // unknow pragma @@ -385,8 +385,8 @@ public class LexicalTest { final Object result = e.execute(ctxt); Assert.assertEquals(42, result); } - - + + @Test public void testScopeFrame() throws Exception { final LexicalScope scope = new LexicalScope(); @@ -399,7 +399,7 @@ public class LexicalTest { Assert.assertFalse(scope.hasSymbol(i + 1)); } } - + @Test public void testContextualOptions0() throws Exception { final JexlFeatures f= new JexlFeatures(); @@ -418,7 +418,7 @@ public class LexicalTest { Assert.assertNotNull(xf); } } - + /** * Context augmented with a tryCatch. */ @@ -472,7 +472,7 @@ public class LexicalTest { // result is exception! Assert.assertTrue(result instanceof JexlException.Variable); } - + @Test public void testParameter0() throws Exception { final String str = "function(u) {}"; @@ -481,8 +481,8 @@ public class LexicalTest { Assert.assertEquals(1, e.getParameters().length); e = jexl.createScript(new JexlInfo("TestScript", 1, 1), str); Assert.assertEquals(1, e.getParameters().length); - } - + } + @Test public void testParameter1() throws Exception { final JexlEngine jexl = new JexlBuilder().strict(true).lexical(true).create(); @@ -492,7 +492,7 @@ public class LexicalTest { final Object result = s42.execute(jc); Assert.assertEquals(42, result); } - + @Test public void testInnerAccess0() throws Exception { final JexlFeatures f = new JexlFeatures(); @@ -504,13 +504,13 @@ public class LexicalTest { + "();"); Assert.assertNull(script.execute(null)); } - + @Test public void testInnerAccess1() throws Exception { final JexlEngine jexl = new JexlBuilder().strict(true).lexical(true).create(); final JexlScript script = jexl.createScript("var x = 32; (()->{ for(var x : null) { var c = 0; {return x; }} })();"); } - + @Test public void testForVariable0() throws Exception { final JexlFeatures f = new JexlFeatures(); @@ -524,7 +524,7 @@ public class LexicalTest { // OK } } - + @Test public void testForVariable1() throws Exception { final JexlFeatures f = new JexlFeatures(); @@ -539,7 +539,7 @@ public class LexicalTest { Assert.assertTrue(ex instanceof JexlException); } } - + @Test public void testUndeclaredVariable() throws Exception { final JexlFeatures f = new JexlFeatures(); @@ -554,7 +554,7 @@ public class LexicalTest { Assert.assertTrue(ex instanceof JexlException); } } - + @Test public void testLexical6a1() throws Exception { final String str = "i = 0; { var i = 32; }; i"; @@ -564,7 +564,7 @@ public class LexicalTest { final JexlScript e = jexl.createScript(str); final JexlContext ctxt = new MapContext(); final Object o = e.execute(ctxt); - Assert.assertEquals(0, o); + Assert.assertEquals(0, o); } public static class VarContext extends MapContext implements JexlContext.PragmaProcessor, JexlContext.OptionsHandle { @@ -590,8 +590,8 @@ public class LexicalTest { public JexlOptions getEngineOptions() { return options; } - } - + } + @Test public void testInternalLexicalFeatures() throws Exception { final String str = "42"; @@ -613,7 +613,7 @@ public class LexicalTest { Assert.assertTrue(opts.isLexical()); Assert.assertTrue(opts.isLexicalShade()); } - + @Test public void testOptionsPragma() throws Exception { try { @@ -671,7 +671,7 @@ public class LexicalTest { final JexlFeatures ft1= runVarLoop(true, src1); final JexlFeatures ff2 = runVarLoop(false, src2); final JexlFeatures ft2= runVarLoop(true, src2); - + // and check some features features Assert.assertEquals(ff0, ff1); Assert.assertEquals(ft0, ft1); @@ -702,7 +702,7 @@ public class LexicalTest { Assert.assertEquals(10, out.size()); return features; } - + public static class OptAnnotationContext extends JexlEvalContext implements JexlContext.AnnotationProcessor { @Override public Object processAnnotation(final String name, final Object[] args, final Callable<Object> statement) throws Exception { @@ -721,7 +721,7 @@ public class LexicalTest { return statement.call(); } } - + @Test public void testAnnotation() throws Exception { final JexlFeatures f = new JexlFeatures(); @@ -732,7 +732,7 @@ public class LexicalTest { final Object result = script.execute(jc); Assert.assertEquals(42, result); } - + @Test public void testNamed() throws Exception { final JexlFeatures f = new JexlFeatures(); @@ -743,7 +743,7 @@ public class LexicalTest { final Object result = script.execute(jc); Assert.assertEquals(42, result); } - + @Test public void tesstCaptured0() throws Exception { final JexlFeatures f = new JexlFeatures(); @@ -755,7 +755,7 @@ public class LexicalTest { final Object result = script.execute(jc); Assert.assertEquals(42, result); } - + @Test public void testCaptured1() throws Exception { final JexlFeatures f = new JexlFeatures(); @@ -767,5 +767,5 @@ public class LexicalTest { jc.set("x", 11); final Object result = script.execute(jc); Assert.assertEquals(43, result); - } + } } diff --git a/src/test/java/org/apache/commons/jexl3/MethodTest.java b/src/test/java/org/apache/commons/jexl3/MethodTest.java index 4808f38..aeb1688 100644 --- a/src/test/java/org/apache/commons/jexl3/MethodTest.java +++ b/src/test/java/org/apache/commons/jexl3/MethodTest.java @@ -177,11 +177,11 @@ public class MethodTest extends JexlTestCase { public static class Functor { private boolean overKill = false; private String under = null; - + void setKill(final boolean ok) { overKill = ok; } - + public int ten() { return 10; } @@ -282,7 +282,7 @@ public class MethodTest extends JexlTestCase { Assert.fail("method should not have thrown!"); } } - + @Test public void testAmbiguousInvoke() throws Exception { // JEXL-299 @@ -319,13 +319,13 @@ public class MethodTest extends JexlTestCase { ctxt.set("func", func); Object result; final JexlUberspect uber = JEXL.getUberspect(); - // tryInvoke + // tryInvoke final JexlMethod method = uber.getMethod(func, "over", "foo", 42); Assert.assertNotNull(method); - // tryInvoke succeeds + // tryInvoke succeeds result = method.tryInvoke("over", func, "foo", 42); Assert.assertEquals("foo + 42", result); - // tryInvoke fails + // tryInvoke fails func.setKill(true); try { /*result = */method.tryInvoke("over", func, "foo", 42); @@ -369,7 +369,7 @@ public class MethodTest extends JexlTestCase { Assert.assertFalse(getter.tryFailed(result)); Assert.assertEquals("-42", result); } - + @Test public void testTryFailedScript() throws Exception { // JEXL-257 @@ -379,13 +379,13 @@ public class MethodTest extends JexlTestCase { Object result; final JexlUberspect uber = JEXL.getUberspect(); final JexlScript method = JEXL.createScript("(x, y)->{ func.over(x, y) }"); - // tryInvoke + // tryInvoke //JexlMethod method = uber.getMethod(func, "over", "foo", 42); Assert.assertNotNull(method); - // tryInvoke succeeds + // tryInvoke succeeds result = method.execute(ctxt, "foo", 42); Assert.assertEquals("foo + 42", result); - // tryInvoke fails + // tryInvoke fails func.setKill(true); try { /*result = */method.execute(ctxt, "foo", 42); diff --git a/src/test/java/org/apache/commons/jexl3/PragmaTest.java b/src/test/java/org/apache/commons/jexl3/PragmaTest.java index 70ce468..321cec2 100644 --- a/src/test/java/org/apache/commons/jexl3/PragmaTest.java +++ b/src/test/java/org/apache/commons/jexl3/PragmaTest.java @@ -59,7 +59,7 @@ public class PragmaTest extends JexlTestCase { Assert.assertEquals(1, pragmas.get("one")); Assert.assertEquals("truth", pragmas.get("the.very.hard")); } - + public static class SafeContext extends JexlEvalContext { // @Override public void processPragmas(final Map<String, Object> pragmas) { @@ -108,11 +108,11 @@ public class PragmaTest extends JexlTestCase { } } - + public static class StaticSleeper { // precludes instantiation private StaticSleeper() {} - + public static void sleep(final long ms) { try { Thread.sleep(ms); @@ -121,7 +121,7 @@ public class PragmaTest extends JexlTestCase { } } } - + public static class Sleeper { public void sleep(final long ms) { try { diff --git a/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java b/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java index 671f1e6..bf3255f 100644 --- a/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java +++ b/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java @@ -94,10 +94,10 @@ public class ScriptCallableTest extends JexlTestCase { Assert.assertTrue(c.isCancelled()); Assert.assertTrue(lr == null || lr.isEmpty()); } - + public static class CancellationContext extends MapContext implements JexlContext.CancellationHandle { private final AtomicBoolean cancellation; - + CancellationContext(final AtomicBoolean c) { cancellation = c; } @@ -106,7 +106,7 @@ public class ScriptCallableTest extends JexlTestCase { return cancellation; } } - + // JEXL-317 @Test public void testCallableCancellation() throws Exception { @@ -139,7 +139,7 @@ public class ScriptCallableTest extends JexlTestCase { Assert.assertTrue(c.isCancelled()); Assert.assertTrue(lr == null || lr.isEmpty()); } - + @Test public void testCallableTimeout() throws Exception { List<Runnable> lr = null; diff --git a/src/test/java/org/apache/commons/jexl3/ScriptTest.java b/src/test/java/org/apache/commons/jexl3/ScriptTest.java index 79c9b36..a501e3b 100644 --- a/src/test/java/org/apache/commons/jexl3/ScriptTest.java +++ b/src/test/java/org/apache/commons/jexl3/ScriptTest.java @@ -60,7 +60,7 @@ public class ScriptTest extends JexlTestCase { final JexlScript s = JEXL.createScript(code); Assert.assertNotNull(s); } - + /** * Test creating a script from a string. */ @@ -86,7 +86,7 @@ public class ScriptTest extends JexlTestCase { Assert.assertNotNull("No result", result); Assert.assertEquals("Wrong result", new Integer(7), result); } - + @Test public void testArgScriptFromFile() throws Exception { final File testScript = new File(TEST_ADD); diff --git a/src/test/java/org/apache/commons/jexl3/SynchronizedArithmetic.java b/src/test/java/org/apache/commons/jexl3/SynchronizedArithmetic.java index 612ba32..a851d12 100644 --- a/src/test/java/org/apache/commons/jexl3/SynchronizedArithmetic.java +++ b/src/test/java/org/apache/commons/jexl3/SynchronizedArithmetic.java @@ -118,7 +118,7 @@ public class SynchronizedArithmetic extends JexlArithmetic { // super.monitorExit(o); // } // } - + /** * Crude monitor replacement... */ @@ -161,7 +161,7 @@ public class SynchronizedArithmetic extends JexlArithmetic { } } } - + /** * An iterator that implements Closeable (at least implements a close method) * and uses monitors to protect iteration. diff --git a/src/test/java/org/apache/commons/jexl3/VarTest.java b/src/test/java/org/apache/commons/jexl3/VarTest.java index e6e1027..19a750a 100644 --- a/src/test/java/org/apache/commons/jexl3/VarTest.java +++ b/src/test/java/org/apache/commons/jexl3/VarTest.java @@ -391,7 +391,7 @@ public class VarTest extends JexlTestCase { cal.setTime(date); cal.setLenient(true); } - + /** * Gets a date property * @param property yyyy or MM or dd @@ -410,7 +410,7 @@ public class VarTest extends JexlTestCase { } return null; } - + /** * Gets a list of properties. * @param keys the property names @@ -419,7 +419,7 @@ public class VarTest extends JexlTestCase { public List<String> get(final String[] keys) { return get(Arrays.asList(keys)); } - + /** * Gets a list of properties. * @param keys the property names @@ -434,8 +434,8 @@ public class VarTest extends JexlTestCase { } } return values; - } - + } + /** * Gets a map of properties. * <p>Uses each map key as a property name and each value as an alias @@ -475,7 +475,7 @@ public class VarTest extends JexlTestCase { } continue; } - // identifier pending to be added (only add map keys) + // identifier pending to be added (only add map keys) if (id != null && c == ']' || c == ')' || (kind != '{' && c == ',') // array or set || (kind == '{' && c == ':')) // map key @@ -496,7 +496,7 @@ public class VarTest extends JexlTestCase { } return ids.toArray(new String[ids.size()]); } - + @Test public void testReferenceLiteral() throws Exception { final JexlEngine jexld = new JexlBuilder().collectMode(2).create(); @@ -508,25 +508,25 @@ public class VarTest extends JexlTestCase { final JexlContext ctxt = new MapContext(); //d.yyyy = 1969; d.MM = 7; d.dd = 20 ctxt.set("moon.landing", new VarDate("1969-07-20")); - + script = jexld.createScript("moon.landing[['yyyy', 'MM', 'dd']]"); result = (List<String>) script.execute(ctxt); Assert.assertEquals(Arrays.asList("1969", "7", "20"), result); - + vars = script.getVariables(); Assert.assertEquals(1, vars.size()); List<String> var = vars.iterator().next(); Assert.assertEquals("moon", var.get(0)); Assert.assertEquals("landing", var.get(1)); Assert.assertArrayEquals(new String[]{"yyyy", "MM", "dd"}, readIdentifiers(var.get(2))); - + script = jexld.createScript("moon.landing[ { 'yyyy' : 'year', 'MM' : 'month', 'dd' : 'day' } ]"); final Map<String, String> mapr = (Map<String, String>) script.execute(ctxt); Assert.assertEquals(3, mapr.size()); Assert.assertEquals("1969", mapr.get("year")); Assert.assertEquals("7", mapr.get("month")); Assert.assertEquals("20", mapr.get("day")); - + vars = script.getVariables(); Assert.assertEquals(1, vars.size()); var = vars.iterator().next(); @@ -540,7 +540,7 @@ public class VarTest extends JexlTestCase { JexlBuilder builder = new JexlBuilder().collectMode(2); Assert.assertEquals(2, builder.collectMode()); Assert.assertTrue(builder.collectAll()); - + JexlEngine jexld = builder.create(); JexlScript e = jexld.createScript("x.y[['z', 't']]"); Set<List<String>> vars = e.getVariables(); @@ -551,33 +551,33 @@ public class VarTest extends JexlTestCase { vars = e.getVariables(); Assert.assertEquals(1, vars.size()); Assert.assertTrue(eq(mkref(new String[][]{{"x", "y", "{ 'z' : 't' }"}}), vars)); - + e = jexld.createScript("x.y.'{ \\'z\\' : \\'t\\' }'"); vars = e.getVariables(); Assert.assertEquals(1, vars.size()); Assert.assertTrue(eq(mkref(new String[][]{{"x", "y", "{ 'z' : 't' }"}}), vars)); - + // only string or number literals builder = builder.collectAll(true); Assert.assertEquals(1, builder.collectMode()); Assert.assertTrue(builder.collectAll()); - + jexld = builder.create(); e = jexld.createScript("x.y[{'z': 't'}]"); vars = e.getVariables(); Assert.assertEquals(1, vars.size()); Assert.assertTrue(eq(mkref(new String[][]{{"x", "y"}}), vars)); - + e = jexld.createScript("x.y[['z', 't']]"); vars = e.getVariables(); Assert.assertEquals(1, vars.size()); Assert.assertTrue(eq(mkref(new String[][]{{"x", "y"}}), vars)); - + e = jexld.createScript("x.y['z']"); vars = e.getVariables(); Assert.assertEquals(1, vars.size()); Assert.assertTrue(eq(mkref(new String[][]{{"x", "y", "z"}}), vars)); - + e = jexld.createScript("x.y[42]"); vars = e.getVariables(); Assert.assertEquals(1, vars.size()); diff --git a/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java b/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java index dc32ba5..24190c4 100644 --- a/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java +++ b/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java @@ -69,7 +69,7 @@ public class SandboxTest extends JexlTestCase { public void callMeNot() { throw new RuntimeException("should not be callable!"); } - + public String allowInherit() { return "this is allowed"; } @@ -100,7 +100,7 @@ public class SandboxTest extends JexlTestCase { public String Quux() { return name + "-quux"; } - + public int doIt() { return 42; } @@ -211,7 +211,7 @@ public class SandboxTest extends JexlTestCase { LOGGER.info(xvar.toString()); } } - + @Test public void testCantSeeMe() throws Exception { final JexlContext jc = new MapContext(); @@ -385,7 +385,7 @@ public class SandboxTest extends JexlTestCase { final List<String> foo = new ArrayList<String>(); final JexlSandbox sandbox = new JexlSandbox(false, true); sandbox.allow(java.util.List.class.getName()); - + final JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).safe(false).strict(true).create(); final JexlScript method = sjexl.createScript("foo.add(y)", "foo", "y"); final JexlScript set = sjexl.createScript("foo[x] = y", "foo", "x", "y"); @@ -404,13 +404,13 @@ public class SandboxTest extends JexlTestCase { result = get.execute(null, foo, 0); Assert.assertEquals("42", result); } - + public abstract static class Operation { protected final int base; public Operation(final int sz) { base = sz; } - + public abstract int someOp(int x); public abstract int nonCallable(int y); } @@ -453,7 +453,7 @@ public class SandboxTest extends JexlTestCase { LOGGER.info(xjm.toString()); } } - + public static class Foo42 { public int getFoo() { return 42; @@ -474,11 +474,11 @@ public class SandboxTest extends JexlTestCase { return 44; } } - + @Test public void testNoJexl312() throws Exception { final JexlContext ctxt = new MapContext(); - + final JexlEngine sjexl = new JexlBuilder().safe(false).strict(true).create(); final JexlScript foo = sjexl.createScript("x.getFoo()", "x"); try { diff --git a/src/test/java/org/apache/commons/jexl3/parser/ParserTest.java b/src/test/java/org/apache/commons/jexl3/parser/ParserTest.java index 94eb462..fa91404 100644 --- a/src/test/java/org/apache/commons/jexl3/parser/ParserTest.java +++ b/src/test/java/org/apache/commons/jexl3/parser/ParserTest.java @@ -76,7 +76,7 @@ public class ParserTest { Assert.fail(xother.toString()); } } - + @Test public void testIdentifierEscape() { final String[] ids = new String[]{"a\\ b", "a\\ b\\ c", "a\\'b\\\"c", "a\\ \\ c"};