aboutsummaryrefslogtreecommitdiffstats
path: root/src/excelant
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2019-12-07 11:45:44 +0000
committerAndreas Beeker <kiwiwings@apache.org>2019-12-07 11:45:44 +0000
commitb2a33515e9662e015b0e0d6b4aa0726245db3231 (patch)
treeed2f8ecb4a162b554bc0a30f81408629f684d2f1 /src/excelant
parent9f2f9dc7937f66397f5fd157df4092ed40998f95 (diff)
downloadpoi-b2a33515e9662e015b0e0d6b4aa0726245db3231.tar.gz
poi-b2a33515e9662e015b0e0d6b4aa0726245db3231.zip
Sonar Fixes - type: bugs / severity: critical - mostly div by 0
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1870976 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/excelant')
-rw-r--r--src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java60
1 files changed, 28 insertions, 32 deletions
diff --git a/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java b/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java
index a624b98b57..eb446dfde6 100644
--- a/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java
+++ b/src/excelant/java/org/apache/poi/ss/excelant/ExcelAntEvaluateCell.java
@@ -27,9 +27,9 @@ import org.apache.tools.ant.Task;
* Instances of this class are used to evaluate a single cell. This is usually
* after some values have been set. The evaluation is actually performed
* by a WorkbookUtil instance. The evaluate() method of the WorkbookUtil
- * class returns an EvaluationResult which encapsulates the results and
+ * class returns an EvaluationResult which encapsulates the results and
* information from the evaluation.
- *
+ *
* @author Jon Svede ( jon [at] loquatic [dot] com )
* @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov )
@@ -40,40 +40,39 @@ public class ExcelAntEvaluateCell extends Task {
private String cell ;
private double expectedValue ;
private double precision ;
- private double precisionToUse ;
private double globalPrecision ;
private boolean requiredToPass;
-
-
+
+
private ExcelAntEvaluationResult result ;
-
+
private ExcelAntWorkbookUtil wbUtil ;
-
+
private boolean showDelta;
-
-
+
+
public ExcelAntEvaluateCell() {}
protected void setWorkbookUtil( ExcelAntWorkbookUtil wb ) {
wbUtil = wb ;
}
-
+
public void setShowDelta( boolean value ) {
showDelta = value ;
}
-
+
protected boolean showDelta() {
return showDelta ;
}
-
+
public void setCell(String cell) {
this.cell = cell;
}
-
+
public void setRequiredToPass( boolean val ) {
requiredToPass = val ;
}
-
+
protected boolean requiredToPass() {
return requiredToPass ;
}
@@ -85,7 +84,7 @@ public class ExcelAntEvaluateCell extends Task {
public void setPrecision(double precision) {
this.precision = precision;
}
-
+
protected void setGlobalPrecision( double prec ) {
globalPrecision = prec ;
}
@@ -98,47 +97,44 @@ public class ExcelAntEvaluateCell extends Task {
return expectedValue;
}
+ @SuppressWarnings("squid:S4275")
protected double getPrecision() {
- return precisionToUse;
- }
-
- @Override
- public void execute() throws BuildException {
-
- precisionToUse = 0 ;
-
// if there is a globalPrecision we will use it unless there is also
// precision set at the evaluate level, then we use that. If there
// is not a globalPrecision, we will use the local precision.
log( "test precision = " + precision + "\tglobal precision = " + globalPrecision, Project.MSG_VERBOSE ) ;
if( globalPrecision > 0 ) {
if( precision > 0 ) {
- precisionToUse = precision ;
log( "Using evaluate precision of " + precision + " over the " +
- "global precision of " + globalPrecision, Project.MSG_VERBOSE ) ;
+ "global precision of " + globalPrecision, Project.MSG_VERBOSE ) ;
+ return precision ;
} else {
- precisionToUse = globalPrecision ;
log( "Using global precision of " + globalPrecision, Project.MSG_VERBOSE ) ;
+ return globalPrecision ;
}
} else {
- precisionToUse = precision ;
log( "Using evaluate precision of " + precision, Project.MSG_VERBOSE ) ;
+ return precision ;
}
- result = wbUtil.evaluateCell(cell, expectedValue, precisionToUse ) ;
-
+ }
+
+ @Override
+ public void execute() throws BuildException {
+ result = wbUtil.evaluateCell(cell, expectedValue, getPrecision() ) ;
+
StringBuilder sb = new StringBuilder() ;
sb.append( "evaluation of cell " ) ;
- sb.append( cell ) ;
+ sb.append( cell ) ;
sb.append( " resulted in " ) ;
sb.append( result.getReturnValue() ) ;
if(showDelta) {
sb.append(" with a delta of ").append(result.getDelta());
}
-
+
log( sb.toString(), Project.MSG_DEBUG) ;
}
-
+
public ExcelAntEvaluationResult getResult() {
return result ;
}