You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/11/21 03:12:45 UTC
[commons-jexl] branch master updated: Use final.
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 f8b0e86 Use final.
f8b0e86 is described below
commit f8b0e8604216411d4a9c722dd3de7bd2c9413c0a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 20 22:12:38 2020 -0500
Use final.
---
.../org/apache/commons/jexl3/JexlArithmetic.java | 340 ++++++------
.../java/org/apache/commons/jexl3/JexlBuilder.java | 46 +-
.../java/org/apache/commons/jexl3/JexlEngine.java | 42 +-
.../org/apache/commons/jexl3/JexlException.java | 144 ++---
.../org/apache/commons/jexl3/JexlFeatures.java | 44 +-
.../java/org/apache/commons/jexl3/JexlInfo.java | 18 +-
.../org/apache/commons/jexl3/JexlOperator.java | 4 +-
.../java/org/apache/commons/jexl3/JexlOptions.java | 38 +-
.../java/org/apache/commons/jexl3/JxltEngine.java | 14 +-
.../java/org/apache/commons/jexl3/MapContext.java | 8 +-
.../org/apache/commons/jexl3/ObjectContext.java | 22 +-
.../commons/jexl3/internal/ArrayBuilder.java | 14 +-
.../org/apache/commons/jexl3/internal/Closure.java | 30 +-
.../apache/commons/jexl3/internal/Debugger.java | 256 ++++-----
.../org/apache/commons/jexl3/internal/Engine.java | 160 +++---
.../org/apache/commons/jexl3/internal/Frame.java | 16 +-
.../commons/jexl3/internal/IntegerRange.java | 36 +-
.../apache/commons/jexl3/internal/Interpreter.java | 608 ++++++++++-----------
.../commons/jexl3/internal/InterpreterBase.java | 174 +++---
.../commons/jexl3/internal/LexicalFrame.java | 12 +-
.../commons/jexl3/internal/LexicalScope.java | 14 +-
.../apache/commons/jexl3/internal/LongRange.java | 36 +-
.../apache/commons/jexl3/internal/MapBuilder.java | 4 +-
.../apache/commons/jexl3/internal/Operators.java | 86 +--
.../org/apache/commons/jexl3/internal/Scope.java | 54 +-
.../org/apache/commons/jexl3/internal/Script.java | 42 +-
.../commons/jexl3/internal/ScriptVisitor.java | 152 +++---
.../apache/commons/jexl3/internal/SetBuilder.java | 4 +-
.../apache/commons/jexl3/internal/SoftCache.java | 16 +-
.../org/apache/commons/jexl3/internal/Source.java | 4 +-
.../commons/jexl3/internal/TemplateDebugger.java | 56 +-
.../commons/jexl3/internal/TemplateEngine.java | 188 +++----
.../jexl3/internal/TemplateInterpreter.java | 52 +-
.../commons/jexl3/internal/TemplateScript.java | 86 +--
.../internal/introspection/AbstractExecutor.java | 30 +-
.../internal/introspection/ArrayIterator.java | 2 +-
.../internal/introspection/ArrayListWrapper.java | 12 +-
.../internal/introspection/BooleanGetExecutor.java | 14 +-
.../jexl3/internal/introspection/ClassMap.java | 48 +-
.../internal/introspection/ConstructorMethod.java | 18 +-
.../internal/introspection/DuckGetExecutor.java | 16 +-
.../internal/introspection/DuckSetExecutor.java | 14 +-
.../introspection/EnumerationIterator.java | 2 +-
.../internal/introspection/FieldGetExecutor.java | 14 +-
.../internal/introspection/FieldSetExecutor.java | 14 +-
.../jexl3/internal/introspection/IndexedType.java | 26 +-
.../jexl3/internal/introspection/Introspector.java | 54 +-
.../internal/introspection/ListGetExecutor.java | 8 +-
.../internal/introspection/ListSetExecutor.java | 12 +-
.../internal/introspection/MapGetExecutor.java | 6 +-
.../internal/introspection/MapSetExecutor.java | 8 +-
.../internal/introspection/MethodExecutor.java | 22 +-
.../jexl3/internal/introspection/MethodKey.java | 104 ++--
.../jexl3/internal/introspection/Permissions.java | 36 +-
.../introspection/PropertyGetExecutor.java | 18 +-
.../introspection/PropertySetExecutor.java | 32 +-
.../internal/introspection/SandboxUberspect.java | 20 +-
.../jexl3/internal/introspection/Uberspect.java | 60 +-
.../commons/jexl3/introspection/JexlSandbox.java | 96 ++--
.../commons/jexl3/introspection/JexlUberspect.java | 4 +-
.../apache/commons/jexl3/parser/ASTAmbiguous.java | 6 +-
.../apache/commons/jexl3/parser/ASTAnnotation.java | 8 +-
.../commons/jexl3/parser/ASTArrayLiteral.java | 12 +-
.../org/apache/commons/jexl3/parser/ASTBlock.java | 6 +-
.../commons/jexl3/parser/ASTForeachStatement.java | 6 +-
.../apache/commons/jexl3/parser/ASTIdentifier.java | 20 +-
.../commons/jexl3/parser/ASTIdentifierAccess.java | 12 +-
.../jexl3/parser/ASTIdentifierAccessJxlt.java | 6 +-
.../jexl3/parser/ASTIdentifierAccessSafe.java | 4 +-
.../jexl3/parser/ASTIdentifierAccessSafeJxlt.java | 4 +-
.../apache/commons/jexl3/parser/ASTJexlLambda.java | 4 +-
.../apache/commons/jexl3/parser/ASTJexlScript.java | 20 +-
.../commons/jexl3/parser/ASTJxltLiteral.java | 8 +-
.../apache/commons/jexl3/parser/ASTMapLiteral.java | 12 +-
.../jexl3/parser/ASTNamespaceIdentifier.java | 4 +-
.../commons/jexl3/parser/ASTNumberLiteral.java | 12 +-
.../jexl3/parser/ASTReferenceExpression.java | 6 +-
.../commons/jexl3/parser/ASTRegexLiteral.java | 10 +-
.../apache/commons/jexl3/parser/ASTSetLiteral.java | 12 +-
.../commons/jexl3/parser/ASTStringLiteral.java | 10 +-
.../org/apache/commons/jexl3/parser/ASTVar.java | 6 +-
.../commons/jexl3/parser/FeatureController.java | 58 +-
.../commons/jexl3/parser/JexlLexicalNode.java | 8 +-
.../org/apache/commons/jexl3/parser/JexlNode.java | 42 +-
.../apache/commons/jexl3/parser/JexlParser.java | 96 ++--
.../apache/commons/jexl3/parser/NumberParser.java | 18 +-
.../commons/jexl3/parser/ParseException.java | 6 +-
.../apache/commons/jexl3/parser/ParserVisitor.java | 4 +-
.../apache/commons/jexl3/parser/SimpleNode.java | 28 +-
.../apache/commons/jexl3/parser/StringParser.java | 44 +-
.../apache/commons/jexl3/parser/TokenMgrError.java | 12 +-
.../commons/jexl3/scripting/JexlScriptEngine.java | 22 +-
.../jexl3/scripting/JexlScriptEngineFactory.java | 16 +-
.../org/apache/commons/jexl3/scripting/Main.java | 16 +-
.../org/apache/commons/jexl3/AnnotationTest.java | 112 ++--
.../org/apache/commons/jexl3/AntishCallTest.java | 68 +--
.../commons/jexl3/ArithmeticOperatorTest.java | 162 +++---
.../org/apache/commons/jexl3/ArithmeticTest.java | 386 ++++++-------
.../org/apache/commons/jexl3/ArrayAccessTest.java | 34 +-
.../org/apache/commons/jexl3/ArrayLiteralTest.java | 78 +--
.../java/org/apache/commons/jexl3/AssignTest.java | 78 +--
.../java/org/apache/commons/jexl3/BlockTest.java | 36 +-
.../java/org/apache/commons/jexl3/CacheTest.java | 124 ++---
.../java/org/apache/commons/jexl3/CaptureLog.java | 36 +-
.../org/apache/commons/jexl3/ClassCreator.java | 58 +-
.../org/apache/commons/jexl3/ClassCreatorTest.java | 86 +--
.../apache/commons/jexl3/ContextNamespaceTest.java | 56 +-
.../java/org/apache/commons/jexl3/DoWhileTest.java | 48 +-
.../org/apache/commons/jexl3/ExceptionTest.java | 108 ++--
.../org/apache/commons/jexl3/FeaturesTest.java | 88 +--
src/test/java/org/apache/commons/jexl3/Foo.java | 10 +-
.../java/org/apache/commons/jexl3/ForEachTest.java | 98 ++--
src/test/java/org/apache/commons/jexl3/IfTest.java | 96 ++--
.../org/apache/commons/jexl3/Issues100Test.java | 258 ++++-----
.../org/apache/commons/jexl3/Issues200Test.java | 408 +++++++-------
.../org/apache/commons/jexl3/Issues300Test.java | 222 ++++----
.../java/org/apache/commons/jexl3/IssuesTest.java | 148 ++---
.../java/org/apache/commons/jexl3/JXLTTest.java | 486 ++++++++--------
src/test/java/org/apache/commons/jexl3/Jexl.java | 14 +-
.../org/apache/commons/jexl3/JexlEvalContext.java | 14 +-
.../java/org/apache/commons/jexl3/JexlTest.java | 144 ++---
.../org/apache/commons/jexl3/JexlTestCase.java | 26 +-
.../java/org/apache/commons/jexl3/LambdaTest.java | 136 ++---
.../java/org/apache/commons/jexl3/LexicalTest.java | 386 ++++++-------
.../org/apache/commons/jexl3/MapLiteralTest.java | 50 +-
.../java/org/apache/commons/jexl3/MethodTest.java | 212 +++----
.../apache/commons/jexl3/ParseFailuresTest.java | 20 +-
.../java/org/apache/commons/jexl3/PragmaTest.java | 72 +--
.../apache/commons/jexl3/PropertyAccessTest.java | 130 ++---
.../org/apache/commons/jexl3/PublicFieldsTest.java | 28 +-
.../java/org/apache/commons/jexl3/RangeTest.java | 58 +-
.../org/apache/commons/jexl3/ReadonlyContext.java | 8 +-
.../apache/commons/jexl3/ScriptCallableTest.java | 202 +++----
.../java/org/apache/commons/jexl3/ScriptTest.java | 56 +-
.../org/apache/commons/jexl3/SetLiteralTest.java | 80 +--
.../org/apache/commons/jexl3/SideEffectTest.java | 180 +++---
.../org/apache/commons/jexl3/StrategyTest.java | 30 +-
.../commons/jexl3/SynchronizedArithmetic.java | 26 +-
.../apache/commons/jexl3/SynchronizedContext.java | 14 +-
.../commons/jexl3/SynchronizedOverloadsTest.java | 30 +-
.../java/org/apache/commons/jexl3/VarTest.java | 136 ++---
.../java/org/apache/commons/jexl3/WhileTest.java | 18 +-
.../apache/commons/jexl3/examples/ArrayTest.java | 12 +-
.../commons/jexl3/examples/MethodPropertyTest.java | 14 +-
.../org/apache/commons/jexl3/examples/Output.java | 4 +-
.../org/apache/commons/jexl3/internal/Dumper.java | 10 +-
.../apache/commons/jexl3/internal/RangeTest.java | 36 +-
.../org/apache/commons/jexl3/internal/Util.java | 52 +-
.../internal/introspection/DiscoveryTest.java | 88 +--
.../internal/introspection/MethodKeyTest.java | 84 +--
.../commons/jexl3/introspection/SandboxTest.java | 148 ++---
.../org/apache/commons/jexl3/junit/Asserter.java | 34 +-
.../apache/commons/jexl3/junit/AsserterTest.java | 8 +-
.../apache/commons/jexl3/parser/ParserTest.java | 38 +-
.../scripting/JexlScriptEngineOptionalTest.java | 8 +-
.../jexl3/scripting/JexlScriptEngineTest.java | 42 +-
156 files changed, 5000 insertions(+), 5000 deletions(-)
diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
index f23b427..2ecb270 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
@@ -94,7 +94,7 @@ public class JexlArithmetic {
*
* @param astrict whether this arithmetic is strict or lenient
*/
- public JexlArithmetic(boolean astrict) {
+ public JexlArithmetic(final boolean astrict) {
this(astrict, null, Integer.MIN_VALUE);
}
@@ -106,14 +106,14 @@ public class JexlArithmetic {
* @param bigdContext the math context instance to use for +,-,/,*,% operations on big decimals.
* @param bigdScale the scale used for big decimals.
*/
- public JexlArithmetic(boolean astrict, MathContext bigdContext, int bigdScale) {
+ public JexlArithmetic(final boolean astrict, final MathContext bigdContext, final int bigdScale) {
this.strict = astrict;
this.mathContext = bigdContext == null ? MathContext.DECIMAL128 : bigdContext;
this.mathScale = bigdScale == Integer.MIN_VALUE ? BIGD_SCALE : bigdScale;
Constructor<? extends JexlArithmetic> actor = null;
try {
actor = getClass().getConstructor(boolean.class, MathContext.class, int.class);
- } catch (Exception xany) {
+ } catch (final Exception xany) {
// ignore
}
this.ctor = actor;
@@ -126,9 +126,9 @@ public class JexlArithmetic {
* @param options the {@link JexlEngine.Options} to use
* @return an arithmetic with those options set
*/
- public JexlArithmetic options(JexlOptions options) {
+ public JexlArithmetic options(final JexlOptions options) {
if (options != null) {
- boolean ostrict = options.isStrictArithmetic();
+ final boolean ostrict = options.isStrictArithmetic();
MathContext bigdContext = options.getMathContext();
if (bigdContext == null) {
bigdContext = getMathContext();
@@ -155,7 +155,7 @@ public class JexlArithmetic {
* @deprecated 3.2
*/
@Deprecated
- public JexlArithmetic options(JexlEngine.Options options) {
+ public JexlArithmetic options(final JexlEngine.Options options) {
if (options != null) {
Boolean ostrict = options.isStrictArithmetic();
if (ostrict == null) {
@@ -186,7 +186,7 @@ public class JexlArithmetic {
* @return a new arithmetic instance or this
* @since 3.1
*/
- public JexlArithmetic options(JexlContext context) {
+ public JexlArithmetic options(final JexlContext context) {
if (context instanceof JexlContext.OptionsHandle) {
return options(((JexlContext.OptionsHandle) context).getEngineOptions());
}
@@ -207,7 +207,7 @@ public class JexlArithmetic {
* @return default is a new JexlArithmetic instance
* @since 3.1
*/
- protected JexlArithmetic createWithOptions(boolean astrict, MathContext bigdContext, int bigdScale) {
+ protected JexlArithmetic createWithOptions(final boolean astrict, final MathContext bigdContext, final int bigdScale) {
if (ctor != null) {
try {
return ctor.newInstance(astrict, bigdContext, bigdScale);
@@ -278,7 +278,7 @@ public class JexlArithmetic {
* @param size the number of elements in the array
* @return the array builder
*/
- public ArrayBuilder arrayBuilder(int size) {
+ public ArrayBuilder arrayBuilder(final int size) {
return new org.apache.commons.jexl3.internal.ArrayBuilder(size);
}
@@ -308,7 +308,7 @@ public class JexlArithmetic {
* @param size the number of elements in the set
* @return the array builder
*/
- public SetBuilder setBuilder(int size) {
+ public SetBuilder setBuilder(final int size) {
return new org.apache.commons.jexl3.internal.SetBuilder(size);
}
@@ -339,7 +339,7 @@ public class JexlArithmetic {
* @param size the number of elements in the map
* @return the map builder
*/
- public MapBuilder mapBuilder(int size) {
+ public MapBuilder mapBuilder(final int size) {
return new org.apache.commons.jexl3.internal.MapBuilder(size);
}
@@ -352,7 +352,7 @@ public class JexlArithmetic {
* @return the range as an iterable
* @throws ArithmeticException as an option if creation fails
*/
- public Iterable<?> createRange(Object from, Object to) throws ArithmeticException {
+ public Iterable<?> createRange(final Object from, final Object to) throws ArithmeticException {
final long lfrom = toLong(from);
final long lto = toLong(to);
if ((lfrom >= Integer.MIN_VALUE && lfrom <= Integer.MAX_VALUE)
@@ -398,7 +398,7 @@ public class JexlArithmetic {
* @return the rounded big decimal
*/
protected BigDecimal roundBigDecimal(final BigDecimal number) {
- int mscale = getMathScale();
+ final int mscale = getMathScale();
if (mscale >= 0) {
return number.setScale(mscale, getMathContext().getRoundingMode());
} else {
@@ -445,7 +445,7 @@ public class JexlArithmetic {
* @param val the object to be tested
* @return true if it is, false otherwise.
*/
- protected boolean isFloatingPointNumber(Object val) {
+ protected boolean isFloatingPointNumber(final Object val) {
if (val instanceof Float || val instanceof Double) {
return true;
}
@@ -493,7 +493,7 @@ public class JexlArithmetic {
* @param original the original number.
* @return a value of the smallest type the original number will fit into.
*/
- public Number narrow(Number original) {
+ public Number narrow(final Number original) {
return narrowNumber(original, null);
}
@@ -504,7 +504,7 @@ public class JexlArithmetic {
* @param source the orginal source class
* @return true if attempt to narrow source to target is accepted
*/
- protected boolean narrowAccept(Class<?> narrow, Class<?> source) {
+ protected boolean narrowAccept(final Class<?> narrow, final Class<?> source) {
return narrow == null || narrow.equals(source);
}
@@ -515,20 +515,20 @@ public class JexlArithmetic {
* @param narrow the attempted target class
* @return the narrowed number or the source if no narrowing was possible
*/
- public Number narrowNumber(Number original, Class<?> narrow) {
+ public Number narrowNumber(final Number original, final Class<?> narrow) {
if (original == null) {
return null;
}
Number result = original;
if (original instanceof BigDecimal) {
- BigDecimal bigd = (BigDecimal) original;
+ final BigDecimal bigd = (BigDecimal) original;
// if it's bigger than a double it can't be narrowed
if (bigd.compareTo(BIGD_DOUBLE_MAX_VALUE) > 0
|| bigd.compareTo(BIGD_DOUBLE_MIN_VALUE) < 0) {
return original;
} else {
try {
- long l = bigd.longValueExact();
+ final long l = bigd.longValueExact();
// coerce to int when possible (int being so often used in method parms)
if (narrowAccept(narrow, Integer.class)
&& l <= Integer.MAX_VALUE
@@ -537,13 +537,13 @@ public class JexlArithmetic {
} else if (narrowAccept(narrow, Long.class)) {
return l;
}
- } catch (ArithmeticException xa) {
+ } catch (final ArithmeticException xa) {
// ignore, no exact value possible
}
}
}
if (original instanceof Double || original instanceof Float) {
- double value = original.doubleValue();
+ final double value = original.doubleValue();
if (narrowAccept(narrow, Float.class)
&& value <= Float.MAX_VALUE
&& value >= Float.MIN_VALUE) {
@@ -552,14 +552,14 @@ public class JexlArithmetic {
// else it fits in a double only
} else {
if (original instanceof BigInteger) {
- BigInteger bigi = (BigInteger) original;
+ final BigInteger bigi = (BigInteger) original;
// if it's bigger than a Long it can't be narrowed
if (bigi.compareTo(BIGI_LONG_MAX_VALUE) > 0
|| bigi.compareTo(BIGI_LONG_MIN_VALUE) < 0) {
return original;
}
}
- long value = original.longValue();
+ final long value = original.longValue();
if (narrowAccept(narrow, Byte.class)
&& value <= Byte.MAX_VALUE
&& value >= Byte.MIN_VALUE) {
@@ -593,13 +593,13 @@ public class JexlArithmetic {
* @param bigi the BigInteger to narrow
* @return an Integer or Long if narrowing is possible, the original BigInteger otherwise
*/
- protected Number narrowBigInteger(Object lhs, Object rhs, BigInteger bigi) {
+ protected Number narrowBigInteger(final Object lhs, final Object rhs, final BigInteger bigi) {
//coerce to long if possible
if (!(lhs instanceof BigInteger || rhs instanceof BigInteger)
&& bigi.compareTo(BIGI_LONG_MAX_VALUE) <= 0
&& bigi.compareTo(BIGI_LONG_MIN_VALUE) >= 0) {
// coerce to int if possible
- long l = bigi.longValue();
+ final long l = bigi.longValue();
// coerce to int when possible (int being so often used in method parms)
if (!(lhs instanceof Long || rhs instanceof Long)
&& l <= Integer.MAX_VALUE
@@ -620,17 +620,17 @@ public class JexlArithmetic {
* @param bigd the BigDecimal to narrow
* @return an Integer or Long if narrowing is possible, the original BigInteger otherwise
*/
- protected Number narrowBigDecimal(Object lhs, Object rhs, BigDecimal bigd) {
+ protected Number narrowBigDecimal(final Object lhs, final Object rhs, final BigDecimal bigd) {
if (isNumberable(lhs) || isNumberable(rhs)) {
try {
- long l = bigd.longValueExact();
+ final long l = bigd.longValueExact();
// coerce to int when possible (int being so often used in method parms)
if (l <= Integer.MAX_VALUE && l >= Integer.MIN_VALUE) {
return (int) l;
} else {
return l;
}
- } catch (ArithmeticException xa) {
+ } catch (final ArithmeticException xa) {
// ignore, no exact value possible
}
}
@@ -644,14 +644,14 @@ public class JexlArithmetic {
* @return true if some arguments were narrowed and args array is modified,
* false if no narrowing occurred and args array has not been modified
*/
- public boolean narrowArguments(Object[] args) {
+ public boolean narrowArguments(final Object[] args) {
boolean narrowed = false;
if (args != null) {
for (int a = 0; a < args.length; ++a) {
- Object arg = args[a];
+ final Object arg = args[a];
if (arg instanceof Number) {
- Number narg = (Number) arg;
- Number narrow = narrow(narg);
+ final Number narg = (Number) arg;
+ final Number narrow = narrow(narg);
if (!narg.equals(narrow)) {
args[a] = narrow;
narrowed = true;
@@ -670,7 +670,7 @@ public class JexlArithmetic {
* @param r the long to narrow
* @return an Integer if narrowing is possible, the original Long otherwise
*/
- protected Number narrowLong(Object lhs, Object rhs, long r) {
+ protected Number narrowLong(final Object lhs, final Object rhs, final long r) {
if (!(lhs instanceof Long || rhs instanceof Long) && (int) r == r) {
return (int) r;
} else {
@@ -684,7 +684,7 @@ public class JexlArithmetic {
* @param value argument
* @return true if argument can be represented by a long
*/
- protected Number asLongNumber(Object value) {
+ protected Number asLongNumber(final Object value) {
return value instanceof Long
|| value instanceof Integer
|| value instanceof Short
@@ -704,22 +704,22 @@ public class JexlArithmetic {
* @param right right argument
* @return left + right.
*/
- public Object add(Object left, Object right) {
+ public Object add(final Object left, final Object right) {
if (left == null && right == null) {
return controlNullNullOperands();
}
- boolean strconcat = strict
+ final boolean strconcat = strict
? left instanceof String || right instanceof String
: left instanceof String && right instanceof String;
if (!strconcat) {
try {
// if both (non null) args fit as long
- Number ln = asLongNumber(left);
- Number rn = asLongNumber(right);
+ final Number ln = asLongNumber(left);
+ final Number rn = asLongNumber(right);
if (ln != null && rn != null) {
- long x = ln.longValue();
- long y = rn.longValue();
- long result = x + y;
+ final long x = ln.longValue();
+ final long y = rn.longValue();
+ final long result = x + y;
// detect overflow, see java8 Math.addExact
if (((x ^ result) & (y ^ result)) < 0) {
return BigInteger.valueOf(x).add(BigInteger.valueOf(y));
@@ -728,23 +728,23 @@ public class JexlArithmetic {
}
// if either are bigdecimal use that type
if (left instanceof BigDecimal || right instanceof BigDecimal) {
- BigDecimal l = toBigDecimal(left);
- BigDecimal r = toBigDecimal(right);
- BigDecimal result = l.add(r, getMathContext());
+ final BigDecimal l = toBigDecimal(left);
+ final BigDecimal r = toBigDecimal(right);
+ final BigDecimal result = l.add(r, getMathContext());
return narrowBigDecimal(left, right, result);
}
// if either are floating point (double or float) use double
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
- double l = toDouble(left);
- double r = toDouble(right);
+ final double l = toDouble(left);
+ final double r = toDouble(right);
return l + r;
}
// otherwise treat as (big) integers
- BigInteger l = toBigInteger(left);
- BigInteger r = toBigInteger(right);
- BigInteger result = l.add(r);
+ final BigInteger l = toBigInteger(left);
+ final BigInteger r = toBigInteger(right);
+ final BigInteger result = l.add(r);
return narrowBigInteger(left, right, result);
- } catch (java.lang.NumberFormatException nfe) {
+ } catch (final java.lang.NumberFormatException nfe) {
if (left == null || right == null) {
controlNullOperand();
}
@@ -761,48 +761,48 @@ public class JexlArithmetic {
* @return left / right
* @throws ArithmeticException if right == 0
*/
- public Object divide(Object left, Object right) {
+ public Object divide(final Object left, final Object right) {
if (left == null && right == null) {
return controlNullNullOperands();
}
// if both (non null) args fit as long
- Number ln = asLongNumber(left);
- Number rn = asLongNumber(right);
+ final Number ln = asLongNumber(left);
+ final Number rn = asLongNumber(right);
if (ln != null && rn != null) {
- long x = ln.longValue();
- long y = rn.longValue();
+ final long x = ln.longValue();
+ final long y = rn.longValue();
if (y == 0L) {
throw new ArithmeticException("/");
}
- long result = x / y;
+ final long result = x / y;
return narrowLong(left, right, result);
}
// if either are bigdecimal use that type
if (left instanceof BigDecimal || right instanceof BigDecimal) {
- BigDecimal l = toBigDecimal(left);
- BigDecimal r = toBigDecimal(right);
+ final BigDecimal l = toBigDecimal(left);
+ final BigDecimal r = toBigDecimal(right);
if (BigDecimal.ZERO.equals(r)) {
throw new ArithmeticException("/");
}
- BigDecimal result = l.divide(r, getMathContext());
+ final BigDecimal result = l.divide(r, getMathContext());
return narrowBigDecimal(left, right, result);
}
// if either are floating point (double or float) use double
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
- double l = toDouble(left);
- double r = toDouble(right);
+ final double l = toDouble(left);
+ final double r = toDouble(right);
if (r == 0.0) {
throw new ArithmeticException("/");
}
return l / r;
}
// otherwise treat as integers
- BigInteger l = toBigInteger(left);
- BigInteger r = toBigInteger(right);
+ final BigInteger l = toBigInteger(left);
+ final BigInteger r = toBigInteger(right);
if (BigInteger.ZERO.equals(r)) {
throw new ArithmeticException("/");
}
- BigInteger result = l.divide(r);
+ final BigInteger result = l.divide(r);
return narrowBigInteger(left, right, result);
}
@@ -814,48 +814,48 @@ public class JexlArithmetic {
* @return left % right
* @throws ArithmeticException if right == 0.0
*/
- public Object mod(Object left, Object right) {
+ public Object mod(final Object left, final Object right) {
if (left == null && right == null) {
return controlNullNullOperands();
}
// if both (non null) args fit as long
- Number ln = asLongNumber(left);
- Number rn = asLongNumber(right);
+ final Number ln = asLongNumber(left);
+ final Number rn = asLongNumber(right);
if (ln != null && rn != null) {
- long x = ln.longValue();
- long y = rn.longValue();
+ final long x = ln.longValue();
+ final long y = rn.longValue();
if (y == 0L) {
throw new ArithmeticException("%");
}
- long result = x % y;
+ final long result = x % y;
return narrowLong(left, right, result);
}
// if either are bigdecimal use that type
if (left instanceof BigDecimal || right instanceof BigDecimal) {
- BigDecimal l = toBigDecimal(left);
- BigDecimal r = toBigDecimal(right);
+ final BigDecimal l = toBigDecimal(left);
+ final BigDecimal r = toBigDecimal(right);
if (BigDecimal.ZERO.equals(r)) {
throw new ArithmeticException("%");
}
- BigDecimal remainder = l.remainder(r, getMathContext());
+ final BigDecimal remainder = l.remainder(r, getMathContext());
return narrowBigDecimal(left, right, remainder);
}
// if either are floating point (double or float) use double
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
- double l = toDouble(left);
- double r = toDouble(right);
+ final double l = toDouble(left);
+ final double r = toDouble(right);
if (r == 0.0) {
throw new ArithmeticException("%");
}
return l % r;
}
// otherwise treat as integers
- BigInteger l = toBigInteger(left);
- BigInteger r = toBigInteger(right);
+ final BigInteger l = toBigInteger(left);
+ final BigInteger r = toBigInteger(right);
if (BigInteger.ZERO.equals(r)) {
throw new ArithmeticException("%");
}
- BigInteger result = l.mod(r);
+ final BigInteger result = l.mod(r);
return narrowBigInteger(left, right, result);
}
@@ -868,9 +868,9 @@ public class JexlArithmetic {
* @return true if product fits a long, false if it overflows
*/
@SuppressWarnings("MagicNumber")
- private static boolean isMultiplyExact(long x, long y, long r) {
- long ax = Math.abs(x);
- long ay = Math.abs(y);
+ private static boolean isMultiplyExact(final long x, final long y, final long r) {
+ final long ax = Math.abs(x);
+ final long ay = Math.abs(y);
return !(((ax | ay) >>> (Integer.SIZE - 1) != 0)
&& (((y != 0) && (r / y != x))
|| (x == Long.MIN_VALUE && y == -1)));
@@ -883,17 +883,17 @@ public class JexlArithmetic {
* @param right right argument
* @return left * right.
*/
- public Object multiply(Object left, Object right) {
+ public Object multiply(final Object left, final Object right) {
if (left == null && right == null) {
return controlNullNullOperands();
}
// if both (non null) args fit as int
- Number ln = asLongNumber(left);
- Number rn = asLongNumber(right);
+ final Number ln = asLongNumber(left);
+ final Number rn = asLongNumber(right);
if (ln != null && rn != null) {
- long x = ln.longValue();
- long y = rn.longValue();
- long result = x * y;
+ final long x = ln.longValue();
+ final long y = rn.longValue();
+ final long result = x * y;
// detect overflow
if (!isMultiplyExact(x, y, result)) {
return BigInteger.valueOf(x).multiply(BigInteger.valueOf(y));
@@ -902,21 +902,21 @@ public class JexlArithmetic {
}
// if either are bigdecimal use that type
if (left instanceof BigDecimal || right instanceof BigDecimal) {
- BigDecimal l = toBigDecimal(left);
- BigDecimal r = toBigDecimal(right);
- BigDecimal result = l.multiply(r, getMathContext());
+ final BigDecimal l = toBigDecimal(left);
+ final BigDecimal r = toBigDecimal(right);
+ final BigDecimal result = l.multiply(r, getMathContext());
return narrowBigDecimal(left, right, result);
}
// if either are floating point (double or float) use double
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
- double l = toDouble(left);
- double r = toDouble(right);
+ final double l = toDouble(left);
+ final double r = toDouble(right);
return l * r;
}
// otherwise treat as integers
- BigInteger l = toBigInteger(left);
- BigInteger r = toBigInteger(right);
- BigInteger result = l.multiply(r);
+ final BigInteger l = toBigInteger(left);
+ final BigInteger r = toBigInteger(right);
+ final BigInteger result = l.multiply(r);
return narrowBigInteger(left, right, result);
}
@@ -927,17 +927,17 @@ public class JexlArithmetic {
* @param right right argument
* @return left - right.
*/
- public Object subtract(Object left, Object right) {
+ public Object subtract(final Object left, final Object right) {
if (left == null && right == null) {
return controlNullNullOperands();
}
// if both (non null) args fit as long
- Number ln = asLongNumber(left);
- Number rn = asLongNumber(right);
+ final Number ln = asLongNumber(left);
+ final Number rn = asLongNumber(right);
if (ln != null && rn != null) {
- long x = ln.longValue();
- long y = rn.longValue();
- long result = x - y;
+ final long x = ln.longValue();
+ final long y = rn.longValue();
+ final long result = x - y;
// detect overflow, see java8 Math.subtractExact
if (((x ^ y) & (x ^ result)) < 0) {
return BigInteger.valueOf(x).subtract(BigInteger.valueOf(y));
@@ -946,21 +946,21 @@ public class JexlArithmetic {
}
// if either are bigdecimal use that type
if (left instanceof BigDecimal || right instanceof BigDecimal) {
- BigDecimal l = toBigDecimal(left);
- BigDecimal r = toBigDecimal(right);
- BigDecimal result = l.subtract(r, getMathContext());
+ final BigDecimal l = toBigDecimal(left);
+ final BigDecimal r = toBigDecimal(right);
+ final BigDecimal result = l.subtract(r, getMathContext());
return narrowBigDecimal(left, right, result);
}
// if either are floating point (double or float) use double
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
- double l = toDouble(left);
- double r = toDouble(right);
+ final double l = toDouble(left);
+ final double r = toDouble(right);
return l - r;
}
// otherwise treat as integers
- BigInteger l = toBigInteger(left);
- BigInteger r = toBigInteger(right);
- BigInteger result = l.subtract(r);
+ final BigInteger l = toBigInteger(left);
+ final BigInteger r = toBigInteger(right);
+ final BigInteger result = l.subtract(r);
return narrowBigInteger(left, right, result);
}
@@ -970,7 +970,7 @@ public class JexlArithmetic {
* @param val the value to negate
* @return the negated value
*/
- public Object negate(Object val) {
+ public Object negate(final Object val) {
if (val == null) {
controlNullOperand();
return null;
@@ -1018,7 +1018,7 @@ public class JexlArithmetic {
* @param val the value to positivize
* @return the positive value
*/
- public Object positivize(Object val) {
+ public Object positivize(final Object val) {
if (val == null) {
controlNullOperand();
return null;
@@ -1064,7 +1064,7 @@ public class JexlArithmetic {
* @param value the value
* @return test result or null if there is no arithmetic solution
*/
- public Boolean contains(Object container, Object value) {
+ public Boolean contains(final Object container, final Object value) {
if (value == null && container == null) {
//if both are null L == R
return true;
@@ -1105,7 +1105,7 @@ public class JexlArithmetic {
* @param right right argument
* @return left $= right if there is no arithmetic solution
*/
- public Boolean endsWith(Object left, Object right) {
+ public Boolean endsWith(final Object left, final Object right) {
if (left == null && right == null) {
//if both are null L == R
return true;
@@ -1127,7 +1127,7 @@ public class JexlArithmetic {
* @param right right argument
* @return left ^= right or null if there is no arithmetic solution
*/
- public Boolean startsWith(Object left, Object right) {
+ public Boolean startsWith(final Object left, final Object right) {
if (left == null && right == null) {
//if both are null L == R
return true;
@@ -1149,7 +1149,7 @@ public class JexlArithmetic {
* @return the boolean or false if object is not null
* @since 3.2
*/
- public Boolean empty(Object object) {
+ public Boolean empty(final Object object) {
return object == null || isEmpty(object, false);
}
@@ -1159,7 +1159,7 @@ public class JexlArithmetic {
* @param object the object to check the emptiness of
* @return the boolean or null if there is no arithmetic solution
*/
- public Boolean isEmpty(Object object) {
+ public Boolean isEmpty(final Object object) {
return isEmpty(object, object == null);
}
@@ -1170,9 +1170,9 @@ public class JexlArithmetic {
* @param def the default value if object emptyness can not be determined
* @return the boolean or null if there is no arithmetic solution
*/
- public Boolean isEmpty(Object object, Boolean def) {
+ public Boolean isEmpty(final Object object, final Boolean def) {
if (object instanceof Number) {
- double d = ((Number) object).doubleValue();
+ final double d = ((Number) object).doubleValue();
return Double.isNaN(d) || d == 0.d ? Boolean.TRUE : Boolean.FALSE;
}
if (object instanceof CharSequence) {
@@ -1197,7 +1197,7 @@ public class JexlArithmetic {
* @param object the object to get the size of
* @return the <i>size</i> of object, 0 if null, 1 if there is no <i>better</i> solution
*/
- public Integer size(Object object) {
+ public Integer size(final Object object) {
return size(object, object == null? 0 : 1);
}
@@ -1208,7 +1208,7 @@ public class JexlArithmetic {
* @param def the default value if object size can not be determined
* @return the size of object or null if there is no arithmetic solution
*/
- public Integer size(Object object, Integer def) {
+ public Integer size(final Object object, final Integer def) {
if (object instanceof CharSequence) {
return ((CharSequence) object).length();
}
@@ -1231,9 +1231,9 @@ public class JexlArithmetic {
* @param right the right operator
* @return left & right
*/
- public Object and(Object left, Object right) {
- long l = toLong(left);
- long r = toLong(right);
+ public Object and(final Object left, final Object right) {
+ final long l = toLong(left);
+ final long r = toLong(right);
return l & r;
}
@@ -1244,9 +1244,9 @@ public class JexlArithmetic {
* @param right the right operator
* @return left | right
*/
- public Object or(Object left, Object right) {
- long l = toLong(left);
- long r = toLong(right);
+ public Object or(final Object left, final Object right) {
+ final long l = toLong(left);
+ final long r = toLong(right);
return l | r;
}
@@ -1257,9 +1257,9 @@ public class JexlArithmetic {
* @param right the right operator
* @return left ^ right
*/
- public Object xor(Object left, Object right) {
- long l = toLong(left);
- long r = toLong(right);
+ public Object xor(final Object left, final Object right) {
+ final long l = toLong(left);
+ final long r = toLong(right);
return l ^ r;
}
@@ -1269,8 +1269,8 @@ public class JexlArithmetic {
* @param val the operand
* @return ~val
*/
- public Object complement(Object val) {
- long l = toLong(val);
+ public Object complement(final Object val) {
+ final long l = toLong(val);
return ~l;
}
@@ -1280,7 +1280,7 @@ public class JexlArithmetic {
* @param val the operand
* @return !val
*/
- public Object not(Object val) {
+ public Object not(final Object val) {
return toBoolean(val) ? Boolean.FALSE : Boolean.TRUE;
}
@@ -1293,19 +1293,19 @@ public class JexlArithmetic {
* @return -1 if left < right; +1 if left > right; 0 if left == right
* @throws ArithmeticException if either left or right is null
*/
- protected int compare(Object left, Object right, String operator) {
+ protected int compare(final Object left, final Object right, final String operator) {
if (left != null && right != null) {
if (left instanceof BigDecimal || right instanceof BigDecimal) {
- BigDecimal l = toBigDecimal(left);
- BigDecimal r = toBigDecimal(right);
+ final BigDecimal l = toBigDecimal(left);
+ final BigDecimal r = toBigDecimal(right);
return l.compareTo(r);
} else if (left instanceof BigInteger || right instanceof BigInteger) {
- BigInteger l = toBigInteger(left);
- BigInteger r = toBigInteger(right);
+ final BigInteger l = toBigInteger(left);
+ final BigInteger r = toBigInteger(right);
return l.compareTo(r);
} else if (isFloatingPoint(left) || isFloatingPoint(right)) {
- double lhs = toDouble(left);
- double rhs = toDouble(right);
+ final double lhs = toDouble(left);
+ final double rhs = toDouble(right);
if (Double.isNaN(lhs)) {
if (Double.isNaN(rhs)) {
return 0;
@@ -1323,8 +1323,8 @@ public class JexlArithmetic {
return 0;
}
} else if (isNumberable(left) || isNumberable(right)) {
- long lhs = toLong(left);
- long rhs = toLong(right);
+ final long lhs = toLong(left);
+ final long rhs = toLong(right);
if (lhs < rhs) {
return -1;
} else if (lhs > rhs) {
@@ -1356,7 +1356,7 @@ public class JexlArithmetic {
* @param right right argument
* @return the test result
*/
- public boolean equals(Object left, Object right) {
+ public boolean equals(final Object left, final Object right) {
if (left == right) {
return true;
} else if (left == null || right == null) {
@@ -1375,7 +1375,7 @@ public class JexlArithmetic {
* @param right right argument
* @return the test result
*/
- public boolean lessThan(Object left, Object right) {
+ public boolean lessThan(final Object left, final Object right) {
if ((left == right) || (left == null) || (right == null)) {
return false;
} else {
@@ -1391,7 +1391,7 @@ public class JexlArithmetic {
* @param right right argument
* @return the test result
*/
- public boolean greaterThan(Object left, Object right) {
+ public boolean greaterThan(final Object left, final Object right) {
if ((left == right) || left == null || right == null) {
return false;
} else {
@@ -1406,7 +1406,7 @@ public class JexlArithmetic {
* @param right right argument
* @return the test result
*/
- public boolean lessThanOrEqual(Object left, Object right) {
+ public boolean lessThanOrEqual(final Object left, final Object right) {
if (left == right) {
return true;
} else if (left == null || right == null) {
@@ -1423,7 +1423,7 @@ public class JexlArithmetic {
* @param right right argument
* @return the test result
*/
- public boolean greaterThanOrEqual(Object left, Object right) {
+ public boolean greaterThanOrEqual(final Object left, final Object right) {
if (left == right) {
return true;
} else if (left == null || right == null) {
@@ -1440,19 +1440,19 @@ public class JexlArithmetic {
* @param val value to coerce
* @return the boolean value if coercion is possible, true if value was not null.
*/
- public boolean toBoolean(Object val) {
+ public boolean toBoolean(final Object val) {
if (val == null) {
controlNullOperand();
return false;
} else if (val instanceof Boolean) {
return ((Boolean) val);
} else if (val instanceof Number) {
- double number = toDouble(val);
+ final double number = toDouble(val);
return !Double.isNaN(number) && number != 0.d;
} else if (val instanceof AtomicBoolean) {
return ((AtomicBoolean) val).get();
} else if (val instanceof String) {
- String strval = val.toString();
+ final String strval = val.toString();
return strval.length() > 0 && !"false".equals(strval);
} else {
// non null value is true
@@ -1469,12 +1469,12 @@ public class JexlArithmetic {
* @return the value coerced to int
* @throws ArithmeticException if val is null and mode is strict or if coercion is not possible
*/
- public int toInteger(Object val) {
+ public int toInteger(final Object val) {
if (val == null) {
controlNullOperand();
return 0;
} else if (val instanceof Double) {
- Double dval = (Double) val;
+ final Double dval = (Double) val;
if (Double.isNaN(dval)) {
return 0;
} else {
@@ -1508,12 +1508,12 @@ public class JexlArithmetic {
* @return the value coerced to long
* @throws ArithmeticException if value is null and mode is strict or if coercion is not possible
*/
- public long toLong(Object val) {
+ public long toLong(final Object val) {
if (val == null) {
controlNullOperand();
return 0L;
} else if (val instanceof Double) {
- Double dval = (Double) val;
+ final Double dval = (Double) val;
if (Double.isNaN(dval)) {
return 0L;
} else {
@@ -1548,14 +1548,14 @@ public class JexlArithmetic {
* @return a BigDecimal
* @throws ArithmeticException if val is null and mode is strict or if coercion is not possible
*/
- public BigInteger toBigInteger(Object val) {
+ public BigInteger toBigInteger(final Object val) {
if (val == null) {
controlNullOperand();
return BigInteger.ZERO;
} else if (val instanceof BigInteger) {
return (BigInteger) val;
} else if (val instanceof Double) {
- Double dval = (Double) val;
+ final Double dval = (Double) val;
if (Double.isNaN(dval)) {
return BigInteger.ZERO;
} else {
@@ -1570,14 +1570,14 @@ public class JexlArithmetic {
} else if (val instanceof AtomicBoolean) {
return BigInteger.valueOf(((AtomicBoolean) val).get() ? 1L : 0L);
} else if (val instanceof String) {
- String string = (String) val;
+ final String string = (String) val;
if ("".equals(string)) {
return BigInteger.ZERO;
} else {
return new BigInteger(string);
}
} else if (val instanceof Character) {
- int i = ((Character) val);
+ final int i = ((Character) val);
return BigInteger.valueOf(i);
}
@@ -1594,7 +1594,7 @@ public class JexlArithmetic {
* @return a BigDecimal.
* @throws ArithmeticException if val is null and mode is strict or if coercion is not possible
*/
- public BigDecimal toBigDecimal(Object val) {
+ public BigDecimal toBigDecimal(final Object val) {
if (val instanceof BigDecimal) {
return roundBigDecimal((BigDecimal) val);
} else if (val == null) {
@@ -1613,13 +1613,13 @@ public class JexlArithmetic {
} else if (val instanceof AtomicBoolean) {
return BigDecimal.valueOf(((AtomicBoolean) val).get() ? 1L : 0L);
} else if (val instanceof String) {
- String string = (String) val;
+ final String string = (String) val;
if ("".equals(string)) {
return BigDecimal.ZERO;
}
return roundBigDecimal(new BigDecimal(string, getMathContext()));
} else if (val instanceof Character) {
- int i = ((Character) val);
+ final int i = ((Character) val);
return new BigDecimal(i);
}
throw new ArithmeticException("BigDecimal coercion: "
@@ -1635,7 +1635,7 @@ public class JexlArithmetic {
* @return The double coerced value.
* @throws ArithmeticException if val is null and mode is strict or if coercion is not possible
*/
- public double toDouble(Object val) {
+ public double toDouble(final Object val) {
if (val == null) {
controlNullOperand();
return 0;
@@ -1650,7 +1650,7 @@ public class JexlArithmetic {
} else if (val instanceof AtomicBoolean) {
return ((AtomicBoolean) val).get() ? 1. : 0.;
} else if (val instanceof String) {
- String string = (String) val;
+ final String string = (String) val;
if ("".equals(string)) {
return Double.NaN;
} else {
@@ -1658,7 +1658,7 @@ public class JexlArithmetic {
return Double.parseDouble(string);
}
} else if (val instanceof Character) {
- int i = ((Character) val);
+ final int i = ((Character) val);
return i;
}
throw new ArithmeticException("Double coercion: "
@@ -1673,12 +1673,12 @@ public class JexlArithmetic {
* @return The String coerced value.
* @throws ArithmeticException if val is null and mode is strict or if coercion is not possible
*/
- public String toString(Object val) {
+ public String toString(final Object val) {
if (val == null) {
controlNullOperand();
return "";
} else if (val instanceof Double) {
- Double dval = (Double) val;
+ final Double dval = (Double) val;
if (Double.isNaN(dval)) {
return "";
} else {
@@ -1698,7 +1698,7 @@ public class JexlArithmetic {
* @deprecated
*/
@Deprecated
- public final Object bitwiseAnd(Object lhs, Object rhs) {
+ public final Object bitwiseAnd(final Object lhs, final Object rhs) {
return and(lhs, rhs);
}
@@ -1712,7 +1712,7 @@ public class JexlArithmetic {
* @deprecated
*/
@Deprecated
- public final Object bitwiseOr(Object lhs, Object rhs) {
+ public final Object bitwiseOr(final Object lhs, final Object rhs) {
return or(lhs, rhs);
}
@@ -1726,7 +1726,7 @@ public class JexlArithmetic {
* @deprecated
*/
@Deprecated
- public final Object bitwiseXor(Object lhs, Object rhs) {
+ public final Object bitwiseXor(final Object lhs, final Object rhs) {
return xor(lhs, rhs);
}
@@ -1739,7 +1739,7 @@ public class JexlArithmetic {
* @deprecated
*/
@Deprecated
- public final Object logicalNot(Object arg) {
+ public final Object logicalNot(final Object arg) {
return not(arg);
}
@@ -1753,7 +1753,7 @@ public class JexlArithmetic {
* @deprecated
*/
@Deprecated
- public final Object matches(Object lhs, Object rhs) {
+ public final Object matches(final Object lhs, final Object rhs) {
return contains(rhs, lhs);
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/JexlBuilder.java b/src/main/java/org/apache/commons/jexl3/JexlBuilder.java
index 2a5b006..cd018c1 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlBuilder.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlBuilder.java
@@ -112,7 +112,7 @@ public class JexlBuilder {
* @param u the uberspect
* @return this builder
*/
- public JexlBuilder uberspect(JexlUberspect u) {
+ public JexlBuilder uberspect(final JexlUberspect u) {
this.uberspect = u;
return this;
}
@@ -129,7 +129,7 @@ public class JexlBuilder {
* @param rs the strategy
* @return this builder
*/
- public JexlBuilder strategy(JexlUberspect.ResolverStrategy rs) {
+ public JexlBuilder strategy(final JexlUberspect.ResolverStrategy rs) {
this.strategy = rs;
return this;
}
@@ -150,7 +150,7 @@ public class JexlBuilder {
* @param a the arithmetic
* @return this builder
*/
- public JexlBuilder arithmetic(JexlArithmetic a) {
+ public JexlBuilder arithmetic(final JexlArithmetic a) {
this.arithmetic = a;
options.setStrictArithmetic(a.isStrict());
options.setMathContext(a.getMathContext());
@@ -169,7 +169,7 @@ public class JexlBuilder {
* @param box the sandbox
* @return this builder
*/
- public JexlBuilder sandbox(JexlSandbox box) {
+ public JexlBuilder sandbox(final JexlSandbox box) {
this.sandbox = box;
return this;
}
@@ -188,7 +188,7 @@ public class JexlBuilder {
* @param f the features
* @return this builder
*/
- public JexlBuilder features(JexlFeatures f) {
+ public JexlBuilder features(final JexlFeatures f) {
this.features = f;
if (features != null) {
if (features.isLexical()) {
@@ -212,7 +212,7 @@ public class JexlBuilder {
* @param log the logger
* @return this builder
*/
- public JexlBuilder logger(Log log) {
+ public JexlBuilder logger(final Log log) {
this.logger = log;
return this;
}
@@ -228,7 +228,7 @@ public class JexlBuilder {
* @param l the class loader
* @return this builder
*/
- public JexlBuilder loader(ClassLoader l) {
+ public JexlBuilder loader(final ClassLoader l) {
this.loader = l;
return this;
}
@@ -246,7 +246,7 @@ public class JexlBuilder {
* @deprecated since 3.1 use {@link #charset(Charset)} instead
*/
@Deprecated
- public JexlBuilder loader(Charset arg) {
+ public JexlBuilder loader(final Charset arg) {
return charset(arg);
}
@@ -257,7 +257,7 @@ public class JexlBuilder {
* @return this builder
* @since 3.1
*/
- public JexlBuilder charset(Charset arg) {
+ public JexlBuilder charset(final Charset arg) {
this.charset = arg;
return this;
}
@@ -273,7 +273,7 @@ public class JexlBuilder {
* @param flag true means antish resolution is enabled, false disables it
* @return this builder
*/
- public JexlBuilder antish(boolean flag) {
+ public JexlBuilder antish(final boolean flag) {
options.setAntish(flag);
return this;
}
@@ -290,7 +290,7 @@ public class JexlBuilder {
* @return this builder
* @since 3.2
*/
- public JexlBuilder lexical(boolean flag) {
+ public JexlBuilder lexical(final boolean flag) {
options.setLexical(flag);
return this;
}
@@ -307,7 +307,7 @@ public class JexlBuilder {
* @return this builder
* @since 3.2
*/
- public JexlBuilder lexicalShade(boolean flag) {
+ public JexlBuilder lexicalShade(final boolean flag) {
options.setLexicalShade(flag);
return this;
}
@@ -323,7 +323,7 @@ public class JexlBuilder {
* @param flag true means no JexlException will occur, false allows them
* @return this builder
*/
- public JexlBuilder silent(boolean flag) {
+ public JexlBuilder silent(final boolean flag) {
options.setSilent(flag);
return this;
}
@@ -340,7 +340,7 @@ public class JexlBuilder {
* @param flag true means strict error reporting, false allows them to be evaluated as null
* @return this builder
*/
- public JexlBuilder strict(boolean flag) {
+ public JexlBuilder strict(final boolean flag) {
options.setStrict(flag);
return this;
}
@@ -359,7 +359,7 @@ public class JexlBuilder {
* @param flag true means safe navigation, false throws exception when dereferencing null
* @return this builder
*/
- public JexlBuilder safe(boolean flag) {
+ public JexlBuilder safe(final boolean flag) {
options.setSafe(flag);
return this;
}
@@ -375,7 +375,7 @@ public class JexlBuilder {
* @param flag true implies debug is on, false implies debug is off.
* @return this builder
*/
- public JexlBuilder debug(boolean flag) {
+ public JexlBuilder debug(final boolean flag) {
this.debug = flag;
return this;
}
@@ -393,7 +393,7 @@ public class JexlBuilder {
* @return this builder
* @since 3.1
*/
- public JexlBuilder cancellable(boolean flag) {
+ public JexlBuilder cancellable(final boolean flag) {
this.cancellable = flag;
options.setCancellable(flag);
return this;
@@ -414,7 +414,7 @@ public class JexlBuilder {
* @return this builder
* @since 3.2
*/
- public JexlBuilder collectAll(boolean flag) {
+ public JexlBuilder collectAll(final boolean flag) {
return collectMode(flag? 1 : 0);
}
@@ -425,7 +425,7 @@ public class JexlBuilder {
* @return this builder
* @since 3.2
*/
- public JexlBuilder collectMode(int mode) {
+ public JexlBuilder collectMode(final int mode) {
this.collectMode = mode;
return this;
}
@@ -471,7 +471,7 @@ public class JexlBuilder {
* @param ns the map of namespaces
* @return this builder
*/
- public JexlBuilder namespaces(Map<String, Object> ns) {
+ public JexlBuilder namespaces(final Map<String, Object> ns) {
options.setNamespaces(ns);
return this;
}
@@ -491,7 +491,7 @@ public class JexlBuilder {
* @param size if not strictly positive, no cache is used.
* @return this builder
*/
- public JexlBuilder cache(int size) {
+ public JexlBuilder cache(final int size) {
this.cache = size;
return this;
}
@@ -513,7 +513,7 @@ public class JexlBuilder {
* @param length if not strictly positive, the value is silently replaced by the default value (64).
* @return this builder
*/
- public JexlBuilder cacheThreshold(int length) {
+ public JexlBuilder cacheThreshold(final int length) {
this.cacheThreshold = length > 0? length : CACHE_THRESHOLD;
return this;
}
@@ -530,7 +530,7 @@ public class JexlBuilder {
* @param size if not strictly positive, limit is reached when java StackOverflow is thrown.
* @return this builder
*/
- public JexlBuilder stackOverflow(int size) {
+ public JexlBuilder stackOverflow(final int size) {
this.stackOverflow = size;
return this;
}
diff --git a/src/main/java/org/apache/commons/jexl3/JexlEngine.java b/src/main/java/org/apache/commons/jexl3/JexlEngine.java
index 30348c6..951b89a 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlEngine.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlEngine.java
@@ -100,7 +100,7 @@ public abstract class JexlEngine {
*
* @param tls the thread local context to set
*/
- public static void setThreadContext(JexlContext.ThreadLocal tls) {
+ public static void setThreadContext(final JexlContext.ThreadLocal tls) {
CONTEXT.set(tls);
}
@@ -180,17 +180,17 @@ public abstract class JexlEngine {
private EmptyContext() {}
@Override
- public Object get(String name) {
+ public Object get(final String name) {
return null;
}
@Override
- public boolean has(String name) {
+ public boolean has(final String name) {
return false;
}
@Override
- public void set(String name, Object value) {
+ public void set(final String name, final Object value) {
throw new UnsupportedOperationException("Not supported in void context.");
}
};
@@ -210,7 +210,7 @@ public abstract class JexlEngine {
private EmptyNamespaceResolver() {}
@Override
- public Object resolveNamespace(String name) {
+ public Object resolveNamespace(final String name) {
return null;
}
};
@@ -292,7 +292,7 @@ public abstract class JexlEngine {
* @param noScript whether the JxltEngine only allows Jexl expressions or scripts
* @return a JEXL Template engine
*/
- public JxltEngine createJxltEngine(boolean noScript) {
+ public JxltEngine createJxltEngine(final boolean noScript) {
return createJxltEngine(noScript, JXLT_CACHE_SIZE, '$', '#');
}
@@ -331,7 +331,7 @@ public abstract class JexlEngine {
* @return An {@link JexlExpression} which can be evaluated using a {@link JexlContext}
* @throws JexlException if there is a problem parsing the script
*/
- public final JexlExpression createExpression(String expression) {
+ public final JexlExpression createExpression(final String expression) {
return createExpression(null, expression);
}
/**
@@ -359,7 +359,7 @@ public abstract class JexlEngine {
* @return A {@link JexlScript} which can be executed using a {@link JexlContext}
* @throws JexlException if there is a problem parsing the script
*/
- public final JexlScript createScript(JexlInfo info, String source, String... names) {
+ public final JexlScript createScript(final JexlInfo info, final String source, final String... names) {
return createScript(null, info, source, names);
}
@@ -371,7 +371,7 @@ public abstract class JexlEngine {
* @return A {@link JexlScript} which can be executed using a {@link JexlContext}
* @throws JexlException if there is a problem parsing the script.
*/
- public final JexlScript createScript(String scriptText) {
+ public final JexlScript createScript(final String scriptText) {
return createScript(null, null, scriptText, (String[]) null);
}
@@ -385,7 +385,7 @@ public abstract class JexlEngine {
* @return A {@link JexlScript} which can be executed using a {@link JexlContext}
* @throws JexlException if there is a problem parsing the script
*/
- public final JexlScript createScript(String source, String... names) {
+ public final JexlScript createScript(final String source, final String... names) {
return createScript(null, null, source, names);
}
@@ -397,7 +397,7 @@ public abstract class JexlEngine {
* @return A {@link JexlScript} which can be executed with a {@link JexlContext}.
* @throws JexlException if there is a problem reading or parsing the script.
*/
- public final JexlScript createScript(File scriptFile) {
+ public final JexlScript createScript(final File scriptFile) {
return createScript(null, null, readSource(scriptFile), (String[]) null);
}
@@ -411,7 +411,7 @@ public abstract class JexlEngine {
* @return A {@link JexlScript} which can be executed with a {@link JexlContext}.
* @throws JexlException if there is a problem reading or parsing the script.
*/
- public final JexlScript createScript(File scriptFile, String... names) {
+ public final JexlScript createScript(final File scriptFile, final String... names) {
return createScript(null, null, readSource(scriptFile), names);
}
@@ -426,7 +426,7 @@ public abstract class JexlEngine {
* @return A {@link JexlScript} which can be executed with a {@link JexlContext}.
* @throws JexlException if there is a problem reading or parsing the script.
*/
- public final JexlScript createScript(JexlInfo info, File scriptFile, String... names) {
+ public final JexlScript createScript(final JexlInfo info, final File scriptFile, final String... names) {
return createScript(null, info, readSource(scriptFile), names);
}
@@ -438,7 +438,7 @@ public abstract class JexlEngine {
* @return A {@link JexlScript} which can be executed with a {@link JexlContext}.
* @throws JexlException if there is a problem reading or parsing the script.
*/
- public final JexlScript createScript(URL scriptUrl) {
+ public final JexlScript createScript(final URL scriptUrl) {
return createScript(null, readSource(scriptUrl), (String[]) null);
}
@@ -452,7 +452,7 @@ public abstract class JexlEngine {
* @return A {@link JexlScript} which can be executed with a {@link JexlContext}.
* @throws JexlException if there is a problem reading or parsing the script.
*/
- public final JexlScript createScript(URL scriptUrl, String... names) {
+ public final JexlScript createScript(final URL scriptUrl, final String... names) {
return createScript(null, null, readSource(scriptUrl), names);
}
@@ -467,7 +467,7 @@ public abstract class JexlEngine {
* @return A {@link JexlScript} which can be executed with a {@link JexlContext}.
* @throws JexlException if there is a problem reading or parsing the script.
*/
- public final JexlScript createScript(JexlInfo info, URL scriptUrl, String... names) {
+ public final JexlScript createScript(final JexlInfo info, final URL scriptUrl, final String... names) {
return createScript(null, info, readSource(scriptUrl), names);
}
@@ -569,7 +569,7 @@ public abstract class JexlEngine {
* @param c column number
* @return a JexlInfo instance
*/
- public JexlInfo createInfo(String fn, int l, int c) {
+ public JexlInfo createInfo(final String fn, final int l, final int c) {
return new JexlInfo(fn, l, c);
}
@@ -591,8 +591,8 @@ public abstract class JexlEngine {
* @return the contents of the reader as a String.
* @throws IOException on any error reading the reader.
*/
- protected static String toString(BufferedReader reader) throws IOException {
- StringBuilder buffer = new StringBuilder();
+ protected static String toString(final BufferedReader reader) throws IOException {
+ final StringBuilder buffer = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
buffer.append(line).append('\n');
@@ -613,7 +613,7 @@ public abstract class JexlEngine {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),
getCharset()))) {
return toString(reader);
- } catch (IOException xio) {
+ } catch (final IOException xio) {
throw new JexlException(createInfo(file.toString(), 1, 1), "could not read source File", xio);
}
}
@@ -630,7 +630,7 @@ public abstract class JexlEngine {
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), getCharset()))) {
return toString(reader);
- } catch (IOException xio) {
+ } catch (final IOException xio) {
throw new JexlException(createInfo(url.toString(), 1, 1), "could not read source URL", xio);
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/JexlException.java b/src/main/java/org/apache/commons/jexl3/JexlException.java
index 5ed8a6e..ee5901d 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlException.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlException.java
@@ -54,7 +54,7 @@ public class JexlException extends RuntimeException {
* @param node the node causing the error
* @param msg the error message
*/
- public JexlException(JexlNode node, String msg) {
+ public JexlException(final JexlNode node, final String msg) {
this(node, msg, null);
}
@@ -65,7 +65,7 @@ public class JexlException extends RuntimeException {
* @param msg the error message
* @param cause the exception causing the error
*/
- public JexlException(JexlNode node, String msg, Throwable cause) {
+ public JexlException(final JexlNode node, final String msg, final Throwable cause) {
super(msg != null ? msg : "", unwrap(cause));
if (node != null) {
mark = node;
@@ -83,7 +83,7 @@ public class JexlException extends RuntimeException {
* @param msg the error message
* @param cause the exception causing the error
*/
- public JexlException(JexlInfo jinfo, String msg, Throwable cause) {
+ public JexlException(final JexlInfo jinfo, final String msg, final Throwable cause) {
super(msg != null ? msg : "", unwrap(cause));
mark = null;
info = jinfo;
@@ -104,9 +104,9 @@ public class JexlException extends RuntimeException {
* @param node the node
* @return a string builder
*/
- private static StringBuilder errorAt(JexlNode node) {
- JexlInfo info = node != null? detailedInfo(node, node.jexlInfo()) : null;
- StringBuilder msg = new StringBuilder();
+ private static StringBuilder errorAt(final JexlNode node) {
+ final JexlInfo info = node != null? detailedInfo(node, node.jexlInfo()) : null;
+ final StringBuilder msg = new StringBuilder();
if (info != null) {
msg.append(info.toString());
} else {
@@ -125,7 +125,7 @@ public class JexlException extends RuntimeException {
* @deprecated 3.2
*/
@Deprecated
- public static JexlInfo getInfo(JexlNode node, JexlInfo info) {
+ public static JexlInfo getInfo(final JexlNode node, final JexlInfo info) {
return detailedInfo(node, info);
}
@@ -136,7 +136,7 @@ public class JexlException extends RuntimeException {
* @param info the information
* @return the information or null
*/
- private static JexlInfo detailedInfo(JexlNode node, JexlInfo info) {
+ private static JexlInfo detailedInfo(final JexlNode node, final JexlInfo info) {
if (info != null && node != null) {
final Debugger dbg = new Debugger();
if (dbg.debug(node)) {
@@ -167,11 +167,11 @@ public class JexlException extends RuntimeException {
* @param xthrow the thowable
* @return the throwable
*/
- private static <X extends Throwable> X clean(X xthrow) {
+ private static <X extends Throwable> X clean(final X xthrow) {
if (xthrow != null) {
- List<StackTraceElement> stackJexl = new ArrayList<StackTraceElement>();
- for (StackTraceElement se : xthrow.getStackTrace()) {
- String className = se.getClassName();
+ final List<StackTraceElement> stackJexl = new ArrayList<StackTraceElement>();
+ for (final StackTraceElement se : xthrow.getStackTrace()) {
+ final String className = se.getClassName();
if (!className.startsWith("org.apache.commons.jexl3.internal")
&& !className.startsWith("org.apache.commons.jexl3.parser")) {
stackJexl.add(se);
@@ -188,7 +188,7 @@ public class JexlException extends RuntimeException {
* @param xthrow the throwable
* @return the cause
*/
- private static Throwable unwrap(Throwable xthrow) {
+ private static Throwable unwrap(final Throwable xthrow) {
if (xthrow instanceof TryFailed
|| xthrow instanceof InvocationTargetException
|| xthrow instanceof UndeclaredThrowableException) {
@@ -204,8 +204,8 @@ public class JexlException extends RuntimeException {
* @param cause the cause
* @return the info to use
*/
- private static JexlInfo merge(JexlInfo info, JavaccError cause) {
- JexlInfo dbgn = info;
+ private static JexlInfo merge(final JexlInfo info, final JavaccError cause) {
+ final JexlInfo dbgn = info;
if (cause == null || cause.getLine() < 0) {
return dbgn;
} else if (dbgn == null) {
@@ -231,12 +231,12 @@ public class JexlException extends RuntimeException {
* @param expr the expression in error
* @return the formatted message
*/
- protected String parserError(String prefix, String expr) {
- int length = expr.length();
+ protected String parserError(final String prefix, final String expr) {
+ final int length = expr.length();
if (length < MAX_EXCHARLOC) {
return prefix + " error in '" + expr + "'";
} else {
- int me = MAX_EXCHARLOC / 2;
+ final int me = MAX_EXCHARLOC / 2;
int begin = info.getColumn() - me;
if (begin < 0 || length < me) {
begin = 0;
@@ -271,7 +271,7 @@ public class JexlException extends RuntimeException {
* @param info the location info
* @param cause the javacc cause
*/
- public Tokenization(JexlInfo info, TokenMgrError cause) {
+ public Tokenization(final JexlInfo info, final TokenMgrError cause) {
super(merge(info, cause), cause.getAfter(), null);
}
@@ -300,7 +300,7 @@ public class JexlException extends RuntimeException {
* @param info the location information
* @param cause the javacc cause
*/
- public Parsing(JexlInfo info, ParseException cause) {
+ public Parsing(final JexlInfo info, final ParseException cause) {
super(merge(info, cause), cause.getAfter(), null);
}
@@ -310,7 +310,7 @@ public class JexlException extends RuntimeException {
* @param info the location information
* @param msg the message
*/
- public Parsing(JexlInfo info, String msg) {
+ public Parsing(final JexlInfo info, final String msg) {
super(info, msg, null);
}
@@ -340,7 +340,7 @@ public class JexlException extends RuntimeException {
* @param info the location information
* @param expr the source expression line
*/
- public Ambiguous(JexlInfo info, String expr) {
+ public Ambiguous(final JexlInfo info, final String expr) {
this(info, null, expr);
}
@@ -350,7 +350,7 @@ public class JexlException extends RuntimeException {
* @param end the end location information
* @param expr the source expression line
*/
- public Ambiguous(JexlInfo begin, JexlInfo end, String expr) {
+ public Ambiguous(final JexlInfo begin, final JexlInfo end, final String expr) {
super(begin, expr);
recover = end;
}
@@ -366,8 +366,8 @@ public class JexlException extends RuntimeException {
* @return the source with the ambiguous statement removed
* or null if no recovery was possible
*/
- public String tryCleanSource(String src) {
- JexlInfo ji = info();
+ public String tryCleanSource(final String src) {
+ final JexlInfo ji = info();
return ji == null || recover == null
? src
: sliceSource(src, ji.getLine(), ji.getColumn(), recover.getLine(), recover.getColumn());
@@ -383,9 +383,9 @@ public class JexlException extends RuntimeException {
* @param toc the to column
* @return the source with the (begin) to (to) zone removed
*/
- public static String sliceSource(String src, int froml, int fromc, int tol, int toc) {
- BufferedReader reader = new BufferedReader(new StringReader(src));
- StringBuilder buffer = new StringBuilder();
+ public static String sliceSource(final String src, final int froml, final int fromc, final int tol, final int toc) {
+ final BufferedReader reader = new BufferedReader(new StringReader(src));
+ final StringBuilder buffer = new StringBuilder();
String line;
int cl = 1;
try {
@@ -402,7 +402,7 @@ public class JexlException extends RuntimeException {
} // else ignore line
cl += 1;
}
- } catch (IOException xignore) {
+ } catch (final IOException xignore) {
//damn the checked exceptions :-)
}
return buffer.toString();
@@ -421,7 +421,7 @@ public class JexlException extends RuntimeException {
* @param name the unknown method
* @param cause the exception causing the error
*/
- public StackOverflow(JexlInfo info, String name, Throwable cause) {
+ public StackOverflow(final JexlInfo info, final String name, final Throwable cause) {
super(info, name, cause);
}
@@ -450,7 +450,7 @@ public class JexlException extends RuntimeException {
* @param info the location information
* @param expr the source expression line
*/
- public Assignment(JexlInfo info, String expr) {
+ public Assignment(final JexlInfo info, final String expr) {
super(info, expr);
}
@@ -474,7 +474,7 @@ public class JexlException extends RuntimeException {
* @param feature the feature code
* @param expr the source expression line
*/
- public Feature(JexlInfo info, int feature, String expr) {
+ public Feature(final JexlInfo info, final int feature, final String expr) {
super(info, expr);
this.code = feature;
}
@@ -501,7 +501,7 @@ public class JexlException extends RuntimeException {
* @param var the variable name
* @return the issue message
*/
- public String message(String var) {
+ public String message(final String var) {
switch(this) {
case NULLVALUE : return "variable '" + var + "' is null";
case REDEFINED : return "variable '" + var + "' is already defined";
@@ -529,7 +529,7 @@ public class JexlException extends RuntimeException {
* @param var the unknown variable
* @param vi the variable issue
*/
- public Variable(JexlNode node, String var, VariableIssue vi) {
+ public Variable(final JexlNode node, final String var, final VariableIssue vi) {
super(node, var, null);
issue = vi;
}
@@ -541,7 +541,7 @@ public class JexlException extends RuntimeException {
* @param var the unknown variable
* @param undef whether the variable is undefined or evaluated as null
*/
- public Variable(JexlNode node, String var, boolean undef) {
+ public Variable(final JexlNode node, final String var, final boolean undef) {
this(node, var, undef ? VariableIssue.UNDEFINED : VariableIssue.NULLVALUE);
}
@@ -576,7 +576,7 @@ public class JexlException extends RuntimeException {
* @return the error message
*/
@Deprecated
- public static String variableError(JexlNode node, String variable, boolean undef) {
+ public static String variableError(final JexlNode node, final String variable, final boolean undef) {
return variableError(node, variable, undef? VariableIssue.UNDEFINED : VariableIssue.NULLVALUE);
}
@@ -588,8 +588,8 @@ public class JexlException extends RuntimeException {
* @param issue the variable kind of issue
* @return the error message
*/
- public static String variableError(JexlNode node, String variable, VariableIssue issue) {
- StringBuilder msg = errorAt(node);
+ public static String variableError(final JexlNode node, final String variable, final VariableIssue issue) {
+ final StringBuilder msg = errorAt(node);
msg.append(issue.message(variable));
return msg.toString();
}
@@ -613,7 +613,7 @@ public class JexlException extends RuntimeException {
* @deprecated 3.2
*/
@Deprecated
- public Property(JexlNode node, String pty) {
+ public Property(final JexlNode node, final String pty) {
this(node, pty, true, null);
}
/**
@@ -625,7 +625,7 @@ public class JexlException extends RuntimeException {
* @deprecated 3.2
*/
@Deprecated
- public Property(JexlNode node, String pty, Throwable cause) {
+ public Property(final JexlNode node, final String pty, final Throwable cause) {
this(node, pty, true, cause);
}
@@ -637,7 +637,7 @@ public class JexlException extends RuntimeException {
* @param undef whether the variable is null or undefined
* @param cause the exception causing the error
*/
- public Property(JexlNode node, String pty, boolean undef, Throwable cause) {
+ public Property(final JexlNode node, final String pty, final boolean undef, final Throwable cause) {
super(node, pty, cause);
undefined = undef;
}
@@ -672,8 +672,8 @@ public class JexlException extends RuntimeException {
* @param undef whether the property is null or undefined
* @return the error message
*/
- public static String propertyError(JexlNode node, String pty, boolean undef) {
- StringBuilder msg = errorAt(node);
+ public static String propertyError(final JexlNode node, final String pty, final boolean undef) {
+ final StringBuilder msg = errorAt(node);
if (undef) {
msg.append("unsolvable");
} else {
@@ -694,7 +694,7 @@ public class JexlException extends RuntimeException {
* @deprecated 3.2
*/
@Deprecated
- public static String propertyError(JexlNode node, String var) {
+ public static String propertyError(final JexlNode node, final String var) {
return propertyError(node, var, true);
}
@@ -712,7 +712,7 @@ public class JexlException extends RuntimeException {
* @deprecated as of 3.2, use call with method arguments
*/
@Deprecated
- public Method(JexlNode node, String name) {
+ public Method(final JexlNode node, final String name) {
this(node, name, null);
}
@@ -725,7 +725,7 @@ public class JexlException extends RuntimeException {
* @deprecated as of 3.2, use call with method arguments
*/
@Deprecated
- public Method(JexlInfo info, String name, Throwable cause) {
+ public Method(final JexlInfo info, final String name, final Throwable cause) {
this(info, name, null, cause);
}
@@ -737,7 +737,7 @@ public class JexlException extends RuntimeException {
* @param args the method arguments
* @since 3.2
*/
- public Method(JexlNode node, String name, Object[] args) {
+ public Method(final JexlNode node, final String name, final Object[] args) {
super(node, methodSignature(name, args));
}
@@ -749,7 +749,7 @@ public class JexlException extends RuntimeException {
* @param args the method arguments
* @since 3.2
*/
- public Method(JexlInfo info, String name, Object[] args) {
+ public Method(final JexlInfo info, final String name, final Object[] args) {
this(info, name, args, null);
}
@@ -763,7 +763,7 @@ public class JexlException extends RuntimeException {
* @param args the method arguments
* @since 3.2
*/
- public Method(JexlInfo info, String name, Object[] args, Throwable cause) {
+ public Method(final JexlInfo info, final String name, final Object[] args, final Throwable cause) {
super(info, methodSignature(name, args), cause);
}
@@ -771,8 +771,8 @@ public class JexlException extends RuntimeException {
* @return the method name
*/
public String getMethod() {
- String signature = getMethodSignature();
- int lparen = signature.indexOf('(');
+ final String signature = getMethodSignature();
+ final int lparen = signature.indexOf('(');
return lparen > 0? signature.substring(0, lparen) : signature;
}
@@ -796,15 +796,15 @@ public class JexlException extends RuntimeException {
* @param args the method arguments
* @return a suitable signed name
*/
- private static String methodSignature(String name, Object[] args) {
+ private static String methodSignature(final String name, final Object[] args) {
if (args != null && args.length > 0) {
- StringBuilder strb = new StringBuilder(name);
+ final StringBuilder strb = new StringBuilder(name);
strb.append('(');
for (int a = 0; a < args.length; ++a) {
if (a > 0) {
strb.append(", ");
}
- Class<?> clazz = args[a] == null ? Object.class : args[a].getClass();
+ final Class<?> clazz = args[a] == null ? Object.class : args[a].getClass();
strb.append(clazz.getSimpleName());
}
strb.append(')');
@@ -820,7 +820,7 @@ public class JexlException extends RuntimeException {
* @param method the method name
* @return the error message
*/
- public static String methodError(JexlNode node, String method) {
+ public static String methodError(final JexlNode node, final String method) {
return methodError(node, method, null);
}
@@ -832,8 +832,8 @@ public class JexlException extends RuntimeException {
* @param args the method arguments
* @return the error message
*/
- public static String methodError(JexlNode node, String method, Object[] args) {
- StringBuilder msg = errorAt(node);
+ public static String methodError(final JexlNode node, final String method, final Object[] args) {
+ final StringBuilder msg = errorAt(node);
msg.append("unsolvable function/method '");
msg.append(methodSignature(method, args));
msg.append('\'');
@@ -853,7 +853,7 @@ public class JexlException extends RuntimeException {
* @param symbol the operator name
* @param cause the exception causing the error
*/
- public Operator(JexlNode node, String symbol, Throwable cause) {
+ public Operator(final JexlNode node, final String symbol, final Throwable cause) {
super(node, symbol, cause);
}
@@ -877,8 +877,8 @@ public class JexlException extends RuntimeException {
* @param symbol the operator name
* @return the error message
*/
- public static String operatorError(JexlNode node, String symbol) {
- StringBuilder msg = errorAt(node);
+ public static String operatorError(final JexlNode node, final String symbol) {
+ final StringBuilder msg = errorAt(node);
msg.append("error calling operator '");
msg.append(symbol);
msg.append('\'');
@@ -898,7 +898,7 @@ public class JexlException extends RuntimeException {
* @param name the annotation name
* @param cause the exception causing the error
*/
- public Annotation(JexlNode node, String name, Throwable cause) {
+ public Annotation(final JexlNode node, final String name, final Throwable cause) {
super(node, name, cause);
}
@@ -923,8 +923,8 @@ public class JexlException extends RuntimeException {
* @return the error message
* @since 3.1
*/
- public static String annotationError(JexlNode node, String annotation) {
- StringBuilder msg = errorAt(node);
+ public static String annotationError(final JexlNode node, final String annotation) {
+ final StringBuilder msg = errorAt(node);
msg.append("error processing annotation '");
msg.append(annotation);
msg.append('\'');
@@ -948,7 +948,7 @@ public class JexlException extends RuntimeException {
* @param msg the message
* @param value the returned value
*/
- public Return(JexlNode node, String msg, Object value) {
+ public Return(final JexlNode node, final String msg, final Object value) {
super(node, msg, null);
this.result = value;
}
@@ -972,7 +972,7 @@ public class JexlException extends RuntimeException {
*
* @param node the node where the interruption was detected
*/
- public Cancel(JexlNode node) {
+ public Cancel(final JexlNode node) {
super(node, "execution cancelled", null);
}
}
@@ -988,7 +988,7 @@ public class JexlException extends RuntimeException {
*
* @param node the break
*/
- public Break(JexlNode node) {
+ public Break(final JexlNode node) {
super(node, "break loop", null);
}
}
@@ -1004,7 +1004,7 @@ public class JexlException extends RuntimeException {
*
* @param node the continue
*/
- public Continue(JexlNode node) {
+ public Continue(final JexlNode node) {
super(node, "continue loop", null);
}
}
@@ -1020,7 +1020,7 @@ public class JexlException extends RuntimeException {
* Creates a new instance.
* @param xany the original invocation target exception
*/
- private TryFailed(InvocationTargetException xany) {
+ private TryFailed(final InvocationTargetException xany) {
super((JexlInfo) null, "tryFailed", xany.getCause());
}
}
@@ -1031,8 +1031,8 @@ public class JexlException extends RuntimeException {
* @param xinvoke the invocation exception
* @return a JexlException
*/
- public static JexlException tryFailed(InvocationTargetException xinvoke) {
- Throwable cause = xinvoke.getCause();
+ public static JexlException tryFailed(final InvocationTargetException xinvoke) {
+ final Throwable cause = xinvoke.getCause();
return cause instanceof JexlException
? (JexlException) cause
: new JexlException.TryFailed(xinvoke); // fail
@@ -1052,7 +1052,7 @@ public class JexlException extends RuntimeException {
*/
@Override
public String getMessage() {
- StringBuilder msg = new StringBuilder();
+ final StringBuilder msg = new StringBuilder();
if (info != null) {
msg.append(info.toString());
} else {
@@ -1060,7 +1060,7 @@ public class JexlException extends RuntimeException {
}
msg.append(' ');
msg.append(detailedMessage());
- Throwable cause = getCause();
+ final Throwable cause = getCause();
if (cause instanceof JexlArithmetic.NullOperand) {
msg.append(" caused by null operand");
}
diff --git a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java
index 2c8dd29..ecceca4 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlFeatures.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlFeatures.java
@@ -112,7 +112,7 @@ public final class JexlFeatures {
* Copy constructor.
* @param features the feature to copy from
*/
- public JexlFeatures(JexlFeatures features) {
+ public JexlFeatures(final JexlFeatures features) {
this.flags = features.flags;
this.reservedNames = features.reservedNames;
}
@@ -126,7 +126,7 @@ public final class JexlFeatures {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
@@ -151,7 +151,7 @@ public final class JexlFeatures {
* @param feature the feature number
* @return the feature name
*/
- public static String stringify(int feature) {
+ public static String stringify(final int feature) {
return feature >= 0 && feature < F_NAMES.length ? F_NAMES[feature] : "unsupported feature";
}
@@ -160,7 +160,7 @@ public final class JexlFeatures {
* @param names the names to reserve
* @return this features instance
*/
- public JexlFeatures reservedNames(Collection<String> names) {
+ public JexlFeatures reservedNames(final Collection<String> names) {
if (names == null || names.isEmpty()) {
reservedNames = Collections.emptySet();
} else {
@@ -182,7 +182,7 @@ public final class JexlFeatures {
* @param name the name to check
* @return true if reserved, false otherwise
*/
- public boolean isReservedName(String name) {
+ public boolean isReservedName(final String name) {
return name != null && reservedNames.contains(name);
}
@@ -191,7 +191,7 @@ public final class JexlFeatures {
* @param feature the feature ordinal
* @param flag turn-on, turn off
*/
- private void setFeature(int feature, boolean flag) {
+ private void setFeature(final int feature, final boolean flag) {
if (flag) {
flags |= (1 << feature);
} else {
@@ -204,7 +204,7 @@ public final class JexlFeatures {
* @param feature feature ordinal
* @return true if on, false if off
*/
- private boolean getFeature(int feature) {
+ private boolean getFeature(final int feature) {
return (flags & (1L << feature)) != 0L;
}
@@ -217,7 +217,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures register(boolean flag) {
+ public JexlFeatures register(final boolean flag) {
setFeature(REGISTER, flag);
return this;
}
@@ -237,7 +237,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures localVar(boolean flag) {
+ public JexlFeatures localVar(final boolean flag) {
setFeature(LOCAL_VAR, flag);
return this;
}
@@ -257,7 +257,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures sideEffectGlobal(boolean flag) {
+ public JexlFeatures sideEffectGlobal(final boolean flag) {
setFeature(SIDE_EFFECT_GLOBAL, flag);
return this;
}
@@ -277,7 +277,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures sideEffect(boolean flag) {
+ public JexlFeatures sideEffect(final boolean flag) {
setFeature(SIDE_EFFECT, flag);
return this;
}
@@ -297,7 +297,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures arrayReferenceExpr(boolean flag) {
+ public JexlFeatures arrayReferenceExpr(final boolean flag) {
setFeature(ARRAY_REF_EXPR, flag);
return this;
}
@@ -317,7 +317,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures methodCall(boolean flag) {
+ public JexlFeatures methodCall(final boolean flag) {
setFeature(METHOD_CALL, flag);
return this;
}
@@ -337,7 +337,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures structuredLiteral(boolean flag) {
+ public JexlFeatures structuredLiteral(final boolean flag) {
setFeature(STRUCTURED_LITERAL, flag);
return this;
}
@@ -357,7 +357,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures newInstance(boolean flag) {
+ public JexlFeatures newInstance(final boolean flag) {
setFeature(NEW_INSTANCE, flag);
return this;
}
@@ -377,7 +377,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures loops(boolean flag) {
+ public JexlFeatures loops(final boolean flag) {
setFeature(LOOP, flag);
return this;
}
@@ -397,7 +397,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures lambda(boolean flag) {
+ public JexlFeatures lambda(final boolean flag) {
setFeature(LAMBDA, flag);
return this;
}
@@ -417,7 +417,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures pragma(boolean flag) {
+ public JexlFeatures pragma(final boolean flag) {
setFeature(PRAGMA, flag);
return this;
}
@@ -437,7 +437,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures annotation(boolean flag) {
+ public JexlFeatures annotation(final boolean flag) {
setFeature(ANNOTATION, flag);
return this;
}
@@ -457,7 +457,7 @@ public final class JexlFeatures {
* @param flag true to enable, false to disable
* @return this features instance
*/
- public JexlFeatures script(boolean flag) {
+ public JexlFeatures script(final boolean flag) {
setFeature(SCRIPT, flag);
return this;
}
@@ -483,7 +483,7 @@ public final class JexlFeatures {
* @param flag true means syntactic lexical function scope is in effect, false implies non-lexical scoping
* @return this features instance
*/
- public JexlFeatures lexical(boolean flag) {
+ public JexlFeatures lexical(final boolean flag) {
setFeature(LEXICAL, flag);
return this;
}
@@ -500,7 +500,7 @@ public final class JexlFeatures {
* @param flag true means syntactic lexical shade is in effect and implies lexical scope
* @return this features instance
*/
- public JexlFeatures lexicalShade(boolean flag) {
+ public JexlFeatures lexicalShade(final boolean flag) {
setFeature(LEXICAL_SHADE, flag);
if (flag) {
setFeature(LEXICAL, true);
diff --git a/src/main/java/org/apache/commons/jexl3/JexlInfo.java b/src/main/java/org/apache/commons/jexl3/JexlInfo.java
index b454159..58b97c3 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlInfo.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlInfo.java
@@ -70,7 +70,7 @@ public class JexlInfo {
* @param l line number
* @param c column number
*/
- public JexlInfo(String source, int l, int c) {
+ public JexlInfo(final String source, final int l, final int c) {
name = source;
line = l;
column = c;
@@ -82,13 +82,13 @@ public class JexlInfo {
* outside of o.a.c.jexl3.</p>
*/
public JexlInfo() {
- StackTraceElement[] stack = new Throwable().getStackTrace();
+ final StackTraceElement[] stack = new Throwable().getStackTrace();
String cname = getClass().getName();
- String pkgname = getClass().getPackage().getName();
+ final String pkgname = getClass().getPackage().getName();
StackTraceElement se = null;
for (int s = 1; s < stack.length; ++s) {
se = stack[s];
- String className = se.getClassName();
+ final String className = se.getClassName();
if (!className.equals(cname)) {
// go deeper if called from jexl implementation classes
if (className.startsWith(pkgname + ".internal.")
@@ -114,7 +114,7 @@ public class JexlInfo {
* @param c the column
* @return a new info instance
*/
- public JexlInfo at(int l, int c) {
+ public JexlInfo at(final int l, final int c) {
return new JexlInfo(name, l, c);
}
@@ -123,7 +123,7 @@ public class JexlInfo {
*
* @param copy the instance to copy
*/
- protected JexlInfo(JexlInfo copy) {
+ protected JexlInfo(final JexlInfo copy) {
name = copy.getName();
line = copy.getLine();
column = copy.getColumn();
@@ -136,7 +136,7 @@ public class JexlInfo {
*/
@Override
public String toString() {
- StringBuilder sb = new StringBuilder(name != null? name : "");
+ final StringBuilder sb = new StringBuilder(name != null? name : "");
if (line > 0) {
sb.append("@");
sb.append(line);
@@ -145,7 +145,7 @@ public class JexlInfo {
sb.append(column);
}
}
- JexlInfo.Detail dbg = getDetail();
+ final JexlInfo.Detail dbg = getDetail();
if (dbg!= null) {
sb.append("![");
sb.append(dbg.start());
@@ -197,7 +197,7 @@ public class JexlInfo {
* @param script the script
* @return the info
*/
- public static JexlInfo from(JexlScript script) {
+ public static JexlInfo from(final JexlScript script) {
return script instanceof Script? ((Script) script).getInfo() : null;
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/JexlOperator.java b/src/main/java/org/apache/commons/jexl3/JexlOperator.java
index 7cbaaba..6f21e41 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlOperator.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlOperator.java
@@ -343,7 +343,7 @@ public enum JexlOperator {
* @param m the method name associated to this operator in a JexlArithmetic
* @param argc the number of parameters for the method
*/
- JexlOperator(String o, String m, int argc) {
+ JexlOperator(final String o, final String m, final int argc) {
this.operator = o;
this.methodName = m;
this.arity = argc;
@@ -357,7 +357,7 @@ public enum JexlOperator {
* @param m the method name associated to this operator in a JexlArithmetic
* @param b the base operator, ie + for +=
*/
- JexlOperator(String o, String m, JexlOperator b) {
+ JexlOperator(final String o, final String m, final JexlOperator b) {
this.operator = o;
this.methodName = m;
this.arity = 2;
diff --git a/src/main/java/org/apache/commons/jexl3/JexlOptions.java b/src/main/java/org/apache/commons/jexl3/JexlOptions.java
index e54985e..62666b9 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlOptions.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlOptions.java
@@ -80,7 +80,7 @@ public final class JexlOptions {
* @param value true or false
* @return the new flags mask value
*/
- private static int set(int ordinal, int mask, boolean value) {
+ private static int set(final int ordinal, final int mask, final boolean value) {
return value? mask | (1 << ordinal) : mask & ~(1 << ordinal);
}
@@ -90,7 +90,7 @@ public final class JexlOptions {
* @param mask the flags mask
* @return the mask value with this flag or-ed in
*/
- private static boolean isSet(int ordinal, int mask) {
+ private static boolean isSet(final int ordinal, final int mask) {
return (mask & 1 << ordinal) != 0;
}
@@ -111,7 +111,7 @@ public final class JexlOptions {
* may ease validating JEXL3.2 in your environment.
* @param flags the flags to set
*/
- public static void setDefaultFlags(String...flags) {
+ public static void setDefaultFlags(final String...flags) {
DEFAULT = parseFlags(DEFAULT, flags);
}
@@ -124,7 +124,7 @@ public final class JexlOptions {
* @param flags the flags to set
* @return the flag mask updated
*/
- public static int parseFlags(int mask, String...flags) {
+ public static int parseFlags(int mask, final String...flags) {
for(String name : flags) {
boolean b = true;
if (name.charAt(0) == '+') {
@@ -151,7 +151,7 @@ public final class JexlOptions {
* Sets this option flags using the +/- syntax.
* @param opts the option flags
*/
- public void setFlags(String[] opts) {
+ public void setFlags(final String[] opts) {
flags = parseFlags(flags, opts);
}
@@ -253,7 +253,7 @@ public final class JexlOptions {
* context.
* @param flag true if antish variables are solved, false otherwise
*/
- public void setAntish(boolean flag) {
+ public void setAntish(final boolean flag) {
flags = set(ANTISH, flags, flag);
}
@@ -262,7 +262,7 @@ public final class JexlOptions {
* null (false) when interrupted during evaluation.
* @param flag true when cancellable, false otherwise
*/
- public void setCancellable(boolean flag) {
+ public void setCancellable(final boolean flag) {
flags = set(CANCELLABLE, flags, flag);
}
@@ -271,7 +271,7 @@ public final class JexlOptions {
* evaluation.
* @param flag true if lexical scope is used, false otherwise
*/
- public void setLexical(boolean flag) {
+ public void setLexical(final boolean flag) {
flags = set(LEXICAL, flags, flag);
}
@@ -282,7 +282,7 @@ public final class JexlOptions {
* If setting to lexical shade, lexical scope is also set.
* @param flag true if creation is allowed, false otherwise
*/
- public void setLexicalShade(boolean flag) {
+ public void setLexicalShade(final boolean flag) {
flags = set(SHADE, flags, flag);
if (flag) {
flags = set(LEXICAL, flags, true);
@@ -293,7 +293,7 @@ public final class JexlOptions {
* Sets the arithmetic math context.
* @param mcontext the context
*/
- public void setMathContext(MathContext mcontext) {
+ public void setMathContext(final MathContext mcontext) {
this.mathContext = mcontext;
}
@@ -301,7 +301,7 @@ public final class JexlOptions {
* Sets the arithmetic math scale.
* @param mscale the scale
*/
- public void setMathScale(int mscale) {
+ public void setMathScale(final int mscale) {
this.mathScale = mscale;
}
@@ -310,7 +310,7 @@ public final class JexlOptions {
* during evaluation.
* @param flag true if safe, false otherwise
*/
- public void setSafe(boolean flag) {
+ public void setSafe(final boolean flag) {
flags = set(SAFE, flags, flag);
}
@@ -319,7 +319,7 @@ public final class JexlOptions {
* is encountered during evaluation.
* @param flag true if silent, false otherwise
*/
- public void setSilent(boolean flag) {
+ public void setSilent(final boolean flag) {
flags = set(SILENT, flags, flag);
}
@@ -328,7 +328,7 @@ public final class JexlOptions {
* constructors as errors during evaluation.
* @param flag true if strict, false otherwise
*/
- public void setStrict(boolean flag) {
+ public void setStrict(final boolean flag) {
flags = set(STRICT, flags, flag);
}
@@ -336,7 +336,7 @@ public final class JexlOptions {
* Sets the strict arithmetic flag.
* @param stricta true or false
*/
- public void setStrictArithmetic(boolean stricta) {
+ public void setStrictArithmetic(final boolean stricta) {
this.strictArithmetic = stricta;
}
@@ -346,7 +346,7 @@ public final class JexlOptions {
* instead of copied.
* @param flag true if shared, false if not
*/
- public void setSharedInstance(boolean flag) {
+ public void setSharedInstance(final boolean flag) {
flags = set(SHARED, flags, flag);
}
@@ -363,7 +363,7 @@ public final class JexlOptions {
* @param jexl the engine
* @return this instance
*/
- public JexlOptions set(JexlEngine jexl) {
+ public JexlOptions set(final JexlEngine jexl) {
if (jexl instanceof Engine) {
((Engine) jexl).optionsSet(this);
}
@@ -375,7 +375,7 @@ public final class JexlOptions {
* @param src the options
* @return this instance
*/
- public JexlOptions set(JexlOptions src) {
+ public JexlOptions set(final JexlOptions src) {
mathContext = src.mathContext;
mathScale = src.mathScale;
strictArithmetic = src.strictArithmetic;
@@ -396,7 +396,7 @@ public final class JexlOptions {
* Sets the optional map of namespaces.
* @param ns a namespaces map
*/
- public void setNamespaces(Map<String, Object> ns) {
+ public void setNamespaces(final Map<String, Object> ns) {
this.namespaces = ns == null? Collections.emptyMap() : ns;
}
diff --git a/src/main/java/org/apache/commons/jexl3/JxltEngine.java b/src/main/java/org/apache/commons/jexl3/JxltEngine.java
index f32b551f..e16f83b 100644
--- a/src/main/java/org/apache/commons/jexl3/JxltEngine.java
+++ b/src/main/java/org/apache/commons/jexl3/JxltEngine.java
@@ -55,7 +55,7 @@ public abstract class JxltEngine {
* @param msg the exception message
* @param cause the exception cause
*/
- public Exception(JexlInfo info, String msg, Throwable cause) {
+ public Exception(final JexlInfo info, final String msg, final Throwable cause) {
super(info, msg, cause);
}
}
@@ -213,7 +213,7 @@ public abstract class JxltEngine {
* @return the {@link Expression}, null if silent and an error occurred
* @throws Exception if an error occurs and the {@link JexlEngine} is not silent
*/
- public Expression createExpression(String expression) {
+ public Expression createExpression(final String expression) {
return createExpression(null, expression);
}
@@ -355,7 +355,7 @@ public abstract class JxltEngine {
* @param source the source
* @return the template
*/
- public Template createTemplate(JexlInfo info, String source, String... parms) {
+ public Template createTemplate(final JexlInfo info, final String source, final String... parms) {
return createTemplate(info, "$$", new StringReader(source), parms);
}
@@ -366,7 +366,7 @@ public abstract class JxltEngine {
* @param source the source
* @return the template
*/
- public Template createTemplate(JexlInfo info, String source) {
+ public Template createTemplate(final JexlInfo info, final String source) {
return createTemplate(info, "$$", new StringReader(source), (String[]) null);
}
@@ -378,7 +378,7 @@ public abstract class JxltEngine {
* @param parms the parameter names
* @return the template
*/
- public Template createTemplate(String prefix, Reader source, String... parms) {
+ public Template createTemplate(final String prefix, final Reader source, final String... parms) {
return createTemplate(null, prefix, source, parms);
}
@@ -389,7 +389,7 @@ public abstract class JxltEngine {
* @param parms the parameter names
* @return the template
*/
- public Template createTemplate(String source, String... parms) {
+ public Template createTemplate(final String source, final String... parms) {
return createTemplate(null, source, parms);
}
@@ -399,7 +399,7 @@ public abstract class JxltEngine {
* @param source the source
* @return the template
*/
- public Template createTemplate(String source) {
+ public Template createTemplate(final String source) {
return createTemplate(null, source);
}
diff --git a/src/main/java/org/apache/commons/jexl3/MapContext.java b/src/main/java/org/apache/commons/jexl3/MapContext.java
index dbaaf8a..c3bbccc 100644
--- a/src/main/java/org/apache/commons/jexl3/MapContext.java
+++ b/src/main/java/org/apache/commons/jexl3/MapContext.java
@@ -43,22 +43,22 @@ public class MapContext implements JexlContext {
*
* @param vars the variable map
*/
- public MapContext(Map<String, Object> vars) {
+ public MapContext(final Map<String, Object> vars) {
map = vars == null ? new HashMap<String, Object>() : vars;
}
@Override
- public boolean has(String name) {
+ public boolean has(final String name) {
return map.containsKey(name);
}
@Override
- public Object get(String name) {
+ public Object get(final String name) {
return map.get(name);
}
@Override
- public void set(String name, Object value) {
+ public void set(final String name, final Object value) {
map.put(name, value);
}
diff --git a/src/main/java/org/apache/commons/jexl3/ObjectContext.java b/src/main/java/org/apache/commons/jexl3/ObjectContext.java
index 9217935..b378659 100644
--- a/src/main/java/org/apache/commons/jexl3/ObjectContext.java
+++ b/src/main/java/org/apache/commons/jexl3/ObjectContext.java
@@ -53,18 +53,18 @@ public class ObjectContext<T> implements JexlContext, JexlContext.NamespaceResol
* @param engine the jexl engine to use to solve properties
* @param wrapped the object to wrap in this context
*/
- public ObjectContext(JexlEngine engine, T wrapped) {
+ public ObjectContext(final JexlEngine engine, final T wrapped) {
this.jexl = engine;
this.object = wrapped;
}
@Override
- public Object get(String name) {
- JexlPropertyGet jget = jexl.getUberspect().getPropertyGet(object, name);
+ public Object get(final String name) {
+ final JexlPropertyGet jget = jexl.getUberspect().getPropertyGet(object, name);
if (jget != null) {
try {
return jget.invoke(object);
- } catch (Exception xany) {
+ } catch (final Exception xany) {
if (jexl.isStrict()) {
throw new JexlException.Property(null, name, true, xany);
}
@@ -74,12 +74,12 @@ public class ObjectContext<T> implements JexlContext, JexlContext.NamespaceResol
}
@Override
- public void set(String name, Object value) {
- JexlPropertySet jset = jexl.getUberspect().getPropertySet(object, name, value);
+ public void set(final String name, final Object value) {
+ final JexlPropertySet jset = jexl.getUberspect().getPropertySet(object, name, value);
if (jset != null) {
try {
jset.invoke(object, value);
- } catch (Exception xany) {
+ } catch (final Exception xany) {
// ignore
if (jexl.isStrict()) {
throw new JexlException.Property(null, name, true, xany);
@@ -89,17 +89,17 @@ public class ObjectContext<T> implements JexlContext, JexlContext.NamespaceResol
}
@Override
- public boolean has(String name) {
- JexlPropertyGet jget = jexl.getUberspect().getPropertyGet(object, name);
+ public boolean has(final String name) {
+ final JexlPropertyGet jget = jexl.getUberspect().getPropertyGet(object, name);
try {
return jget != null && jget.invoke(object) != null;
- } catch (Exception xany) {
+ } catch (final Exception xany) {
return false;
}
}
@Override
- public Object resolveNamespace(String name) {
+ public Object resolveNamespace(final String name) {
if (name == null || name.isEmpty()) {
return object;
} else {
diff --git a/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java b/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java
index da1ffbb..5ad472c 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/ArrayBuilder.java
@@ -50,8 +50,8 @@ public class ArrayBuilder implements JexlArithmetic.ArrayBuilder {
* @param parm a class
* @return the primitive type or null it the argument is not unboxable
*/
- protected static Class<?> unboxingClass(Class<?> parm) {
- Class<?> prim = BOXING_CLASSES.get(parm);
+ protected static Class<?> unboxingClass(final Class<?> parm) {
+ final Class<?> prim = BOXING_CLASSES.get(parm);
return prim == null ? parm : prim;
}
@@ -70,12 +70,12 @@ public class ArrayBuilder implements JexlArithmetic.ArrayBuilder {
* Creates a new builder.
* @param size the exact array size
*/
- public ArrayBuilder(int size) {
+ public ArrayBuilder(final int size) {
untyped = new Object[size];
}
@Override
- public void add(Object value) {
+ public void add(final Object value) {
// for all children after first...
if (!Object.class.equals(commonClass)) {
if (value == null) {
@@ -111,10 +111,10 @@ public class ArrayBuilder implements JexlArithmetic.ArrayBuilder {
}
@Override
- public Object create(boolean extended) {
+ public Object create(final boolean extended) {
if (untyped != null) {
if (extended) {
- List<Object> list = new ArrayList<Object>(added);
+ final List<Object> list = new ArrayList<Object>(added);
list.addAll(Arrays.asList(untyped).subList(0, added));
return list;
}
@@ -126,7 +126,7 @@ public class ArrayBuilder implements JexlArithmetic.ArrayBuilder {
commonClass = unboxingClass(commonClass);
}
// allocate and fill up the typed array
- Object typed = Array.newInstance(commonClass, size);
+ final Object typed = Array.newInstance(commonClass, size);
for (int i = 0; i < size; ++i) {
Array.set(typed, i, untyped[i]);
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/Closure.java b/src/main/java/org/apache/commons/jexl3/internal/Closure.java
index 091129b..18ae8e1 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Closure.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Closure.java
@@ -33,7 +33,7 @@ public class Closure extends Script {
* @param theCaller the calling interpreter
* @param lambda the lambda
*/
- protected Closure(Interpreter theCaller, ASTJexlLambda lambda) {
+ protected Closure(final Interpreter theCaller, final ASTJexlLambda lambda) {
super(theCaller.jexl, null, lambda);
frame = lambda.createFrame(theCaller.frame);
}
@@ -43,9 +43,9 @@ public class Closure extends Script {
* @param base the base script
* @param args the script arguments
*/
- protected Closure(Script base, Object[] args) {
+ protected Closure(final Script base, final Object[] args) {
super(base.jexl, base.source, base.script);
- Frame sf = (base instanceof Closure) ? ((Closure) base).frame : null;
+ final Frame sf = (base instanceof Closure) ? ((Closure) base).frame : null;
frame = sf == null
? script.createFrame(args)
: sf.assign(args);
@@ -63,7 +63,7 @@ public class Closure extends Script {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
@@ -97,12 +97,12 @@ public class Closure extends Script {
* @param symbol the symbol index (in the caller of this closure)
* @param value the value to set in the local frame
*/
- public void setCaptured(int symbol, Object value) {
+ public void setCaptured(final int symbol, final Object value) {
if (script instanceof ASTJexlLambda) {
- ASTJexlLambda lambda = (ASTJexlLambda) script;
- Scope scope = lambda.getScope();
+ final ASTJexlLambda lambda = (ASTJexlLambda) script;
+ final Scope scope = lambda.getScope();
if (scope != null) {
- Integer reg = scope.getCaptured(symbol);
+ final Integer reg = scope.getCaptured(symbol);
if (reg != null) {
frame.set(reg, value);
}
@@ -111,25 +111,25 @@ public class Closure extends Script {
}
@Override
- public Object evaluate(JexlContext context) {
+ public Object evaluate(final JexlContext context) {
return execute(context, (Object[])null);
}
@Override
- public Object execute(JexlContext context) {
+ public Object execute(final JexlContext context) {
return execute(context, (Object[])null);
}
@Override
- public Object execute(JexlContext context, Object... args) {
- Frame local = frame != null? frame.assign(args) : null;
- Interpreter interpreter = createInterpreter(context, local);
+ public Object execute(final JexlContext context, final Object... args) {
+ final Frame local = frame != null? frame.assign(args) : null;
+ final Interpreter interpreter = createInterpreter(context, local);
return interpreter.runClosure(this, null);
}
@Override
- public Callable callable(JexlContext context, Object... args) {
- Frame local = frame != null? frame.assign(args) : null;
+ public Callable callable(final JexlContext context, final Object... args) {
+ final Frame local = frame != null? frame.assign(args) : null;
return new Callable(createInterpreter(context, local)) {
@Override
public Object interpret() {
diff --git a/src/main/java/org/apache/commons/jexl3/internal/Debugger.java b/src/main/java/org/apache/commons/jexl3/internal/Debugger.java
index 28ef4b6..4a024e0 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Debugger.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Debugger.java
@@ -149,7 +149,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param jscript the expression
* @return true if the expression was a {@link Script} instance, false otherwise
*/
- public boolean debug(JexlExpression jscript) {
+ public boolean debug(final JexlExpression jscript) {
if (jscript instanceof Script) {
return debug(((Script) jscript).script);
} else {
@@ -162,7 +162,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param jscript the script
* @return true if the script was a {@link Script} instance, false otherwise
*/
- public boolean debug(JexlScript jscript) {
+ public boolean debug(final JexlScript jscript) {
if (jscript instanceof Script) {
return debug(((Script) jscript).script);
} else {
@@ -175,7 +175,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param node the node to debug
* @return true if the cause was located, false otherwise
*/
- public boolean debug(JexlNode node) {
+ public boolean debug(final JexlNode node) {
return debug(node, true);
}
@@ -185,7 +185,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param r whether we should actively find the root node of the debugged node
* @return true if the cause was located, false otherwise
*/
- public boolean debug(JexlNode node, boolean r) {
+ public boolean debug(final JexlNode node, final boolean r) {
start = 0;
end = 0;
indentLevel = 0;
@@ -218,7 +218,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @return the rebuilt expression
* @since 3.0
*/
- public String data(JexlNode node) {
+ public String data(final JexlNode node) {
start = 0;
end = 0;
indentLevel = 0;
@@ -250,7 +250,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* Sets the indentation level.
* @param level the number of spaces for indentation, none if less or equal to zero
*/
- public void setIndentation(int level) {
+ public void setIndentation(final int level) {
indentation(level);
}
@@ -259,7 +259,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param level the number of spaces for indentation, none if less or equal to zero
* @return this debugger instance
*/
- public Debugger indentation(int level) {
+ public Debugger indentation(final int level) {
indent = Math.max(level, 0);
indentLevel = 0;
return this;
@@ -270,7 +270,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param rdepth the maximum relative depth from the debugged node
* @return this debugger instance
*/
- public Debugger depth(int rdepth) {
+ public Debugger depth(final int rdepth) {
this.depth = rdepth;
return this;
}
@@ -281,7 +281,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param data visitor pattern argument
* @return visitor pattern value
*/
- protected Object accept(JexlNode node, Object data) {
+ protected Object accept(final JexlNode node, final Object data) {
if (depth <= 0) {
builder.append("...");
return data;
@@ -290,7 +290,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
start = builder.length();
}
depth -= 1;
- Object value = node.jjtAccept(this, data);
+ final Object value = node.jjtAccept(this, data);
depth += 1;
if (node == cause) {
end = builder.length();
@@ -304,8 +304,8 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param data visitor pattern argument
* @return visitor pattern value
*/
- protected Object acceptStatement(JexlNode child, Object data) {
- JexlNode parent = child.jjtGetParent();
+ protected Object acceptStatement(final JexlNode child, final Object data) {
+ final JexlNode parent = child.jjtGetParent();
if (indent > 0 && (parent instanceof ASTBlock || parent instanceof ASTJexlScript)) {
for (int i = 0; i < indentLevel; ++i) {
for(int s = 0; s < indent; ++s) {
@@ -314,7 +314,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
}
depth -= 1;
- Object value = accept(child, data);
+ final Object value = accept(child, data);
depth += 1;
// blocks, if, for & while dont need a ';' at end
if (!(child instanceof ASTJexlScript
@@ -341,7 +341,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param data visitor pattern argument
* @return visitor pattern value
*/
- protected Object check(JexlNode node, String image, Object data) {
+ protected Object check(final JexlNode node, final String image, final Object data) {
if (node == cause) {
start = builder.length();
}
@@ -365,8 +365,8 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param data visitor pattern argument
* @return visitor pattern value
*/
- protected Object infixChildren(JexlNode node, String infix, boolean paren, Object data) {
- int num = node.jjtGetNumChildren(); //child.jjtGetNumChildren() > 1;
+ protected Object infixChildren(final JexlNode node, final String infix, final boolean paren, final Object data) {
+ final int num = node.jjtGetNumChildren(); //child.jjtGetNumChildren() > 1;
if (paren) {
builder.append('(');
}
@@ -390,8 +390,8 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param data visitor pattern argument
* @return visitor pattern value
*/
- protected Object prefixChild(JexlNode node, String prefix, Object data) {
- boolean paren = node.jjtGetChild(0).jjtGetNumChildren() > 1;
+ protected Object prefixChild(final JexlNode node, final String prefix, final Object data) {
+ final boolean paren = node.jjtGetChild(0).jjtGetNumChildren() > 1;
builder.append(prefix);
if (paren) {
builder.append('(');
@@ -404,12 +404,12 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTAddNode node, Object data) {
+ protected Object visit(final ASTAddNode node, final Object data) {
return additiveNode(node, " + ", data);
}
@Override
- protected Object visit(ASTSubNode node, Object data) {
+ protected Object visit(final ASTSubNode node, final Object data) {
return additiveNode(node, " - ", data);
}
@@ -420,12 +420,12 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param data visitor pattern argument
* @return visitor pattern value
*/
- protected Object additiveNode(JexlNode node, String op, Object data) {
+ protected Object additiveNode(final JexlNode node, final String op, final Object data) {
// need parenthesis if not in operator precedence order
- boolean paren = node.jjtGetParent() instanceof ASTMulNode
+ final boolean paren = node.jjtGetParent() instanceof ASTMulNode
|| node.jjtGetParent() instanceof ASTDivNode
|| node.jjtGetParent() instanceof ASTModNode;
- int num = node.jjtGetNumChildren();
+ final int num = node.jjtGetNumChildren();
if (paren) {
builder.append('(');
}
@@ -441,13 +441,13 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTAndNode node, Object data) {
+ protected Object visit(final ASTAndNode node, final Object data) {
return infixChildren(node, " && ", false, data);
}
@Override
- protected Object visit(ASTArrayAccess node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTArrayAccess node, final Object data) {
+ final int num = node.jjtGetNumChildren();
for (int i = 0; i < num; ++i) {
builder.append('[');
accept(node.jjtGetChild(i), data);
@@ -457,14 +457,14 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTExtendedLiteral node, Object data) {
+ protected Object visit(final ASTExtendedLiteral node, final Object data) {
builder.append("...");
return data;
}
@Override
- protected Object visit(ASTArrayLiteral node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTArrayLiteral node, final Object data) {
+ final int num = node.jjtGetNumChildren();
builder.append("[ ");
if (num > 0) {
accept(node.jjtGetChild(0), data);
@@ -478,39 +478,39 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTRangeNode node, Object data) {
+ protected Object visit(final ASTRangeNode node, final Object data) {
return infixChildren(node, " .. ", false, data);
}
@Override
- protected Object visit(ASTAssignment node, Object data) {
+ protected Object visit(final ASTAssignment node, final Object data) {
return infixChildren(node, " = ", false, data);
}
@Override
- protected Object visit(ASTBitwiseAndNode node, Object data) {
+ protected Object visit(final ASTBitwiseAndNode node, final Object data) {
return infixChildren(node, " & ", false, data);
}
@Override
- protected Object visit(ASTBitwiseComplNode node, Object data) {
+ protected Object visit(final ASTBitwiseComplNode node, final Object data) {
return prefixChild(node, "~", data);
}
@Override
- protected Object visit(ASTBitwiseOrNode node, Object data) {
- boolean paren = node.jjtGetParent() instanceof ASTBitwiseAndNode;
+ protected Object visit(final ASTBitwiseOrNode node, final Object data) {
+ final boolean paren = node.jjtGetParent() instanceof ASTBitwiseAndNode;
return infixChildren(node, " | ", paren, data);
}
@Override
- protected Object visit(ASTBitwiseXorNode node, Object data) {
- boolean paren = node.jjtGetParent() instanceof ASTBitwiseAndNode;
+ protected Object visit(final ASTBitwiseXorNode node, final Object data) {
+ final boolean paren = node.jjtGetParent() instanceof ASTBitwiseAndNode;
return infixChildren(node, " ^ ", paren, data);
}
@Override
- protected Object visit(ASTBlock node, Object data) {
+ protected Object visit(final ASTBlock node, final Object data) {
builder.append('{');
if (indent > 0) {
indentLevel += 1;
@@ -518,9 +518,9 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
} else {
builder.append(' ');
}
- int num = node.jjtGetNumChildren();
+ final int num = node.jjtGetNumChildren();
for (int i = 0; i < num; ++i) {
- JexlNode child = node.jjtGetChild(i);
+ final JexlNode child = node.jjtGetChild(i);
acceptStatement(child, data);
}
if (indent > 0) {
@@ -536,64 +536,64 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTDivNode node, Object data) {
+ protected Object visit(final ASTDivNode node, final Object data) {
return infixChildren(node, " / ", false, data);
}
@Override
- protected Object visit(ASTEmptyFunction node, Object data) {
+ protected Object visit(final ASTEmptyFunction node, final Object data) {
builder.append("empty ");
accept(node.jjtGetChild(0), data);
return data;
}
@Override
- protected Object visit(ASTEQNode node, Object data) {
+ protected Object visit(final ASTEQNode node, final Object data) {
return infixChildren(node, " == ", false, data);
}
@Override
- protected Object visit(ASTERNode node, Object data) {
+ protected Object visit(final ASTERNode node, final Object data) {
return infixChildren(node, " =~ ", false, data);
}
@Override
- protected Object visit(ASTSWNode node, Object data) {
+ protected Object visit(final ASTSWNode node, final Object data) {
return infixChildren(node, " =^ ", false, data);
}
@Override
- protected Object visit(ASTEWNode node, Object data) {
+ protected Object visit(final ASTEWNode node, final Object data) {
return infixChildren(node, " =$ ", false, data);
}
@Override
- protected Object visit(ASTNSWNode node, Object data) {
+ protected Object visit(final ASTNSWNode node, final Object data) {
return infixChildren(node, " !^ ", false, data);
}
@Override
- protected Object visit(ASTNEWNode node, Object data) {
+ protected Object visit(final ASTNEWNode node, final Object data) {
return infixChildren(node, " !$ ", false, data);
}
@Override
- protected Object visit(ASTFalseNode node, Object data) {
+ protected Object visit(final ASTFalseNode node, final Object data) {
return check(node, "false", data);
}
@Override
- protected Object visit(ASTContinue node, Object data) {
+ protected Object visit(final ASTContinue node, final Object data) {
return check(node, "continue", data);
}
@Override
- protected Object visit(ASTBreak node, Object data) {
+ protected Object visit(final ASTBreak node, final Object data) {
return check(node, "break", data);
}
@Override
- protected Object visit(ASTForeachStatement node, Object data) {
+ protected Object visit(final ASTForeachStatement node, final Object data) {
builder.append("for(");
accept(node.jjtGetChild(0), data);
builder.append(" : ");
@@ -608,12 +608,12 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTGENode node, Object data) {
+ protected Object visit(final ASTGENode node, final Object data) {
return infixChildren(node, " >= ", false, data);
}
@Override
- protected Object visit(ASTGTNode node, Object data) {
+ protected Object visit(final ASTGTNode node, final Object data) {
return infixChildren(node, " > ", false, data);
}
@@ -628,28 +628,28 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param str the identifier
* @return true if needing quotes, false otherwise
*/
- protected boolean needQuotes(String str) {
+ protected boolean needQuotes(final String str) {
return QUOTED_IDENTIFIER.matcher(str).find()
|| "size".equals(str)
|| "empty".equals(str);
}
@Override
- protected Object visit(ASTIdentifier node, Object data) {
- String ns = node.getNamespace();
- String image = StringParser.escapeIdentifier(node.getName());
+ protected Object visit(final ASTIdentifier node, final Object data) {
+ final String ns = node.getNamespace();
+ final String image = StringParser.escapeIdentifier(node.getName());
if (ns == null) {
return check(node, image, data);
} else {
- String nsid = StringParser.escapeIdentifier(ns) + ":" + image;
+ final String nsid = StringParser.escapeIdentifier(ns) + ":" + image;
return check(node, nsid, data);
}
}
@Override
- protected Object visit(ASTIdentifierAccess node, Object data) {
+ protected Object visit(final ASTIdentifierAccess node, final Object data) {
builder.append(node.isSafe() ? "?." : ".");
- String image = node.getName();
+ final String image = node.getName();
if (node.isExpression()) {
builder.append('`');
builder.append(image.replace("`", "\\`"));
@@ -666,7 +666,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTIfStatement node, Object data) {
+ protected Object visit(final ASTIfStatement node, final Object data) {
final int numChildren = node.jjtGetNumChildren();
// if (...) ...
builder.append("if (");
@@ -689,7 +689,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTNumberLiteral node, Object data) {
+ protected Object visit(final ASTNumberLiteral node, final Object data) {
return check(node, node.toString(), data);
}
@@ -699,22 +699,22 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
* @param data the visitor argument
* @return the parameter name to use
*/
- protected String visitParameter(String p, Object data) {
+ protected String visitParameter(final String p, final Object data) {
return p;
}
@Override
- protected Object visit(ASTJexlScript node, Object data) {
+ protected Object visit(final ASTJexlScript node, Object data) {
// if lambda, produce parameters
if (node instanceof ASTJexlLambda) {
- JexlNode parent = node.jjtGetParent();
+ final JexlNode parent = node.jjtGetParent();
// use lambda syntax if not assigned
- boolean named = parent instanceof ASTAssignment;
+ final boolean named = parent instanceof ASTAssignment;
if (named) {
builder.append("function");
}
builder.append('(');
- String[] params = node.getParameters();
+ final String[] params = node.getParameters();
if (params != null && params.length > 0) {
builder.append(visitParameter(params[0], data));
for (int p = 1; p < params.length; ++p) {
@@ -731,12 +731,12 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
// we will need a block...
}
// no parameters or done with them
- int num = node.jjtGetNumChildren();
+ final int num = node.jjtGetNumChildren();
if (num == 1 && !(node instanceof ASTJexlLambda)) {
data = accept(node.jjtGetChild(0), data);
} else {
for (int i = 0; i < num; ++i) {
- JexlNode child = node.jjtGetChild(i);
+ final JexlNode child = node.jjtGetChild(i);
acceptStatement(child, data);
}
}
@@ -744,17 +744,17 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTLENode node, Object data) {
+ protected Object visit(final ASTLENode node, final Object data) {
return infixChildren(node, " <= ", false, data);
}
@Override
- protected Object visit(ASTLTNode node, Object data) {
+ protected Object visit(final ASTLTNode node, final Object data) {
return infixChildren(node, " < ", false, data);
}
@Override
- protected Object visit(ASTMapEntry node, Object data) {
+ protected Object visit(final ASTMapEntry node, final Object data) {
accept(node.jjtGetChild(0), data);
builder.append(" : ");
accept(node.jjtGetChild(1), data);
@@ -762,8 +762,8 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTSetLiteral node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTSetLiteral node, final Object data) {
+ final int num = node.jjtGetNumChildren();
builder.append("{ ");
if (num > 0) {
accept(node.jjtGetChild(0), data);
@@ -777,8 +777,8 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTMapLiteral node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTMapLiteral node, final Object data) {
+ final int num = node.jjtGetNumChildren();
builder.append("{ ");
if (num > 0) {
accept(node.jjtGetChild(0), data);
@@ -794,8 +794,8 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTConstructorNode node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTConstructorNode node, final Object data) {
+ final int num = node.jjtGetNumChildren();
builder.append("new(");
if (num > 0) {
accept(node.jjtGetChild(0), data);
@@ -809,8 +809,8 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTFunctionNode node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTFunctionNode node, final Object data) {
+ final int num = node.jjtGetNumChildren();
if (num == 3) {
accept(node.jjtGetChild(0), data);
builder.append(":");
@@ -824,8 +824,8 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTMethodNode node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTMethodNode node, final Object data) {
+ final int num = node.jjtGetNumChildren();
if (num == 2) {
accept(node.jjtGetChild(0), data);
accept(node.jjtGetChild(1), data);
@@ -834,8 +834,8 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTArguments node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTArguments node, final Object data) {
+ final int num = node.jjtGetNumChildren();
builder.append("(");
if (num > 0) {
accept(node.jjtGetChild(0), data);
@@ -849,48 +849,48 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTModNode node, Object data) {
+ protected Object visit(final ASTModNode node, final Object data) {
return infixChildren(node, " % ", false, data);
}
@Override
- protected Object visit(ASTMulNode node, Object data) {
+ protected Object visit(final ASTMulNode node, final Object data) {
return infixChildren(node, " * ", false, data);
}
@Override
- protected Object visit(ASTNENode node, Object data) {
+ protected Object visit(final ASTNENode node, final Object data) {
return infixChildren(node, " != ", false, data);
}
@Override
- protected Object visit(ASTNRNode node, Object data) {
+ protected Object visit(final ASTNRNode node, final Object data) {
return infixChildren(node, " !~ ", false, data);
}
@Override
- protected Object visit(ASTNotNode node, Object data) {
+ protected Object visit(final ASTNotNode node, final Object data) {
builder.append("!");
accept(node.jjtGetChild(0), data);
return data;
}
@Override
- protected Object visit(ASTNullLiteral node, Object data) {
+ protected Object visit(final ASTNullLiteral node, final Object data) {
check(node, "null", data);
return data;
}
@Override
- protected Object visit(ASTOrNode node, Object data) {
+ protected Object visit(final ASTOrNode node, final Object data) {
// need parenthesis if not in operator precedence order
- boolean paren = node.jjtGetParent() instanceof ASTAndNode;
+ final boolean paren = node.jjtGetParent() instanceof ASTAndNode;
return infixChildren(node, " || ", paren, data);
}
@Override
- protected Object visit(ASTReference node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTReference node, final Object data) {
+ final int num = node.jjtGetNumChildren();
for (int i = 0; i < num; ++i) {
accept(node.jjtGetChild(i), data);
}
@@ -898,12 +898,12 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTReferenceExpression node, Object data) {
- JexlNode first = node.jjtGetChild(0);
+ protected Object visit(final ASTReferenceExpression node, final Object data) {
+ final JexlNode first = node.jjtGetChild(0);
builder.append('(');
accept(first, data);
builder.append(')');
- int num = node.jjtGetNumChildren();
+ final int num = node.jjtGetNumChildren();
for (int i = 1; i < num; ++i) {
builder.append("[");
accept(node.jjtGetChild(i), data);
@@ -913,33 +913,33 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTReturnStatement node, Object data) {
+ protected Object visit(final ASTReturnStatement node, final Object data) {
builder.append("return ");
accept(node.jjtGetChild(0), data);
return data;
}
@Override
- protected Object visit(ASTSizeFunction node, Object data) {
+ protected Object visit(final ASTSizeFunction node, final Object data) {
builder.append("size ");
accept(node.jjtGetChild(0), data);
return data;
}
@Override
- protected Object visit(ASTStringLiteral node, Object data) {
- String img = node.getLiteral().replace("'", "\\'");
+ protected Object visit(final ASTStringLiteral node, final Object data) {
+ final String img = node.getLiteral().replace("'", "\\'");
return check(node, "'" + img + "'", data);
}
@Override
- protected Object visit(ASTRegexLiteral node, Object data) {
- String img = node.toString().replace("/", "\\/");
+ protected Object visit(final ASTRegexLiteral node, final Object data) {
+ final String img = node.toString().replace("/", "\\/");
return check(node, "~/" + img + "/", data);
}
@Override
- protected Object visit(ASTTernaryNode node, Object data) {
+ protected Object visit(final ASTTernaryNode node, final Object data) {
accept(node.jjtGetChild(0), data);
if (node.jjtGetNumChildren() > 2) {
builder.append("? ");
@@ -955,7 +955,7 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTNullpNode node, Object data) {
+ protected Object visit(final ASTNullpNode node, final Object data) {
accept(node.jjtGetChild(0), data);
builder.append("??");
accept(node.jjtGetChild(1), data);
@@ -963,30 +963,30 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTTrueNode node, Object data) {
+ protected Object visit(final ASTTrueNode node, final Object data) {
check(node, "true", data);
return data;
}
@Override
- protected Object visit(ASTUnaryMinusNode node, Object data) {
+ protected Object visit(final ASTUnaryMinusNode node, final Object data) {
return prefixChild(node, "-", data);
}
@Override
- protected Object visit(ASTUnaryPlusNode node, Object data) {
+ protected Object visit(final ASTUnaryPlusNode node, final Object data) {
return prefixChild(node, "+", data);
}
@Override
- protected Object visit(ASTVar node, Object data) {
+ protected Object visit(final ASTVar node, final Object data) {
builder.append("var ");
check(node, node.getName(), data);
return data;
}
@Override
- protected Object visit(ASTWhileStatement node, Object data) {
+ protected Object visit(final ASTWhileStatement node, final Object data) {
builder.append("while (");
accept(node.jjtGetChild(0), data);
builder.append(") ");
@@ -999,9 +999,9 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTDoWhileStatement node, Object data) {
+ protected Object visit(final ASTDoWhileStatement node, final Object data) {
builder.append("do ");
- int nc = node.jjtGetNumChildren();
+ final int nc = node.jjtGetNumChildren();
if (nc > 1) {
acceptStatement(node.jjtGetChild(0), data);
} else {
@@ -1014,54 +1014,54 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTSetAddNode node, Object data) {
+ protected Object visit(final ASTSetAddNode node, final Object data) {
return infixChildren(node, " += ", false, data);
}
@Override
- protected Object visit(ASTSetSubNode node, Object data) {
+ protected Object visit(final ASTSetSubNode node, final Object data) {
return infixChildren(node, " -= ", false, data);
}
@Override
- protected Object visit(ASTSetMultNode node, Object data) {
+ protected Object visit(final ASTSetMultNode node, final Object data) {
return infixChildren(node, " *= ", false, data);
}
@Override
- protected Object visit(ASTSetDivNode node, Object data) {
+ protected Object visit(final ASTSetDivNode node, final Object data) {
return infixChildren(node, " /= ", false, data);
}
@Override
- protected Object visit(ASTSetModNode node, Object data) {
+ protected Object visit(final ASTSetModNode node, final Object data) {
return infixChildren(node, " %= ", false, data);
}
@Override
- protected Object visit(ASTSetAndNode node, Object data) {
+ protected Object visit(final ASTSetAndNode node, final Object data) {
return infixChildren(node, " &= ", false, data);
}
@Override
- protected Object visit(ASTSetOrNode node, Object data) {
+ protected Object visit(final ASTSetOrNode node, final Object data) {
return infixChildren(node, " |= ", false, data);
}
@Override
- protected Object visit(ASTSetXorNode node, Object data) {
+ protected Object visit(final ASTSetXorNode node, final Object data) {
return infixChildren(node, " ^= ", false, data);
}
@Override
- protected Object visit(ASTJxltLiteral node, Object data) {
- String img = node.getLiteral().replace("`", "\\`");
+ protected Object visit(final ASTJxltLiteral node, final Object data) {
+ final String img = node.getLiteral().replace("`", "\\`");
return check(node, "`" + img + "`", data);
}
@Override
- protected Object visit(ASTAnnotation node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTAnnotation node, final Object data) {
+ final int num = node.jjtGetNumChildren();
builder.append('@');
builder.append(node.getName());
if (num > 0) {
@@ -1071,13 +1071,13 @@ public class Debugger extends ParserVisitor implements JexlInfo.Detail {
}
@Override
- protected Object visit(ASTAnnotatedStatement node, Object data) {
- int num = node.jjtGetNumChildren();
+ protected Object visit(final ASTAnnotatedStatement node, final Object data) {
+ final int num = node.jjtGetNumChildren();
for (int i = 0; i < num; ++i) {
if (i > 0) {// && child instanceof ASTBlock) {
builder.append(' ');
}
- JexlNode child = node.jjtGetChild(i);
+ final JexlNode child = node.jjtGetChild(i);
acceptStatement(child, data);
}
return data;
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 ec2e58b..7a2dd3c 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Engine.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Engine.java
@@ -181,7 +181,7 @@ public class Engine extends JexlEngine {
* Creates a JEXL engine using the provided {@link JexlBuilder}.
* @param conf the builder
*/
- public Engine(JexlBuilder conf) {
+ public Engine(final JexlBuilder conf) {
// options:
this.options = conf.options().copy();
this.strict = options.isStrict();
@@ -193,12 +193,12 @@ public class Engine extends JexlEngine {
this.collectMode = conf.collectMode();
this.stackOverflow = conf.stackOverflow() > 0? conf.stackOverflow() : Integer.MAX_VALUE;
// core properties:
- JexlUberspect uber = conf.uberspect() == null ? getUberspect(conf.logger(), conf.strategy()) : conf.uberspect();
- ClassLoader loader = conf.loader();
+ final JexlUberspect uber = conf.uberspect() == null ? getUberspect(conf.logger(), conf.strategy()) : conf.uberspect();
+ final ClassLoader loader = conf.loader();
if (loader != null) {
uber.setClassLoader(loader);
}
- JexlSandbox sandbox = conf.sandbox();
+ final JexlSandbox sandbox = conf.sandbox();
if (sandbox == null) {
this.uberspect = uber;
} else {
@@ -211,7 +211,7 @@ public class Engine extends JexlEngine {
options.setStrictArithmetic(arithmetic.isStrict());
this.functions = conf.namespaces() == null ? Collections.<String, Object>emptyMap() : conf.namespaces();
// parsing & features:
- JexlFeatures features = conf.features() == null? DEFAULT_FEATURES : conf.features();
+ final JexlFeatures features = conf.features() == null? DEFAULT_FEATURES : conf.features();
this.expressionFeatures = new JexlFeatures(features).script(false);
this.scriptFeatures = new JexlFeatures(features).script(true);
this.charset = conf.charset();
@@ -234,7 +234,7 @@ public class Engine extends JexlEngine {
* @param strategy the property resolver strategy
* @return Uberspect the default uberspector instance.
*/
- public static Uberspect getUberspect(Log logger, JexlUberspect.ResolverStrategy strategy) {
+ public static Uberspect getUberspect(final Log logger, final JexlUberspect.ResolverStrategy strategy) {
if ((logger == null || logger.equals(LogFactory.getLog(JexlEngine.class)))
&& (strategy == null || strategy == JexlUberspect.JEXL_STRATEGY)) {
return UberspectHolder.UBERSPECT;
@@ -273,21 +273,21 @@ public class Engine extends JexlEngine {
}
@Override
- public void setClassLoader(ClassLoader loader) {
+ public void setClassLoader(final ClassLoader loader) {
jxlt = null;
uberspect.setClassLoader(loader);
if (functions != null) {
- List<String> names = new ArrayList<String>(functions.keySet());
- for(String name : names) {
- Object functor = functions.get(name);
+ final List<String> names = new ArrayList<String>(functions.keySet());
+ for(final String name : names) {
+ final Object functor = functions.get(name);
if (functor instanceof Class<?>) {
- Class<?> fclass = ((Class<?>) functor);
+ final Class<?> fclass = ((Class<?>) functor);
try {
- Class<?> nclass = loader.loadClass(fclass.getName());
+ final Class<?> nclass = loader.loadClass(fclass.getName());
if (nclass != fclass) {
functions.put(name, nclass);
}
- } catch (ClassNotFoundException xany) {
+ } catch (final ClassNotFoundException xany) {
functions.put(name, fclass.getName());
}
}
@@ -310,7 +310,7 @@ public class Engine extends JexlEngine {
* @param <T> the option type
* @return conf or def
*/
- private static <T> T option(T conf, T def) {
+ private static <T> T option(final T conf, final T def) {
return conf == null? def : conf;
}
@@ -322,22 +322,22 @@ public class Engine extends JexlEngine {
* @param context the context
* @return the options if any
*/
- protected JexlOptions options(JexlContext context) {
+ protected JexlOptions options(final JexlContext context) {
// Make a copy of the handled options if any
if (context instanceof JexlContext.OptionsHandle) {
- JexlOptions jexlo = ((JexlContext.OptionsHandle) context).getEngineOptions();
+ final JexlOptions jexlo = ((JexlContext.OptionsHandle) context).getEngineOptions();
if (jexlo != null) {
return jexlo.isSharedInstance()? jexlo : jexlo.copy();
}
} else if (context instanceof JexlEngine.Options) {
// This condition and block for compatibility between 3.1 and 3.2
- JexlOptions jexlo = options.copy();
- JexlEngine jexl = this;
- JexlEngine.Options opts = (JexlEngine.Options) context;
+ final JexlOptions jexlo = options.copy();
+ final JexlEngine jexl = this;
+ final JexlEngine.Options opts = (JexlEngine.Options) context;
jexlo.setCancellable(option(opts.isCancellable(), jexl.isCancellable()));
jexlo.setSilent(option(opts.isSilent(), jexl.isSilent()));
jexlo.setStrict(option(opts.isStrict(), jexl.isStrict()));
- JexlArithmetic jexla = jexl.getArithmetic();
+ final JexlArithmetic jexla = jexl.getArithmetic();
jexlo.setStrictArithmetic(option(opts.isStrictArithmetic(), jexla.isStrict()));
jexlo.setMathContext(opts.getArithmeticMathContext());
jexlo.setMathScale(opts.getArithmeticMathScale());
@@ -353,7 +353,7 @@ public class Engine extends JexlEngine {
* @param context the context
* @return the options
*/
- protected JexlOptions options(ASTJexlScript script, JexlContext context) {
+ protected JexlOptions options(final ASTJexlScript script, final JexlContext context) {
final JexlOptions opts = options(context);
if (opts != options) {
// when feature lexical, try hard to run lexical
@@ -378,33 +378,33 @@ public class Engine extends JexlEngine {
* @param context the context
* @param opts the options
*/
- protected void processPragmas(ASTJexlScript script, JexlContext context, JexlOptions opts) {
- Map<String, Object> pragmas = script.getPragmas();
+ protected void processPragmas(final ASTJexlScript script, final JexlContext context, final JexlOptions opts) {
+ final Map<String, Object> pragmas = script.getPragmas();
if (pragmas != null && !pragmas.isEmpty()) {
- JexlContext.PragmaProcessor processor =
+ final JexlContext.PragmaProcessor processor =
context instanceof JexlContext.PragmaProcessor
? (JexlContext.PragmaProcessor) context
: null;
Map<String, Object> ns = null;
- for(Map.Entry<String, Object> pragma : pragmas.entrySet()) {
- String key = pragma.getKey();
- Object value = pragma.getValue();
+ for(final Map.Entry<String, Object> pragma : pragmas.entrySet()) {
+ final String key = pragma.getKey();
+ final Object value = pragma.getValue();
if (value instanceof String) {
if (PRAGMA_OPTIONS.equals(key)) {
// jexl.options
- String[] vs = value.toString().split(" ");
+ final String[] vs = value.toString().split(" ");
opts.setFlags(vs);
} else if (key.startsWith(PRAGMA_JEXLNS)) {
// jexl.namespace.***
- String nsname = key.substring(PRAGMA_JEXLNS.length());
+ final String nsname = key.substring(PRAGMA_JEXLNS.length());
if (nsname != null && !nsname.isEmpty()) {
if (ns == null) {
ns = new HashMap<>(functions);
}
- String nsclass = value.toString();
+ final String nsclass = value.toString();
try {
ns.put(nsname, uberspect.getClassLoader().loadClass(nsclass));
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
ns.put(nsname, nsclass);
}
}
@@ -425,7 +425,7 @@ public class Engine extends JexlEngine {
* @param opts the options to set
* @return the options
*/
- public JexlOptions optionsSet(JexlOptions opts) {
+ public JexlOptions optionsSet(final JexlOptions opts) {
if (opts != null) {
opts.set(options);
}
@@ -433,7 +433,7 @@ public class Engine extends JexlEngine {
}
@Override
- public TemplateEngine createJxltEngine(boolean noScript, int cacheSize, char immediate, char deferred) {
+ public TemplateEngine createJxltEngine(final boolean noScript, final int cacheSize, final char immediate, final char deferred) {
return new TemplateEngine(this, noScript, cacheSize, immediate, deferred);
}
@@ -451,25 +451,25 @@ public class Engine extends JexlEngine {
* @param opts the evaluation options
* @return an Interpreter
*/
- protected Interpreter createInterpreter(JexlContext context, Frame frame, JexlOptions opts) {
+ protected Interpreter createInterpreter(final JexlContext context, final Frame frame, final JexlOptions opts) {
return new Interpreter(this, opts, context, frame);
}
@Override
- public Script createExpression(JexlInfo info, String expression) {
+ public Script createExpression(final JexlInfo info, final String expression) {
return createScript(expressionFeatures, info, expression, null);
}
@Override
- public Script createScript(JexlFeatures features, JexlInfo info, String scriptText, String[] names) {
+ public Script createScript(final JexlFeatures features, final JexlInfo info, final String scriptText, final String[] names) {
if (scriptText == null) {
throw new NullPointerException("source is null");
}
- String source = trimSource(scriptText);
- Scope scope = names == null || names.length == 0? null : new Scope(null, names);
- JexlFeatures ftrs = features == null? scriptFeatures : features;
- ASTJexlScript tree = parse(info, ftrs, source, scope);
+ final String source = trimSource(scriptText);
+ final Scope scope = names == null || names.length == 0? null : new Scope(null, names);
+ final JexlFeatures ftrs = features == null? scriptFeatures : features;
+ final ASTJexlScript tree = parse(info, ftrs, source, scope);
return new Script(this, source, tree);
}
@@ -486,12 +486,12 @@ public class Engine extends JexlEngine {
.register(true);
@Override
- public Object getProperty(Object bean, String expr) {
+ public Object getProperty(final Object bean, final String expr) {
return getProperty(null, bean, expr);
}
@Override
- public Object getProperty(JexlContext context, Object bean, String expr) {
+ public Object getProperty(JexlContext context, final Object bean, final String expr) {
if (context == null) {
context = EMPTY_CONTEXT;
}
@@ -505,7 +505,7 @@ public class Engine extends JexlEngine {
final Frame frame = script.createFrame(bean);
final Interpreter interpreter = createInterpreter(context, frame, options);
return interpreter.visitLexicalNode(node, null);
- } catch (JexlException xjexl) {
+ } catch (final JexlException xjexl) {
if (silent) {
logger.warn(xjexl.getMessage(), xjexl.getCause());
return null;
@@ -515,12 +515,12 @@ public class Engine extends JexlEngine {
}
@Override
- public void setProperty(Object bean, String expr, Object value) {
+ public void setProperty(final Object bean, final String expr, final Object value) {
setProperty(null, bean, expr, value);
}
@Override
- public void setProperty(JexlContext context, Object bean, String expr, Object value) {
+ public void setProperty(JexlContext context, final Object bean, final String expr, final Object value) {
if (context == null) {
context = EMPTY_CONTEXT;
}
@@ -534,7 +534,7 @@ public class Engine extends JexlEngine {
final Frame frame = script.createFrame(bean, value);
final Interpreter interpreter = createInterpreter(context, frame, options);
interpreter.visitLexicalNode(node, null);
- } catch (JexlException xjexl) {
+ } catch (final JexlException xjexl) {
if (silent) {
logger.warn(xjexl.getMessage(), xjexl.getCause());
return;
@@ -544,7 +544,7 @@ public class Engine extends JexlEngine {
}
@Override
- public Object invokeMethod(Object obj, String meth, Object... args) {
+ public Object invokeMethod(final Object obj, final String meth, final Object... args) {
JexlException xjexl = null;
Object result = null;
final JexlInfo info = debug ? createInfo() : null;
@@ -558,9 +558,9 @@ public class Engine extends JexlEngine {
} else {
xjexl = new JexlException.Method(info, meth, args);
}
- } catch (JexlException xany) {
+ } catch (final JexlException xany) {
xjexl = xany;
- } catch (Exception xany) {
+ } catch (final Exception xany) {
xjexl = new JexlException.Method(info, meth, args, xany);
}
if (xjexl != null) {
@@ -575,12 +575,12 @@ public class Engine extends JexlEngine {
}
@Override
- public <T> T newInstance(Class<? extends T> clazz, Object... args) {
+ public <T> T newInstance(final Class<? extends T> clazz, final Object... args) {
return clazz.cast(doCreateInstance(clazz, args));
}
@Override
- public Object newInstance(String clazz, Object... args) {
+ public Object newInstance(final String clazz, final Object... args) {
return doCreateInstance(clazz, args);
}
@@ -591,7 +591,7 @@ public class Engine extends JexlEngine {
* @param args the constructor arguments
* @return the created object instance or null on failure when silent
*/
- protected Object doCreateInstance(Object clazz, Object... args) {
+ protected Object doCreateInstance(final Object clazz, final Object... args) {
JexlException xjexl = null;
Object result = null;
final JexlInfo info = debug ? createInfo() : null;
@@ -605,9 +605,9 @@ public class Engine extends JexlEngine {
} else {
xjexl = new JexlException.Method(info, clazz.toString(), args);
}
- } catch (JexlException xany) {
+ } catch (final JexlException xany) {
xjexl = xany;
- } catch (Exception xany) {
+ } catch (final Exception xany) {
xjexl = new JexlException.Method(info, clazz.toString(), args, xany);
}
if (xjexl != null) {
@@ -625,8 +625,8 @@ public class Engine extends JexlEngine {
* @param tls the context or null
* @return the previous thread local context
*/
- protected JexlContext.ThreadLocal putThreadLocal(JexlContext.ThreadLocal tls) {
- JexlContext.ThreadLocal local = CONTEXT.get();
+ protected JexlContext.ThreadLocal putThreadLocal(final JexlContext.ThreadLocal tls) {
+ final JexlContext.ThreadLocal local = CONTEXT.get();
CONTEXT.set(tls);
return local;
}
@@ -636,8 +636,8 @@ public class Engine extends JexlEngine {
* @param jexl the engine or null
* @return the previous thread local engine
*/
- protected JexlEngine putThreadEngine(JexlEngine jexl) {
- JexlEngine pjexl = ENGINE.get();
+ protected JexlEngine putThreadEngine(final JexlEngine jexl) {
+ final JexlEngine pjexl = ENGINE.get();
ENGINE.set(jexl);
return pjexl;
}
@@ -650,8 +650,8 @@ public class Engine extends JexlEngine {
* @return the set of variables, each as a list of strings (ant-ish variables use more than 1 string)
* or the empty set if no variables are used
*/
- protected Set<List<String>> getVariables(ASTJexlScript script) {
- VarCollector collector = varCollector();
+ protected Set<List<String>> getVariables(final ASTJexlScript script) {
+ final VarCollector collector = varCollector();
getVariables(script, script, collector);
return collector.collected();
}
@@ -691,7 +691,7 @@ public class Engine extends JexlEngine {
* Constructor.
* @param constaa whether constant array-access is considered equivalent to dot-access
*/
- protected VarCollector(int constaa) {
+ protected VarCollector(final int constaa) {
mode = constaa;
}
@@ -699,7 +699,7 @@ public class Engine extends JexlEngine {
* Starts/stops a variable collect.
* @param node starts if not null, stop if null
*/
- public void collect(JexlNode node) {
+ public void collect(final JexlNode node) {
if (!ref.isEmpty()) {
refs.add(ref);
ref = new ArrayList<String>();
@@ -718,7 +718,7 @@ public class Engine extends JexlEngine {
* Adds a 'segment' to the variable being collected.
* @param name the name
*/
- public void add(String name) {
+ public void add(final String name) {
ref.add(name);
}
@@ -736,16 +736,16 @@ public class Engine extends JexlEngine {
* @param node the node
* @param collector the variable collector
*/
- protected void getVariables(final ASTJexlScript script, JexlNode node, VarCollector collector) {
+ protected void getVariables(final ASTJexlScript script, final JexlNode node, final VarCollector collector) {
if (node instanceof ASTIdentifier) {
- JexlNode parent = node.jjtGetParent();
+ final JexlNode parent = node.jjtGetParent();
if (parent instanceof ASTMethodNode || parent instanceof ASTFunctionNode) {
// skip identifiers for methods and functions
collector.collect(null);
return;
}
- ASTIdentifier identifier = (ASTIdentifier) node;
- int symbol = identifier.getSymbol();
+ final ASTIdentifier identifier = (ASTIdentifier) node;
+ final int symbol = identifier.getSymbol();
// symbols that are captured are considered "global" variables
if (symbol >= 0 && script != null && !script.isCapturedSymbol(symbol)) {
collector.collect(null);
@@ -755,7 +755,7 @@ public class Engine extends JexlEngine {
collector.add(identifier.getName());
}
} else if (node instanceof ASTIdentifierAccess) {
- JexlNode parent = node.jjtGetParent();
+ final JexlNode parent = node.jjtGetParent();
if (parent instanceof ASTMethodNode || parent instanceof ASTFunctionNode) {
// skip identifiers for methods and functions
collector.collect(null);
@@ -766,17 +766,17 @@ public class Engine extends JexlEngine {
collector.add(((ASTIdentifierAccess) node).getName());
}
} else if (node instanceof ASTArrayAccess && collector.mode > 0) {
- int num = node.jjtGetNumChildren();
+ final int num = node.jjtGetNumChildren();
// collect only if array access is const and follows an identifier
boolean collecting = collector.isCollecting();
for (int i = 0; i < num; ++i) {
- JexlNode child = node.jjtGetChild(i);
+ final JexlNode child = node.jjtGetChild(i);
if (collecting && child.isConstant()) {
// collect all constants or only string and number literals
- boolean collect = collector.mode > 1
+ final boolean collect = collector.mode > 1
|| (child instanceof ASTStringLiteral || child instanceof ASTNumberLiteral);
if (collect) {
- String image = child.toString();
+ final String image = child.toString();
collector.add(image);
}
} else {
@@ -787,7 +787,7 @@ public class Engine extends JexlEngine {
}
}
} else {
- int num = node.jjtGetNumChildren();
+ final int num = node.jjtGetNumChildren();
for (int i = 0; i < num; ++i) {
getVariables(script, node.jjtGetChild(i), collector);
}
@@ -801,7 +801,7 @@ public class Engine extends JexlEngine {
* @return the parameters which may be empty (but not null) if no parameters were defined
* @since 3.0
*/
- protected String[] getParameters(JexlScript script) {
+ protected String[] getParameters(final JexlScript script) {
return script.getParameters();
}
@@ -811,7 +811,7 @@ public class Engine extends JexlEngine {
* @return the local variables array which may be empty (but not null) if no local variables were defined
* @since 3.0
*/
- protected String[] getLocalVariables(JexlScript script) {
+ protected String[] getLocalVariables(final JexlScript script) {
return script.getLocalVariables();
}
@@ -825,7 +825,7 @@ public class Engine extends JexlEngine {
* @return the parsed tree
* @throws JexlException if any error occurred during parsing
*/
- protected ASTJexlScript parse(JexlInfo info, boolean expr, String src, Scope scope) {
+ protected ASTJexlScript parse(final JexlInfo info, final boolean expr, final String src, final Scope scope) {
return parse(info, expr? this.expressionFeatures : this.scriptFeatures, src, scope);
}
@@ -839,7 +839,7 @@ public class Engine extends JexlEngine {
* @return the parsed tree
* @throws JexlException if any error occurred during parsing
*/
- protected ASTJexlScript parse(JexlInfo info, JexlFeatures parsingf, String src, Scope scope) {
+ protected ASTJexlScript parse(final JexlInfo info, final JexlFeatures parsingf, final String src, final Scope scope) {
final boolean cached = src.length() < cacheThreshold && cache != null;
final JexlFeatures features = parsingf != null? parsingf : DEFAULT_FEATURES;
final Source source = cached? new Source(features, src) : null;
@@ -847,7 +847,7 @@ public class Engine extends JexlEngine {
if (source != null) {
script = cache.get(source);
if (script != null) {
- Scope f = script.getScope();
+ final Scope f = script.getScope();
if ((f == null && scope == null) || (f != null && f.equals(scope))) {
return script;
}
@@ -865,7 +865,7 @@ public class Engine extends JexlEngine {
}
} else {
// ...otherwise parser was in use, create a new temporary one
- Parser lparser = new Parser(new StringReader(";"));
+ final Parser lparser = new Parser(new StringReader(";"));
script = lparser.parse(ninfo, features, src, scope);
}
if (source != null) {
@@ -879,7 +879,7 @@ public class Engine extends JexlEngine {
* @param str expression to clean
* @return trimmed expression ending in a semi-colon
*/
- protected String trimSource(CharSequence str) {
+ protected String trimSource(final CharSequence str) {
if (str != null) {
int start = 0;
int end = str.length();
diff --git a/src/main/java/org/apache/commons/jexl3/internal/Frame.java b/src/main/java/org/apache/commons/jexl3/internal/Frame.java
index 9fe9ac8..3dfbe4d 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Frame.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Frame.java
@@ -36,7 +36,7 @@ public final class Frame {
* @param r the stack frame
* @param c the number of curried parameters
*/
- public Frame(Scope s, Object[] r, int c) {
+ public Frame(final Scope s, final Object[] r, final int c) {
scope = s;
stack = r;
curried = c;
@@ -64,7 +64,7 @@ public final class Frame {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
@@ -80,7 +80,7 @@ public final class Frame {
* @param s the offset in this frame
* @return the stacked value
*/
- Object get(int s) {
+ Object get(final int s) {
return stack[s];
}
@@ -89,7 +89,7 @@ public final class Frame {
* @param s the offset in this frame
* @return true if this symbol has been assigned a value, false otherwise
*/
- boolean has(int s) {
+ boolean has(final int s) {
return s >= 0 && s < stack.length && stack[s] != Scope.UNDECLARED;
}
@@ -98,7 +98,7 @@ public final class Frame {
* @param r the offset in this frame
* @param value the value to set in this frame
*/
- void set(int r, Object value) {
+ void set(final int r, final Object value) {
stack[r] = value;
}
@@ -107,10 +107,10 @@ public final class Frame {
* @param values the values
* @return this frame
*/
- Frame assign(Object... values) {
+ Frame assign(final Object... values) {
if (stack != null) {
- int nparm = scope.getArgCount();
- Object[] copy = stack.clone();
+ final int nparm = scope.getArgCount();
+ final Object[] copy = stack.clone();
int ncopy = 0;
if (values != null && values.length > 0) {
ncopy = Math.min(nparm - curried, Math.min(nparm, values.length));
diff --git a/src/main/java/org/apache/commons/jexl3/internal/IntegerRange.java b/src/main/java/org/apache/commons/jexl3/internal/IntegerRange.java
index 29dbbff..e04bd66 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/IntegerRange.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/IntegerRange.java
@@ -36,7 +36,7 @@ public abstract class IntegerRange implements Collection<Integer> {
* @param to the higher inclusive boundary
* @return a range
*/
- public static IntegerRange create(int from, int to) {
+ public static IntegerRange create(final int from, final int to) {
if (from <= to) {
return new IntegerRange.Ascending(from, to);
} else {
@@ -48,7 +48,7 @@ public abstract class IntegerRange implements Collection<Integer> {
* @param from the lower inclusive boundary
* @param to the higher inclusive boundary
*/
- public IntegerRange(int from, int to) {
+ public IntegerRange(final int from, final int to) {
min = from;
max = to;
}
@@ -81,7 +81,7 @@ public abstract class IntegerRange implements Collection<Integer> {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
@@ -112,9 +112,9 @@ public abstract class IntegerRange implements Collection<Integer> {
}
@Override
- public boolean contains(Object o) {
+ public boolean contains(final Object o) {
if (o instanceof Number) {
- long v = ((Number) o).intValue();
+ final long v = ((Number) o).intValue();
return min <= v && v <= max;
} else {
return false;
@@ -124,7 +124,7 @@ public abstract class IntegerRange implements Collection<Integer> {
@Override
public Object[] toArray() {
final int size = size();
- Object[] array = new Object[size];
+ final Object[] array = new Object[size];
for(int a = 0; a < size; ++a) {
array[a] = min + a;
}
@@ -133,7 +133,7 @@ public abstract class IntegerRange implements Collection<Integer> {
@Override
@SuppressWarnings("unchecked")
- public <T> T[] toArray(T[] array) {
+ public <T> T[] toArray(final T[] array) {
final Class<?> ct = array.getClass().getComponentType();
final int length = size();
T[] copy = array;
@@ -153,8 +153,8 @@ public abstract class IntegerRange implements Collection<Integer> {
}
@Override
- public boolean containsAll(Collection<?> c) {
- for(Object cc : c) {
+ public boolean containsAll(final Collection<?> c) {
+ for(final Object cc : c) {
if (!contains(cc)) {
return false;
}
@@ -163,27 +163,27 @@ public abstract class IntegerRange implements Collection<Integer> {
}
@Override
- public boolean add(Integer e) {
+ public boolean add(final Integer e) {
throw new UnsupportedOperationException();
}
@Override
- public boolean remove(Object o) {
+ public boolean remove(final Object o) {
throw new UnsupportedOperationException();
}
@Override
- public boolean addAll(Collection<? extends Integer> c) {
+ public boolean addAll(final Collection<? extends Integer> c) {
throw new UnsupportedOperationException();
}
@Override
- public boolean removeAll(Collection<?> c) {
+ public boolean removeAll(final Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
- public boolean retainAll(Collection<?> c) {
+ public boolean retainAll(final Collection<?> c) {
throw new UnsupportedOperationException();
}
@@ -201,7 +201,7 @@ public abstract class IntegerRange implements Collection<Integer> {
* @param from lower boundary
* @param to upper boundary
*/
- protected Ascending(int from, int to) {
+ protected Ascending(final int from, final int to) {
super(from, to);
}
@@ -220,7 +220,7 @@ public abstract class IntegerRange implements Collection<Integer> {
* @param from upper boundary
* @param to lower boundary
*/
- protected Descending(int from, int to) {
+ protected Descending(final int from, final int to) {
super(from, to);
}
@@ -246,7 +246,7 @@ class AscIntegerIterator implements Iterator<Integer> {
* @param l low boundary
* @param h high boundary
*/
- public AscIntegerIterator(int l, int h) {
+ public AscIntegerIterator(final int l, final int h) {
min = l;
max = h;
cursor = min;
@@ -286,7 +286,7 @@ class DescIntegerIterator implements Iterator<Integer> {
* @param l low boundary
* @param h high boundary
*/
- public DescIntegerIterator(int l, int h) {
+ public DescIntegerIterator(final int l, final int h) {
min = l;
max = h;
cursor = max;
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 5b31987..d37120f 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
@@ -137,7 +137,7 @@ public class Interpreter extends InterpreterBase {
* @param opts the evaluation options, flags modifying evaluation behavior
* @param eFrame the evaluation frame, arguments and local variables
*/
- protected Interpreter(Engine engine, JexlOptions opts, JexlContext aContext, Frame eFrame) {
+ protected Interpreter(final Engine engine, final JexlOptions opts, final JexlContext aContext, final Frame eFrame) {
super(engine, opts, aContext);
this.frame = eFrame;
}
@@ -147,7 +147,7 @@ public class Interpreter extends InterpreterBase {
* @param ii the interpreter to copy
* @param jexla the arithmetic instance to use (or null)
*/
- protected Interpreter(Interpreter ii, JexlArithmetic jexla) {
+ protected Interpreter(final Interpreter ii, final JexlArithmetic jexla) {
super(ii, jexla);
frame = ii.frame;
block = ii.block != null? new LexicalFrame(ii.block) : null;
@@ -158,8 +158,8 @@ public class Interpreter extends InterpreterBase {
* @param inter the interpreter or null
* @return the previous thread local interpreter
*/
- protected Interpreter putThreadInterpreter(Interpreter inter) {
- Interpreter pinter = INTER.get();
+ protected Interpreter putThreadInterpreter(final Interpreter inter) {
+ final Interpreter pinter = INTER.get();
INTER.set(inter);
return pinter;
}
@@ -173,7 +173,7 @@ public class Interpreter extends InterpreterBase {
* @return the result of the interpretation.
* @throws JexlException if any error occurs during interpretation.
*/
- public Object interpret(JexlNode node) {
+ public Object interpret(final JexlNode node) {
JexlContext.ThreadLocal tcontext = null;
JexlEngine tjexl = null;
Interpreter tinter = null;
@@ -191,23 +191,23 @@ public class Interpreter extends InterpreterBase {
}
cancelCheck(node);
return node.jjtAccept(this, null);
- } catch(StackOverflowError xstack) {
- JexlException xjexl = new JexlException.StackOverflow(node.jexlInfo(), "jvm", xstack);
+ } catch(final StackOverflowError xstack) {
+ final JexlException xjexl = new JexlException.StackOverflow(node.jexlInfo(), "jvm", xstack);
if (!isSilent()) {
throw xjexl.clean();
}
if (logger.isWarnEnabled()) {
logger.warn(xjexl.getMessage(), xjexl.getCause());
}
- } catch (JexlException.Return xreturn) {
+ } catch (final JexlException.Return xreturn) {
return xreturn.getValue();
- } catch (JexlException.Cancel xcancel) {
+ } catch (final JexlException.Cancel xcancel) {
// cancelled |= Thread.interrupted();
cancelled.weakCompareAndSet(false, Thread.interrupted());
if (isCancellable()) {
throw xcancel.clean();
}
- } catch (JexlException xjexl) {
+ } catch (final JexlException xjexl) {
if (!isSilent()) {
throw xjexl.clean();
}
@@ -217,7 +217,7 @@ public class Interpreter extends InterpreterBase {
} finally {
synchronized(this) {
if (functors != null) {
- for (Object functor : functors.values()) {
+ for (final Object functor : functors.values()) {
closeIfSupported(functor);
}
functors.clear();
@@ -243,7 +243,7 @@ public class Interpreter extends InterpreterBase {
* @param attribute the attribute of the object, e.g. an index (1, 0, 2) or key for a map
* @return the attribute value
*/
- public Object getAttribute(Object object, Object attribute) {
+ public Object getAttribute(final Object object, final Object attribute) {
return getAttribute(object, attribute, null);
}
/**
@@ -253,265 +253,265 @@ public class Interpreter extends InterpreterBase {
* @param attribute the attribute of the object, e.g. an index (1, 0, 2) or key for a map
* @param value the value to assign to the object's attribute
*/
- public void setAttribute(Object object, Object attribute, Object value) {
+ public void setAttribute(final Object object, final Object attribute, final Object value) {
setAttribute(object, attribute, value, null);
}
@Override
- protected Object visit(ASTAddNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTAddNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.ADD, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.ADD, left, right);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.add(left, right);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "+ error", xrt);
}
}
@Override
- protected Object visit(ASTSubNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTSubNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.SUBTRACT, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.SUBTRACT, left, right);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.subtract(left, right);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "- error", xrt);
}
}
@Override
- protected Object visit(ASTMulNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTMulNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.MULTIPLY, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.MULTIPLY, left, right);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.multiply(left, right);
- } catch (ArithmeticException xrt) {
- JexlNode xnode = findNullOperand(xrt, node, left, right);
+ } catch (final ArithmeticException xrt) {
+ final JexlNode xnode = findNullOperand(xrt, node, left, right);
throw new JexlException(xnode, "* error", xrt);
}
}
@Override
- protected Object visit(ASTDivNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTDivNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.DIVIDE, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.DIVIDE, left, right);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.divide(left, right);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
if (!arithmetic.isStrict()) {
return 0.0d;
}
- JexlNode xnode = findNullOperand(xrt, node, left, right);
+ final JexlNode xnode = findNullOperand(xrt, node, left, right);
throw new JexlException(xnode, "/ error", xrt);
}
}
@Override
- protected Object visit(ASTModNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTModNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.MOD, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.MOD, left, right);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.mod(left, right);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
if (!arithmetic.isStrict()) {
return 0.0d;
}
- JexlNode xnode = findNullOperand(xrt, node, left, right);
+ final JexlNode xnode = findNullOperand(xrt, node, left, right);
throw new JexlException(xnode, "% error", xrt);
}
}
@Override
- protected Object visit(ASTBitwiseAndNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTBitwiseAndNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.AND, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.AND, left, right);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.and(left, right);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "& error", xrt);
}
}
@Override
- protected Object visit(ASTBitwiseOrNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTBitwiseOrNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.OR, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.OR, left, right);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.or(left, right);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "| error", xrt);
}
}
@Override
- protected Object visit(ASTBitwiseXorNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTBitwiseXorNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.XOR, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.XOR, left, right);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.xor(left, right);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "^ error", xrt);
}
}
@Override
- protected Object visit(ASTEQNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTEQNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.EQ, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.EQ, left, right);
return result != JexlEngine.TRY_FAILED
? result
: arithmetic.equals(left, right) ? Boolean.TRUE : Boolean.FALSE;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "== error", xrt);
}
}
@Override
- protected Object visit(ASTNENode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTNENode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.EQ, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.EQ, left, right);
return result != JexlEngine.TRY_FAILED
? arithmetic.toBoolean(result) ? Boolean.FALSE : Boolean.TRUE
: arithmetic.equals(left, right) ? Boolean.FALSE : Boolean.TRUE;
- } catch (ArithmeticException xrt) {
- JexlNode xnode = findNullOperand(xrt, node, left, right);
+ } catch (final ArithmeticException xrt) {
+ final JexlNode xnode = findNullOperand(xrt, node, left, right);
throw new JexlException(xnode, "!= error", xrt);
}
}
@Override
- protected Object visit(ASTGENode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTGENode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.GTE, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.GTE, left, right);
return result != JexlEngine.TRY_FAILED
? result
: arithmetic.greaterThanOrEqual(left, right) ? Boolean.TRUE : Boolean.FALSE;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, ">= error", xrt);
}
}
@Override
- protected Object visit(ASTGTNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTGTNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.GT, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.GT, left, right);
return result != JexlEngine.TRY_FAILED
? result
: arithmetic.greaterThan(left, right) ? Boolean.TRUE : Boolean.FALSE;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "> error", xrt);
}
}
@Override
- protected Object visit(ASTLENode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTLENode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.LTE, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.LTE, left, right);
return result != JexlEngine.TRY_FAILED
? result
: arithmetic.lessThanOrEqual(left, right) ? Boolean.TRUE : Boolean.FALSE;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "<= error", xrt);
}
}
@Override
- protected Object visit(ASTLTNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTLTNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.LT, left, right);
+ final Object result = operators.tryOverload(node, JexlOperator.LT, left, right);
return result != JexlEngine.TRY_FAILED
? result
: arithmetic.lessThan(left, right) ? Boolean.TRUE : Boolean.FALSE;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "< error", xrt);
}
}
@Override
- protected Object visit(ASTSWNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTSWNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
return operators.startsWith(node, "^=", left, right) ? Boolean.TRUE : Boolean.FALSE;
}
@Override
- protected Object visit(ASTNSWNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTNSWNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
return operators.startsWith(node, "^!", left, right) ? Boolean.FALSE : Boolean.TRUE;
}
@Override
- protected Object visit(ASTEWNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTEWNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
return operators.endsWith(node, "$=", left, right) ? Boolean.TRUE : Boolean.FALSE;
}
@Override
- protected Object visit(ASTNEWNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTNEWNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
return operators.endsWith(node, "$!", left, right) ? Boolean.FALSE : Boolean.TRUE;
}
@Override
- protected Object visit(ASTERNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTERNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
return operators.contains(node, "=~", right, left) ? Boolean.TRUE : Boolean.FALSE;
}
@Override
- protected Object visit(ASTNRNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTNRNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
return operators.contains(node, "!~", right, left) ? Boolean.FALSE : Boolean.TRUE;
}
@Override
- protected Object visit(ASTRangeNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTRangeNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
return arithmetic.createRange(left, right);
- } catch (ArithmeticException xrt) {
- JexlNode xnode = findNullOperand(xrt, node, left, right);
+ } catch (final ArithmeticException xrt) {
+ final JexlNode xnode = findNullOperand(xrt, node, left, right);
throw new JexlException(xnode, ".. error", xrt);
}
}
@Override
- protected Object visit(ASTUnaryMinusNode node, Object data) {
+ protected Object visit(final ASTUnaryMinusNode node, final Object data) {
// use cached value if literal
- Object value = node.jjtGetValue();
+ final Object value = node.jjtGetValue();
if (value != null && !(value instanceof JexlMethod)) {
return value;
}
- JexlNode valNode = node.jjtGetChild(0);
- Object val = valNode.jjtAccept(this, data);
+ final JexlNode valNode = node.jjtGetChild(0);
+ final Object val = valNode.jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.NEGATE, val);
+ final Object result = operators.tryOverload(node, JexlOperator.NEGATE, val);
if (result != JexlEngine.TRY_FAILED) {
return result;
}
@@ -527,68 +527,68 @@ public class Interpreter extends InterpreterBase {
}
}
return number;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(valNode, "- error", xrt);
}
}
@Override
- protected Object visit(ASTUnaryPlusNode node, Object data) {
+ protected Object visit(final ASTUnaryPlusNode node, final Object data) {
// use cached value if literal
- Object value = node.jjtGetValue();
+ final Object value = node.jjtGetValue();
if (value != null && !(value instanceof JexlMethod)) {
return value;
}
- JexlNode valNode = node.jjtGetChild(0);
- Object val = valNode.jjtAccept(this, data);
+ final JexlNode valNode = node.jjtGetChild(0);
+ final Object val = valNode.jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.POSITIVIZE, val);
+ final Object result = operators.tryOverload(node, JexlOperator.POSITIVIZE, val);
if (result != JexlEngine.TRY_FAILED) {
return result;
}
- Object number = arithmetic.positivize(val);
+ final Object number = arithmetic.positivize(val);
if (valNode instanceof ASTNumberLiteral
&& number instanceof Number
&& arithmetic.isPositivizeStable()) {
node.jjtSetValue(number);
}
return number;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(valNode, "- error", xrt);
}
}
@Override
- protected Object visit(ASTBitwiseComplNode node, Object data) {
- Object arg = node.jjtGetChild(0).jjtAccept(this, data);
+ protected Object visit(final ASTBitwiseComplNode node, final Object data) {
+ final Object arg = node.jjtGetChild(0).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.COMPLEMENT, arg);
+ final Object result = operators.tryOverload(node, JexlOperator.COMPLEMENT, arg);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.complement(arg);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "~ error", xrt);
}
}
@Override
- protected Object visit(ASTNotNode node, Object data) {
- Object val = node.jjtGetChild(0).jjtAccept(this, data);
+ protected Object visit(final ASTNotNode node, final Object data) {
+ final Object val = node.jjtGetChild(0).jjtAccept(this, data);
try {
- Object result = operators.tryOverload(node, JexlOperator.NOT, val);
+ final Object result = operators.tryOverload(node, JexlOperator.NOT, val);
return result != JexlEngine.TRY_FAILED ? result : arithmetic.not(val);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, "! error", xrt);
}
}
@Override
- protected Object visit(ASTIfStatement node, Object data) {
- int n = 0;
+ protected Object visit(final ASTIfStatement node, final Object data) {
+ final int n = 0;
final int numChildren = node.jjtGetNumChildren();
try {
Object result = null;
// pairs of { conditions , 'then' statement }
for(int ifElse = 0; ifElse < (numChildren - 1); ifElse += 2) {
- Object condition = node.jjtGetChild(ifElse).jjtAccept(this, null);
+ final Object condition = node.jjtGetChild(ifElse).jjtAccept(this, null);
if (arithmetic.toBoolean(condition)) {
// first objectNode is true statement
return node.jjtGetChild(ifElse + 1).jjtAccept(this, null);
@@ -601,14 +601,14 @@ public class Interpreter extends InterpreterBase {
result = node.jjtGetChild(numChildren - 1).jjtAccept(this, null);
}
return result;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node.jjtGetChild(n), "if error", xrt);
}
}
@Override
- protected Object visit(ASTVar node, Object data) {
- int symbol = node.getSymbol();
+ protected Object visit(final ASTVar node, final Object data) {
+ final int symbol = node.getSymbol();
// if we have a var, we have a scope thus a frame
if (!options.isLexical()) {
if (frame.has(symbol)) {
@@ -622,8 +622,8 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTBlock node, Object data) {
- int cnt = node.getSymbolCount();
+ protected Object visit(final ASTBlock node, final Object data) {
+ final int cnt = node.getSymbolCount();
if (!options.isLexical() || cnt <= 0) {
return visitBlock(node, data);
}
@@ -641,8 +641,8 @@ public class Interpreter extends InterpreterBase {
* @param data the usual data
* @return the result of the last expression evaluation
*/
- private Object visitBlock(ASTBlock node, Object data) {
- int numChildren = node.jjtGetNumChildren();
+ private Object visitBlock(final ASTBlock node, final Object data) {
+ final int numChildren = node.jjtGetNumChildren();
Object result = null;
for (int i = 0; i < numChildren; i++) {
cancelCheck(node);
@@ -652,28 +652,28 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTReturnStatement node, Object data) {
- Object val = node.jjtGetChild(0).jjtAccept(this, data);
+ protected Object visit(final ASTReturnStatement node, final Object data) {
+ final Object val = node.jjtGetChild(0).jjtAccept(this, data);
cancelCheck(node);
throw new JexlException.Return(node, null, val);
}
@Override
- protected Object visit(ASTContinue node, Object data) {
+ protected Object visit(final ASTContinue node, final Object data) {
throw new JexlException.Continue(node);
}
@Override
- protected Object visit(ASTBreak node, Object data) {
+ protected Object visit(final ASTBreak node, final Object data) {
throw new JexlException.Break(node);
}
@Override
- protected Object visit(ASTForeachStatement node, Object data) {
+ protected Object visit(final ASTForeachStatement node, final Object data) {
Object result = null;
/* first objectNode is the loop variable */
- ASTReference loopReference = (ASTReference) node.jjtGetChild(0);
- ASTIdentifier loopVariable = (ASTIdentifier) loopReference.jjtGetChild(0);
+ final ASTReference loopReference = (ASTReference) node.jjtGetChild(0);
+ final ASTIdentifier loopVariable = (ASTIdentifier) loopReference.jjtGetChild(0);
final int symbol = loopVariable.getSymbol();
final boolean lexical = options.isLexical();// && node.getSymbolCount() > 0;
final LexicalFrame locals = lexical? new LexicalFrame(frame, block) : null;
@@ -689,14 +689,14 @@ public class Interpreter extends InterpreterBase {
Object forEach = null;
try {
/* second objectNode is the variable to iterate */
- Object iterableValue = node.jjtGetChild(1).jjtAccept(this, data);
+ final Object iterableValue = node.jjtGetChild(1).jjtAccept(this, data);
// make sure there is a value to iterate upon
if (iterableValue != null) {
/* third objectNode is the statement to execute */
- JexlNode statement = node.jjtGetNumChildren() >= 3 ? node.jjtGetChild(2) : null;
+ final JexlNode statement = node.jjtGetNumChildren() >= 3 ? node.jjtGetChild(2) : null;
// get an iterator for the collection/array etc via the introspector.
forEach = operators.tryOverload(node, JexlOperator.FOR_EACH, iterableValue);
- Iterator<?> itemsIterator = forEach instanceof Iterator
+ final Iterator<?> itemsIterator = forEach instanceof Iterator
? (Iterator<?>) forEach
: uberspect.getIterator(iterableValue);
if (itemsIterator != null) {
@@ -713,7 +713,7 @@ public class Interpreter extends InterpreterBase {
}
}
// set loopVariable to value of iterator
- Object value = itemsIterator.next();
+ final Object value = itemsIterator.next();
if (symbol < 0) {
setContextVariable(node, loopVariable.getName(), value);
} else {
@@ -723,9 +723,9 @@ public class Interpreter extends InterpreterBase {
try {
// execute statement
result = statement.jjtAccept(this, data);
- } catch (JexlException.Break stmtBreak) {
+ } catch (final JexlException.Break stmtBreak) {
break;
- } catch (JexlException.Continue stmtContinue) {
+ } catch (final JexlException.Continue stmtContinue) {
//continue;
}
}
@@ -744,19 +744,19 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTWhileStatement node, Object data) {
+ protected Object visit(final ASTWhileStatement node, final Object data) {
Object result = null;
/* first objectNode is the condition */
- Node condition = node.jjtGetChild(0);
+ final Node condition = node.jjtGetChild(0);
while (arithmetic.toBoolean(condition.jjtAccept(this, data))) {
cancelCheck(node);
if (node.jjtGetNumChildren() > 1) {
try {
// execute statement
result = node.jjtGetChild(1).jjtAccept(this, data);
- } catch (JexlException.Break stmtBreak) {
+ } catch (final JexlException.Break stmtBreak) {
break;
- } catch (JexlException.Continue stmtContinue) {
+ } catch (final JexlException.Continue stmtContinue) {
//continue;
}
}
@@ -765,20 +765,20 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTDoWhileStatement node, Object data) {
+ protected Object visit(final ASTDoWhileStatement node, final Object data) {
Object result = null;
- int nc = node.jjtGetNumChildren();
+ final int nc = node.jjtGetNumChildren();
/* last objectNode is the condition */
- Node condition = node.jjtGetChild(nc - 1);
+ final Node condition = node.jjtGetChild(nc - 1);
do {
cancelCheck(node);
if (nc > 1) {
try {
// execute statement
result = node.jjtGetChild(0).jjtAccept(this, data);
- } catch (JexlException.Break stmtBreak) {
+ } catch (final JexlException.Break stmtBreak) {
break;
- } catch (JexlException.Continue stmtContinue) {
+ } catch (final JexlException.Continue stmtContinue) {
//continue;
}
}
@@ -787,73 +787,73 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTAndNode node, Object data) {
+ protected Object visit(final ASTAndNode node, final Object data) {
/*
* The pattern for exception mgmt is to let the child*.jjtAccept out of the try/catch loop so that if one fails,
* the ex will traverse up to the interpreter. In cases where this is not convenient/possible, JexlException
* must be caught explicitly and rethrown.
*/
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
try {
- boolean leftValue = arithmetic.toBoolean(left);
+ final boolean leftValue = arithmetic.toBoolean(left);
if (!leftValue) {
return Boolean.FALSE;
}
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node.jjtGetChild(0), "boolean coercion error", xrt);
}
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- boolean rightValue = arithmetic.toBoolean(right);
+ final boolean rightValue = arithmetic.toBoolean(right);
if (!rightValue) {
return Boolean.FALSE;
}
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node.jjtGetChild(1), "boolean coercion error", xrt);
}
return Boolean.TRUE;
}
@Override
- protected Object visit(ASTOrNode node, Object data) {
- Object left = node.jjtGetChild(0).jjtAccept(this, data);
+ protected Object visit(final ASTOrNode node, final Object data) {
+ final Object left = node.jjtGetChild(0).jjtAccept(this, data);
try {
- boolean leftValue = arithmetic.toBoolean(left);
+ final boolean leftValue = arithmetic.toBoolean(left);
if (leftValue) {
return Boolean.TRUE;
}
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node.jjtGetChild(0), "boolean coercion error", xrt);
}
- Object right = node.jjtGetChild(1).jjtAccept(this, data);
+ final Object right = node.jjtGetChild(1).jjtAccept(this, data);
try {
- boolean rightValue = arithmetic.toBoolean(right);
+ final boolean rightValue = arithmetic.toBoolean(right);
if (rightValue) {
return Boolean.TRUE;
}
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node.jjtGetChild(1), "boolean coercion error", xrt);
}
return Boolean.FALSE;
}
@Override
- protected Object visit(ASTNullLiteral node, Object data) {
+ protected Object visit(final ASTNullLiteral node, final Object data) {
return null;
}
@Override
- protected Object visit(ASTTrueNode node, Object data) {
+ protected Object visit(final ASTTrueNode node, final Object data) {
return Boolean.TRUE;
}
@Override
- protected Object visit(ASTFalseNode node, Object data) {
+ protected Object visit(final ASTFalseNode node, final Object data) {
return Boolean.FALSE;
}
@Override
- protected Object visit(ASTNumberLiteral node, Object data) {
+ protected Object visit(final ASTNumberLiteral node, final Object data) {
if (data != null && node.isInteger()) {
return getAttribute(data, node.getLiteral(), node);
}
@@ -861,7 +861,7 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTStringLiteral node, Object data) {
+ protected Object visit(final ASTStringLiteral node, final Object data) {
if (data != null) {
return getAttribute(data, node.getLiteral(), node);
}
@@ -869,22 +869,22 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTRegexLiteral node, Object data) {
+ protected Object visit(final ASTRegexLiteral node, final Object data) {
return node.getLiteral();
}
@Override
- protected Object visit(ASTArrayLiteral node, Object data) {
- int childCount = node.jjtGetNumChildren();
- JexlArithmetic.ArrayBuilder ab = arithmetic.arrayBuilder(childCount);
+ protected Object visit(final ASTArrayLiteral node, final Object data) {
+ final int childCount = node.jjtGetNumChildren();
+ final JexlArithmetic.ArrayBuilder ab = arithmetic.arrayBuilder(childCount);
boolean extended = false;
for (int i = 0; i < childCount; i++) {
cancelCheck(node);
- JexlNode child = node.jjtGetChild(i);
+ final JexlNode child = node.jjtGetChild(i);
if (child instanceof ASTExtendedLiteral) {
extended = true;
} else {
- Object entry = node.jjtGetChild(i).jjtAccept(this, data);
+ final Object entry = node.jjtGetChild(i).jjtAccept(this, data);
ab.add(entry);
}
}
@@ -892,47 +892,47 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTExtendedLiteral node, Object data) {
+ protected Object visit(final ASTExtendedLiteral node, final Object data) {
return node;
}
@Override
- protected Object visit(ASTSetLiteral node, Object data) {
- int childCount = node.jjtGetNumChildren();
- JexlArithmetic.SetBuilder mb = arithmetic.setBuilder(childCount);
+ protected Object visit(final ASTSetLiteral node, final Object data) {
+ final int childCount = node.jjtGetNumChildren();
+ final JexlArithmetic.SetBuilder mb = arithmetic.setBuilder(childCount);
for (int i = 0; i < childCount; i++) {
cancelCheck(node);
- Object entry = node.jjtGetChild(i).jjtAccept(this, data);
+ final Object entry = node.jjtGetChild(i).jjtAccept(this, data);
mb.add(entry);
}
return mb.create();
}
@Override
- protected Object visit(ASTMapLiteral node, Object data) {
- int childCount = node.jjtGetNumChildren();
- JexlArithmetic.MapBuilder mb = arithmetic.mapBuilder(childCount);
+ protected Object visit(final ASTMapLiteral node, final Object data) {
+ final int childCount = node.jjtGetNumChildren();
+ final JexlArithmetic.MapBuilder mb = arithmetic.mapBuilder(childCount);
for (int i = 0; i < childCount; i++) {
cancelCheck(node);
- Object[] entry = (Object[]) (node.jjtGetChild(i)).jjtAccept(this, data);
+ final Object[] entry = (Object[]) (node.jjtGetChild(i)).jjtAccept(this, data);
mb.put(entry[0], entry[1]);
}
return mb.create();
}
@Override
- protected Object visit(ASTMapEntry node, Object data) {
- Object key = node.jjtGetChild(0).jjtAccept(this, data);
- Object value = node.jjtGetChild(1).jjtAccept(this, data);
+ protected Object visit(final ASTMapEntry node, final Object data) {
+ final Object key = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object value = node.jjtGetChild(1).jjtAccept(this, data);
return new Object[]{key, value};
}
@Override
- protected Object visit(ASTTernaryNode node, Object data) {
+ protected Object visit(final ASTTernaryNode node, final Object data) {
Object condition;
try {
condition = node.jjtGetChild(0).jjtAccept(this, data);
- } catch(JexlException xany) {
+ } catch(final JexlException xany) {
if (!(xany.getCause() instanceof JexlArithmetic.NullOperand)) {
throw xany;
}
@@ -955,11 +955,11 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTNullpNode node, Object data) {
+ protected Object visit(final ASTNullpNode node, final Object data) {
Object lhs;
try {
lhs = node.jjtGetChild(0).jjtAccept(this, data);
- } catch(JexlException xany) {
+ } catch(final JexlException xany) {
if (!(xany.getCause() instanceof JexlArithmetic.NullOperand)) {
throw xany;
}
@@ -970,21 +970,21 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTSizeFunction node, Object data) {
+ protected Object visit(final ASTSizeFunction node, final Object data) {
try {
- Object val = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object val = node.jjtGetChild(0).jjtAccept(this, data);
return operators.size(node, val);
- } catch(JexlException xany) {
+ } catch(final JexlException xany) {
return 0;
}
}
@Override
- protected Object visit(ASTEmptyFunction node, Object data) {
+ protected Object visit(final ASTEmptyFunction node, final Object data) {
try {
- Object value = node.jjtGetChild(0).jjtAccept(this, data);
+ final Object value = node.jjtGetChild(0).jjtAccept(this, data);
return operators.empty(node, value);
- } catch(JexlException xany) {
+ } catch(final JexlException xany) {
return true;
}
}
@@ -995,7 +995,7 @@ public class Interpreter extends InterpreterBase {
* @param data the usual data
* @return the return value
*/
- protected Object visitLexicalNode(JexlNode node, Object data) {
+ protected Object visitLexicalNode(final JexlNode node, final Object data) {
block = new LexicalFrame(frame, null);
try {
return node.jjtAccept(this, data);
@@ -1010,11 +1010,11 @@ public class Interpreter extends InterpreterBase {
* @param data the usual data
* @return the closure return value
*/
- protected Object runClosure(Closure closure, Object data) {
- ASTJexlScript script = closure.getScript();
+ protected Object runClosure(final Closure closure, final Object data) {
+ final ASTJexlScript script = closure.getScript();
block = new LexicalFrame(frame, block).defineArgs();
try {
- JexlNode body = script.jjtGetChild(script.jjtGetNumChildren() - 1);
+ final JexlNode body = script.jjtGetChild(script.jjtGetNumChildren() - 1);
return interpret(body);
} finally {
block = block.pop();
@@ -1022,7 +1022,7 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTJexlScript script, Object data) {
+ protected Object visit(final ASTJexlScript script, final Object data) {
if (script instanceof ASTJexlLambda && !((ASTJexlLambda) script).isTopLevel()) {
return new Closure(this, (ASTJexlLambda) script);
} else {
@@ -1031,7 +1031,7 @@ public class Interpreter extends InterpreterBase {
final int numChildren = script.jjtGetNumChildren();
Object result = null;
for (int i = 0; i < numChildren; i++) {
- JexlNode child = script.jjtGetChild(i);
+ final JexlNode child = script.jjtGetChild(i);
result = child.jjtAccept(this, data);
cancelCheck(child);
}
@@ -1043,12 +1043,12 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTReferenceExpression node, Object data) {
+ protected Object visit(final ASTReferenceExpression node, final Object data) {
return node.jjtGetChild(0).jjtAccept(this, data);
}
@Override
- protected Object visit(ASTIdentifier identifier, Object data) {
+ protected Object visit(final ASTIdentifier identifier, final Object data) {
cancelCheck(identifier);
return data != null
? getAttribute(data, identifier.getName(), identifier)
@@ -1056,17 +1056,17 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTArrayAccess node, Object data) {
+ protected Object visit(final ASTArrayAccess node, final Object data) {
// first objectNode is the identifier
Object object = data;
// can have multiple nodes - either an expression, integer literal or reference
- int numChildren = node.jjtGetNumChildren();
+ final int numChildren = node.jjtGetNumChildren();
for (int i = 0; i < numChildren; i++) {
- JexlNode nindex = node.jjtGetChild(i);
+ final JexlNode nindex = node.jjtGetChild(i);
if (object == null) {
return unsolvableProperty(nindex, stringifyProperty(nindex), false, null);
}
- Object index = nindex.jjtAccept(this, null);
+ final Object index = nindex.jjtAccept(this, null);
cancelCheck(node);
object = getAttribute(object, index, nindex);
}
@@ -1079,7 +1079,7 @@ public class Interpreter extends InterpreterBase {
* @param node the identifier access node
* @return the evaluated identifier
*/
- private Object evalIdentifier(ASTIdentifierAccess node) {
+ private Object evalIdentifier(final ASTIdentifierAccess node) {
if (node instanceof ASTIdentifierAccessJxlt) {
final ASTIdentifierAccessJxlt accessJxlt = (ASTIdentifierAccessJxlt) node;
final String src = node.getName();
@@ -1087,18 +1087,18 @@ public class Interpreter extends InterpreterBase {
TemplateEngine.TemplateExpression expr = (TemplateEngine.TemplateExpression) accessJxlt.getExpression();
try {
if (expr == null) {
- TemplateEngine jxlt = jexl.jxlt();
+ final TemplateEngine jxlt = jexl.jxlt();
expr = jxlt.parseExpression(node.jexlInfo(), src, frame != null ? frame.getScope() : null);
accessJxlt.setExpression(expr);
}
if (expr != null) {
- Object name = expr.evaluate(frame, context);
+ final Object name = expr.evaluate(frame, context);
if (name != null) {
- Integer id = ASTIdentifierAccess.parseIdentifier(name.toString());
+ final Integer id = ASTIdentifierAccess.parseIdentifier(name.toString());
return id != null ? id : name;
}
}
- } catch (JxltEngine.Exception xjxlt) {
+ } catch (final JxltEngine.Exception xjxlt) {
cause = xjxlt;
}
return node.isSafe() ? null : unsolvableProperty(node, src, true, cause);
@@ -1108,16 +1108,16 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTIdentifierAccess node, Object data) {
+ protected Object visit(final ASTIdentifierAccess node, final Object data) {
if (data == null) {
return null;
}
- Object id = evalIdentifier(node);
+ final Object id = evalIdentifier(node);
return getAttribute(data, id, node);
}
@Override
- protected Object visit(final ASTReference node, Object data) {
+ protected Object visit(final ASTReference node, final Object data) {
cancelCheck(node);
final int numChildren = node.jjtGetNumChildren();
final JexlNode parent = node.jjtGetParent();
@@ -1136,9 +1136,9 @@ public class Interpreter extends InterpreterBase {
if (object == null) {
// we may be performing a method call on an antish var
if (ant != null) {
- JexlNode child = objectNode.jjtGetChild(0);
+ final JexlNode child = objectNode.jjtGetChild(0);
if (child instanceof ASTIdentifierAccess) {
- int alen = ant.length();
+ final int alen = ant.length();
ant.append('.');
ant.append(((ASTIdentifierAccess) child).getName());
object = context.get(ant.toString());
@@ -1171,9 +1171,9 @@ public class Interpreter extends InterpreterBase {
// create first from first node
if (ant == null) {
// if we still have a null object, check for an antish variable
- JexlNode first = node.jjtGetChild(0);
+ final JexlNode first = node.jjtGetChild(0);
if (first instanceof ASTIdentifier) {
- ASTIdentifier afirst = (ASTIdentifier) first;
+ final ASTIdentifier afirst = (ASTIdentifier) first;
ant = new StringBuilder(afirst.getName());
// skip the else...*
} else {
@@ -1193,9 +1193,9 @@ public class Interpreter extends InterpreterBase {
}
// catch up to current node
for (; v <= c; ++v) {
- JexlNode child = node.jjtGetChild(v);
+ final JexlNode child = node.jjtGetChild(v);
if (child instanceof ASTIdentifierAccess) {
- ASTIdentifierAccess achild = (ASTIdentifierAccess) child;
+ final ASTIdentifierAccess achild = (ASTIdentifierAccess) child;
if (achild.isSafe() || achild.isExpression()) {
break main;
}
@@ -1222,8 +1222,8 @@ public class Interpreter extends InterpreterBase {
return null;
}
if (ant != null) {
- String aname = ant.toString();
- boolean defined = isVariableDefined(frame, block, aname);
+ final String aname = ant.toString();
+ final boolean defined = isVariableDefined(frame, block, aname);
return unsolvableVariable(node, aname, !defined);
}
return unsolvableProperty(node,
@@ -1233,8 +1233,8 @@ public class Interpreter extends InterpreterBase {
if (node.isSafeLhs(isSafe())) {
return null;
}
- String aname = ant != null ? ant.toString() : "?";
- boolean defined = isVariableDefined(frame, block, aname);
+ final String aname = ant != null ? ant.toString() : "?";
+ final boolean defined = isVariableDefined(frame, block, aname);
if (defined && !arithmetic.isStrict()) {
return null;
}
@@ -1247,47 +1247,47 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTAssignment node, Object data) {
+ protected Object visit(final ASTAssignment node, final Object data) {
return executeAssign(node, null, data);
}
@Override
- protected Object visit(ASTSetAddNode node, Object data) {
+ protected Object visit(final ASTSetAddNode node, final Object data) {
return executeAssign(node, JexlOperator.SELF_ADD, data);
}
@Override
- protected Object visit(ASTSetSubNode node, Object data) {
+ protected Object visit(final ASTSetSubNode node, final Object data) {
return executeAssign(node, JexlOperator.SELF_SUBTRACT, data);
}
@Override
- protected Object visit(ASTSetMultNode node, Object data) {
+ protected Object visit(final ASTSetMultNode node, final Object data) {
return executeAssign(node, JexlOperator.SELF_MULTIPLY, data);
}
@Override
- protected Object visit(ASTSetDivNode node, Object data) {
+ protected Object visit(final ASTSetDivNode node, final Object data) {
return executeAssign(node, JexlOperator.SELF_DIVIDE, data);
}
@Override
- protected Object visit(ASTSetModNode node, Object data) {
+ protected Object visit(final ASTSetModNode node, final Object data) {
return executeAssign(node, JexlOperator.SELF_MOD, data);
}
@Override
- protected Object visit(ASTSetAndNode node, Object data) {
+ protected Object visit(final ASTSetAndNode node, final Object data) {
return executeAssign(node, JexlOperator.SELF_AND, data);
}
@Override
- protected Object visit(ASTSetOrNode node, Object data) {
+ protected Object visit(final ASTSetOrNode node, final Object data) {
return executeAssign(node, JexlOperator.SELF_OR, data);
}
@Override
- protected Object visit(ASTSetXorNode node, Object data) {
+ protected Object visit(final ASTSetXorNode node, final Object data) {
return executeAssign(node, JexlOperator.SELF_XOR, data);
}
@@ -1298,7 +1298,7 @@ public class Interpreter extends InterpreterBase {
* @param data the data
* @return the left hand side
*/
- protected Object executeAssign(JexlNode node, JexlOperator assignop, Object data) { // CSOFF: MethodLength
+ protected Object executeAssign(final JexlNode node, final JexlOperator assignop, final Object data) { // CSOFF: MethodLength
cancelCheck(node);
// left contains the reference to assign to
final JexlNode left = node.jjtGetChild(0);
@@ -1330,7 +1330,7 @@ public class Interpreter extends InterpreterBase {
// check we are not assigning a symbol itself
if (last < 0) {
if (assignop != null) {
- Object self = getVariable(frame, block, var);
+ final Object self = getVariable(frame, block, var);
right = operators.tryAssignOverload(node, assignop, self, right);
if (right == JexlOperator.ASSIGN) {
return self;
@@ -1350,7 +1350,7 @@ public class Interpreter extends InterpreterBase {
// check we are not assigning direct global
if (last < 0) {
if (assignop != null) {
- Object self = context.get(var.getName());
+ final Object self = context.get(var.getName());
right = operators.tryAssignOverload(node, assignop, self, right);
if (right == JexlOperator.ASSIGN) {
return self;
@@ -1382,8 +1382,8 @@ public class Interpreter extends InterpreterBase {
} else if (antish) {
// initialize if first time
if (ant == null) {
- JexlNode first = left.jjtGetChild(0);
- ASTIdentifier firstId = first instanceof ASTIdentifier
+ final JexlNode first = left.jjtGetChild(0);
+ final ASTIdentifier firstId = first instanceof ASTIdentifier
? (ASTIdentifier) first
: null;
if (firstId != null && firstId.getSymbol() < 0) {
@@ -1396,8 +1396,8 @@ public class Interpreter extends InterpreterBase {
}
// catch up to current child
for (; v <= c; ++v) {
- JexlNode child = left.jjtGetChild(v);
- ASTIdentifierAccess aid = child instanceof ASTIdentifierAccess
+ final JexlNode child = left.jjtGetChild(v);
+ final ASTIdentifierAccess aid = child instanceof ASTIdentifierAccess
? (ASTIdentifierAccess) child
: null;
// remain antish only if unsafe navigation
@@ -1418,7 +1418,7 @@ public class Interpreter extends InterpreterBase {
// 2: last objectNode will perform assignement in all cases
Object property = null;
JexlNode propertyNode = left.jjtGetChild(last);
- ASTIdentifierAccess propertyId = propertyNode instanceof ASTIdentifierAccess
+ final ASTIdentifierAccess propertyId = propertyNode instanceof ASTIdentifierAccess
? (ASTIdentifierAccess) propertyNode
: null;
if (propertyId != null) {
@@ -1429,7 +1429,7 @@ public class Interpreter extends InterpreterBase {
}
ant.append(propertyId.getName());
if (assignop != null) {
- Object self = context.get(ant.toString());
+ final Object self = context.get(ant.toString());
right = operators.tryAssignOverload(node, assignop, self, right);
if (right == JexlOperator.ASSIGN) {
return self;
@@ -1442,10 +1442,10 @@ public class Interpreter extends InterpreterBase {
property = evalIdentifier(propertyId);
} else if (propertyNode instanceof ASTArrayAccess) {
// can have multiple nodes - either an expression, integer literal or reference
- int numChildren = propertyNode.jjtGetNumChildren() - 1;
+ final int numChildren = propertyNode.jjtGetNumChildren() - 1;
for (int i = 0; i < numChildren; i++) {
- JexlNode nindex = propertyNode.jjtGetChild(i);
- Object index = nindex.jjtAccept(this, null);
+ final JexlNode nindex = propertyNode.jjtGetChild(i);
+ final Object index = nindex.jjtAccept(this, null);
object = getAttribute(object, index, nindex);
}
propertyNode = propertyNode.jjtGetChild(numChildren);
@@ -1461,7 +1461,7 @@ public class Interpreter extends InterpreterBase {
}
// 3: one before last, assign
if (assignop != null) {
- Object self = getAttribute(object, property, propertyNode);
+ final Object self = getAttribute(object, property, propertyNode);
right = operators.tryAssignOverload(node, assignop, self, right);
if (right == JexlOperator.ASSIGN) {
return self;
@@ -1472,7 +1472,7 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object[] visit(ASTArguments node, Object data) {
+ protected Object[] visit(final ASTArguments node, final Object data) {
final int argc = node.jjtGetNumChildren();
final Object[] argv = new Object[argc];
for (int i = 0; i < argc; i++) {
@@ -1482,7 +1482,7 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(final ASTMethodNode node, Object data) {
+ protected Object visit(final ASTMethodNode node, final Object data) {
return visit(node, null, data);
}
@@ -1493,7 +1493,7 @@ public class Interpreter extends InterpreterBase {
* @param data the context
* @return the method call result
*/
- private Object visit(final ASTMethodNode node, Object object, Object data) {
+ private Object visit(final ASTMethodNode node, Object object, final Object data) {
// left contains the reference to the method
final JexlNode methodNode = node.jjtGetChild(0);
Object method;
@@ -1523,7 +1523,7 @@ public class Interpreter extends InterpreterBase {
? null
: unsolvableMethod(methodNode, "<?>.<null>(...)");
}
- ASTArguments argNode = (ASTArguments) node.jjtGetChild(a);
+ final ASTArguments argNode = (ASTArguments) node.jjtGetChild(a);
result = call(node, object, result, argNode);
object = result;
}
@@ -1531,11 +1531,11 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTFunctionNode node, Object data) {
- ASTIdentifier functionNode = (ASTIdentifier) node.jjtGetChild(0);
- String nsid = functionNode.getNamespace();
- Object namespace = (nsid != null)? resolveNamespace(nsid, node) : context;
- ASTArguments argNode = (ASTArguments) node.jjtGetChild(1);
+ protected Object visit(final ASTFunctionNode node, final Object data) {
+ final ASTIdentifier functionNode = (ASTIdentifier) node.jjtGetChild(0);
+ final String nsid = functionNode.getNamespace();
+ final Object namespace = (nsid != null)? resolveNamespace(nsid, node) : context;
+ final ASTArguments argNode = (ASTArguments) node.jjtGetChild(1);
return call(node, namespace, functionNode, argNode);
}
@@ -1556,7 +1556,7 @@ public class Interpreter extends InterpreterBase {
* @param argNode the node carrying the arguments
* @return the result of the method invocation
*/
- protected Object call(final JexlNode node, Object target, Object functor, final ASTArguments argNode) {
+ protected Object call(final JexlNode node, final Object target, Object functor, final ASTArguments argNode) {
cancelCheck(node);
// evaluate the arguments
final Object[] argv = visit(argNode, null);
@@ -1567,7 +1567,7 @@ public class Interpreter extends InterpreterBase {
boolean isavar = false;
if (functor instanceof ASTIdentifier) {
// function call, target is context or namespace (if there was one)
- ASTIdentifier methodIdentifier = (ASTIdentifier) functor;
+ final ASTIdentifier methodIdentifier = (ASTIdentifier) functor;
symbol = methodIdentifier.getSymbol();
methodName = methodIdentifier.getName();
functor = null;
@@ -1602,10 +1602,10 @@ public class Interpreter extends InterpreterBase {
}
// solving the call site
- CallDispatcher call = new CallDispatcher(node, cacheable);
+ final CallDispatcher call = new CallDispatcher(node, cacheable);
try {
// do we have a cached version method/function name ?
- Object eval = call.tryEval(target, methodName, argv);
+ final Object eval = call.tryEval(target, methodName, argv);
if (JexlEngine.TRY_FAILED != eval) {
return eval;
}
@@ -1622,7 +1622,7 @@ public class Interpreter extends InterpreterBase {
}
if (target == context) {
// solve 'null' namespace
- Object namespace = resolveNamespace(null, node);
+ final Object namespace = resolveNamespace(null, node);
if (namespace != null
&& namespace != context
&& call.isTargetMethod(namespace, methodName, argv)) {
@@ -1637,7 +1637,7 @@ public class Interpreter extends InterpreterBase {
} else {
// try prepending target to arguments and look for
// applicable method in context...
- Object[] pargv = functionArguments(target, narrow, argv);
+ final Object[] pargv = functionArguments(target, narrow, argv);
if (call.isContextMethod(methodName, pargv)) {
return call.eval(methodName);
}
@@ -1647,7 +1647,7 @@ public class Interpreter extends InterpreterBase {
}
// the method may also be a functor stored in a property of the target
if (!narrow) {
- JexlPropertyGet get = uberspect.getPropertyGet(target, methodName);
+ final JexlPropertyGet get = uberspect.getPropertyGet(target, methodName);
if (get != null) {
functor = get.tryInvoke(target, methodName);
functorp = functor != null;
@@ -1681,7 +1681,7 @@ public class Interpreter extends InterpreterBase {
}
// try prepending functor to arguments and look for
// context or arithmetic function called 'call'
- Object[] pargv = functionArguments(functor, narrow, argv);
+ final Object[] pargv = functionArguments(functor, narrow, argv);
if (call.isContextMethod(mCALL, pargv)) {
return call.eval(mCALL);
}
@@ -1702,36 +1702,36 @@ public class Interpreter extends InterpreterBase {
return node.isSafeLhs(isSafe())
? null
: unsolvableMethod(node, methodName, argv);
- } catch (JexlException.TryFailed xany) {
+ } catch (final JexlException.TryFailed xany) {
throw invocationException(node, methodName, xany);
- } catch (JexlException xthru) {
+ } catch (final JexlException xthru) {
throw xthru;
- } catch (Exception xany) {
+ } catch (final Exception xany) {
throw invocationException(node, methodName, xany);
}
}
@Override
- protected Object visit(ASTConstructorNode node, Object data) {
+ protected Object visit(final ASTConstructorNode node, final Object data) {
if (isCancelled()) {
throw new JexlException.Cancel(node);
}
// first child is class or class name
final Object target = node.jjtGetChild(0).jjtAccept(this, data);
// get the ctor args
- int argc = node.jjtGetNumChildren() - 1;
+ final int argc = node.jjtGetNumChildren() - 1;
Object[] argv = new Object[argc];
for (int i = 0; i < argc; i++) {
argv[i] = node.jjtGetChild(i + 1).jjtAccept(this, data);
}
try {
- boolean cacheable = cache;
+ final boolean cacheable = cache;
// attempt to reuse last funcall cached in volatile JexlNode.value
if (cacheable) {
- Object cached = node.jjtGetValue();
+ final Object cached = node.jjtGetValue();
if (cached instanceof Funcall) {
- Object eval = ((Funcall) cached).tryInvoke(this, null, target, argv);
+ final Object eval = ((Funcall) cached).tryInvoke(this, null, target, argv);
if (JexlEngine.TRY_FAILED != eval) {
return eval;
}
@@ -1750,7 +1750,7 @@ public class Interpreter extends InterpreterBase {
break;
}
// try with prepending context as first argument
- Object[] nargv = callArguments(context, narrow, argv);
+ final Object[] nargv = callArguments(context, narrow, argv);
ctor = uberspect.getConstructor(target, nargv);
if (ctor != null) {
if (cacheable && ctor.isCacheable()) {
@@ -1770,28 +1770,28 @@ public class Interpreter extends InterpreterBase {
}
// we have either evaluated and returned or might have found a ctor
if (ctor != null) {
- Object eval = ctor.invoke(target, argv);
+ final Object eval = ctor.invoke(target, argv);
// cache executor in volatile JexlNode.value
if (funcall != null) {
node.jjtSetValue(funcall);
}
return eval;
}
- String tstr = target != null ? target.toString() : "?";
+ final String tstr = target != null ? target.toString() : "?";
return unsolvableMethod(node, tstr, argv);
- } catch (JexlException.Method xmethod) {
+ } catch (final JexlException.Method xmethod) {
throw xmethod;
- } catch (Exception xany) {
- String tstr = target != null ? target.toString() : "?";
+ } catch (final Exception xany) {
+ final String tstr = target != null ? target.toString() : "?";
throw invocationException(node, tstr, xany);
}
}
@Override
- protected Object visit(ASTJxltLiteral node, Object data) {
+ protected Object visit(final ASTJxltLiteral node, final Object data) {
TemplateEngine.TemplateExpression tp = (TemplateEngine.TemplateExpression) node.jjtGetValue();
if (tp == null) {
- TemplateEngine jxlt = jexl.jxlt();
+ final TemplateEngine jxlt = jexl.jxlt();
JexlInfo info = node.jexlInfo();
if (this.block != null) {
info = new JexlNode.Info(node, info);
@@ -1806,12 +1806,12 @@ public class Interpreter extends InterpreterBase {
}
@Override
- protected Object visit(ASTAnnotation node, Object data) {
+ protected Object visit(final ASTAnnotation node, final Object data) {
throw new UnsupportedOperationException(ASTAnnotation.class.getName() + ": Not supported.");
}
@Override
- protected Object visit(ASTAnnotatedStatement node, Object data) {
+ protected Object visit(final ASTAnnotatedStatement node, final Object data) {
return processAnnotation(node, 0, data);
}
@@ -1877,7 +1877,7 @@ public class Interpreter extends InterpreterBase {
// are we evaluating the block ?
final int last = stmt.jjtGetNumChildren() - 1;
if (index == last) {
- JexlNode cblock = stmt.jjtGetChild(last);
+ final JexlNode cblock = stmt.jjtGetChild(last);
// if the context has changed, might need a new interpreter
final JexlArithmetic jexla = arithmetic.options(context);
if (jexla != arithmetic) {
@@ -1886,8 +1886,8 @@ public class Interpreter extends InterpreterBase {
+ ", got " + jexla.getClass().getSimpleName()
);
}
- Interpreter ii = new Interpreter(Interpreter.this, jexla);
- Object r = cblock.jjtAccept(ii, data);
+ final Interpreter ii = new Interpreter(Interpreter.this, jexla);
+ final Object r = cblock.jjtAccept(ii, data);
if (ii.isCancelled()) {
Interpreter.this.cancel();
}
@@ -1902,7 +1902,7 @@ public class Interpreter extends InterpreterBase {
final ASTAnnotation anode = (ASTAnnotation) stmt.jjtGetChild(index);
final String aname = anode.getName();
// evaluate the arguments
- Object[] argv = anode.jjtGetNumChildren() > 0
+ final Object[] argv = anode.jjtGetNumChildren() > 0
? visit((ASTArguments) anode.jjtGetChild(0), null) : null;
// wrap the future, will recurse through annotation processor
Object result;
@@ -1912,9 +1912,9 @@ public class Interpreter extends InterpreterBase {
if (!jstmt.isProcessed()) {
return annotationError(anode, aname, null);
}
- } catch (JexlException xany) {
+ } catch (final JexlException xany) {
throw xany;
- } catch (Exception xany) {
+ } catch (final Exception xany) {
return annotationError(anode, aname, xany);
}
// the caller may return a return, break or continue
@@ -1932,7 +1932,7 @@ public class Interpreter extends InterpreterBase {
* @return the result of statement.call()
* @throws Exception if anything goes wrong
*/
- protected Object processAnnotation(String annotation, Object[] args, Callable<Object> stmt) throws Exception {
+ protected Object processAnnotation(final String annotation, final Object[] args, final Callable<Object> stmt) throws Exception {
return context instanceof JexlContext.AnnotationProcessor
? ((JexlContext.AnnotationProcessor) context).processAnnotation(annotation, args, stmt)
: stmt.call();
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 16402e3..29e12f4 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/InterpreterBase.java
@@ -84,13 +84,13 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param opts the evaluation options
* @param aContext the evaluation context
*/
- protected InterpreterBase(Engine engine, JexlOptions opts, JexlContext aContext) {
+ protected InterpreterBase(final Engine engine, final JexlOptions opts, final JexlContext aContext) {
this.jexl = engine;
this.logger = jexl.logger;
this.uberspect = jexl.uberspect;
this.context = aContext != null ? aContext : Engine.EMPTY_CONTEXT;
this.cache = engine.cache != null;
- JexlArithmetic jexla = jexl.arithmetic;
+ final JexlArithmetic jexla = jexl.arithmetic;
this.options = opts == null? engine.options(aContext) : opts;
this.arithmetic = jexla.options(options);
if (arithmetic != jexla && !arithmetic.getClass().equals(jexla.getClass())) {
@@ -108,7 +108,7 @@ public abstract class InterpreterBase extends ParserVisitor {
acancel = ((JexlContext.CancellationHandle) context).getCancellation();
}
this.cancelled = acancel != null? acancel : new AtomicBoolean(false);
- Map<String,Object> ons = options.getNamespaces();
+ final Map<String,Object> ons = options.getNamespaces();
this.functions = ons.isEmpty()? jexl.functions : ons;
this.functors = null;
this.operators = new Operators(this);
@@ -119,7 +119,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param ii the base to copy
* @param jexla the arithmetic instance to use (or null)
*/
- protected InterpreterBase(InterpreterBase ii, JexlArithmetic jexla) {
+ protected InterpreterBase(final InterpreterBase ii, final JexlArithmetic jexla) {
jexl = ii.jexl;
logger = ii.logger;
uberspect = ii.uberspect;
@@ -139,13 +139,13 @@ public abstract class InterpreterBase extends ParserVisitor {
* <p>This is used when dealing with auto-closeable (duck-like) objects
* @param closeable the object we'd like to close
*/
- protected void closeIfSupported(Object closeable) {
+ protected void closeIfSupported(final Object closeable) {
if (closeable != null) {
- JexlMethod mclose = uberspect.getMethod(closeable, "close", EMPTY_PARAMS);
+ final JexlMethod mclose = uberspect.getMethod(closeable, "close", EMPTY_PARAMS);
if (mclose != null) {
try {
mclose.invoke(closeable, EMPTY_PARAMS);
- } catch (Exception xignore) {
+ } catch (final Exception xignore) {
logger.warn(xignore);
}
}
@@ -160,7 +160,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param node the AST node
* @return the namespace instance
*/
- protected Object resolveNamespace(String prefix, JexlNode node) {
+ protected Object resolveNamespace(final String prefix, final JexlNode node) {
Object namespace;
// check whether this namespace is a functor
synchronized (this) {
@@ -181,7 +181,7 @@ public abstract class InterpreterBase extends ParserVisitor {
}
// shortcut if ns is known to be not-a-functor
final boolean cacheable = cache;
- Object cached = cacheable ? node.jjtGetValue() : null;
+ final Object cached = cacheable ? node.jjtGetValue() : null;
if (cached != JexlContext.NamespaceFunctor.class) {
// allow namespace to instantiate a functor with context if possible, not an error otherwise
Object functor = null;
@@ -191,11 +191,11 @@ public abstract class InterpreterBase extends ParserVisitor {
// attempt to reuse last ctor cached in volatile JexlNode.value
if (cached instanceof JexlMethod) {
try {
- Object eval = ((JexlMethod) cached).tryInvoke(null, context);
+ final Object eval = ((JexlMethod) cached).tryInvoke(null, context);
if (JexlEngine.TRY_FAILED != eval) {
functor = eval;
}
- } catch (JexlException.TryFailed xtry) {
+ } catch (final JexlException.TryFailed xtry) {
throw new JexlException(node, "unable to instantiate namespace " + prefix, xtry.getCause());
}
}
@@ -208,7 +208,7 @@ public abstract class InterpreterBase extends ParserVisitor {
if (cacheable && ctor.isCacheable()) {
node.jjtSetValue(ctor);
}
- } catch (Exception xinst) {
+ } catch (final Exception xinst) {
throw new JexlException(node, "unable to instantiate namespace " + prefix, xinst);
}
}
@@ -218,7 +218,7 @@ public abstract class InterpreterBase extends ParserVisitor {
if (ctor != null) {
try {
functor = ctor.invoke(namespace);
- } catch (Exception xinst) {
+ } catch (final Exception xinst) {
throw new JexlException(node, "unable to instantiate namespace " + prefix, xinst);
}
}
@@ -228,7 +228,7 @@ public abstract class InterpreterBase extends ParserVisitor {
if (namespace instanceof String) {
try {
namespace = uberspect.getClassLoader().loadClass((String) namespace);
- } catch (ClassNotFoundException xignore) {
+ } catch (final ClassNotFoundException xignore) {
// not a class
namespace = null;
}
@@ -260,8 +260,8 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param frame the frame in which it will be defined
* @return true if definition succeeded, false otherwise
*/
- protected boolean defineVariable(ASTVar var, LexicalFrame frame) {
- int symbol = var.getSymbol();
+ protected boolean defineVariable(final ASTVar var, final LexicalFrame frame) {
+ final int symbol = var.getSymbol();
if (symbol < 0) {
return false;
}
@@ -280,12 +280,12 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param name the variable name
* @return true if variable is defined, false otherwise
*/
- protected boolean isVariableDefined(Frame frame, LexicalScope block, String name) {
+ protected boolean isVariableDefined(final Frame frame, final LexicalScope block, final String name) {
if (frame != null && block != null) {
- Integer ref = frame.getScope().getSymbol(name);
- int symbol = ref != null? ref : -1;
+ final Integer ref = frame.getScope().getSymbol(name);
+ final int symbol = ref != null? ref : -1;
if (symbol >= 0 && block.hasSymbol(symbol)) {
- Object value = frame.get(symbol);
+ final Object value = frame.get(symbol);
return value != Scope.UNDEFINED && value != Scope.UNDECLARED;
}
}
@@ -299,24 +299,24 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param identifier the variable node
* @return the value
*/
- protected Object getVariable(Frame frame, LexicalScope block, ASTIdentifier identifier) {
- int symbol = identifier.getSymbol();
+ protected Object getVariable(final Frame frame, final LexicalScope block, final ASTIdentifier identifier) {
+ final int symbol = identifier.getSymbol();
// if we have a symbol, we have a scope thus a frame
if (options.isLexicalShade() && identifier.isShaded()) {
return undefinedVariable(identifier, identifier.getName());
}
if (symbol >= 0) {
if (frame.has(symbol)) {
- Object value = frame.get(symbol);
+ final Object value = frame.get(symbol);
if (value != Scope.UNDEFINED) {
return value;
}
}
}
- String name = identifier.getName();
- Object value = context.get(name);
+ final String name = identifier.getName();
+ final Object value = context.get(name);
if (value == null && !context.has(name)) {
- boolean ignore = (isSafe()
+ final boolean ignore = (isSafe()
&& (symbol >= 0
|| identifier.jjtGetParent() instanceof ASTAssignment))
|| (identifier.jjtGetParent() instanceof ASTReference);
@@ -335,13 +335,13 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param name the variable name
* @param value the variable value
*/
- protected void setContextVariable(JexlNode node, String name, Object value) {
+ protected void setContextVariable(final JexlNode node, final String name, final Object value) {
if (options.isLexicalShade() && !context.has(name)) {
throw new JexlException.Variable(node, name, true);
}
try {
context.set(name, value);
- } catch (UnsupportedOperationException xsupport) {
+ } catch (final UnsupportedOperationException xsupport) {
throw new JexlException(node, "context is readonly", xsupport);
}
}
@@ -385,7 +385,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param right the right argument
* @return the left, right or parent node
*/
- protected JexlNode findNullOperand(RuntimeException xrt, JexlNode node, Object left, Object right) {
+ protected JexlNode findNullOperand(final RuntimeException xrt, final JexlNode node, final Object left, final Object right) {
if (xrt instanceof JexlArithmetic.NullOperand) {
if (left == null) {
return node.jjtGetChild(0);
@@ -404,7 +404,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param undef whether the variable is undefined or null
* @return throws JexlException if strict and not silent, null otherwise
*/
- protected Object unsolvableVariable(JexlNode node, String var, boolean undef) {
+ protected Object unsolvableVariable(final JexlNode node, final String var, final boolean undef) {
return variableError(node, var, undef? VariableIssue.UNDEFINED : VariableIssue.NULLVALUE);
}
@@ -414,7 +414,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param var the variable name
* @return throws JexlException if strict and not silent, null otherwise
*/
- protected Object undefinedVariable(JexlNode node, String var) {
+ protected Object undefinedVariable(final JexlNode node, final String var) {
return variableError(node, var, VariableIssue.UNDEFINED);
}
@@ -424,7 +424,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param var the variable name
* @return throws JexlException if strict and not silent, null otherwise
*/
- protected Object redefinedVariable(JexlNode node, String var) {
+ protected Object redefinedVariable(final JexlNode node, final String var) {
return variableError(node, var, VariableIssue.REDEFINED);
}
@@ -435,7 +435,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param issue the issue type
* @return throws JexlException if strict and not silent, null otherwise
*/
- protected Object variableError(JexlNode node, String var, VariableIssue issue) {
+ protected Object variableError(final JexlNode node, final String var, final VariableIssue issue) {
if (isStrictEngine() && !node.isTernaryProtected()) {
throw new JexlException.Variable(node, var, issue);
} else if (logger.isDebugEnabled()) {
@@ -449,7 +449,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param method the method name
* @return throws JexlException if strict and not silent, null otherwise
*/
- protected Object unsolvableMethod(JexlNode node, String method) {
+ protected Object unsolvableMethod(final JexlNode node, final String method) {
return unsolvableMethod(node, method, null);
}
@@ -460,7 +460,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param args the method arguments
* @return throws JexlException if strict and not silent, null otherwise
*/
- protected Object unsolvableMethod(JexlNode node, String method, Object[] args) {
+ protected Object unsolvableMethod(final JexlNode node, final String method, final Object[] args) {
if (isStrictEngine()) {
throw new JexlException.Method(node, method, args);
} else if (logger.isDebugEnabled()) {
@@ -477,7 +477,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param undef whether the property is undefined or null
* @return throws JexlException if strict and not silent, null otherwise
*/
- protected Object unsolvableProperty(JexlNode node, String property, boolean undef, Throwable cause) {
+ protected Object unsolvableProperty(final JexlNode node, final String property, final boolean undef, final Throwable cause) {
if (isStrictEngine() && !node.isTernaryProtected()) {
throw new JexlException.Property(node, property, undef, cause);
} else if (logger.isDebugEnabled()) {
@@ -492,7 +492,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param which the child we are checking
* @return true if child is local variable, false otherwise
*/
- protected boolean isLocalVariable(ASTReference node, int which) {
+ protected boolean isLocalVariable(final ASTReference node, final int which) {
return (node.jjtGetNumChildren() > which
&& node.jjtGetChild(which) instanceof ASTIdentifier
&& ((ASTIdentifier) node.jjtGetChild(which)).getSymbol() >= 0);
@@ -503,7 +503,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param node the reference node
* @return true if child is function call, false otherwise
*/
- protected boolean isFunctionCall(ASTReference node) {
+ protected boolean isFunctionCall(final ASTReference node) {
return (node.jjtGetNumChildren() > 0
&& node.jjtGetChild(0) instanceof ASTFunctionNode);
}
@@ -514,7 +514,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param node the property node
* @return the (pretty) string
*/
- protected String stringifyProperty(JexlNode node) {
+ protected String stringifyProperty(final JexlNode node) {
if (node instanceof ASTArrayAccess) {
return "["
+ stringifyPropertyValue(node.jjtGetChild(0))
@@ -541,7 +541,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param node the property node
* @return the (pretty) string value
*/
- protected static String stringifyPropertyValue(JexlNode node) {
+ protected static String stringifyPropertyValue(final JexlNode node) {
return node != null? new Debugger().depth(1).data(node) : "???";
}
@@ -552,7 +552,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param cause the cause of error (if any)
* @return throws JexlException if strict and not silent, null otherwise
*/
- protected Object operatorError(JexlNode node, JexlOperator operator, Throwable cause) {
+ protected Object operatorError(final JexlNode node, final JexlOperator operator, final Throwable cause) {
if (isStrictEngine()) {
throw new JexlException.Operator(node, operator.getOperatorSymbol(), cause);
} else if (logger.isDebugEnabled()) {
@@ -568,7 +568,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param cause the cause of error (if any)
* @return throws a JexlException if strict and not silent, null otherwise
*/
- protected Object annotationError(JexlNode node, String annotation, Throwable cause) {
+ protected Object annotationError(final JexlNode node, final String annotation, final Throwable cause) {
if (isStrictEngine()) {
throw new JexlException.Annotation(node, annotation, cause);
} else if (logger.isDebugEnabled()) {
@@ -584,8 +584,8 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param xany the cause
* @return a JexlException that will be thrown
*/
- protected JexlException invocationException(JexlNode node, String methodName, Throwable xany) {
- Throwable cause = xany.getCause();
+ protected JexlException invocationException(final JexlNode node, final String methodName, final Throwable xany) {
+ final Throwable cause = xany.getCause();
if (cause instanceof JexlException) {
return (JexlException) cause;
}
@@ -615,7 +615,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* Throws a JexlException.Cancel if script execution was cancelled.
* @param node the node being evaluated
*/
- protected void cancelCheck(JexlNode node) {
+ protected void cancelCheck(final JexlNode node) {
if (isCancelled()) {
throw new JexlException.Cancel(node);
}
@@ -629,7 +629,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param args the other (non null) arguments
* @return the arguments array
*/
- protected Object[] functionArguments(Object target, boolean narrow, Object[] args) {
+ protected Object[] functionArguments(final Object target, final boolean narrow, final Object[] args) {
// when target == context, we are dealing with the null namespace
if (target == null || target == context) {
if (narrow) {
@@ -638,7 +638,7 @@ public abstract class InterpreterBase extends ParserVisitor {
return args;
}
// makes target 1st args, copy others - optionally narrow numbers
- Object[] nargv = new Object[args.length + 1];
+ final Object[] nargv = new Object[args.length + 1];
if (narrow) {
nargv[0] = functionArgument(true, target);
for (int a = 1; a <= args.length; ++a) {
@@ -658,9 +658,9 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param args the other (non null) arguments
* @return the arguments array
*/
- protected Object[] callArguments(Object target, boolean narrow, Object[] args) {
+ protected Object[] callArguments(final Object target, final boolean narrow, final Object[] args) {
// makes target 1st args, copy others - optionally narrow numbers
- Object[] nargv = new Object[args.length + 1];
+ final Object[] nargv = new Object[args.length + 1];
if (narrow) {
nargv[0] = functionArgument(true, target);
for (int a = 1; a <= args.length; ++a) {
@@ -679,7 +679,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param arg the argument
* @return the narrowed argument
*/
- protected Object functionArgument(boolean narrow, Object arg) {
+ protected Object functionArgument(final boolean narrow, final Object arg) {
return narrow && arg instanceof Number ? arithmetic.narrow((Number) arg) : arg;
}
@@ -696,7 +696,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param jme the method
* @param flag the narrow flag
*/
- protected Funcall(JexlMethod jme, boolean flag) {
+ protected Funcall(final JexlMethod jme, final boolean flag) {
this.me = jme;
this.narrow = flag;
}
@@ -709,7 +709,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param args the method arguments
* @return the method invocation result (or JexlEngine.TRY_FAILED)
*/
- protected Object tryInvoke(InterpreterBase ii, String name, Object target, Object[] args) {
+ protected Object tryInvoke(final InterpreterBase ii, final String name, final Object target, final Object[] args) {
return me.tryInvoke(name, target, ii.functionArguments(null, narrow, args));
}
}
@@ -723,12 +723,12 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param jme the method
* @param flag the narrow flag
*/
- protected ArithmeticFuncall(JexlMethod jme, boolean flag) {
+ protected ArithmeticFuncall(final JexlMethod jme, final boolean flag) {
super(jme, flag);
}
@Override
- protected Object tryInvoke(InterpreterBase ii, String name, Object target, Object[] args) {
+ protected Object tryInvoke(final InterpreterBase ii, final String name, final Object target, final Object[] args) {
return me.tryInvoke(name, ii.arithmetic, ii.functionArguments(target, narrow, args));
}
}
@@ -742,12 +742,12 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param jme the method
* @param flag the narrow flag
*/
- protected ContextFuncall(JexlMethod jme, boolean flag) {
+ protected ContextFuncall(final JexlMethod jme, final boolean flag) {
super(jme, flag);
}
@Override
- protected Object tryInvoke(InterpreterBase ii, String name, Object target, Object[] args) {
+ protected Object tryInvoke(final InterpreterBase ii, final String name, final Object target, final Object[] args) {
return me.tryInvoke(name, ii.context, ii.functionArguments(target, narrow, args));
}
}
@@ -761,12 +761,12 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param jme the method
* @param flag the narrow flag
*/
- protected ContextualCtor(JexlMethod jme, boolean flag) {
+ protected ContextualCtor(final JexlMethod jme, final boolean flag) {
super(jme, flag);
}
@Override
- protected Object tryInvoke(InterpreterBase ii, String name, Object target, Object[] args) {
+ protected Object tryInvoke(final InterpreterBase ii, final String name, final Object target, final Object[] args) {
return me.tryInvoke(name, target, ii.callArguments(ii.context, narrow, args));
}
}
@@ -810,7 +810,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param anode the syntactic node.
* @param acacheable whether resolution can be cached
*/
- CallDispatcher(JexlNode anode, boolean acacheable) {
+ CallDispatcher(final JexlNode anode, final boolean acacheable) {
this.node = anode;
this.cacheable = acacheable;
}
@@ -823,7 +823,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param arguments the method arguments
* @return true if arithmetic, false otherwise
*/
- protected boolean isTargetMethod(Object ntarget, String mname, final Object[] arguments) {
+ protected boolean isTargetMethod(final Object ntarget, final String mname, final Object[] arguments) {
// try a method
vm = uberspect.getMethod(ntarget, mname, arguments);
if (vm != null) {
@@ -844,7 +844,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param arguments the method arguments
* @return true if arithmetic, false otherwise
*/
- protected boolean isContextMethod(String mname, final Object[] arguments) {
+ protected boolean isContextMethod(final String mname, final Object[] arguments) {
vm = uberspect.getMethod(context, mname, arguments);
if (vm != null) {
argv = arguments;
@@ -864,7 +864,7 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param arguments the method arguments
* @return true if arithmetic, false otherwise
*/
- protected boolean isArithmeticMethod(String mname, final Object[] arguments) {
+ protected boolean isArithmeticMethod(final String mname, final Object[] arguments) {
vm = uberspect.getMethod(arithmetic, mname, arguments);
if (vm != null) {
argv = arguments;
@@ -891,7 +891,7 @@ public abstract class InterpreterBase extends ParserVisitor {
// do we have a method/function name ?
// attempt to reuse last funcall cached in volatile JexlNode.value (if it was not a variable)
if (mname != null && cacheable && ntarget != null) {
- Object cached = node.jjtGetValue();
+ final Object cached = node.jjtGetValue();
if (cached instanceof Funcall) {
return ((Funcall) cached).tryInvoke(InterpreterBase.this, mname, ntarget, arguments);
}
@@ -906,11 +906,11 @@ public abstract class InterpreterBase extends ParserVisitor {
* @return the method invocation result
* @throws Exception when invocation fails
*/
- protected Object eval(String mname) throws Exception {
+ protected Object eval(final String mname) throws Exception {
// we have either evaluated and returned or might have found a method
if (vm != null) {
// vm cannot be null if xjexl is null
- Object eval = vm.invoke(target, argv);
+ final Object eval = vm.invoke(target, argv);
// cache executor in volatile JexlNode.value
if (funcall != null) {
node.jjtSetValue(funcall);
@@ -929,14 +929,14 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param node the node that evaluated as the object
* @return the attribute value
*/
- protected Object getAttribute(Object object, Object attribute, JexlNode node) {
+ protected Object getAttribute(final Object object, final Object attribute, final JexlNode node) {
if (object == null) {
throw new JexlException(node, "object is null");
}
cancelCheck(node);
final JexlOperator operator = node != null && node.jjtGetParent() instanceof ASTArrayAccess
? JexlOperator.ARRAY_GET : JexlOperator.PROPERTY_GET;
- Object result = operators.tryOverload(node, operator, object, attribute);
+ final Object result = operators.tryOverload(node, operator, object, attribute);
if (result != JexlEngine.TRY_FAILED) {
return result;
}
@@ -944,41 +944,41 @@ public abstract class InterpreterBase extends ParserVisitor {
try {
// attempt to reuse last executor cached in volatile JexlNode.value
if (node != null && cache) {
- Object cached = node.jjtGetValue();
+ final Object cached = node.jjtGetValue();
if (cached instanceof JexlPropertyGet) {
- JexlPropertyGet vg = (JexlPropertyGet) cached;
- Object value = vg.tryInvoke(object, attribute);
+ final JexlPropertyGet vg = (JexlPropertyGet) cached;
+ final Object value = vg.tryInvoke(object, attribute);
if (!vg.tryFailed(value)) {
return value;
}
}
}
// resolve that property
- List<JexlUberspect.PropertyResolver> resolvers = uberspect.getResolvers(operator, object);
- JexlPropertyGet vg = uberspect.getPropertyGet(resolvers, object, attribute);
+ final List<JexlUberspect.PropertyResolver> resolvers = uberspect.getResolvers(operator, object);
+ final JexlPropertyGet vg = uberspect.getPropertyGet(resolvers, object, attribute);
if (vg != null) {
- Object value = vg.invoke(object);
+ final Object value = vg.invoke(object);
// cache executor in volatile JexlNode.value
if (node != null && cache && vg.isCacheable()) {
node.jjtSetValue(vg);
}
return value;
}
- } catch (Exception xany) {
+ } catch (final Exception xany) {
xcause = xany;
}
// lets fail
if (node != null) {
- boolean safe = (node instanceof ASTIdentifierAccess) && ((ASTIdentifierAccess) node).isSafe();
+ final boolean safe = (node instanceof ASTIdentifierAccess) && ((ASTIdentifierAccess) node).isSafe();
if (safe) {
return null;
} else {
- String attrStr = attribute != null ? attribute.toString() : null;
+ final String attrStr = attribute != null ? attribute.toString() : null;
return unsolvableProperty(node, attrStr, true, xcause);
}
} else {
// direct call
- String error = "unable to get object property"
+ final String error = "unable to get object property"
+ ", class: " + object.getClass().getName()
+ ", property: " + attribute;
throw new UnsupportedOperationException(error, xcause);
@@ -993,11 +993,11 @@ public abstract class InterpreterBase extends ParserVisitor {
* @param value the value to assign to the object's attribute
* @param node the node that evaluated as the object
*/
- protected void setAttribute(Object object, Object attribute, Object value, JexlNode node) {
+ protected void setAttribute(final Object object, final Object attribute, final Object value, final JexlNode node) {
cancelCheck(node);
final JexlOperator operator = node != null && node.jjtGetParent() instanceof ASTArrayAccess
? JexlOperator.ARRAY_SET : JexlOperator.PROPERTY_SET;
- Object result = operators.tryOverload(node, operator, object, attribute, value);
+ final Object result = operators.tryOverload(node, operator, object, attribute, value);
if (result != JexlEngine.TRY_FAILED) {
return;
}
@@ -1005,21 +1005,21 @@ public abstract class InterpreterBase extends ParserVisitor {
try {
// attempt to reuse last executor cached in volatile JexlNode.value
if (node != null && cache) {
- Object cached = node.jjtGetValue();
+ final Object cached = node.jjtGetValue();
if (cached instanceof JexlPropertySet) {
- JexlPropertySet setter = (JexlPropertySet) cached;
- Object eval = setter.tryInvoke(object, attribute, value);
+ final JexlPropertySet setter = (JexlPropertySet) cached;
+ final Object eval = setter.tryInvoke(object, attribute, value);
if (!setter.tryFailed(eval)) {
return;
}
}
}
- List<JexlUberspect.PropertyResolver> resolvers = uberspect.getResolvers(operator, object);
+ final List<JexlUberspect.PropertyResolver> resolvers = uberspect.getResolvers(operator, object);
JexlPropertySet vs = uberspect.getPropertySet(resolvers, object, attribute, value);
// if we can't find an exact match, narrow the value argument and try again
if (vs == null) {
// replace all numbers with the smallest type that will fit
- Object[] narrow = {value};
+ final Object[] narrow = {value};
if (arithmetic.narrowArguments(narrow)) {
vs = uberspect.getPropertySet(resolvers, object, attribute, narrow[0]);
}
@@ -1032,16 +1032,16 @@ public abstract class InterpreterBase extends ParserVisitor {
}
return;
}
- } catch (Exception xany) {
+ } catch (final Exception xany) {
xcause = xany;
}
// lets fail
if (node != null) {
- String attrStr = attribute != null ? attribute.toString() : null;
+ final String attrStr = attribute != null ? attribute.toString() : null;
unsolvableProperty(node, attrStr, true, xcause);
} else {
// direct call
- String error = "unable to set object property"
+ final String error = "unable to set object property"
+ ", class: " + object.getClass().getName()
+ ", property: " + attribute
+ ", argument: " + value.getClass().getSimpleName();
diff --git a/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java b/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java
index 9318da5..077517b 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java
@@ -43,7 +43,7 @@ public class LexicalFrame extends LexicalScope {
* @param scriptf the script frame
* @param outerf the previous lexical frame
*/
- public LexicalFrame(Frame scriptf, LexicalFrame outerf) {
+ public LexicalFrame(final Frame scriptf, final LexicalFrame outerf) {
this.previous = outerf;
this.frame = scriptf;
}
@@ -53,7 +53,7 @@ public class LexicalFrame extends LexicalScope {
*
* @param src the frame to copy
*/
- public LexicalFrame(LexicalFrame src) {
+ public LexicalFrame(final LexicalFrame src) {
super(src.symbols, src.moreSymbols);
frame = src.frame;
previous = src.previous;
@@ -67,7 +67,7 @@ public class LexicalFrame extends LexicalScope {
*/
public LexicalFrame defineArgs() {
if (frame != null) {
- int argc = frame.getScope().getArgCount();
+ final int argc = frame.getScope().getArgCount();
for (int a = 0; a < argc; ++a) {
super.addSymbol(a);
}
@@ -82,8 +82,8 @@ public class LexicalFrame extends LexicalScope {
* @param capture whether this redefines a captured symbol
* @return true if symbol is defined, false otherwise
*/
- public boolean defineSymbol(int symbol, boolean capture) {
- boolean declared = addSymbol(symbol);
+ public boolean defineSymbol(final int symbol, final boolean capture) {
+ final boolean declared = addSymbol(symbol);
if (declared && capture) {
if (stack == null) {
stack = new ArrayDeque<>();
@@ -115,7 +115,7 @@ public class LexicalFrame extends LexicalScope {
} else if (value == this) {
value = null;
}
- int symbol = (Integer) stack.pop();
+ final int symbol = (Integer) stack.pop();
frame.set(symbol, value);
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/LexicalScope.java b/src/main/java/org/apache/commons/jexl3/internal/LexicalScope.java
index 1a10e47..43f9173 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/LexicalScope.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/LexicalScope.java
@@ -48,7 +48,7 @@ public class LexicalScope {
* @param s the symbols mask
* @param ms the more symbols bitset
*/
- protected LexicalScope(long s, BitSet ms) {
+ protected LexicalScope(final long s, final BitSet ms) {
symbols = s;
moreSymbols = ms != null ? (BitSet) ms.clone() : null;
}
@@ -71,7 +71,7 @@ public class LexicalScope {
* @param symbol the symbol
* @return true if declared, false otherwise
*/
- public boolean hasSymbol(int symbol) {
+ public boolean hasSymbol(final int symbol) {
if (symbol < LONGBITS) {
return (symbols & (1L << symbol)) != 0L;
} else {
@@ -85,15 +85,15 @@ public class LexicalScope {
* @param symbol the symbol
* @return true if registered, false if symbol was already registered
*/
- public boolean addSymbol(int symbol) {
+ public boolean addSymbol(final int symbol) {
if (symbol < LONGBITS) {
if ((symbols & (1L << symbol)) != 0L) {
return false;
}
symbols |= (1L << symbol);
} else {
- int s = symbol - LONGBITS;
- BitSet ms = moreSymbols();
+ final int s = symbol - LONGBITS;
+ final BitSet ms = moreSymbols();
if (ms.get(s)) {
return false;
}
@@ -107,12 +107,12 @@ public class LexicalScope {
*
* @param cleanSymbol a (optional, may be null) functor to call for each cleaned symbol
*/
- public final void clearSymbols(java.util.function.IntConsumer cleanSymbol) {
+ public final void clearSymbols(final java.util.function.IntConsumer cleanSymbol) {
// undefine symbols getting out of scope
if (cleanSymbol != null) {
long clean = symbols;
while (clean != 0L) {
- int s = Long.numberOfTrailingZeros(clean);
+ final int s = Long.numberOfTrailingZeros(clean);
clean &= ~(1L << s);
cleanSymbol.accept(s);
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/LongRange.java b/src/main/java/org/apache/commons/jexl3/internal/LongRange.java
index 4de4035..03be0bb 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/LongRange.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/LongRange.java
@@ -38,7 +38,7 @@ public abstract class LongRange implements Collection<Long> {
* @param to the higher inclusive boundary
* @return a range
*/
- public static LongRange create(long from, long to) {
+ public static LongRange create(final long from, final long to) {
if (from <= to) {
return new LongRange.Ascending(from, to);
} else {
@@ -51,7 +51,7 @@ public abstract class LongRange implements Collection<Long> {
* @param from the lower inclusive boundary
* @param to the higher inclusive boundary
*/
- protected LongRange(long from, long to) {
+ protected LongRange(final long from, final long to) {
min = from;
max = to;
}
@@ -83,7 +83,7 @@ public abstract class LongRange implements Collection<Long> {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
@@ -114,9 +114,9 @@ public abstract class LongRange implements Collection<Long> {
}
@Override
- public boolean contains(Object o) {
+ public boolean contains(final Object o) {
if (o instanceof Number) {
- long v = ((Number) o).longValue();
+ final long v = ((Number) o).longValue();
return min <= v && v <= max;
} else {
return false;
@@ -126,7 +126,7 @@ public abstract class LongRange implements Collection<Long> {
@Override
public Object[] toArray() {
final int size = size();
- Object[] array = new Object[size];
+ final Object[] array = new Object[size];
for (int a = 0; a < size; ++a) {
array[a] = min + a;
}
@@ -135,7 +135,7 @@ public abstract class LongRange implements Collection<Long> {
@Override
@SuppressWarnings("unchecked")
- public <T> T[] toArray(T[] array) {
+ public <T> T[] toArray(final T[] array) {
final Class<?> ct = array.getClass().getComponentType();
final int length = size();
T[] copy = array;
@@ -155,8 +155,8 @@ public abstract class LongRange implements Collection<Long> {
}
@Override
- public boolean containsAll(Collection<?> c) {
- for (Object cc : c) {
+ public boolean containsAll(final Collection<?> c) {
+ for (final Object cc : c) {
if (!contains(cc)) {
return false;
}
@@ -165,27 +165,27 @@ public abstract class LongRange implements Collection<Long> {
}
@Override
- public boolean add(Long e) {
+ public boolean add(final Long e) {
throw new UnsupportedOperationException();
}
@Override
- public boolean remove(Object o) {
+ public boolean remove(final Object o) {
throw new UnsupportedOperationException();
}
@Override
- public boolean addAll(Collection<? extends Long> c) {
+ public boolean addAll(final Collection<? extends Long> c) {
throw new UnsupportedOperationException();
}
@Override
- public boolean removeAll(Collection<?> c) {
+ public boolean removeAll(final Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
- public boolean retainAll(Collection<?> c) {
+ public boolean retainAll(final Collection<?> c) {
throw new UnsupportedOperationException();
}
@@ -203,7 +203,7 @@ public abstract class LongRange implements Collection<Long> {
* @param from lower boundary
* @param to upper boundary
*/
- protected Ascending(long from, long to) {
+ protected Ascending(final long from, final long to) {
super(from, to);
}
@@ -222,7 +222,7 @@ public abstract class LongRange implements Collection<Long> {
* @param from upper boundary
* @param to lower boundary
*/
- protected Descending(long from, long to) {
+ protected Descending(final long from, final long to) {
super(from, to);
}
@@ -249,7 +249,7 @@ class AscLongIterator implements Iterator<Long> {
* @param l low boundary
* @param h high boundary
*/
- AscLongIterator(long l, long h) {
+ AscLongIterator(final long l, final long h) {
min = l;
max = h;
cursor = min;
@@ -290,7 +290,7 @@ class DescLongIterator implements Iterator<Long> {
* @param l low boundary
* @param h high boundary
*/
- DescLongIterator(long l, long h) {
+ DescLongIterator(final long l, final long h) {
min = l;
max = h;
cursor = max;
diff --git a/src/main/java/org/apache/commons/jexl3/internal/MapBuilder.java b/src/main/java/org/apache/commons/jexl3/internal/MapBuilder.java
index 66e7668..b6aac4e 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/MapBuilder.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/MapBuilder.java
@@ -31,12 +31,12 @@ public class MapBuilder implements JexlArithmetic.MapBuilder {
* Creates a new builder.
* @param size the expected map size
*/
- public MapBuilder(int size) {
+ public MapBuilder(final int size) {
map = new HashMap<Object, Object>(size);
}
@Override
- public void put(Object key, Object value) {
+ public void put(final Object key, final Object value) {
map.put(key, value);
}
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 7698cb0..c81fc0e 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Operators.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Operators.java
@@ -40,7 +40,7 @@ public class Operators {
* Constructor.
* @param owner the owning interpreter
*/
- protected Operators(InterpreterBase owner) {
+ protected Operators(final InterpreterBase owner) {
final JexlArithmetic arithmetic = owner.arithmetic;
final JexlUberspect uberspect = owner.uberspect;
this.interpreter = owner;
@@ -52,9 +52,9 @@ public class Operators {
* @param vm the JexlMethod (may be null)
* @return true of false
*/
- private boolean returnsBoolean(JexlMethod vm) {
+ private boolean returnsBoolean(final JexlMethod vm) {
if (vm !=null) {
- Class<?> rc = vm.getReturnType();
+ final Class<?> rc = vm.getReturnType();
return Boolean.TYPE.equals(rc) || Boolean.class.equals(rc);
}
return false;
@@ -65,9 +65,9 @@ public class Operators {
* @param vm the JexlMethod (may be null)
* @return true of false
*/
- private boolean returnsInteger(JexlMethod vm) {
+ private boolean returnsInteger(final JexlMethod vm) {
if (vm !=null) {
- Class<?> rc = vm.getReturnType();
+ final Class<?> rc = vm.getReturnType();
return Integer.TYPE.equals(rc) || Integer.class.equals(rc);
}
return false;
@@ -78,9 +78,9 @@ public class Operators {
* @param vm the JexlMethod (may be null)
* @return true of false
*/
- private boolean isArithmetic(JexlMethod vm) {
+ private boolean isArithmetic(final JexlMethod vm) {
if (vm instanceof MethodExecutor) {
- Method method = ((MethodExecutor) vm).getMethod();
+ final Method method = ((MethodExecutor) vm).getMethod();
return JexlArithmetic.class.equals(method.getDeclaringClass());
}
return false;
@@ -95,30 +95,30 @@ public class Operators {
* @param args the arguments
* @return the result of the operator evaluation or TRY_FAILED
*/
- protected Object tryOverload(JexlNode node, JexlOperator operator, Object... args) {
+ protected Object tryOverload(final JexlNode node, final JexlOperator operator, final Object... args) {
if (operators != null && operators.overloads(operator)) {
final JexlArithmetic arithmetic = interpreter.arithmetic;
final boolean cache = interpreter.cache;
try {
if (cache) {
- Object cached = node.jjtGetValue();
+ final Object cached = node.jjtGetValue();
if (cached instanceof JexlMethod) {
- JexlMethod me = (JexlMethod) cached;
- Object eval = me.tryInvoke(operator.getMethodName(), arithmetic, args);
+ final JexlMethod me = (JexlMethod) cached;
+ final Object eval = me.tryInvoke(operator.getMethodName(), arithmetic, args);
if (!me.tryFailed(eval)) {
return eval;
}
}
}
- JexlMethod vm = operators.getOperator(operator, args);
+ final JexlMethod vm = operators.getOperator(operator, args);
if (vm != null && !isArithmetic(vm)) {
- Object result = vm.invoke(arithmetic, args);
+ final Object result = vm.invoke(arithmetic, args);
if (cache) {
node.jjtSetValue(vm);
}
return result;
}
- } catch (Exception xany) {
+ } catch (final Exception xany) {
return interpreter.operatorError(node, operator, xany);
}
}
@@ -139,7 +139,7 @@ public class Operators {
* JexlEngine.TRY_FAILED if no operation was performed,
* the value to use as the side effect argument otherwise
*/
- protected Object tryAssignOverload(JexlNode node, JexlOperator operator, Object...args) {
+ protected Object tryAssignOverload(final JexlNode node, final JexlOperator operator, final Object...args) {
final JexlArithmetic arithmetic = interpreter.arithmetic;
if (args.length != operator.getArity()) {
return JexlEngine.TRY_FAILED;
@@ -150,21 +150,21 @@ public class Operators {
return result;
}
// call base operator
- JexlOperator base = operator.getBaseOperator();
+ final JexlOperator base = operator.getBaseOperator();
if (base == null) {
throw new IllegalArgumentException("must be called with a side-effect operator");
}
if (operators != null && operators.overloads(base)) {
// in case there is an overload on the base operator
try {
- JexlMethod vm = operators.getOperator(base, args);
+ final JexlMethod vm = operators.getOperator(base, args);
if (vm != null) {
result = vm.invoke(arithmetic, args);
if (result != JexlEngine.TRY_FAILED) {
return result;
}
}
- } catch (Exception xany) {
+ } catch (final Exception xany) {
interpreter.operatorError(node, base, xany);
}
}
@@ -191,7 +191,7 @@ public class Operators {
// unexpected, new operator added?
throw new UnsupportedOperationException(operator.getOperatorSymbol());
}
- } catch (Exception xany) {
+ } catch (final Exception xany) {
interpreter.operatorError(node, base, xany);
}
return JexlEngine.TRY_FAILED;
@@ -205,23 +205,23 @@ public class Operators {
* @param right the right operand
* @return true if left starts with right, false otherwise
*/
- protected boolean startsWith(JexlNode node, String operator, Object left, Object right) {
+ protected boolean startsWith(final JexlNode node, final String operator, final Object left, final Object right) {
final JexlArithmetic arithmetic = interpreter.arithmetic;
final JexlUberspect uberspect = interpreter.uberspect;
try {
// try operator overload
- Object result = tryOverload(node, JexlOperator.STARTSWITH, left, right);
+ final Object result = tryOverload(node, JexlOperator.STARTSWITH, left, right);
if (result instanceof Boolean) {
return (Boolean) result;
}
// use arithmetic / pattern matching ?
- Boolean matched = arithmetic.startsWith(left, right);
+ final Boolean matched = arithmetic.startsWith(left, right);
if (matched != null) {
return matched;
}
// try a startsWith method (duck type)
try {
- Object[] argv = {right};
+ final Object[] argv = {right};
JexlMethod vm = uberspect.getMethod(left, "startsWith", argv);
if (returnsBoolean(vm)) {
return (Boolean) vm.invoke(left, argv);
@@ -231,12 +231,12 @@ public class Operators {
return (Boolean) vm.invoke(left, argv);
}
}
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new JexlException(node, operator + " error", e);
}
// defaults to equal
return arithmetic.equals(left, right) ? Boolean.TRUE : Boolean.FALSE;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, operator + " error", xrt);
}
}
@@ -249,23 +249,23 @@ public class Operators {
* @param right the right operand
* @return true if left ends with right, false otherwise
*/
- protected boolean endsWith(JexlNode node, String operator, Object left, Object right) {
+ protected boolean endsWith(final JexlNode node, final String operator, final Object left, final Object right) {
final JexlArithmetic arithmetic = interpreter.arithmetic;
final JexlUberspect uberspect = interpreter.uberspect;
try {
// try operator overload
- Object result = tryOverload(node, JexlOperator.ENDSWITH, left, right);
+ final Object result = tryOverload(node, JexlOperator.ENDSWITH, left, right);
if (result instanceof Boolean) {
return (Boolean) result;
}
// use arithmetic / pattern matching ?
- Boolean matched = arithmetic.endsWith(left, right);
+ final Boolean matched = arithmetic.endsWith(left, right);
if (matched != null) {
return matched;
}
// try a endsWith method (duck type)
try {
- Object[] argv = {right};
+ final Object[] argv = {right};
JexlMethod vm = uberspect.getMethod(left, "endsWith", argv);
if (returnsBoolean(vm)) {
return (Boolean) vm.invoke(left, argv);
@@ -275,12 +275,12 @@ public class Operators {
return (Boolean) vm.invoke(left, argv);
}
}
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new JexlException(node, operator + " error", e);
}
// defaults to equal
return arithmetic.equals(left, right) ? Boolean.TRUE : Boolean.FALSE;
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, operator + " error", xrt);
}
}
@@ -297,23 +297,23 @@ public class Operators {
* @param left the right operand
* @return true if left matches right, false otherwise
*/
- protected boolean contains(JexlNode node, String op, Object left, Object right) {
+ protected boolean contains(final JexlNode node, final String op, final Object left, final Object right) {
final JexlArithmetic arithmetic = interpreter.arithmetic;
final JexlUberspect uberspect = interpreter.uberspect;
try {
// try operator overload
- Object result = tryOverload(node, JexlOperator.CONTAINS, left, right);
+ final Object result = tryOverload(node, JexlOperator.CONTAINS, left, right);
if (result instanceof Boolean) {
return (Boolean) result;
}
// use arithmetic / pattern matching ?
- Boolean matched = arithmetic.contains(left, right);
+ final Boolean matched = arithmetic.contains(left, right);
if (matched != null) {
return matched;
}
// try a contains method (duck type set)
try {
- Object[] argv = {right};
+ final Object[] argv = {right};
JexlMethod vm = uberspect.getMethod(left, "contains", argv);
if (returnsBoolean(vm)) {
return (Boolean) vm.invoke(left, argv);
@@ -323,12 +323,12 @@ public class Operators {
return (Boolean) vm.invoke(left, argv);
}
}
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new JexlException(node, op + " error", e);
}
// defaults to equal
return arithmetic.equals(left, right);
- } catch (ArithmeticException xrt) {
+ } catch (final ArithmeticException xrt) {
throw new JexlException(node, op + " error", xrt);
}
}
@@ -342,7 +342,7 @@ public class Operators {
* @param object the object to check the emptyness of
* @return the evaluation result
*/
- protected Object empty(JexlNode node, Object object) {
+ protected Object empty(final JexlNode node, final Object object) {
if (object == null) {
return true;
}
@@ -357,11 +357,11 @@ public class Operators {
result = false;
// check if there is an isEmpty method on the object that returns a
// boolean and if so, just use it
- JexlMethod vm = uberspect.getMethod(object, "isEmpty", Interpreter.EMPTY_PARAMS);
+ final JexlMethod vm = uberspect.getMethod(object, "isEmpty", Interpreter.EMPTY_PARAMS);
if (returnsBoolean(vm)) {
try {
result = vm.invoke(object, Interpreter.EMPTY_PARAMS);
- } catch (Exception xany) {
+ } catch (final Exception xany) {
interpreter.operatorError(node, JexlOperator.EMPTY, xany);
}
}
@@ -378,7 +378,7 @@ public class Operators {
* @param object the object to get the size of
* @return the evaluation result
*/
- protected Object size(JexlNode node, Object object) {
+ protected Object size(final JexlNode node, final Object object) {
if (object == null) {
return 0;
}
@@ -392,11 +392,11 @@ public class Operators {
final JexlUberspect uberspect = interpreter.uberspect;
// check if there is a size method on the object that returns an
// integer and if so, just use it
- JexlMethod vm = uberspect.getMethod(object, "size", Interpreter.EMPTY_PARAMS);
+ final JexlMethod vm = uberspect.getMethod(object, "size", Interpreter.EMPTY_PARAMS);
if (returnsInteger(vm)) {
try {
result = vm.invoke(object, Interpreter.EMPTY_PARAMS);
- } catch (Exception xany) {
+ } catch (final Exception xany) {
interpreter.operatorError(node, JexlOperator.SIZE, xany);
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/Scope.java b/src/main/java/org/apache/commons/jexl3/internal/Scope.java
index 0434de2..3b231df 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Scope.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Scope.java
@@ -76,7 +76,7 @@ public final class Scope {
* @param scope the parent scope if any
* @param parameters the list of parameters
*/
- public Scope(Scope scope, String... parameters) {
+ public Scope(final Scope scope, final String... parameters) {
if (parameters != null) {
parms = parameters.length;
namedVariables = new LinkedHashMap<String, Integer>();
@@ -96,14 +96,14 @@ public final class Scope {
}
@Override
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Scope)) {
return false;
}
- Scope scope = (Scope) o;
+ final Scope scope = (Scope) o;
if (parms != scope.parms) {
return false;
}
@@ -119,7 +119,7 @@ public final class Scope {
* @param name the symbol name
* @return the symbol index
*/
- public Integer getSymbol(String name) {
+ public Integer getSymbol(final String name) {
return getSymbol(name, true);
}
@@ -129,10 +129,10 @@ public final class Scope {
* @param capture whether solving by capturing a parent symbol is allowed
* @return the symbol index
*/
- private Integer getSymbol(String name, boolean capture) {
+ private Integer getSymbol(final String name, final boolean capture) {
Integer register = namedVariables != null ? namedVariables.get(name) : null;
if (register == null && capture && parent != null) {
- Integer pr = parent.getSymbol(name, true);
+ final Integer pr = parent.getSymbol(name, true);
if (pr != null) {
if (capturedVariables == null) {
capturedVariables = new LinkedHashMap<Integer, Integer>();
@@ -153,7 +153,7 @@ public final class Scope {
* @param symbol the symbol number
* @return true if captured, false otherwise
*/
- public boolean isCapturedSymbol(int symbol) {
+ public boolean isCapturedSymbol(final int symbol) {
return capturedVariables != null && capturedVariables.containsKey(symbol);
}
@@ -165,7 +165,7 @@ public final class Scope {
* @param name the parameter name
* @return the register index storing this variable
*/
- public int declareParameter(String name) {
+ public int declareParameter(final String name) {
if (namedVariables == null) {
namedVariables = new LinkedHashMap<String, Integer>();
} else if (vars > 0) {
@@ -188,7 +188,7 @@ public final class Scope {
* @param name the variable name
* @return the register index storing this variable
*/
- public int declareVariable(String name) {
+ public int declareVariable(final String name) {
if (namedVariables == null) {
namedVariables = new LinkedHashMap<String, Integer>();
}
@@ -199,7 +199,7 @@ public final class Scope {
vars += 1;
// check if local is redefining captured
if (parent != null) {
- Integer pr = parent.getSymbol(name, true);
+ final Integer pr = parent.getSymbol(name, true);
if (pr != null) {
if (capturedVariables == null) {
capturedVariables = new LinkedHashMap<Integer, Integer>();
@@ -218,15 +218,15 @@ public final class Scope {
* @param args the arguments
* @return the arguments array
*/
- public Frame createFrame(Frame frame, Object...args) {
+ public Frame createFrame(final Frame frame, final Object...args) {
if (namedVariables != null) {
- Object[] arguments = new Object[namedVariables.size()];
+ final Object[] arguments = new Object[namedVariables.size()];
Arrays.fill(arguments, UNDECLARED);
if (frame != null && capturedVariables != null && parent != null) {
- for (Map.Entry<Integer, Integer> capture : capturedVariables.entrySet()) {
- Integer target = capture.getKey();
- Integer source = capture.getValue();
- Object arg = frame.get(source);
+ for (final Map.Entry<Integer, Integer> capture : capturedVariables.entrySet()) {
+ final Integer target = capture.getKey();
+ final Integer source = capture.getValue();
+ final Object arg = frame.get(source);
arguments[target] = arg;
}
}
@@ -241,10 +241,10 @@ public final class Scope {
* @param symbol the symbol index
* @return the target symbol index or null if the symbol is not captured
*/
- public Integer getCaptured(int symbol) {
+ public Integer getCaptured(final int symbol) {
if (capturedVariables != null) {
- for (Map.Entry<Integer, Integer> capture : capturedVariables.entrySet()) {
- Integer source = capture.getValue();
+ for (final Map.Entry<Integer, Integer> capture : capturedVariables.entrySet()) {
+ final Integer source = capture.getValue();
if (source == symbol) {
return capture.getKey();
}
@@ -282,13 +282,13 @@ public final class Scope {
* @param bound number of known bound parameters (curry)
* @return the parameter names
*/
- protected String[] getParameters(int bound) {
- int unbound = parms - bound;
+ protected String[] getParameters(final int bound) {
+ final int unbound = parms - bound;
if (namedVariables != null && unbound > 0) {
- String[] pa = new String[unbound];
+ final String[] pa = new String[unbound];
int p = 0;
- for (Map.Entry<String, Integer> entry : namedVariables.entrySet()) {
- int argn = entry.getValue();
+ for (final Map.Entry<String, Integer> entry : namedVariables.entrySet()) {
+ final int argn = entry.getValue();
if (argn >= bound && argn < parms) {
pa[p++] = entry.getKey();
}
@@ -305,9 +305,9 @@ public final class Scope {
*/
public String[] getLocalVariables() {
if (namedVariables != null && vars > 0) {
- List<String> locals = new ArrayList<String>(vars);
- for (Map.Entry<String, Integer> entry : namedVariables.entrySet()) {
- int symnum = entry.getValue();
+ final List<String> locals = new ArrayList<String>(vars);
+ for (final Map.Entry<String, Integer> entry : namedVariables.entrySet()) {
+ final int symnum = entry.getValue();
if (symnum >= parms && (capturedVariables == null || !capturedVariables.containsKey(symnum))) {
locals.add(entry.getKey());
}
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 086b6b2..129a033 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Script.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Script.java
@@ -65,7 +65,7 @@ public class Script implements JexlScript, JexlExpression {
* @param expr the expression source.
* @param ref the parsed expression.
*/
- protected Script(Engine engine, String expr, ASTJexlScript ref) {
+ protected Script(final Engine engine, final String expr, final ASTJexlScript ref) {
jexl = engine;
source = expr;
script = ref;
@@ -81,7 +81,7 @@ public class Script implements JexlScript, JexlExpression {
* </p>
*/
protected void checkCacheVersion() {
- int uberVersion = jexl.getUberspect().getVersion();
+ final int uberVersion = jexl.getUberspect().getVersion();
if (version != uberVersion) {
// version 0 of the uberSpect is an illusion due to order of construction; no need to clear cache
if (version > 0) {
@@ -96,7 +96,7 @@ public class Script implements JexlScript, JexlExpression {
* @param args the arguments to bind to parameters
* @return the frame (may be null)
*/
- protected Frame createFrame(Object[] args) {
+ protected Frame createFrame(final Object[] args) {
return script.createFrame(args);
}
@@ -106,8 +106,8 @@ public class Script implements JexlScript, JexlExpression {
* @param frame the calling frame
* @return the interpreter
*/
- protected Interpreter createInterpreter(JexlContext context, Frame frame) {
- JexlOptions opts = jexl.options(script, context);
+ protected Interpreter createInterpreter(final JexlContext context, final Frame frame) {
+ final JexlOptions opts = jexl.options(script, context);
return jexl.createInterpreter(context, frame, opts);
}
@@ -129,8 +129,8 @@ public class Script implements JexlScript, JexlExpression {
}
@Override
- public String getParsedText(int indent) {
- Debugger debug = new Debugger();
+ public String getParsedText(final int indent) {
+ final Debugger debug = new Debugger();
debug.setIndentation(indent);
debug.debug(script, false);
return debug.toString();
@@ -140,7 +140,7 @@ public class Script implements JexlScript, JexlExpression {
public String toString() {
CharSequence src = source;
if (src == null) {
- Debugger debug = new Debugger();
+ final Debugger debug = new Debugger();
debug.debug(script, false);
src = debug.toString();
}
@@ -158,7 +158,7 @@ public class Script implements JexlScript, JexlExpression {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
@@ -176,29 +176,29 @@ public class Script implements JexlScript, JexlExpression {
}
@Override
- public Object evaluate(JexlContext context) {
+ public Object evaluate(final JexlContext context) {
return execute(context);
}
@Override
- public Object execute(JexlContext context) {
+ public Object execute(final JexlContext context) {
checkCacheVersion();
- Frame frame = createFrame(null);
- Interpreter interpreter = createInterpreter(context, frame);
+ final Frame frame = createFrame(null);
+ final Interpreter interpreter = createInterpreter(context, frame);
return interpreter.interpret(script);
}
@Override
- public Object execute(JexlContext context, Object... args) {
+ public Object execute(final JexlContext context, final Object... args) {
checkCacheVersion();
- Frame frame = createFrame(args != null && args.length > 0 ? args : null);
- Interpreter interpreter = createInterpreter(context, frame);
+ final Frame frame = createFrame(args != null && args.length > 0 ? args : null);
+ final Interpreter interpreter = createInterpreter(context, frame);
return interpreter.interpret(script);
}
@Override
- public JexlScript curry(Object... args) {
- String[] parms = script.getParameters();
+ public JexlScript curry(final Object... args) {
+ final String[] parms = script.getParameters();
if (parms == null || parms.length == 0) {
return this;
}
@@ -263,7 +263,7 @@ public class Script implements JexlScript, JexlExpression {
* @return the callable
*/
@Override
- public Callable callable(JexlContext context) {
+ public Callable callable(final JexlContext context) {
return callable(context, (Object[]) null);
}
@@ -276,7 +276,7 @@ public class Script implements JexlScript, JexlExpression {
* @return the callable
*/
@Override
- public Callable callable(JexlContext context, Object... args) {
+ public Callable callable(final JexlContext context, final Object... args) {
return new Callable(createInterpreter(context, script.createFrame(args)));
}
@@ -293,7 +293,7 @@ public class Script implements JexlScript, JexlExpression {
* The base constructor.
* @param intrprtr the interpreter to use
*/
- protected Callable(Interpreter intrprtr) {
+ protected Callable(final Interpreter intrprtr) {
this.interpreter = intrprtr;
this.result = intrprtr;
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/ScriptVisitor.java b/src/main/java/org/apache/commons/jexl3/internal/ScriptVisitor.java
index 94e946a..19afd27 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/ScriptVisitor.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/ScriptVisitor.java
@@ -104,7 +104,7 @@ public class ScriptVisitor extends ParserVisitor {
* @param data some data context
* @return the visit result or null if jscript was not a Script implementation
*/
- public Object visitExpression (JexlExpression jscript, Object data) {
+ public Object visitExpression (final JexlExpression jscript, final Object data) {
if (jscript instanceof Script) {
return ((Script) jscript).getScript().jjtAccept(this, data);
}
@@ -117,7 +117,7 @@ public class ScriptVisitor extends ParserVisitor {
* @param data some data context
* @return the visit result or null if jscript was not a Script implementation
*/
- public Object visitScript(JexlScript jscript, Object data) {
+ public Object visitScript(final JexlScript jscript, final Object data) {
if (jscript instanceof Script) {
return ((Script) jscript).getScript().jjtAccept(this, data);
}
@@ -131,372 +131,372 @@ public class ScriptVisitor extends ParserVisitor {
* @param data visitor pattern argument
* @return visitor pattern value
*/
- protected Object visitNode(JexlNode node, Object data) {
+ protected Object visitNode(final JexlNode node, final Object data) {
return node.childrenAccept(this, data);
}
@Override
- protected Object visit(ASTJexlScript node, Object data) {
+ protected Object visit(final ASTJexlScript node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTBlock node, Object data) {
+ protected Object visit(final ASTBlock node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTIfStatement node, Object data) {
+ protected Object visit(final ASTIfStatement node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTWhileStatement node, Object data) {
+ protected Object visit(final ASTWhileStatement node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTDoWhileStatement node, Object data) {
+ protected Object visit(final ASTDoWhileStatement node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTContinue node, Object data) {
+ protected Object visit(final ASTContinue node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTBreak node, Object data) {
+ protected Object visit(final ASTBreak node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTForeachStatement node, Object data) {
+ protected Object visit(final ASTForeachStatement node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTReturnStatement node, Object data) {
+ protected Object visit(final ASTReturnStatement node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTAssignment node, Object data) {
+ protected Object visit(final ASTAssignment node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTVar node, Object data) {
+ protected Object visit(final ASTVar node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTReference node, Object data) {
+ protected Object visit(final ASTReference node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTTernaryNode node, Object data) {
+ protected Object visit(final ASTTernaryNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTNullpNode node, Object data) {
+ protected Object visit(final ASTNullpNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTOrNode node, Object data) {
+ protected Object visit(final ASTOrNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTAndNode node, Object data) {
+ protected Object visit(final ASTAndNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTBitwiseOrNode node, Object data) {
+ protected Object visit(final ASTBitwiseOrNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTBitwiseXorNode node, Object data) {
+ protected Object visit(final ASTBitwiseXorNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTBitwiseAndNode node, Object data) {
+ protected Object visit(final ASTBitwiseAndNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTEQNode node, Object data) {
+ protected Object visit(final ASTEQNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTNENode node, Object data) {
+ protected Object visit(final ASTNENode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTLTNode node, Object data) {
+ protected Object visit(final ASTLTNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTGTNode node, Object data) {
+ protected Object visit(final ASTGTNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTLENode node, Object data) {
+ protected Object visit(final ASTLENode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTGENode node, Object data) {
+ protected Object visit(final ASTGENode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTERNode node, Object data) {
+ protected Object visit(final ASTERNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTNRNode node, Object data) {
+ protected Object visit(final ASTNRNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSWNode node, Object data) {
+ protected Object visit(final ASTSWNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTNSWNode node, Object data) {
+ protected Object visit(final ASTNSWNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTEWNode node, Object data) {
+ protected Object visit(final ASTEWNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTNEWNode node, Object data) {
+ protected Object visit(final ASTNEWNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTAddNode node, Object data) {
+ protected Object visit(final ASTAddNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSubNode node, Object data) {
+ protected Object visit(final ASTSubNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTMulNode node, Object data) {
+ protected Object visit(final ASTMulNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTDivNode node, Object data) {
+ protected Object visit(final ASTDivNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTModNode node, Object data) {
+ protected Object visit(final ASTModNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTUnaryMinusNode node, Object data) {
+ protected Object visit(final ASTUnaryMinusNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTUnaryPlusNode node, Object data) {
+ protected Object visit(final ASTUnaryPlusNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTBitwiseComplNode node, Object data) {
+ protected Object visit(final ASTBitwiseComplNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTNotNode node, Object data) {
+ protected Object visit(final ASTNotNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTIdentifier node, Object data) {
+ protected Object visit(final ASTIdentifier node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTNullLiteral node, Object data) {
+ protected Object visit(final ASTNullLiteral node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTTrueNode node, Object data) {
+ protected Object visit(final ASTTrueNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTFalseNode node, Object data) {
+ protected Object visit(final ASTFalseNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTNumberLiteral node, Object data) {
+ protected Object visit(final ASTNumberLiteral node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTStringLiteral node, Object data) {
+ protected Object visit(final ASTStringLiteral node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTRegexLiteral node, Object data) {
+ protected Object visit(final ASTRegexLiteral node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSetLiteral node, Object data) {
+ protected Object visit(final ASTSetLiteral node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTExtendedLiteral node, Object data) {
+ protected Object visit(final ASTExtendedLiteral node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTArrayLiteral node, Object data) {
+ protected Object visit(final ASTArrayLiteral node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTRangeNode node, Object data) {
+ protected Object visit(final ASTRangeNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTMapLiteral node, Object data) {
+ protected Object visit(final ASTMapLiteral node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTMapEntry node, Object data) {
+ protected Object visit(final ASTMapEntry node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTEmptyFunction node, Object data) {
+ protected Object visit(final ASTEmptyFunction node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSizeFunction node, Object data) {
+ protected Object visit(final ASTSizeFunction node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTFunctionNode node, Object data) {
+ protected Object visit(final ASTFunctionNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTMethodNode node, Object data) {
+ protected Object visit(final ASTMethodNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTConstructorNode node, Object data) {
+ protected Object visit(final ASTConstructorNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTArrayAccess node, Object data) {
+ protected Object visit(final ASTArrayAccess node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTIdentifierAccess node, Object data) {
+ protected Object visit(final ASTIdentifierAccess node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTArguments node, Object data) {
+ protected Object visit(final ASTArguments node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTReferenceExpression node, Object data) {
+ protected Object visit(final ASTReferenceExpression node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSetAddNode node, Object data) {
+ protected Object visit(final ASTSetAddNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSetSubNode node, Object data) {
+ protected Object visit(final ASTSetSubNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSetMultNode node, Object data) {
+ protected Object visit(final ASTSetMultNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSetDivNode node, Object data) {
+ protected Object visit(final ASTSetDivNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSetModNode node, Object data) {
+ protected Object visit(final ASTSetModNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSetAndNode node, Object data) {
+ protected Object visit(final ASTSetAndNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSetOrNode node, Object data) {
+ protected Object visit(final ASTSetOrNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTSetXorNode node, Object data) {
+ protected Object visit(final ASTSetXorNode node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTJxltLiteral node, Object data) {
+ protected Object visit(final ASTJxltLiteral node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTAnnotation node, Object data) {
+ protected Object visit(final ASTAnnotation node, final Object data) {
return visitNode(node, data);
}
@Override
- protected Object visit(ASTAnnotatedStatement node, Object data) {
+ protected Object visit(final ASTAnnotatedStatement node, final Object data) {
return visitNode(node, data);
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/SetBuilder.java b/src/main/java/org/apache/commons/jexl3/internal/SetBuilder.java
index cdb0a36..bb33ff2 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/SetBuilder.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/SetBuilder.java
@@ -31,12 +31,12 @@ public class SetBuilder implements JexlArithmetic.SetBuilder {
* Creates a new builder.
* @param size the expected set size
*/
- public SetBuilder(int size) {
+ public SetBuilder(final int size) {
set = new HashSet<Object>(size);
}
@Override
- public void add(Object value) {
+ public void add(final Object value) {
set.add(value);
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java b/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java
index 5328cab..3028e8a 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/SoftCache.java
@@ -57,7 +57,7 @@ public class SoftCache<K, V> {
*
* @param theSize the cache size
*/
- SoftCache(int theSize) {
+ SoftCache(final int theSize) {
size = theSize;
lock = new ReentrantReadWriteLock();
}
@@ -89,7 +89,7 @@ public class SoftCache<K, V> {
* @param key the cache entry key
* @return the cache entry value
*/
- public V get(K key) {
+ public V get(final K key) {
lock.readLock().lock();
try {
final Map<K, V> map = ref != null ? ref.get() : null;
@@ -105,7 +105,7 @@ public class SoftCache<K, V> {
* @param key the cache entry key
* @param script the cache entry value
*/
- public void put(K key, V script) {
+ public void put(final K key, final V script) {
lock.writeLock().lock();
try {
Map<K, V> map = ref != null ? ref.get() : null;
@@ -129,13 +129,13 @@ public class SoftCache<K, V> {
public List<Map.Entry<K, V>> entries() {
lock.readLock().lock();
try {
- Map<K, V> map = ref != null ? ref.get() : null;
+ final Map<K, V> map = ref != null ? ref.get() : null;
if (map == null) {
return Collections.emptyList();
}
final Set<Map.Entry<K, V>> set = map.entrySet();
final List<Map.Entry<K, V>> entries = new ArrayList<Map.Entry<K, V>>(set.size());
- for (Map.Entry<K, V> e : set) {
+ for (final Map.Entry<K, V> e : set) {
entries.add(new SoftCacheEntry<K, V>(e));
}
return entries;
@@ -160,7 +160,7 @@ public class SoftCache<K, V> {
private static final long serialVersionUID = 1L;
@Override
- protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
+ protected boolean removeEldestEntry(final Map.Entry<K, V> eldest) {
return super.size() > cacheSize;
}
};
@@ -188,7 +188,7 @@ class SoftCacheEntry<K, V> implements Map.Entry<K, V> {
*
* @param e the entry to clone
*/
- SoftCacheEntry(Map.Entry<K, V> e) {
+ SoftCacheEntry(final Map.Entry<K, V> e) {
key = e.getKey();
value = e.getValue();
}
@@ -204,7 +204,7 @@ class SoftCacheEntry<K, V> implements Map.Entry<K, V> {
}
@Override
- public V setValue(V v) {
+ public V setValue(final V v) {
throw new UnsupportedOperationException("Not supported.");
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/Source.java b/src/main/java/org/apache/commons/jexl3/internal/Source.java
index c7dd2e6..a9d16f2 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Source.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Source.java
@@ -38,7 +38,7 @@ public final class Source {
* @param theFeatures the features
* @param theStr the script source
*/
- Source(JexlFeatures theFeatures, String theStr) { // CSOFF: MagicNumber
+ Source(final JexlFeatures theFeatures, final String theStr) { // CSOFF: MagicNumber
this.features = theFeatures;
this.str = theStr;
int hash = 3;
@@ -60,7 +60,7 @@ public final class Source {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
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 aa45923..6008aa8 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/TemplateDebugger.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateDebugger.java
@@ -60,9 +60,9 @@ public class TemplateDebugger extends Debugger {
* @param je the expression
* @return true if the expression was a {@link TemplateExpression} instance, false otherwise
*/
- public boolean debug(JxltEngine.Expression je) {
+ public boolean debug(final JxltEngine.Expression je) {
if (je instanceof TemplateExpression) {
- TemplateEngine.TemplateExpression te = (TemplateEngine.TemplateExpression) je;
+ final TemplateEngine.TemplateExpression te = (TemplateEngine.TemplateExpression) je;
return visit(te, this) != null;
} else {
return false;
@@ -74,9 +74,9 @@ public class TemplateDebugger extends Debugger {
* @param jt the template
* @return true if the template was a {@link TemplateScript} instance, false otherwise
*/
- public boolean debug(JxltEngine.Template jt) {
+ public boolean debug(final JxltEngine.Template jt) {
if (jt instanceof TemplateScript) {
- TemplateScript ts = (TemplateScript) jt;
+ final TemplateScript ts = (TemplateScript) jt;
// ensure expr is not null for templates
this.exprs = ts.getExpressions() == null? new TemplateExpression[0] : ts.getExpressions();
this.script = ts.getScript();
@@ -85,9 +85,9 @@ public class TemplateDebugger extends Debugger {
indentLevel = 0;
builder.setLength(0);
cause = script;
- int num = script.jjtGetNumChildren();
+ final int num = script.jjtGetNumChildren();
for (int i = 0; i < num; ++i) {
- JexlNode child = script.jjtGetChild(i);
+ final JexlNode child = script.jjtGetChild(i);
acceptStatement(child, null);
}
// the last line
@@ -103,7 +103,7 @@ public class TemplateDebugger extends Debugger {
@Override
- protected Object visit(ASTBlock node, Object data) {
+ protected Object visit(final ASTBlock node, final Object data) {
// if not really a template, must use super impl
if (exprs == null) {
return super.visit(node, data);
@@ -116,9 +116,9 @@ public class TemplateDebugger extends Debugger {
} else {
builder.append(' ');
}
- int num = node.jjtGetNumChildren();
+ final int num = node.jjtGetNumChildren();
for (int i = 0; i < num; ++i) {
- JexlNode child = node.jjtGetChild(i);
+ final JexlNode child = node.jjtGetChild(i);
acceptStatement(child, data);
}
// before we close this block node, $$ might be needed
@@ -137,12 +137,12 @@ public class TemplateDebugger extends Debugger {
}
@Override
- protected Object acceptStatement(JexlNode child, Object data) {
+ protected Object acceptStatement(final JexlNode child, final Object data) {
// if not really a template, must use super impl
if (exprs == null) {
return super.acceptStatement(child, data);
}
- TemplateExpression te = getPrintStatement(child);
+ final TemplateExpression te = getPrintStatement(child);
if (te != null) {
// if statement is a jexl:print(...), may need to prepend '\n'
newJxltLine();
@@ -159,17 +159,17 @@ public class TemplateDebugger extends Debugger {
* @param child the node to check
* @return the expression number or -1 if the node is not a jexl:print
*/
- private TemplateExpression getPrintStatement(JexlNode child) {
+ private TemplateExpression getPrintStatement(final JexlNode child) {
if (exprs != null && child instanceof ASTFunctionNode) {
- ASTFunctionNode node = (ASTFunctionNode) child;
- ASTIdentifier ns = (ASTIdentifier) node.jjtGetChild(0);
- JexlNode args = node.jjtGetChild(1);
+ final ASTFunctionNode node = (ASTFunctionNode) child;
+ final ASTIdentifier ns = (ASTIdentifier) node.jjtGetChild(0);
+ final JexlNode args = node.jjtGetChild(1);
if ("jexl".equals(ns.getNamespace())
&& "print".equals(ns.getName())
&& args.jjtGetNumChildren() == 1
&& args.jjtGetChild(0) instanceof ASTNumberLiteral) {
- ASTNumberLiteral exprn = (ASTNumberLiteral) args.jjtGetChild(0);
- int n = exprn.getLiteral().intValue();
+ final ASTNumberLiteral exprn = (ASTNumberLiteral) args.jjtGetChild(0);
+ final int n = exprn.getLiteral().intValue();
if (n >= 0 && n < exprs.length) {
return exprs[n];
}
@@ -182,12 +182,12 @@ public class TemplateDebugger extends Debugger {
* Insert $$ and \n when needed.
*/
private void newJexlLine() {
- int length = builder.length();
+ final int length = builder.length();
if (length == 0) {
builder.append("$$ ");
} else {
for (int i = length - 1; i >= 0; --i) {
- char c = builder.charAt(i);
+ final char c = builder.charAt(i);
switch (c) {
case '\n':
builder.append("$$ ");
@@ -208,9 +208,9 @@ public class TemplateDebugger extends Debugger {
* Insert \n when needed.
*/
private void newJxltLine() {
- int length = builder.length();
+ final int length = builder.length();
for (int i = length - 1; i >= 0; --i) {
- char c = builder.charAt(i);
+ final char c = builder.charAt(i);
switch (c) {
case '\n':
case ';':
@@ -229,7 +229,7 @@ public class TemplateDebugger extends Debugger {
* @param data the visitor argument
* @return the visitor argument
*/
- private Object visit(TemplateExpression expr, Object data) {
+ private Object visit(final TemplateExpression expr, final Object data) {
Object r;
switch (expr.getType()) {
case CONSTANT:
@@ -259,7 +259,7 @@ public class TemplateDebugger extends Debugger {
* @param data the visitor argument
* @return the visitor argument
*/
- private Object visit(ConstantExpression expr, Object data) {
+ private Object visit(final ConstantExpression expr, final Object data) {
expr.asString(builder);
return data;
}
@@ -270,7 +270,7 @@ public class TemplateDebugger extends Debugger {
* @param data the visitor argument
* @return the visitor argument
*/
- private Object visit(ImmediateExpression expr, Object data) {
+ private Object visit(final ImmediateExpression expr, final Object data) {
builder.append(expr.isImmediate() ? '$' : '#');
builder.append('{');
super.accept(expr.node, data);
@@ -284,7 +284,7 @@ public class TemplateDebugger extends Debugger {
* @param data the visitor argument
* @return the visitor argument
*/
- private Object visit(DeferredExpression expr, Object data) {
+ private Object visit(final DeferredExpression expr, final Object data) {
builder.append(expr.isImmediate() ? '$' : '#');
builder.append('{');
super.accept(expr.node, data);
@@ -298,7 +298,7 @@ public class TemplateDebugger extends Debugger {
* @param data the visitor argument
* @return the visitor argument
*/
- private Object visit(NestedExpression expr, Object data) {
+ private Object visit(final NestedExpression expr, final Object data) {
super.accept(expr.node, data);
return data;
}
@@ -308,8 +308,8 @@ public class TemplateDebugger extends Debugger {
* @param data the visitor argument
* @return the visitor argument
*/
- private Object visit(CompositeExpression expr, Object data) {
- for (TemplateExpression ce : expr.exprs) {
+ private Object visit(final CompositeExpression expr, final Object data) {
+ for (final TemplateExpression ce : expr.exprs) {
visit(ce, data);
}
return data;
diff --git a/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java b/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java
index 72a081a..33a49db 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateEngine.java
@@ -60,7 +60,7 @@ public final class TemplateEngine extends JxltEngine {
* @param immediate the immediate template expression character, default is '$'
* @param deferred the deferred template expression character, default is '#'
*/
- public TemplateEngine(Engine aJexl, boolean noScript, int cacheSize, char immediate, char deferred) {
+ public TemplateEngine(final Engine aJexl, final boolean noScript, final int cacheSize, final char immediate, final char deferred) {
this.jexl = aJexl;
this.cache = new SoftCache<>(cacheSize);
immediateChar = immediate;
@@ -106,7 +106,7 @@ public final class TemplateEngine extends JxltEngine {
* Creates an ExpressionType.
* @param idx the index for this type in counters arrays.
*/
- ExpressionType(int idx) {
+ ExpressionType(final int idx) {
this.index = idx;
}
}
@@ -125,7 +125,7 @@ public final class TemplateEngine extends JxltEngine {
* Creates a builder.
* @param size the initial TemplateExpression array size
*/
- private ExpressionBuilder(int size) {
+ private ExpressionBuilder(final int size) {
counts = new int[]{0, 0, 0};
expressions = new ArrayList<>(size <= 0 ? 3 : size);
}
@@ -134,7 +134,7 @@ public final class TemplateEngine extends JxltEngine {
* Adds an TemplateExpression to the list of expressions, maintain per-type counts.
* @param expr the TemplateExpression to add
*/
- private void add(TemplateExpression expr) {
+ private void add(final TemplateExpression expr) {
counts[expr.getType().index] += 1;
expressions.add(expr);
}
@@ -149,7 +149,7 @@ public final class TemplateEngine extends JxltEngine {
* @param error the builder to fill
* @return the builder
*/
- private StringBuilder toString(StringBuilder error) {
+ private StringBuilder toString(final StringBuilder error) {
error.append("exprs{");
error.append(expressions.size());
error.append(", constant:");
@@ -168,13 +168,13 @@ public final class TemplateEngine extends JxltEngine {
* @param source the source TemplateExpression
* @return an TemplateExpression
*/
- private TemplateExpression build(TemplateEngine el, TemplateExpression source) {
+ private TemplateExpression build(final TemplateEngine el, final TemplateExpression source) {
int sum = 0;
- for (int count : counts) {
+ for (final int count : counts) {
sum += count;
}
if (expressions.size() != sum) {
- StringBuilder error = new StringBuilder("parsing algorithm error: ");
+ final StringBuilder error = new StringBuilder("parsing algorithm error: ");
throw new IllegalStateException(toString(error).toString());
}
// if only one sub-expr, no need to create a composite
@@ -216,7 +216,7 @@ public final class TemplateEngine extends JxltEngine {
* Creates an TemplateExpression.
* @param src the source TemplateExpression if any
*/
- TemplateExpression(TemplateExpression src) {
+ TemplateExpression(final TemplateExpression src) {
this.source = src != null ? src : this;
}
@@ -243,7 +243,7 @@ public final class TemplateEngine extends JxltEngine {
@Override
public final String toString() {
- StringBuilder strb = new StringBuilder();
+ final StringBuilder strb = new StringBuilder();
asString(strb);
if (source != this) {
strb.append(" /*= ");
@@ -255,7 +255,7 @@ public final class TemplateEngine extends JxltEngine {
@Override
public String asString() {
- StringBuilder strb = new StringBuilder();
+ final StringBuilder strb = new StringBuilder();
asString(strb);
return strb.toString();
}
@@ -274,12 +274,12 @@ public final class TemplateEngine extends JxltEngine {
* Fills up the list of variables accessed by this unified expression.
* @param collector the variable collector
*/
- protected void getVariables(Engine.VarCollector collector) {
+ protected void getVariables(final Engine.VarCollector collector) {
// nothing to do
}
@Override
- public final TemplateExpression prepare(JexlContext context) {
+ public final TemplateExpression prepare(final JexlContext context) {
return prepare(null, context);
}
@@ -290,12 +290,12 @@ public final class TemplateEngine extends JxltEngine {
* @return the expression value
* @throws JexlException
*/
- protected final TemplateExpression prepare(Frame frame, JexlContext context) {
+ protected final TemplateExpression prepare(final Frame frame, final JexlContext context) {
try {
- Interpreter interpreter = jexl.createInterpreter(context, frame, jexl.options(context));
+ final Interpreter interpreter = jexl.createInterpreter(context, frame, jexl.options(context));
return prepare(interpreter);
- } catch (JexlException xjexl) {
- JexlException xuel = createException(xjexl.getInfo(), "prepare", this, xjexl);
+ } catch (final JexlException xjexl) {
+ final JexlException xuel = createException(xjexl.getInfo(), "prepare", this, xjexl);
if (jexl.isSilent()) {
jexl.logger.warn(xuel.getMessage(), xuel.getCause());
return null;
@@ -310,12 +310,12 @@ public final class TemplateEngine extends JxltEngine {
* @return a prepared unified expression
* @throws JexlException (only for nested and composite)
*/
- protected TemplateExpression prepare(Interpreter interpreter) {
+ protected TemplateExpression prepare(final Interpreter interpreter) {
return this;
}
@Override
- public final Object evaluate(JexlContext context) {
+ public final Object evaluate(final JexlContext context) {
return evaluate(null, context);
}
@@ -324,7 +324,7 @@ public final class TemplateEngine extends JxltEngine {
* @param context the context
* @return the options
*/
- protected JexlOptions options(JexlContext context) {
+ protected JexlOptions options(final JexlContext context) {
return jexl.options(null, context);
}
@@ -335,18 +335,18 @@ public final class TemplateEngine extends JxltEngine {
* @return the expression value
* @throws JexlException
*/
- protected final Object evaluate(Frame frame, JexlContext context) {
+ protected final Object evaluate(final Frame frame, final JexlContext context) {
try {
- JexlOptions options = options(context);
- TemplateInterpreter.Arguments args = new TemplateInterpreter
+ final JexlOptions options = options(context);
+ final TemplateInterpreter.Arguments args = new TemplateInterpreter
.Arguments(jexl)
.context(context)
.options(options)
.frame(frame);
- Interpreter interpreter = new TemplateInterpreter(args);
+ final Interpreter interpreter = new TemplateInterpreter(args);
return evaluate(interpreter);
- } catch (JexlException xjexl) {
- JexlException xuel = createException(xjexl.getInfo(), "evaluate", this, xjexl);
+ } catch (final JexlException xjexl) {
+ final JexlException xuel = createException(xjexl.getInfo(), "evaluate", this, xjexl);
if (jexl.isSilent()) {
jexl.logger.warn(xuel.getMessage(), xuel.getCause());
return null;
@@ -379,7 +379,7 @@ public final class TemplateEngine extends JxltEngine {
* @param val the constant value
* @param source the source TemplateExpression if any
*/
- ConstantExpression(Object val, TemplateExpression source) {
+ ConstantExpression(Object val, final TemplateExpression source) {
super(source);
if (val == null) {
throw new NullPointerException("constant can not be null");
@@ -396,7 +396,7 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- public StringBuilder asString(StringBuilder strb) {
+ public StringBuilder asString(final StringBuilder strb) {
if (value != null) {
strb.append(value.toString());
}
@@ -404,7 +404,7 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- protected Object evaluate(Interpreter interpreter) {
+ protected Object evaluate(final Interpreter interpreter) {
return value;
}
}
@@ -422,14 +422,14 @@ public final class TemplateEngine extends JxltEngine {
* @param theNode the unified expression as an AST
* @param theSource the source unified expression if any
*/
- protected JexlBasedExpression(CharSequence theExpr, JexlNode theNode, TemplateExpression theSource) {
+ protected JexlBasedExpression(final CharSequence theExpr, final JexlNode theNode, final TemplateExpression theSource) {
super(theSource);
this.expr = theExpr;
this.node = theNode;
}
@Override
- public StringBuilder asString(StringBuilder strb) {
+ public StringBuilder asString(final StringBuilder strb) {
strb.append(isImmediate() ? immediateChar : deferredChar);
strb.append("{");
strb.append(expr);
@@ -438,24 +438,24 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- protected JexlOptions options(JexlContext context) {
+ protected JexlOptions options(final JexlContext context) {
return jexl.options(node instanceof ASTJexlScript? (ASTJexlScript) node : null, context);
}
@Override
- protected Object evaluate(Interpreter interpreter) {
+ protected Object evaluate(final Interpreter interpreter) {
return interpreter.interpret(node);
}
@Override
public Set<List<String>> getVariables() {
- Engine.VarCollector collector = jexl.varCollector();
+ final Engine.VarCollector collector = jexl.varCollector();
getVariables(collector);
return collector.collected();
}
@Override
- protected void getVariables(Engine.VarCollector collector) {
+ protected void getVariables(final Engine.VarCollector collector) {
jexl.getVariables(node instanceof ASTJexlScript? (ASTJexlScript) node : null, node, collector);
}
@@ -473,7 +473,7 @@ public final class TemplateEngine extends JxltEngine {
* @param node the unified expression as an AST
* @param source the source unified expression if any
*/
- ImmediateExpression(CharSequence expr, JexlNode node, TemplateExpression source) {
+ ImmediateExpression(final CharSequence expr, final JexlNode node, final TemplateExpression source) {
super(expr, node, source);
}
@@ -483,9 +483,9 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- protected TemplateExpression prepare(Interpreter interpreter) {
+ protected TemplateExpression prepare(final Interpreter interpreter) {
// evaluate immediate as constant
- Object value = evaluate(interpreter);
+ final Object value = evaluate(interpreter);
return value != null ? new ConstantExpression(value, source) : null;
}
}
@@ -498,7 +498,7 @@ public final class TemplateEngine extends JxltEngine {
* @param node the unified expression as an AST
* @param source the source unified expression if any
*/
- DeferredExpression(CharSequence expr, JexlNode node, TemplateExpression source) {
+ DeferredExpression(final CharSequence expr, final JexlNode node, final TemplateExpression source) {
super(expr, node, source);
}
@@ -513,12 +513,12 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- protected TemplateExpression prepare(Interpreter interpreter) {
+ protected TemplateExpression prepare(final Interpreter interpreter) {
return new ImmediateExpression(expr, node, source);
}
@Override
- protected void getVariables(Engine.VarCollector collector) {
+ protected void getVariables(final Engine.VarCollector collector) {
// noop
}
}
@@ -535,7 +535,7 @@ public final class TemplateEngine extends JxltEngine {
* @param node the unified expression as an AST
* @param source the source unified expression if any
*/
- NestedExpression(CharSequence expr, JexlNode node, TemplateExpression source) {
+ NestedExpression(final CharSequence expr, final JexlNode node, final TemplateExpression source) {
super(expr, node, source);
if (this.source != this) {
throw new IllegalArgumentException("Nested TemplateExpression can not have a source");
@@ -543,7 +543,7 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- public StringBuilder asString(StringBuilder strb) {
+ public StringBuilder asString(final StringBuilder strb) {
strb.append(expr);
return strb;
}
@@ -559,14 +559,14 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- protected TemplateExpression prepare(Interpreter interpreter) {
- String value = interpreter.interpret(node).toString();
- JexlNode dnode = jexl.parse(node.jexlInfo(), noscript, value, null);
+ protected TemplateExpression prepare(final Interpreter interpreter) {
+ final String value = interpreter.interpret(node).toString();
+ final JexlNode dnode = jexl.parse(node.jexlInfo(), noscript, value, null);
return new ImmediateExpression(value, dnode, this);
}
@Override
- protected Object evaluate(Interpreter interpreter) {
+ protected Object evaluate(final Interpreter interpreter) {
return prepare(interpreter).evaluate(interpreter);
}
}
@@ -584,7 +584,7 @@ public final class TemplateEngine extends JxltEngine {
* @param list the sub-expressions
* @param src the source for this expresion if any
*/
- CompositeExpression(int[] counters, ArrayList<TemplateExpression> list, TemplateExpression src) {
+ CompositeExpression(final int[] counters, final ArrayList<TemplateExpression> list, final TemplateExpression src) {
super(src);
this.exprs = list.toArray(new TemplateExpression[list.size()]);
this.meta = (counters[ExpressionType.DEFERRED.index] > 0 ? 2 : 0)
@@ -603,8 +603,8 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- public StringBuilder asString(StringBuilder strb) {
- for (TemplateExpression e : exprs) {
+ public StringBuilder asString(final StringBuilder strb) {
+ for (final TemplateExpression e : exprs) {
e.asString(strb);
}
return strb;
@@ -612,8 +612,8 @@ public final class TemplateEngine extends JxltEngine {
@Override
public Set<List<String>> getVariables() {
- Engine.VarCollector collector = jexl.varCollector();
- for (TemplateExpression expr : exprs) {
+ final Engine.VarCollector collector = jexl.varCollector();
+ for (final TemplateExpression expr : exprs) {
expr.getVariables(collector);
}
return collector.collected();
@@ -624,14 +624,14 @@ public final class TemplateEngine extends JxltEngine {
* @param collector the variable collector
*/
@Override
- protected void getVariables(Engine.VarCollector collector) {
- for (TemplateExpression expr : exprs) {
+ protected void getVariables(final Engine.VarCollector collector) {
+ for (final TemplateExpression expr : exprs) {
expr.getVariables(collector);
}
}
@Override
- protected TemplateExpression prepare(Interpreter interpreter) {
+ protected TemplateExpression prepare(final Interpreter interpreter) {
// if this composite is not its own source, it is already prepared
if (source != this) {
return this;
@@ -641,8 +641,8 @@ public final class TemplateEngine extends JxltEngine {
final ExpressionBuilder builder = new ExpressionBuilder(size);
// tracking whether prepare will return a different expression
boolean eq = true;
- for (TemplateExpression expr : exprs) {
- TemplateExpression prepared = expr.prepare(interpreter);
+ for (final TemplateExpression expr : exprs) {
+ final TemplateExpression prepared = expr.prepare(interpreter);
// add it if not null
if (prepared != null) {
builder.add(prepared);
@@ -654,11 +654,11 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- protected Object evaluate(Interpreter interpreter) {
+ protected Object evaluate(final Interpreter interpreter) {
Object value;
// common case: evaluate all expressions & concatenate them as a string
- StringBuilder strb = new StringBuilder();
- for (TemplateExpression expr : exprs) {
+ final StringBuilder strb = new StringBuilder();
+ for (final TemplateExpression expr : exprs) {
value = expr.evaluate(interpreter);
if (value != null) {
strb.append(value.toString());
@@ -671,7 +671,7 @@ public final class TemplateEngine extends JxltEngine {
@Override
- public JxltEngine.Expression createExpression(JexlInfo info, String expression) {
+ public JxltEngine.Expression createExpression(JexlInfo info, final String expression) {
if (info == null) {
info = jexl.createInfo();
}
@@ -683,7 +683,7 @@ public final class TemplateEngine extends JxltEngine {
stmt = parseExpression(info, expression, null);
cache.put(expression, stmt);
}
- } catch (JexlException xjexl) {
+ } catch (final JexlException xjexl) {
xuel = new Exception(xjexl.getInfo(), "failed to parse '" + expression + "'", xjexl);
}
if (xuel != null) {
@@ -705,17 +705,17 @@ public final class TemplateEngine extends JxltEngine {
* @param xany the exception
* @return an exception containing an explicit error message
*/
- static Exception createException(JexlInfo info, String action, TemplateExpression expr, java.lang.Exception xany) {
- StringBuilder strb = new StringBuilder("failed to ");
+ static Exception createException(final JexlInfo info, final String action, final TemplateExpression expr, final java.lang.Exception xany) {
+ final StringBuilder strb = new StringBuilder("failed to ");
strb.append(action);
if (expr != null) {
strb.append(" '");
strb.append(expr.toString());
strb.append("'");
}
- Throwable cause = xany.getCause();
+ final Throwable cause = xany.getCause();
if (cause != null) {
- String causeMsg = cause.getMessage();
+ final String causeMsg = cause.getMessage();
if (causeMsg != null) {
strb.append(", ");
strb.append(causeMsg);
@@ -748,17 +748,17 @@ public final class TemplateEngine extends JxltEngine {
* @param c the separator character
* @return the new position to read the source from
*/
- private static int append(StringBuilder strb, CharSequence expr, int position, char c) {
+ private static int append(final StringBuilder strb, final CharSequence expr, final int position, final char c) {
strb.append(c);
if (c != '"' && c != '\'') {
return position;
}
// read thru strings
- int end = expr.length();
+ final int end = expr.length();
boolean escape= false;
int index = position + 1;
for (; index < end; ++index) {
- char ec = expr.charAt(index);
+ final char ec = expr.charAt(index);
strb.append(ec);
if (ec == '\\') {
escape = !escape;
@@ -779,7 +779,7 @@ public final class TemplateEngine extends JxltEngine {
* @return the unified expression instance
* @throws JexlException if an error occur during parsing
*/
- TemplateExpression parseExpression(JexlInfo info, String expr, Scope scope) { // CSOFF: MethodLength
+ TemplateExpression parseExpression(final JexlInfo info, final String expr, final Scope scope) { // CSOFF: MethodLength
final int size = expr.length();
final ExpressionBuilder builder = new ExpressionBuilder(0);
final StringBuilder strb = new StringBuilder(size);
@@ -791,7 +791,7 @@ public final class TemplateEngine extends JxltEngine {
int inested = -1;
int lineno = info.getLine();
for (int column = 0; column < size; ++column) {
- char c = expr.charAt(column);
+ final char c = expr.charAt(column);
switch (state) {
default: // in case we ever add new unified expresssion type
throw new UnsupportedOperationException("unexpected unified expression type");
@@ -813,7 +813,7 @@ public final class TemplateEngine extends JxltEngine {
state = ParseState.IMMEDIATE1;
// if chars in buffer, create constant
if (strb.length() > 0) {
- TemplateExpression cexpr = new ConstantExpression(strb.toString(), null);
+ final TemplateExpression cexpr = new ConstantExpression(strb.toString(), null);
builder.add(cexpr);
strb.delete(0, Integer.MAX_VALUE);
}
@@ -829,7 +829,7 @@ public final class TemplateEngine extends JxltEngine {
state = ParseState.DEFERRED1;
// if chars in buffer, create constant
if (strb.length() > 0) {
- TemplateExpression cexpr = new ConstantExpression(strb.toString(), null);
+ final TemplateExpression cexpr = new ConstantExpression(strb.toString(), null);
builder.add(cexpr);
strb.delete(0, Integer.MAX_VALUE);
}
@@ -847,8 +847,8 @@ public final class TemplateEngine extends JxltEngine {
strb.append(c);
} else {
// materialize the immediate expr
- String src = strb.toString();
- TemplateExpression iexpr = new ImmediateExpression(
+ final String src = strb.toString();
+ final TemplateExpression iexpr = new ImmediateExpression(
src,
jexl.parse(info.at(lineno, column), noscript, src, scope),
null);
@@ -893,7 +893,7 @@ public final class TemplateEngine extends JxltEngine {
inner1 -= 1;
} else {
// materialize the nested/deferred expr
- String src = strb.toString();
+ final String src = strb.toString();
TemplateExpression dexpr;
if (nested) {
dexpr = new NestedExpression(
@@ -951,7 +951,7 @@ public final class TemplateEngine extends JxltEngine {
}
// if any chars were buffered, add them as a constant
if (strb.length() > 0) {
- TemplateExpression cexpr = new ConstantExpression(strb.toString(), null);
+ final TemplateExpression cexpr = new ConstantExpression(strb.toString(), null);
builder.add(cexpr);
}
return builder.build(this, null);
@@ -984,7 +984,7 @@ public final class TemplateEngine extends JxltEngine {
* @param theLine the line number
* @param theBlock the content
*/
- Block(BlockType theType, int theLine, String theBlock) {
+ Block(final BlockType theType, final int theLine, final String theBlock) {
type = theType;
line = theLine;
body = theBlock;
@@ -1017,9 +1017,9 @@ public final class TemplateEngine extends JxltEngine {
return body;
} else {
// CHECKSTYLE:OFF
- StringBuilder strb = new StringBuilder(64); // CSOFF: MagicNumber
+ final StringBuilder strb = new StringBuilder(64); // CSOFF: MagicNumber
// CHECKSTYLE:ON
- Iterator<CharSequence> lines = readLines(new StringReader(body));
+ final Iterator<CharSequence> lines = readLines(new StringReader(body));
while (lines.hasNext()) {
strb.append("$$").append(lines.next());
}
@@ -1032,11 +1032,11 @@ public final class TemplateEngine extends JxltEngine {
* @param strb the string builder to append to
* @param prefix the line prefix (immediate or deferred)
*/
- protected void toString(StringBuilder strb, String prefix) {
+ protected void toString(final StringBuilder strb, final String prefix) {
if (BlockType.VERBATIM.equals(type)) {
strb.append(body);
} else {
- Iterator<CharSequence> lines = readLines(new StringReader(body));
+ final Iterator<CharSequence> lines = readLines(new StringReader(body));
while (lines.hasNext()) {
strb.append(prefix).append(lines.next());
}
@@ -1051,8 +1051,8 @@ public final class TemplateEngine extends JxltEngine {
* @param pattern the pattern to match at start of sequence
* @return the first position after end of pattern if it matches, -1 otherwise
*/
- protected int startsWith(CharSequence sequence, CharSequence pattern) {
- int length = sequence.length();
+ protected int startsWith(CharSequence sequence, final CharSequence pattern) {
+ final int length = sequence.length();
int s = 0;
while (s < length && Character.isSpaceChar(sequence.charAt(s))) {
s += 1;
@@ -1079,7 +1079,7 @@ public final class TemplateEngine extends JxltEngine {
private CharSequence next = doNext();
private CharSequence doNext() {
- StringBuffer strb = new StringBuffer(64); // CSOFF: MagicNumber
+ final StringBuffer strb = new StringBuffer(64); // CSOFF: MagicNumber
int c;
boolean eol = false;
try {
@@ -1094,7 +1094,7 @@ public final class TemplateEngine extends JxltEngine {
strb.append((char) c);
reader.mark(1);
}
- } catch (IOException xio) {
+ } catch (final IOException xio) {
return null;
}
return strb.length() > 0 ? strb : null;
@@ -1107,7 +1107,7 @@ public final class TemplateEngine extends JxltEngine {
@Override
public CharSequence next() {
- CharSequence current = next;
+ final CharSequence current = next;
if (current != null) {
next = doNext();
}
@@ -1127,7 +1127,7 @@ public final class TemplateEngine extends JxltEngine {
* @param source the source reader
* @return the list of blocks
*/
- protected List<Block> readTemplate(final String prefix, Reader source) {
+ protected List<Block> readTemplate(final String prefix, final Reader source) {
final ArrayList<Block> blocks = new ArrayList<Block>();
final BufferedReader reader;
if (source instanceof BufferedReader) {
@@ -1138,11 +1138,11 @@ public final class TemplateEngine extends JxltEngine {
final StringBuilder strb = new StringBuilder();
BlockType type = null;
int prefixLen;
- Iterator<CharSequence> lines = readLines(reader);
+ final Iterator<CharSequence> lines = readLines(reader);
int lineno = 1;
int start = 0;
while (lines.hasNext()) {
- CharSequence line = lines.next();
+ final CharSequence line = lines.next();
if (line == null) {
break;
} else if (type == null) {
@@ -1160,7 +1160,7 @@ public final class TemplateEngine extends JxltEngine {
// switch to verbatim if necessary
prefixLen = startsWith(line, prefix);
if (prefixLen < 0) {
- Block directive = new Block(BlockType.DIRECTIVE, start, strb.toString());
+ final Block directive = new Block(BlockType.DIRECTIVE, start, strb.toString());
strb.delete(0, Integer.MAX_VALUE);
blocks.add(directive);
type = BlockType.VERBATIM;
@@ -1174,7 +1174,7 @@ public final class TemplateEngine extends JxltEngine {
// switch to directive if necessary
prefixLen = startsWith(line, prefix);
if (prefixLen >= 0) {
- Block verbatim = new Block(BlockType.VERBATIM, start, strb.toString());
+ final Block verbatim = new Block(BlockType.VERBATIM, start, strb.toString());
strb.delete(0, Integer.MAX_VALUE);
blocks.add(verbatim);
type = BlockType.DIRECTIVE;
@@ -1188,7 +1188,7 @@ public final class TemplateEngine extends JxltEngine {
}
// input may be null
if (type != null && strb.length() > 0) {
- Block block = new Block(type, start, strb.toString());
+ final Block block = new Block(type, start, strb.toString());
blocks.add(block);
}
blocks.trimToSize();
@@ -1196,7 +1196,7 @@ public final class TemplateEngine extends JxltEngine {
}
@Override
- public TemplateScript createTemplate(JexlInfo info, String prefix, Reader source, String... parms) {
+ public TemplateScript createTemplate(final JexlInfo info, final String prefix, final Reader source, final String... parms) {
return new TemplateScript(this, info, prefix, source, parms);
}
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java b/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java
index 865469e..c3ecc27 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateInterpreter.java
@@ -62,7 +62,7 @@ public class TemplateInterpreter extends Interpreter {
* Sole ctor.
* @param e the JEXL engine
*/
- Arguments(Engine e) {
+ Arguments(final Engine e) {
this.jexl = e;
}
/**
@@ -70,7 +70,7 @@ public class TemplateInterpreter extends Interpreter {
* @param o the options
* @return this instance
*/
- Arguments options(JexlOptions o) {
+ Arguments options(final JexlOptions o) {
this.options = o;
return this;
}
@@ -79,7 +79,7 @@ public class TemplateInterpreter extends Interpreter {
* @param j the context
* @return this instance
*/
- Arguments context(JexlContext j) {
+ Arguments context(final JexlContext j) {
this.jcontext = j;
return this;
}
@@ -88,7 +88,7 @@ public class TemplateInterpreter extends Interpreter {
* @param f the frame
* @return this instance
*/
- Arguments frame(Frame f) {
+ Arguments frame(final Frame f) {
this.jframe = f;
return this;
}
@@ -97,7 +97,7 @@ public class TemplateInterpreter extends Interpreter {
* @param e the expressions
* @return this instance
*/
- Arguments expressions(TemplateExpression[] e) {
+ Arguments expressions(final TemplateExpression[] e) {
this.expressions = e;
return this;
}
@@ -106,7 +106,7 @@ public class TemplateInterpreter extends Interpreter {
* @param o the writer
* @return this instance
*/
- Arguments writer(Writer o) {
+ Arguments writer(final Writer o) {
this.out = o;
return this;
}
@@ -116,7 +116,7 @@ public class TemplateInterpreter extends Interpreter {
* Creates a template interpreter instance.
* @param args the template interpreter arguments
*/
- TemplateInterpreter(Arguments args) {
+ TemplateInterpreter(final Arguments args) {
super(args.jexl, args.options, args.jcontext, args.jframe);
exprs = args.expressions;
writer = args.out;
@@ -130,7 +130,7 @@ public class TemplateInterpreter extends Interpreter {
* @param script the TemplateScript to evaluate
* @param args the arguments
*/
- public void include(TemplateScript script, Object... args) {
+ public void include(final TemplateScript script, final Object... args) {
script.evaluate(context, writer, args);
}
@@ -138,7 +138,7 @@ public class TemplateInterpreter extends Interpreter {
* Prints a unified expression evaluation result.
* @param e the expression number
*/
- public void print(int e) {
+ public void print(final int e) {
if (e < 0 || e >= exprs.length) {
return;
}
@@ -157,10 +157,10 @@ public class TemplateInterpreter extends Interpreter {
* Prints a composite expression.
* @param composite the composite expression
*/
- private void printComposite(TemplateEngine.CompositeExpression composite) {
- TemplateEngine.TemplateExpression[] cexprs = composite.exprs;
+ private void printComposite(final TemplateEngine.CompositeExpression composite) {
+ final TemplateEngine.TemplateExpression[] cexprs = composite.exprs;
Object value;
- for (TemplateExpression cexpr : cexprs) {
+ for (final TemplateExpression cexpr : cexprs) {
value = cexpr.evaluate(this);
doPrint(cexpr.getInfo(), value);
}
@@ -175,15 +175,15 @@ public class TemplateInterpreter extends Interpreter {
* @param info the source info
* @param arg the argument to print out
*/
- private void doPrint(JexlInfo info, Object arg) {
+ private void doPrint(final JexlInfo info, final Object arg) {
try {
if (writer != null) {
if (arg instanceof CharSequence) {
writer.write(arg.toString());
} else if (arg != null) {
- Object[] value = {arg};
- JexlUberspect uber = jexl.getUberspect();
- JexlMethod method = uber.getMethod(writer, "print", value);
+ final Object[] value = {arg};
+ final JexlUberspect uber = jexl.getUberspect();
+ final JexlMethod method = uber.getMethod(writer, "print", value);
if (method != null) {
method.invoke(writer, value);
} else {
@@ -191,21 +191,21 @@ public class TemplateInterpreter extends Interpreter {
}
}
}
- } catch (java.io.IOException xio) {
+ } catch (final java.io.IOException xio) {
throw TemplateEngine.createException(info, "call print", null, xio);
- } catch (java.lang.Exception xany) {
+ } catch (final java.lang.Exception xany) {
throw TemplateEngine.createException(info, "invoke print", null, xany);
}
}
@Override
- protected Object resolveNamespace(String prefix, JexlNode node) {
+ protected Object resolveNamespace(final String prefix, final JexlNode node) {
return "jexl".equals(prefix)? this : super.resolveNamespace(prefix, node);
}
@Override
- protected Object visit(ASTIdentifier node, Object data) {
- String name = node.getName();
+ protected Object visit(final ASTIdentifier node, final Object data) {
+ final String name = node.getName();
if ("$jexl".equals(name)) {
return writer;
}
@@ -213,13 +213,13 @@ public class TemplateInterpreter extends Interpreter {
}
@Override
- protected Object visit(ASTJexlScript script, Object data) {
+ protected Object visit(final ASTJexlScript script, final Object data) {
if (script instanceof ASTJexlLambda && !((ASTJexlLambda) script).isTopLevel()) {
return new Closure(this, (ASTJexlLambda) script) {
@Override
- protected Interpreter createInterpreter(JexlContext context, Frame local) {
- JexlOptions opts = jexl.options(script, context);
- TemplateInterpreter.Arguments targs = new TemplateInterpreter.Arguments(jexl)
+ protected Interpreter createInterpreter(final JexlContext context, final Frame local) {
+ final JexlOptions opts = jexl.options(script, context);
+ final TemplateInterpreter.Arguments targs = new TemplateInterpreter.Arguments(jexl)
.context(context)
.options(opts)
.frame(local)
@@ -233,7 +233,7 @@ public class TemplateInterpreter extends Interpreter {
final int numChildren = script.jjtGetNumChildren();
Object result = null;
for (int i = 0; i < numChildren; i++) {
- JexlNode child = script.jjtGetChild(i);
+ final JexlNode child = script.jjtGetChild(i);
result = child.jjtAccept(this, data);
cancelCheck(child);
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/TemplateScript.java b/src/main/java/org/apache/commons/jexl3/internal/TemplateScript.java
index 12fa01e..129bc59 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/TemplateScript.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/TemplateScript.java
@@ -65,7 +65,7 @@ public final class TemplateScript implements JxltEngine.Template {
* @throws NullPointerException if either the directive prefix or input is null
* @throws IllegalArgumentException if the directive prefix is invalid
*/
- public TemplateScript(TemplateEngine engine, JexlInfo info, String directive, Reader reader, String... parms) {
+ public TemplateScript(final TemplateEngine engine, JexlInfo info, final String directive, final Reader reader, final String... parms) {
if (directive == null) {
throw new NullPointerException("null prefix");
}
@@ -83,15 +83,15 @@ public final class TemplateScript implements JxltEngine.Template {
}
this.jxlt = engine;
this.prefix = directive;
- List<Block> blocks = jxlt.readTemplate(prefix, reader);
- List<TemplateExpression> uexprs = new ArrayList<>();
- StringBuilder strb = new StringBuilder();
+ final List<Block> blocks = jxlt.readTemplate(prefix, reader);
+ final List<TemplateExpression> uexprs = new ArrayList<>();
+ final StringBuilder strb = new StringBuilder();
int nuexpr = 0;
int codeStart = -1;
int line = 1;
for (int b = 0; b < blocks.size(); ++b) {
- Block block = blocks.get(b);
- int bl = block.getLine();
+ final Block block = blocks.get(b);
+ final int bl = block.getLine();
while(line < bl) {
strb.append("//\n");
line += 1;
@@ -106,7 +106,7 @@ public final class TemplateScript implements JxltEngine.Template {
if (codeStart < 0) {
codeStart = b;
}
- String body = block.getBody();
+ final String body = block.getBody();
strb.append(body);
for(int c = 0; c < body.length(); ++c) {
if (body.charAt(c) == '\n') {
@@ -120,18 +120,18 @@ public final class TemplateScript implements JxltEngine.Template {
info = jxlt.getEngine().createInfo();
}
// allow lambda defining params
- Scope scope = parms == null ? null : new Scope(null, parms);
+ final Scope scope = parms == null ? null : new Scope(null, parms);
script = jxlt.getEngine().parse(info.at(1, 1), false, strb.toString(), scope).script();
// seek the map of expression number to scope so we can parse Unified
// expression blocks with the appropriate symbols
- Map<Integer, JexlNode.Info> minfo = new TreeMap<>();
+ final Map<Integer, JexlNode.Info> minfo = new TreeMap<>();
collectPrintScope(script.script(), minfo);
// jexl:print(...) expression counter
int jpe = 0;
// create the exprs using the intended scopes
- for (Block block : blocks) {
+ for (final Block block : blocks) {
if (block.getType() == BlockType.VERBATIM) {
- JexlNode.Info ji = minfo.get(jpe);
+ final JexlNode.Info ji = minfo.get(jpe);
TemplateExpression te;
// no node info means this verbatim is surrounded by comments markers;
// expr at this index is never called
@@ -156,11 +156,11 @@ public final class TemplateScript implements JxltEngine.Template {
* @param theScript the script
* @param theExprs the expressions
*/
- TemplateScript(TemplateEngine engine,
- String thePrefix,
- Block[] theSource,
- ASTJexlScript theScript,
- TemplateExpression[] theExprs) {
+ TemplateScript(final TemplateEngine engine,
+ final String thePrefix,
+ final Block[] theSource,
+ final ASTJexlScript theScript,
+ final TemplateExpression[] theExprs) {
jxlt = engine;
prefix = thePrefix;
source = theSource;
@@ -173,7 +173,7 @@ public final class TemplateScript implements JxltEngine.Template {
* @param info the node info
* @return the scope
*/
- private static Scope scopeOf(JexlNode.Info info) {
+ private static Scope scopeOf(final JexlNode.Info info) {
JexlNode walk = info.getNode();
while(walk != null) {
if (walk instanceof ASTJexlScript) {
@@ -191,19 +191,19 @@ public final class TemplateScript implements JxltEngine.Template {
* @param node the visited node
* @param minfo the map of printed expression number to node info
*/
- private static void collectPrintScope(JexlNode node, Map<Integer, JexlNode.Info> minfo) {
- int nc = node.jjtGetNumChildren();
+ private static void collectPrintScope(final JexlNode node, final Map<Integer, JexlNode.Info> minfo) {
+ final int nc = node.jjtGetNumChildren();
if (node instanceof ASTFunctionNode) {
if (nc == 2) {
// 0 must be the prefix jexl:
- ASTIdentifier nameNode = (ASTIdentifier) node.jjtGetChild(0);
+ final ASTIdentifier nameNode = (ASTIdentifier) node.jjtGetChild(0);
if ("print".equals(nameNode.getName()) && "jexl".equals(nameNode.getNamespace())) {
- ASTArguments argNode = (ASTArguments) node.jjtGetChild(1);
+ final ASTArguments argNode = (ASTArguments) node.jjtGetChild(1);
if (argNode.jjtGetNumChildren() == 1) {
// seek the epression number
- JexlNode arg0 = argNode.jjtGetChild(0);
+ final JexlNode arg0 = argNode.jjtGetChild(0);
if (arg0 instanceof ASTNumberLiteral) {
- int exprNumber = ((ASTNumberLiteral) arg0).getLiteral().intValue();
+ final int exprNumber = ((ASTNumberLiteral) arg0).getLiteral().intValue();
minfo.put(exprNumber, new JexlNode.Info(nameNode));
return;
}
@@ -232,8 +232,8 @@ public final class TemplateScript implements JxltEngine.Template {
@Override
public String toString() {
- StringBuilder strb = new StringBuilder();
- for (Block block : source) {
+ final StringBuilder strb = new StringBuilder();
+ for (final Block block : source) {
block.toString(strb, prefix);
}
return strb.toString();
@@ -241,9 +241,9 @@ public final class TemplateScript implements JxltEngine.Template {
@Override
public String asString() {
- StringBuilder strb = new StringBuilder();
+ final StringBuilder strb = new StringBuilder();
int e = 0;
- for (Block block : source) {
+ for (final Block block : source) {
if (block.getType() == BlockType.DIRECTIVE) {
strb.append(prefix);
strb.append(block.getBody());
@@ -255,22 +255,22 @@ public final class TemplateScript implements JxltEngine.Template {
}
@Override
- public TemplateScript prepare(JexlContext context) {
+ public TemplateScript prepare(final JexlContext context) {
final Engine jexl = jxlt.getEngine();
- JexlOptions options = jexl.options(script, context);
- Frame frame = script.createFrame((Object[]) null);
- TemplateInterpreter.Arguments targs = new TemplateInterpreter
+ final JexlOptions options = jexl.options(script, context);
+ final Frame frame = script.createFrame((Object[]) null);
+ final TemplateInterpreter.Arguments targs = new TemplateInterpreter
.Arguments(jxlt.getEngine())
.context(context)
.options(options)
.frame(frame);
- Interpreter interpreter = new TemplateInterpreter(targs);
- TemplateExpression[] immediates = new TemplateExpression[exprs.length];
+ final Interpreter interpreter = new TemplateInterpreter(targs);
+ final TemplateExpression[] immediates = new TemplateExpression[exprs.length];
for (int e = 0; e < exprs.length; ++e) {
try {
immediates[e] = exprs[e].prepare(interpreter);
- } catch (JexlException xjexl) {
- JexlException xuel = TemplateEngine.createException(xjexl.getInfo(), "prepare", exprs[e], xjexl);
+ } catch (final JexlException xjexl) {
+ final JexlException xuel = TemplateEngine.createException(xjexl.getInfo(), "prepare", exprs[e], xjexl);
if (jexl.isSilent()) {
jexl.logger.warn(xuel.getMessage(), xuel.getCause());
return null;
@@ -282,30 +282,30 @@ public final class TemplateScript implements JxltEngine.Template {
}
@Override
- public void evaluate(JexlContext context, Writer writer) {
+ public void evaluate(final JexlContext context, final Writer writer) {
evaluate(context, writer, (Object[]) null);
}
@Override
- public void evaluate(JexlContext context, Writer writer, Object... args) {
+ public void evaluate(final JexlContext context, final Writer writer, final Object... args) {
final Engine jexl = jxlt.getEngine();
- JexlOptions options = jexl.options(script, context);
- Frame frame = script.createFrame(args);
- TemplateInterpreter.Arguments targs = new TemplateInterpreter
+ final JexlOptions options = jexl.options(script, context);
+ final Frame frame = script.createFrame(args);
+ final TemplateInterpreter.Arguments targs = new TemplateInterpreter
.Arguments(jexl)
.context(context)
.options(options)
.frame(frame)
.expressions(exprs)
.writer(writer);
- Interpreter interpreter = new TemplateInterpreter(targs);
+ final Interpreter interpreter = new TemplateInterpreter(targs);
interpreter.interpret(script);
}
@Override
public Set<List<String>> getVariables() {
- Engine.VarCollector collector = jxlt.getEngine().varCollector();
- for (TemplateExpression expr : exprs) {
+ final Engine.VarCollector collector = jxlt.getEngine().varCollector();
+ for (final TemplateExpression expr : exprs) {
expr.getVariables(collector);
}
return collector.collected();
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 1cbbc64..06f660b 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
@@ -39,10 +39,10 @@ abstract class AbstractExecutor {
* @param parms the parameters
* @return the method
*/
- static java.lang.reflect.Method initMarker(Class<?> clazz, String name, Class<?>... parms) {
+ static java.lang.reflect.Method initMarker(final Class<?> clazz, final String name, final Class<?>... parms) {
try {
return clazz.getMethod(name, parms);
- } catch (Exception xnever) {
+ } catch (final Exception xnever) {
throw new Error(xnever);
}
}
@@ -52,7 +52,7 @@ abstract class AbstractExecutor {
* @param arg the Object to coerce
* @return an Integer if it can be converted, null otherwise
*/
- static Integer castInteger(Object arg) {
+ static Integer castInteger(final Object arg) {
return arg instanceof Number? ((Number) arg).intValue() : null;
}
@@ -61,7 +61,7 @@ abstract class AbstractExecutor {
* @param arg the Object to coerce
* @return a String if it can be converted, null otherwise
*/
- static String castString(Object arg) {
+ static String castString(final Object arg) {
return arg instanceof CharSequence || arg instanceof Integer ? arg.toString() : null;
}
@@ -70,7 +70,7 @@ abstract class AbstractExecutor {
* @param args the list of arguments
* @return the arguments array
*/
- static Object[] makeArgs(Object... args) {
+ static Object[] makeArgs(final Object... args) {
return args;
}
@@ -79,7 +79,7 @@ abstract class AbstractExecutor {
* @param instance the instance
* @return the class
*/
- static Class<?> classOf(Object instance) {
+ static Class<?> classOf(final Object instance) {
return instance == null? Object.class : instance.getClass();
}
@@ -93,13 +93,13 @@ abstract class AbstractExecutor {
* @param theClass the class this executor applies to
* @param theMethod the method held by this executor
*/
- protected AbstractExecutor(Class<?> theClass, java.lang.reflect.Method theMethod) {
+ protected AbstractExecutor(final Class<?> theClass, final java.lang.reflect.Method theMethod) {
objectClass = theClass;
method = theMethod;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
return this == obj || (obj instanceof AbstractExecutor && equals((AbstractExecutor) obj));
}
@@ -113,7 +113,7 @@ abstract class AbstractExecutor {
* @param arg the other executor to check
* @return true if both executors are equivalent, false otherwise
*/
- public boolean equals(AbstractExecutor arg) {
+ public boolean equals(final AbstractExecutor arg) {
// common equality check
if (!this.getClass().equals(arg.getClass())) {
return false;
@@ -125,8 +125,8 @@ abstract class AbstractExecutor {
return false;
}
// specific equality check
- Object lhsp = this.getTargetProperty();
- Object rhsp = arg.getTargetProperty();
+ final Object lhsp = this.getTargetProperty();
+ final Object rhsp = arg.getTargetProperty();
if (lhsp == null && rhsp == null) {
return true;
}
@@ -193,7 +193,7 @@ abstract class AbstractExecutor {
* @param exec the value returned by tryExecute
* @return true if tryExecute failed, false otherwise
*/
- public final boolean tryFailed(Object exec) {
+ public final boolean tryFailed(final Object exec) {
return exec == JexlEngine.TRY_FAILED;
}
@@ -206,7 +206,7 @@ abstract class AbstractExecutor {
* @param theClass the class this executor applies to
* @param theMethod the method held by this executor
*/
- protected Get(Class<?> theClass, java.lang.reflect.Method theMethod) {
+ protected Get(final Class<?> theClass, final java.lang.reflect.Method theMethod) {
super(theClass, theMethod);
}
}
@@ -220,7 +220,7 @@ abstract class AbstractExecutor {
* @param theClass the class this executor applies to
* @param theMethod the method held by this executor
*/
- protected Set(Class<?> theClass, java.lang.reflect.Method theMethod) {
+ protected Set(final Class<?> theClass, final java.lang.reflect.Method theMethod) {
super(theClass, theMethod);
}
}
@@ -238,7 +238,7 @@ abstract class AbstractExecutor {
* @param m the method
* @param k the MethodKey
*/
- protected Method(Class<?> c, java.lang.reflect.Method m, MethodKey k) {
+ protected Method(final Class<?> c, final java.lang.reflect.Method m, final MethodKey k) {
super(c, m);
key = k;
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayIterator.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayIterator.java
index e65e12d..d86d43a 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayIterator.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayIterator.java
@@ -49,7 +49,7 @@ public class ArrayIterator implements Iterator<Object> {
* Creates a new iterator instance for the specified array.
* @param arr The array for which an iterator is desired.
*/
- public ArrayIterator(Object arr) {
+ public ArrayIterator(final Object arr) {
if (arr == null) {
array = null;
pos = 0;
diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayListWrapper.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayListWrapper.java
index 6bc5167..fb31742 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayListWrapper.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/ArrayListWrapper.java
@@ -36,7 +36,7 @@ public class ArrayListWrapper extends AbstractList<Object> implements RandomAcce
* Create the wrapper.
* @param anArray {@link #array}
*/
- public ArrayListWrapper(Object anArray) {
+ public ArrayListWrapper(final Object anArray) {
if (!anArray.getClass().isArray()) {
throw new IllegalArgumentException(anArray.getClass() + " is not an array");
}
@@ -44,13 +44,13 @@ public class ArrayListWrapper extends AbstractList<Object> implements RandomAcce
}
@Override
- public Object get(int index) {
+ public Object get(final int index) {
return Array.get(array, index);
}
@Override
- public Object set(int index, Object element) {
- Object old = Array.get(array, index);
+ public Object set(final int index, final Object element) {
+ final Object old = Array.get(array, index);
Array.set(array, index, element);
return old;
}
@@ -61,7 +61,7 @@ public class ArrayListWrapper extends AbstractList<Object> implements RandomAcce
}
@Override
- public int indexOf(Object o) {
+ public int indexOf(final Object o) {
final int size = size();
if (o == null) {
for (int i = 0; i < size; i++) {
@@ -80,7 +80,7 @@ public class ArrayListWrapper extends AbstractList<Object> implements RandomAcce
}
@Override
- public boolean contains(Object o) {
+ public boolean contains(final Object o) {
return indexOf(o) != -1;
}
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/BooleanGetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/BooleanGetExecutor.java
index 76d1c93..111f91f 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/introspection/BooleanGetExecutor.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/BooleanGetExecutor.java
@@ -35,9 +35,9 @@ public final class BooleanGetExecutor extends AbstractExecutor.Get {
* @param property the the property name
* @return the executor if found, null otherwise
*/
- public static BooleanGetExecutor discover(Introspector is, final Class<?> clazz, String property) {
+ public static BooleanGetExecutor discover(final Introspector is, final Class<?> clazz, final String property) {
if (property != null && !property.isEmpty()) {
- java.lang.reflect.Method m = PropertyGetExecutor.discoverGet(is, "is", clazz, property);
+ final java.lang.reflect.Method m = PropertyGetExecutor.discoverGet(is, "is", clazz, property);
if (m != null && (m.getReturnType() == Boolean.TYPE || m.getReturnType() == Boolean.class)) {
return new BooleanGetExecutor(clazz, m, property);
}
@@ -51,7 +51,7 @@ public final class BooleanGetExecutor extends AbstractExecutor.Get {
* @param method the method held by this executor
* @param key the property to get
*/
- private BooleanGetExecutor(Class<?> clazz, java.lang.reflect.Method method, String key) {
+ private BooleanGetExecutor(final Class<?> clazz, final java.lang.reflect.Method method, final String key) {
super(clazz, method);
property = key;
}
@@ -62,21 +62,21 @@ public final class BooleanGetExecutor extends AbstractExecutor.Get {
}
@Override
- public Object invoke(Object obj) throws IllegalAccessException, InvocationTargetException {
+ public Object invoke(final Object obj) throws IllegalAccessException, InvocationTargetException {
return method == null ? null : method.invoke(obj, (Object[]) null);
}
@Override
- public Object tryInvoke(Object obj, Object key) {
+ public Object tryInvoke(final Object obj, final Object key) {
if (obj != null && method != null
// ensure method name matches the property name
&& property.equals(key)
&& objectClass.equals(obj.getClass())) {
try {
return method.invoke(obj, (Object[]) null);
- } catch (IllegalAccessException xill) {
+ } catch (final IllegalAccessException xill) {
return TRY_FAILED;// fail
- } catch (InvocationTargetException xinvoke) {
+ } catch (final InvocationTargetException xinvoke) {
throw JexlException.tryFailed(xinvoke); // throw
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java
index 002366f..e0dae57 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/ClassMap.java
@@ -53,7 +53,7 @@ final class ClassMap {
public static Method cacheMiss() {
try {
return ClassMap.class.getMethod("cacheMiss");
- } catch (Exception xio) {
+ } catch (final Exception xio) {
// this really cant make an error...
return null;
}
@@ -95,14 +95,14 @@ final class ClassMap {
* @param log the logger.
*/
@SuppressWarnings("LeakingThisInConstructor")
- ClassMap(Class<?> aClass, Permissions permissions, Log log) {
+ ClassMap(final Class<?> aClass, final Permissions permissions, final Log log) {
// eagerly cache methods
create(this, permissions, aClass, log);
// eagerly cache public fields
- Field[] fields = aClass.getFields();
+ final Field[] fields = aClass.getFields();
if (fields.length > 0) {
- Map<String, Field> cache = new HashMap<>();
- for (Field field : fields) {
+ final Map<String, Field> cache = new HashMap<>();
+ for (final Field field : fields) {
if (permissions.allow(field)) {
cache.put(field.getName(), field);
}
@@ -148,7 +148,7 @@ final class ClassMap {
* @return the array of methods (null or non-empty)
*/
Method[] getMethods(final String methodName) {
- Method[] lm = byName.get(methodName);
+ final Method[] lm = byName.get(methodName);
if (lm != null && lm.length > 0) {
return lm.clone();
} else {
@@ -182,7 +182,7 @@ final class ClassMap {
} else if (cacheEntry == null) {
try {
// That one is expensive...
- Method[] methodList = byName.get(methodKey.getMethod());
+ final Method[] methodList = byName.get(methodKey.getMethod());
if (methodList != null) {
cacheEntry = methodKey.getMostSpecificMethod(methodList);
}
@@ -191,7 +191,7 @@ final class ClassMap {
} else {
byKey.put(methodKey, cacheEntry);
}
- } catch (MethodKey.AmbiguousException ae) {
+ } catch (final MethodKey.AmbiguousException ae) {
// that's a miss :-)
byKey.put(methodKey, CACHE_MISS);
throw ae;
@@ -211,7 +211,7 @@ final class ClassMap {
* @param classToReflect the class to cache
* @param log the Log
*/
- private static void create(ClassMap cache, Permissions permissions, Class<?> classToReflect, Log log) {
+ private static void create(final ClassMap cache, final Permissions permissions, Class<?> classToReflect, final Log log) {
//
// Build a list of all elements in the class hierarchy. This one is bottom-first (i.e. we start
// with the actual declaring class and its interfaces and then move up (superclass etc.) until we
@@ -224,31 +224,31 @@ final class ClassMap {
if (Modifier.isPublic(classToReflect.getModifiers())) {
populateWithClass(cache, permissions, classToReflect, log);
}
- Class<?>[] interfaces = classToReflect.getInterfaces();
- for (Class<?> anInterface : interfaces) {
+ final Class<?>[] interfaces = classToReflect.getInterfaces();
+ for (final Class<?> anInterface : interfaces) {
populateWithInterface(cache, permissions, anInterface, log);
}
}
// now that we've got all methods keyed in, lets organize them by name
if (!cache.byKey.isEmpty()) {
- List<Method> lm = new ArrayList<>(cache.byKey.size());
+ final List<Method> lm = new ArrayList<>(cache.byKey.size());
lm.addAll(cache.byKey.values());
// sort all methods by name
lm.sort(Comparator.comparing(Method::getName));
// put all lists of methods with same name in byName cache
int start = 0;
while (start < lm.size()) {
- String name = lm.get(start).getName();
+ final String name = lm.get(start).getName();
int end = start + 1;
while (end < lm.size()) {
- String walk = lm.get(end).getName();
+ final String walk = lm.get(end).getName();
if (walk.equals(name)) {
end += 1;
} else {
break;
}
}
- Method[] lmn = lm.subList(start, end).toArray(new Method[end - start]);
+ final Method[] lmn = lm.subList(start, end).toArray(new Method[end - start]);
cache.byName.put(name, lmn);
start = end;
}
@@ -263,11 +263,11 @@ final class ClassMap {
* @param iface the interface to populate the cache from
* @param log the Log
*/
- private static void populateWithInterface(ClassMap cache, Permissions permissions, Class<?> iface, Log log) {
+ private static void populateWithInterface(final ClassMap cache, final Permissions permissions, final Class<?> iface, final Log log) {
if (Modifier.isPublic(iface.getModifiers())) {
populateWithClass(cache, permissions, iface, log);
- Class<?>[] supers = iface.getInterfaces();
- for (Class<?> aSuper : supers) {
+ final Class<?>[] supers = iface.getInterfaces();
+ for (final Class<?> aSuper : supers) {
populateWithInterface(cache, permissions, aSuper, log);
}
}
@@ -281,19 +281,19 @@ final class ClassMap {
* @param clazz the class to populate the cache from
* @param log the Log
*/
- private static void populateWithClass(ClassMap cache, Permissions permissions, Class<?> clazz, Log log) {
+ private static void populateWithClass(final ClassMap cache, final Permissions permissions, final Class<?> clazz, final Log log) {
try {
- Method[] methods = clazz.getDeclaredMethods();
- for (Method mi : methods) {
+ final Method[] methods = clazz.getDeclaredMethods();
+ for (final Method mi : methods) {
// add method to byKey cache; do not override
- MethodKey key = new MethodKey(mi);
- Method pmi = cache.byKey.putIfAbsent(key, permissions.allow(mi) ? mi : CACHE_MISS);
+ final MethodKey key = new MethodKey(mi);
+ final Method pmi = cache.byKey.putIfAbsent(key, permissions.allow(mi) ? mi : CACHE_MISS);
if (pmi != null && pmi != CACHE_MISS && log.isDebugEnabled() && !key.equals(new MethodKey(pmi))) {
// foo(int) and foo(Integer) have the same signature for JEXL
log.debug("Method " + pmi + " is already registered, key: " + key.debugString());
}
}
- } catch (SecurityException se) {
+ } catch (final SecurityException se) {
// Everybody feels better with...
if (log.isDebugEnabled()) {
log.debug("While accessing methods of " + clazz + ": ", se);
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 0e17ef3..16bc4c3 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
@@ -36,7 +36,7 @@ public final class ConstructorMethod implements JexlMethod {
* @param args constructor arguments
* @return a {@link JexlMethod}
*/
- public static ConstructorMethod discover(Introspector is, Object ctorHandle, Object... args) {
+ public static ConstructorMethod discover(final Introspector is, final Object ctorHandle, final Object... args) {
String className;
Class<?> clazz = null;
if (ctorHandle instanceof Class<?>) {
@@ -47,7 +47,7 @@ public final class ConstructorMethod implements JexlMethod {
} else {
return null;
}
- Constructor<?> ctor = is.getConstructor(clazz, new MethodKey(className, args));
+ final Constructor<?> ctor = is.getConstructor(clazz, new MethodKey(className, args));
if (ctor != null) {
return new ConstructorMethod(ctor);
} else {
@@ -58,13 +58,13 @@ public final class ConstructorMethod implements JexlMethod {
* Creates a constructor method.
* @param theCtor the constructor to wrap
*/
- ConstructorMethod(Constructor<?> theCtor) {
+ ConstructorMethod(final Constructor<?> theCtor) {
this.ctor = theCtor;
}
@Override
- public Object invoke(Object obj, Object... params) throws Exception {
- Class<?> ctorClass = ctor.getDeclaringClass();
+ public Object invoke(final Object obj, final Object... params) throws Exception {
+ final Class<?> ctorClass = ctor.getDeclaringClass();
boolean invoke = true;
if (obj != null) {
if (obj instanceof Class<?>) {
@@ -80,9 +80,9 @@ public final class ConstructorMethod implements JexlMethod {
}
@Override
- public Object tryInvoke(String name, Object obj, Object... params) {
+ public Object tryInvoke(final String name, final Object obj, final Object... params) {
try {
- Class<?> ctorClass = ctor.getDeclaringClass();
+ final Class<?> ctorClass = ctor.getDeclaringClass();
boolean invoke = true;
if (obj != null) {
if (obj instanceof Class<?>) {
@@ -97,14 +97,14 @@ public final class ConstructorMethod implements JexlMethod {
}
} catch (InstantiationException | IllegalArgumentException | IllegalAccessException xinstance) {
return Uberspect.TRY_FAILED;
- } catch (InvocationTargetException xinvoke) {
+ } catch (final InvocationTargetException xinvoke) {
throw JexlException.tryFailed(xinvoke); // throw
}
return Uberspect.TRY_FAILED;
}
@Override
- public boolean tryFailed(Object rval) {
+ public boolean tryFailed(final Object rval) {
return rval == Uberspect.TRY_FAILED;
}
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 8ec3836..c1e067a 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
@@ -41,8 +41,8 @@ public final class DuckGetExecutor extends AbstractExecutor.Get {
* @param identifier the key to use as an argument to the get method
* @return the executor if found, null otherwise
*/
- public static DuckGetExecutor discover(Introspector is, Class<?> clazz, Object identifier) {
- java.lang.reflect.Method method = is.getMethod(clazz, "get", makeArgs(identifier));
+ public static DuckGetExecutor discover(final Introspector is, final Class<?> clazz, final Object identifier) {
+ final java.lang.reflect.Method method = is.getMethod(clazz, "get", makeArgs(identifier));
return method == null? null : new DuckGetExecutor(clazz, method, identifier);
}
@@ -52,7 +52,7 @@ public final class DuckGetExecutor extends AbstractExecutor.Get {
* @param method the method held by this executor
* @param identifier the property to get
*/
- private DuckGetExecutor(Class<?> clazz, java.lang.reflect.Method method, Object identifier) {
+ private DuckGetExecutor(final Class<?> clazz, final java.lang.reflect.Method method, final Object identifier) {
super(clazz, method);
property = identifier;
}
@@ -63,13 +63,13 @@ public final class DuckGetExecutor extends AbstractExecutor.Get {
}
@Override
- public Object invoke(Object obj) throws IllegalAccessException, InvocationTargetException {
- Object[] args = {property};
+ public Object invoke(final Object obj) throws IllegalAccessException, InvocationTargetException {
+ final Object[] args = {property};
return method == null ? null : method.invoke(obj, args);
}
@Override
- public Object tryInvoke(Object obj, Object key) {
+ public Object tryInvoke(final Object obj, final Object key) {
if (obj != null
&& objectClass.equals(obj.getClass())
// ensure method name matches the property name
@@ -77,11 +77,11 @@ public final class DuckGetExecutor extends AbstractExecutor.Get {
&& ((property == null && key == null)
|| (property != null && property.equals(key)))) {
try {
- Object[] args = {property};
+ final Object[] args = {property};
return method.invoke(obj, args);
} catch (IllegalAccessException | IllegalArgumentException xill) {
return TRY_FAILED;// fail
- } catch (InvocationTargetException xinvoke) {
+ } catch (final InvocationTargetException xinvoke) {
throw JexlException.tryFailed(xinvoke); // throw
}
}
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 146f947..b7f32d3 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
@@ -51,7 +51,7 @@ public final class DuckSetExecutor extends AbstractExecutor.Set {
* @param value the value to use as 2nd argument to the set method
* @return the executor if found, null otherwise
*/
- public static DuckSetExecutor discover(Introspector is, Class<?> clazz, Object key, Object value) {
+ public static DuckSetExecutor discover(final Introspector is, final Class<?> clazz, final Object key, final Object value) {
java.lang.reflect.Method method = is.getMethod(clazz, "set", makeArgs(key, value));
if (method == null) {
method = is.getMethod(clazz, "put", makeArgs(key, value));
@@ -66,7 +66,7 @@ public final class DuckSetExecutor extends AbstractExecutor.Set {
* @param key the key to use as 1st argument to the set method
* @param value the value to use as 2nd argument to the set method
*/
- private DuckSetExecutor(Class<?> clazz, java.lang.reflect.Method method, Object key, Object value) {
+ private DuckSetExecutor(final Class<?> clazz, final java.lang.reflect.Method method, final Object key, final Object value) {
super(clazz, method);
property = key;
valueClass = classOf(value);
@@ -78,8 +78,8 @@ public final class DuckSetExecutor extends AbstractExecutor.Set {
}
@Override
- public Object invoke(Object obj, Object value) throws IllegalAccessException, InvocationTargetException {
- Object[] pargs = {property, value};
+ public Object invoke(final Object obj, final Object value) throws IllegalAccessException, InvocationTargetException {
+ final Object[] pargs = {property, value};
if (method != null) {
method.invoke(obj, pargs);
}
@@ -87,7 +87,7 @@ public final class DuckSetExecutor extends AbstractExecutor.Set {
}
@Override
- public Object tryInvoke(Object obj, Object key, Object value) {
+ public Object tryInvoke(final Object obj, final Object key, final Object value) {
if (obj != null
&& objectClass.equals(obj.getClass())
&& method != null
@@ -95,12 +95,12 @@ public final class DuckSetExecutor extends AbstractExecutor.Set {
|| (property == null && key == null))
&& valueClass.equals(classOf(value))) {
try {
- Object[] args = {property, value};
+ final Object[] args = {property, value};
method.invoke(obj, args);
return value;
} catch (IllegalAccessException | IllegalArgumentException xill) {
return TRY_FAILED;// fail
- } catch (InvocationTargetException xinvoke) {
+ } catch (final InvocationTargetException xinvoke) {
throw JexlException.tryFailed(xinvoke); // throw
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/EnumerationIterator.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/EnumerationIterator.java
index 88e03cc..12e9931 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/introspection/EnumerationIterator.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/EnumerationIterator.java
@@ -38,7 +38,7 @@ public class EnumerationIterator<T> implements Iterator<T> {
*
* @param enumer The Enumeration to wrap.
*/
- public EnumerationIterator(Enumeration<T> enumer) {
+ public EnumerationIterator(final Enumeration<T> enumer) {
enumeration = enumer;
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldGetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldGetExecutor.java
index 48871ba..c431a6b 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldGetExecutor.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldGetExecutor.java
@@ -37,9 +37,9 @@ public final class FieldGetExecutor implements JexlPropertyGet {
* @param identifier the key to use as an argument to the get method
* @return the executor if found, null otherwise
*/
- public static JexlPropertyGet discover(Introspector is, Class<?> clazz, String identifier) {
+ public static JexlPropertyGet discover(final Introspector is, final Class<?> clazz, final String identifier) {
if (identifier != null) {
- Field field = is.getField(clazz, identifier);
+ final Field field = is.getField(clazz, identifier);
if (field != null) {
return new FieldGetExecutor(field);
}
@@ -50,21 +50,21 @@ public final class FieldGetExecutor implements JexlPropertyGet {
* Creates a new instance of FieldPropertyGet.
* @param theField the class public field
*/
- private FieldGetExecutor(Field theField) {
+ private FieldGetExecutor(final Field theField) {
field = theField;
}
@Override
- public Object invoke(Object obj) throws Exception {
+ public Object invoke(final Object obj) throws Exception {
return field.get(obj);
}
@Override
- public Object tryInvoke(Object obj, Object key) {
+ public Object tryInvoke(final Object obj, final Object key) {
if (obj.getClass().equals(field.getDeclaringClass()) && key.equals(field.getName())) {
try {
return field.get(obj);
- } catch (IllegalAccessException xill) {
+ } catch (final IllegalAccessException xill) {
return Uberspect.TRY_FAILED;
}
}
@@ -72,7 +72,7 @@ public final class FieldGetExecutor implements JexlPropertyGet {
}
@Override
- public boolean tryFailed(Object rval) {
+ public boolean tryFailed(final Object rval) {
return rval == Uberspect.TRY_FAILED;
}
diff --git a/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldSetExecutor.java b/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldSetExecutor.java
index 001f4b8..75f6b81 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldSetExecutor.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/introspection/FieldSetExecutor.java
@@ -39,9 +39,9 @@ public final class FieldSetExecutor implements JexlPropertySet {
* @param value the value to set the field to
* @return the executor if found, null otherwise
*/
- public static JexlPropertySet discover(Introspector is, Class<?> clazz, String identifier, Object value) {
+ public static JexlPropertySet discover(final Introspector is, final Class<?> clazz, final String identifier, final Object value) {
if (identifier != null) {
- Field field = is.getField(clazz, identifier);
+ final Field field = is.getField(clazz, identifier);
if (field != null
&& !Modifier.isFinal(field.getModifiers())
&& (value == null || MethodKey.isInvocationConvertible(field.getType(), value.getClass(), false))) {
@@ -55,25 +55,25 @@ public final class FieldSetExecutor implements JexlPropertySet {
* Creates a new instance of FieldPropertySet.
* @param theField the class public field
*/
- private FieldSetExecutor(Field theField) {
+ private FieldSetExecutor(final Field theField) {
field = theField;
}
@Override
- public Object invoke(Object obj, Object arg) throws Exception {
+ public Object invoke(final Object obj, final Object arg) throws Exception {
field.set(obj, arg);
return arg;
}
@Override
- public Object tryInvoke(Object obj, Object key, Object value) {
+ public Object tryInvoke(final Object obj, final Object key, final Object value) {
if (obj.getClass().equals(field.getDeclaringClass())
&& key.equals(field.getName())
&& (value == null || MethodKey.isInvocationConvertible(field.getType(), value.getClass(), false))) {
try {
field.set(obj, value);
return value;
- } catch (IllegalAccessException xill) {
+ } catch (final IllegalAccessException xill) {
return Uberspect.TRY_FAILED;
}
}
@@ -81,7 +81,7 @@ public final class FieldSetExecutor implements JexlPropertySet {
}
@Override
- public boolean tryFailed(Object rval) {
+ public boolean tryFailed(final Object rval) {
return rval == Uberspect.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 5efda28..1245451 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
@@ -53,9 +53,9 @@ public final class IndexedType implements JexlPropertyGet {
* @param name the container name
* @return a JexlPropertyGet is successful, null otherwise
*/
- public static JexlPropertyGet discover(Introspector is, Object object, String name) {
+ public static JexlPropertyGet discover(final Introspector is, final Object object, final String name) {
if (object != null && name != null && !name.isEmpty()) {
- String base = name.substring(0, 1).toUpperCase() + name.substring(1);
+ final String base = name.substring(0, 1).toUpperCase() + name.substring(1);
final String container = name;
final Class<?> clazz = object.getClass();
final Method[] getters = is.getMethods(object.getClass(), "get" + base);
@@ -83,7 +83,7 @@ public final class IndexedType implements JexlPropertyGet {
* @param theType the container type
* @param theContainer the container instance
*/
- private IndexedContainer(IndexedType theType, Object theContainer) {
+ private IndexedContainer(final IndexedType theType, final Object theContainer) {
this.type = theType;
this.container = theContainer;
}
@@ -110,7 +110,7 @@ public final class IndexedType implements JexlPropertyGet {
* @return the property value
* @throws Exception if inner invocation fails
*/
- public Object get(Object key) throws Exception {
+ public Object get(final Object key) throws Exception {
return type.invokeGet(container, key);
}
@@ -121,7 +121,7 @@ public final class IndexedType implements JexlPropertyGet {
* @return the invocation result (frequently null)
* @throws Exception if inner invocation fails
*/
- public Object set(Object key, Object value) throws Exception {
+ public Object set(final Object key, final Object value) throws Exception {
return type.invokeSet(container, key, value);
}
}
@@ -133,7 +133,7 @@ public final class IndexedType implements JexlPropertyGet {
* @param gets the array of getter methods
* @param sets the array of setter methods
*/
- private IndexedType(String name, Class<?> c, Method[] gets, Method[] sets) {
+ private IndexedType(final String name, final Class<?> c, final Method[] gets, final Method[] sets) {
this.container = name;
this.clazz = c;
this.getters = gets;
@@ -141,7 +141,7 @@ public final class IndexedType implements JexlPropertyGet {
}
@Override
- public Object invoke(Object obj) throws Exception {
+ public Object invoke(final Object obj) throws Exception {
if (obj != null && clazz.equals(obj.getClass())) {
return new IndexedContainer(this, obj);
} else {
@@ -150,7 +150,7 @@ public final class IndexedType implements JexlPropertyGet {
}
@Override
- public Object tryInvoke(Object obj, Object key) {
+ public Object tryInvoke(final Object obj, final Object key) {
if (obj != null && key != null
&& clazz.equals(obj.getClass())
... 19163 lines suppressed ...