]> source.dussan.org Git - poi.git/commitdiff
revert change to IDStarAlgorithm.processMatch
authorPJ Fanning <fanningpj@apache.org>
Wed, 25 May 2022 18:18:40 +0000 (18:18 +0000)
committerPJ Fanning <fanningpj@apache.org>
Wed, 25 May 2022 18:18:40 +0000 (18:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901252 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/formula/functions/DCount.java
poi/src/main/java/org/apache/poi/ss/formula/functions/DGet.java
poi/src/main/java/org/apache/poi/ss/formula/functions/DMax.java
poi/src/main/java/org/apache/poi/ss/formula/functions/DMin.java
poi/src/main/java/org/apache/poi/ss/formula/functions/DStarRunner.java
poi/src/main/java/org/apache/poi/ss/formula/functions/DSum.java
poi/src/main/java/org/apache/poi/ss/formula/functions/IDStarAlgorithm.java

index a367eca81444268590f15cf0854b054d1bc35c9a..0fda8fa32c37d04478bfc66d06c0a9bd197ac162 100644 (file)
@@ -29,8 +29,8 @@ public final class DCount implements IDStarAlgorithm {
     private int count;
 
     @Override
-    public boolean processMatch(ValueEval eval, int fieldNumber) {
-        if (fieldNumber < 0 || eval instanceof NumericValueEval) {
+    public boolean processMatch(ValueEval eval) {
+        if (eval instanceof NumericValueEval) {
             count++;
         }
         return true;
index 34c2900462c1212e9bcbb6369078a712eed4e4f4..78b1b9235ee87e547a81a6f610abc7273e53fa3a 100644 (file)
@@ -31,7 +31,7 @@ public final class DGet implements IDStarAlgorithm {
     private ValueEval result;
 
     @Override
-    public boolean processMatch(ValueEval eval, int fieldNumber) {
+    public boolean processMatch(ValueEval eval) {
         if(result == null) // First match, just set the value.
         {
             result = eval;
index 77b4624406e0e1c5d835e2143c62eb44ff9cbcb9..4d442f041512df6ee27c0dfe834de0ebf79f6fdc 100644 (file)
@@ -33,7 +33,7 @@ public final class DMax implements IDStarAlgorithm {
     private ValueEval maximumValue;
 
     @Override
-    public boolean processMatch(ValueEval eval, int fieldNumber) {
+    public boolean processMatch(ValueEval eval) {
         if(eval instanceof NumericValueEval) {
             if(maximumValue == null) { // First match, just set the value.
                 maximumValue = eval;
index 216d194ca589c05a9b8bb188acd93c494da6c8f1..61b75768c7116ef5bf3ea5851a0244dd62451bcf 100644 (file)
@@ -33,7 +33,7 @@ public final class DMin implements IDStarAlgorithm {
     private ValueEval minimumValue;
 
     @Override
-    public boolean processMatch(ValueEval eval, int fieldNumber) {
+    public boolean processMatch(ValueEval eval) {
         if(eval instanceof NumericValueEval) {
             if(minimumValue == null) { // First match, just set the value.
                 minimumValue = eval;
index 5c014802aaef5cbd32a366e6523dacd9de94aff8..9a2e2637eb86ead127ed2c8ce0d7c5d9a81d47b5 100644 (file)
@@ -23,7 +23,9 @@ import org.apache.poi.ss.formula.eval.AreaEval;
 import org.apache.poi.ss.formula.eval.BlankEval;
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.EvaluationException;
+import org.apache.poi.ss.formula.eval.MissingArgEval;
 import org.apache.poi.ss.formula.eval.NotImplementedException;
+import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.NumericValueEval;
 import org.apache.poi.ss.formula.eval.OperandResolver;
 import org.apache.poi.ss.formula.eval.StringEval;
@@ -138,10 +140,13 @@ public final class DStarRunner implements Function3Arg {
                 return ErrorEval.VALUE_INVALID;
             }
             // Filter each entry.
-            if(matches) {
+            if (matches) {
                 ValueEval currentValueEval = resolveReference(db, row, fc);
+                if (fc < 0 && algorithm.allowEmptyMatchField() && !(currentValueEval instanceof NumericValueEval)) {
+                    currentValueEval = NumberEval.ZERO;
+                }
                 // Pass the match to the algorithm and conditionally abort the search.
-                boolean shouldContinue = algorithm.processMatch(currentValueEval, fc);
+                boolean shouldContinue = algorithm.processMatch(currentValueEval);
                 if(! shouldContinue) {
                     break;
                 }
index 758b2481c3dcdb3895eb9e065cf14c13860b45c3..26604677deddc3232470e4e6227e9f133b14bfc5 100644 (file)
@@ -33,7 +33,7 @@ public final class DSum implements IDStarAlgorithm {
     private double totalValue = 0;
 
     @Override
-    public boolean processMatch(ValueEval eval, int fieldNumber) {
+    public boolean processMatch(ValueEval eval) {
         if(eval instanceof NumericValueEval) {
             double currentValue = ((NumericValueEval)eval).getNumberValue();
             totalValue += currentValue;
index dff5eb227f07029ad59458f22ecfb2ff5d6e66fd..0d8d52266ebbd145452bfb59846ecc19ef8fff96 100644 (file)
@@ -27,10 +27,9 @@ public interface IDStarAlgorithm {
     /**
      * Process a match that is found during a run through a database.
      * @param eval ValueEval of the cell in the matching row. References will already be resolved.
-     * @param fieldNumber the field number (added in POI 5.2.3)
      * @return Whether we should continue iterating through the database.
      */
-    boolean processMatch(ValueEval eval, int fieldNumber);
+    boolean processMatch(ValueEval eval);
 
     /**
      * Return a result ValueEval that will be the result of the calculation.