You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2012/03/13 10:31:57 UTC
svn commit: r1300023 -
/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
Author: henrib
Date: Tue Mar 13 09:31:57 2012
New Revision: 1300023
URL: http://svn.apache.org/viewvc?rev=1300023&view=rev
Log:
JEXL-130 port (boolean conversion)
Modified:
commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java?rev=1300023&r1=1300022&r2=1300023&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java Tue Mar 13 09:31:57 2012
@@ -333,7 +333,7 @@ public class JexlArithmetic {
/**
* Given a BigDecimal, attempt to narrow it to an Integer or Long if it fits if
* one of the arguments is a numberable.
- *
+ *
* @param lhs the left hand side operand that lead to the bigd result
* @param rhs the right hand side operand that lead to the bigd result
* @param bigd the BigDecimal to narrow
@@ -465,7 +465,7 @@ public class JexlArithmetic {
return new Double(l + r);
}
- // if either are bigdecimal use that type
+ // if either are bigdecimal use that type
if (left instanceof BigDecimal || right instanceof BigDecimal) {
BigDecimal l = toBigDecimal(left);
BigDecimal r = toBigDecimal(right);
@@ -552,7 +552,7 @@ public class JexlArithmetic {
return new Double(l % r);
}
- // if either are bigdecimal use that type
+ // if either are bigdecimal use that type
if (left instanceof BigDecimal || right instanceof BigDecimal) {
BigDecimal l = toBigDecimal(left);
BigDecimal r = toBigDecimal(right);
@@ -591,7 +591,7 @@ public class JexlArithmetic {
return new Double(l * r);
}
- // if either are bigdecimal use that type
+ // if either are bigdecimal use that type
if (left instanceof BigDecimal || right instanceof BigDecimal) {
BigDecimal l = toBigDecimal(left);
BigDecimal r = toBigDecimal(right);
@@ -624,7 +624,7 @@ public class JexlArithmetic {
return new Double(l - r);
}
- // if either are bigdecimal use that type
+ // if either are bigdecimal use that type
if (left instanceof BigDecimal || right instanceof BigDecimal) {
BigDecimal l = toBigDecimal(left);
BigDecimal r = toBigDecimal(right);
@@ -897,7 +897,7 @@ public class JexlArithmetic {
* Coerce to a boolean (not a java.lang.Boolean).
*
* @param val Object to be coerced.
- * @return The boolean coerced value, or false if none possible.
+ * @return the boolean value if coercion is possible, true if value was not null.
*/
public boolean toBoolean(Object val) {
if (val == null) {
@@ -911,9 +911,10 @@ public class JexlArithmetic {
} else if (val instanceof String) {
String strval = val.toString();
return strval.length() > 0 && !"false".equals(strval);
+ } else {
+ // non null value is true
+ return true;
}
- // TODO: is this a reasonable default?
- return false;
}
/**