Author: henrib
Date: Sun Jul 17 20:33:14 2011
New Revision: 1147711
URL: http://svn.apache.org/viewvc?rev=1147711&view=rev
Log:
Checkstyle, findbugs, etc
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Debugger.java
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ExpressionImpl.java
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlException.java
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlThreadedArithmetic.java
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ObjectContext.java
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ReadonlyContext.java
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Debugger.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Debugger.java?rev=1147711&r1=1147710&r2=1147711&view=diff
==============================================================================
---
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Debugger.java
(original)
+++
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Debugger.java
Sun Jul 17 20:33:14 2011
@@ -641,6 +641,7 @@ final class Debugger implements ParserVi
return prefixChild(node, "-", data);
}
+ /** {@inheritDoc} */
public Object visit(ASTVar node, Object data) {
builder.append("var ");
check(node, node.image, data);
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ExpressionImpl.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ExpressionImpl.java?rev=1147711&r1=1147710&r2=1147711&view=diff
==============================================================================
---
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ExpressionImpl.java
(original)
+++
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ExpressionImpl.java
Sun Jul 17 20:33:14 2011
@@ -153,7 +153,7 @@ public class ExpressionImpl implements E
return new Callable<Object>() {
/** Use interpreter as marker for not having run. */
- Object result = interpreter;
+ private Object result = interpreter;
public Object call() throws Exception {
if (result == interpreter) {
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java?rev=1147711&r1=1147710&r2=1147711&view=diff
==============================================================================
---
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java
(original)
+++
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/Interpreter.java
Sun Jul 17 20:33:14 2011
@@ -133,7 +133,7 @@ public class Interpreter implements Pars
* @param jexl the engine creating this interpreter
* @param aContext the context to evaluate expression
* @param strictFlag whether this interpreter runs in strict mode
- * @param simentFlag whether this interpreter runs in silent mode
+ * @param silentFlag whether this interpreter runs in silent mode
*/
public Interpreter(JexlEngine jexl, JexlContext aContext, boolean
strictFlag, boolean silentFlag) {
this.logger = jexl.logger;
@@ -242,12 +242,12 @@ public class Interpreter implements Pars
/**
* Sets this interpreter parameters and arguments.
- * @param parameters the array of parameters
- * @param arguments the array of arguments
+ * @param theParms the array of parameters
+ * @param theArgs the array of arguments
*/
- protected void setArguments(String[] parameters, Object[] arguments) {
- this.parameters = parameters;
- this.registers = arguments;
+ protected void setArguments(String[] theParms, Object[] theArgs) {
+ this.parameters = theParms;
+ this.registers = theArgs;
}
/**
@@ -306,7 +306,10 @@ public class Interpreter implements Pars
* @return true if cancelled, false otherwise
*/
protected boolean isCancelled() {
- return cancelled |= Thread.interrupted();
+ if (cancelled | Thread.interrupted()) {
+ cancelled = true;
+ }
+ return cancelled;
}
/**
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java?rev=1147711&r1=1147710&r2=1147711&view=diff
==============================================================================
---
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
(original)
+++
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
Sun Jul 17 20:33:14 2011
@@ -889,7 +889,7 @@ public class JexlArithmetic {
* Whether we consider the narrow class as a potential candidate for
narrowing the source.
* @param narrow the target narrow class
* @param source the orginal source class
- * @return
+ * @return true if attempt to narrow source to target is accepted
*/
protected boolean narrowAccept(Class<?> narrow, Class<?> source) {
return narrow == null || narrow.equals(source);
@@ -915,7 +915,9 @@ public class JexlArithmetic {
try {
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 && l >= Integer.MIN_VALUE) {
+ if (narrowAccept(narrow, Integer.class)
+ && l <= Integer.MAX_VALUE
+ && l >= Integer.MIN_VALUE) {
return Integer.valueOf((int) l);
} else if (narrowAccept(narrow, Long.class)) {
return Long.valueOf(l);
@@ -927,7 +929,9 @@ public class JexlArithmetic {
}
if (original instanceof Double || original instanceof Float ||
original instanceof BigDecimal) {
double value = original.doubleValue();
- if (narrowAccept(narrow, Float.class) && value <= Float.MAX_VALUE
&& value >= Float.MIN_VALUE) {
+ if (narrowAccept(narrow, Float.class)
+ && value <= Float.MAX_VALUE
+ && value >= Float.MIN_VALUE) {
result = Float.valueOf(result.floatValue());
}
// else it fits in a double only
@@ -936,17 +940,23 @@ public class JexlArithmetic {
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) {
+ || bigi.compareTo(BIGI_LONG_MIN_VALUE) < 0) {
return original;
}
}
long value = original.longValue();
- if (narrowAccept(narrow, Byte.class) && value <= Byte.MAX_VALUE &&
value >= Byte.MIN_VALUE) {
+ if (narrowAccept(narrow, Byte.class)
+ && value <= Byte.MAX_VALUE
+ && value >= Byte.MIN_VALUE) {
// it will fit in a byte
result = Byte.valueOf((byte) value);
- } else if (narrowAccept(narrow, Short.class) && value <=
Short.MAX_VALUE && value >= Short.MIN_VALUE) {
+ } else if (narrowAccept(narrow, Short.class)
+ && value <= Short.MAX_VALUE
+ && value >= Short.MIN_VALUE) {
result = Short.valueOf((short) value);
- } else if (narrowAccept(narrow, Integer.class) && value <=
Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
+ } else if (narrowAccept(narrow, Integer.class)
+ && value <= Integer.MAX_VALUE
+ && value >= Integer.MIN_VALUE) {
result = Integer.valueOf((int) value);
}
// else it fits in a long
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java?rev=1147711&r1=1147710&r2=1147711&view=diff
==============================================================================
---
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java
(original)
+++
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlEngine.java
Sun Jul 17 20:33:14 2011
@@ -761,7 +761,7 @@ public class JexlEngine {
* Creates an interpreter.
* @param context a JexlContext; if null, the EMPTY_CONTEXT is used
instead.
* @param strictFlag whether the interpreter runs in strict mode
- * @param simentFlag whether the interpreter runs in silent mode
+ * @param silentFlag whether the interpreter runs in silent mode
* @return an Interpreter
*/
protected Interpreter createInterpreter(JexlContext context, boolean
strictFlag, boolean silentFlag) {
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlException.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlException.java?rev=1147711&r1=1147710&r2=1147711&view=diff
==============================================================================
---
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlException.java
(original)
+++
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlException.java
Sun Jul 17 20:33:14 2011
@@ -95,6 +95,7 @@ public class JexlException extends Runti
* Creates a new Tokenization exception instance.
* @param node the location info
* @param expr the expression
+ * @param cause the javacc cause
*/
public Tokenization(JexlInfo node, CharSequence expr, Throwable cause)
{
super(node, expr.toString(), cause);
@@ -121,6 +122,7 @@ public class JexlException extends Runti
* Creates a new Variable exception instance.
* @param node the offending ASTnode
* @param expr the unknown variable
+ * @param cause the javacc cause
*/
public Parsing(JexlInfo node, CharSequence expr, Throwable cause) {
super(node, expr.toString(), cause);
@@ -194,12 +196,22 @@ public class JexlException extends Runti
/**
* The class of exceptions that will force the interpreter to return,
allways behaving in strict mode.
*/
- protected static class Return extends JexlException {
+ protected static class Return extends JexlException {
+ /** The returned value. */
private final Object result;
- protected Return(JexlNode node, String msg, Object result) {
+ /**
+ * Creates a new instance of Return.
+ * @param node the return node
+ * @param msg the message
+ * @param value the returned value
+ */
+ protected Return(JexlNode node, String msg, Object value) {
super(node, msg);
- this.result = result;
+ this.result = value;
}
+ /**
+ * @return the returned value
+ */
public Object getValue() {
return result;
}
@@ -209,6 +221,10 @@ public class JexlException extends Runti
* The class of exceptions used when the interpreter cancels a script
execution.
*/
protected static class Cancel extends JexlException {
+ /**
+ * Creates a new instance of Cancel.
+ * @param node the node where the interruption was detected
+ */
protected Cancel(JexlNode node) {
super(node, "execution cancelled", null);
}
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlThreadedArithmetic.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlThreadedArithmetic.java?rev=1147711&r1=1147710&r2=1147711&view=diff
==============================================================================
---
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlThreadedArithmetic.java
(original)
+++
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/JexlThreadedArithmetic.java
Sun Jul 17 20:33:14 2011
@@ -29,11 +29,11 @@ public class JexlThreadedArithmetic exte
Features() {
}
/** Whether this JexlArithmetic instance behaves in strict or lenient
mode. */
- Boolean lenient = null;
+ private Boolean lenient = null;
/** The big decimal math context. */
- MathContext mathContext = null;
+ private MathContext mathContext = null;
/** The big decimal scale. */
- Integer mathScale = null;
+ private Integer mathScale = null;
}
/**
@@ -45,7 +45,7 @@ public class JexlThreadedArithmetic exte
}
/**
- * Creates a JexlThreadedArithmetic.
+ * Creates a JexlThreadedArithmetic instance.
* @param lenient whether this arithmetic is lenient or strict
* @param bigdContext the math context instance to use for +,-,/,*,%
operations on big decimals.
* @param bigdScale the scale used for big decimals.
@@ -66,8 +66,8 @@ public class JexlThreadedArithmetic exte
/**
* Overrides the default behavior and sets whether this JexlArithmetic
instance triggers errors
* during evaluation when null is used as an operand for the current
thread.
- * <p>It is advised to protect calls by either calling
JexlThreadedArithmetic.setLenient explicitly before evaluation
- * or add a try/finally clause resetting the flag to avoid unexpected
reuse of the lenient
+ * <p>It is advised to protect calls by either calling
JexlThreadedArithmetic.setLenient explicitly
+ * before evaluation or add a try/finally clause resetting the flag to
avoid unexpected reuse of the lenient
* flag value through thread pools side-effects.</p>
* @see JexlEngine#setSilent
* @see JexlEngine#setDebug
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ObjectContext.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ObjectContext.java?rev=1147711&r1=1147710&r2=1147711&view=diff
==============================================================================
---
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ObjectContext.java
(original)
+++
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ObjectContext.java
Sun Jul 17 20:33:14 2011
@@ -21,17 +21,19 @@ package org.apache.commons.jexl2;
* @param <T> the wrapped object type to use
*/
public class ObjectContext<T> implements JexlContext {
+ /** The property solving jexl engine. */
private final JexlEngine jexl;
+ /** The object serving as context provider. */
private final T object;
/**
* Creates a new ObjectContext.
- * @param jexl the jexl engine to use to solve properties
- * @param object the object to wrap in this context
+ * @param engine the jexl engine to use to solve properties
+ * @param wrapped the object to wrap in this context
*/
- public ObjectContext(JexlEngine jexl, T object) {
- this.jexl = jexl;
- this.object = object;
+ public ObjectContext(JexlEngine engine, T wrapped) {
+ this.jexl = engine;
+ this.object = wrapped;
}
/** {@inheritDoc} */
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ReadonlyContext.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ReadonlyContext.java?rev=1147711&r1=1147710&r2=1147711&view=diff
==============================================================================
---
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ReadonlyContext.java
(original)
+++
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl2/ReadonlyContext.java
Sun Jul 17 20:33:14 2011
@@ -21,15 +21,19 @@ package org.apache.commons.jexl2;
*/
public final class ReadonlyContext implements JexlContext {
/** The wrapped context. */
- private final JexlContext base;
+ private final JexlContext wrapped;
- public ReadonlyContext(JexlContext theBase) {
- base = theBase;
+ /**
+ * Creates a new readonly context.
+ * @param context the wrapped context
+ */
+ public ReadonlyContext(JexlContext context) {
+ wrapped = context;
}
/** {@inheritDoc} */
public Object get(String name) {
- return base.get(name);
+ return wrapped.get(name);
}
/** {@inheritDoc} */
@@ -39,6 +43,6 @@ public final class ReadonlyContext imple
/** {@inheritDoc} */
public boolean has(String name) {
- return base.has(name);
+ return wrapped.has(name);
}
}