revert change to IDStarAlgorithm.processMatch

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901252 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-05-25 18:18:40 +00:00
parent 39dff4479d
commit 3bdc1bd16a
7 changed files with 14 additions and 10 deletions

View 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;

View 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;

View 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;

View 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;

View 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;
}

View 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;

View 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.