Author: sebb
Date: Wed Aug 5 00:08:11 2009
New Revision: 801035
URL: http://svn.apache.org/viewvc?rev=801035&view=rev
Log:
Make boxing explicit (use Integer.valueOf() for numbers that are likely to be
small)
Remove Long=>long conversions where the return value is Long anyway!
Modified:
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/JexlArithmetic.java
Modified:
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java?rev=801035&r1=801034&r2=801035&view=diff
==============================================================================
---
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java
(original)
+++
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/Interpreter.java
Wed Aug 5 00:08:11 2009
@@ -371,7 +371,7 @@
long l = arithmetic.toLong(left);
n = 1;
long r = arithmetic.toLong(right);
- return l & r;
+ return new Long(l & r);
} catch (RuntimeException xrt) {
throw new JexlException(node.jjtGetChild(n), "long coercion
error", xrt);
}
@@ -382,7 +382,7 @@
Object left = node.jjtGetChild(0).jjtAccept(this, data);
try {
long l = arithmetic.toLong(left);
- return ~l;
+ return new Long(~l);
} catch (RuntimeException xrt) {
throw new JexlException(node.jjtGetChild(0), "long coercion
error", xrt);
}
@@ -398,7 +398,7 @@
long l = arithmetic.toLong(left);
n = 1;
long r = arithmetic.toLong(right);
- return l | r;
+ return new Long(l | r);
} catch (RuntimeException xrt) {
throw new JexlException(node.jjtGetChild(n), "long coercion
error", xrt);
}
@@ -414,7 +414,7 @@
long l = arithmetic.toLong(left);
n = 1;
long r = arithmetic.toLong(right);
- return l ^ r;
+ return new Long(l ^ r);
} catch (RuntimeException xrt) {
throw new JexlException(node.jjtGetChild(n), "long coercion
error", xrt);
}
@@ -438,7 +438,7 @@
return arithmetic.divide(left, right);
} catch (RuntimeException xrt) {
if (!strict && xrt instanceof ArithmeticException) {
- return 0.0;
+ return new Double(0.0);
}
JexlNode xnode = findNullOperand(xrt, node, left, right);
throw new JexlException(xnode, "divide error", xrt);
@@ -879,7 +879,7 @@
return arithmetic.mod(left, right);
} catch (RuntimeException xrt) {
if (!strict && xrt instanceof ArithmeticException) {
- return 0.0;
+ return new Double(0.0);
}
JexlNode xnode = findNullOperand(xrt, node, left, right);
throw new JexlException(xnode, "% error", xrt);
@@ -1003,12 +1003,12 @@
throw new JexlException(node, "size() : argument is null", null);
}
- return sizeOf(node, val);
+ return Integer.valueOf(sizeOf(node, val));
}
/** {...@inheritdoc} */
public Object visit(ASTSizeMethod node, Object data) {
- return sizeOf(node, data);
+ return Integer.valueOf(sizeOf(node, data));
}
/** {...@inheritdoc} */
Modified:
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/JexlArithmetic.java
URL:
http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/JexlArithmetic.java?rev=801035&r1=801034&r2=801035&view=diff
==============================================================================
---
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/JexlArithmetic.java
(original)
+++
commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/JexlArithmetic.java
Wed Aug 5 00:08:11 2009
@@ -66,7 +66,7 @@
* @return Long(0)
*/
protected Object controlNullNullOperands() {
- return strict? null : 0L;
+ return strict? null : Long.valueOf(0);
}
/**
@@ -101,7 +101,7 @@
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
double l = toDouble(left);
double r = toDouble(right);
- return l + r;
+ return new Double(l + r);
}
// if both are bigintegers use that type
@@ -124,7 +124,7 @@
BigInteger result = l.add(r);
if (result.compareTo(BIGI_LONG_MAX_VALUE) <= 0
&& result.compareTo(BIGI_LONG_MIN_VALUE) >= 0) {
- return result.longValue();
+ return result;
}
return result;
} catch (java.lang.NumberFormatException nfe) {
@@ -167,7 +167,7 @@
if (r == 0.0) {
throw new ArithmeticException("/");
}
- return l / r;
+ return new Double(l / r);
}
@@ -192,7 +192,7 @@
if (r == 0.0) {
throw new ArithmeticException("/");
}
- return l % r;
+ return new Double(l % r);
}
// if both are bigintegers use that type
@@ -218,7 +218,7 @@
BigInteger result = l.mod(r);
if (result.compareTo(BIGI_LONG_MAX_VALUE) <= 0
&& result.compareTo(BIGI_LONG_MIN_VALUE) >= 0) {
- return result.longValue();
+ return result;
}
return result;
}
@@ -245,7 +245,7 @@
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
double l = toDouble(left);
double r = toDouble(right);
- return l * r;
+ return new Double(l * r);
}
// if both are bigintegers use that type
@@ -268,7 +268,7 @@
BigInteger result = l.multiply(r);
if (result.compareTo(BIGI_LONG_MAX_VALUE) <= 0
&& result.compareTo(BIGI_LONG_MIN_VALUE) >= 0) {
- return result.longValue();
+ return result;
}
return result;
}
@@ -295,7 +295,7 @@
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
double l = toDouble(left);
double r = toDouble(right);
- return l - r;
+ return new Double(l - r);
}
// if both are bigintegers use that type
@@ -318,7 +318,7 @@
BigInteger result = l.subtract(r);
if (result.compareTo(BIGI_LONG_MAX_VALUE) <= 0
&& result.compareTo(BIGI_LONG_MIN_VALUE) >= 0) {
- return result.longValue();
+ return result;
}
return result;
}