Top Description Inners Constructors Methods
org.apache.poi.ss.formula.functions

pack-priv abstract Class Baseifs

extends Object
implements FreeRefFunction
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.formula.functions.FreeRefFunction
Known Direct Subclasses
org.apache.poi.ss.formula.functions.Countifs, org.apache.poi.ss.formula.functions.Maxifs, org.apache.poi.ss.formula.functions.Minifs, org.apache.poi.ss.formula.functions.Sumifs, org.apache.poi.ss.formula.functions.AverageIf, org.apache.poi.ss.formula.functions.Averageifs
Imports
org.apache.poi.ss.formula.OperationEvaluationContext, org.apache.poi.ss.formula.eval.AreaEval, .ErrorEval, .EvaluationException, .RefEval, .ValueEval, org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate, .Countif.ErrorMatcher

Base class for SUMIFS() and COUNTIFS() functions, as they share much of the same logic, the difference being the source of the totals.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
Baseifs.Aggregator

Implements the details of a specific aggregation function

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static ValueEval

Returns:

the computed value
aggregateMatchingCells
(Baseifs.Aggregator aggregator, AreaEval
the range to sum, if used (uses 1 for each match if not present)
sumRange
,
AreaEval[]
criteria ranges
ranges
,
CountUtils.I_MatchPredicate[]
array of predicates, a predicate for each value in ranges
predicates
)

protected static AreaEval
protected abstract Baseifs.Aggregator
public ValueEval
evaluate(ValueEval[]
the pre-evaluated arguments for this function. args is never null, nor are any of its elements.
args
,
OperationEvaluationContext
primarily used to identify the source cell containing the formula being evaluated. may also be used to dynamically create reference evals.
ec
)

Implements org.apache.poi.ss.formula.functions.FreeRefFunction.evaluate.

protected abstract boolean

Returns:

true if there should be a range argument before the criteria pairs
hasInitialRange
()

Implementations must be stateless.

private static void
validateCriteria(CountUtils.I_MatchPredicate[]
to check
criteria
)

Verify that each criteria predicate is valid, i.e. not an error

private static void
validateCriteriaRanges(AreaEval
if used, it must match the shape of the criteriaRanges
sumRange
,
AreaEval[]
to check
criteriaRanges
)

Verify that each criteriaRanges argument contains the same number of rows and columns including the sumRange argument if present

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Baseifsback to summary
pack-priv Baseifs()

Method Detail

aggregateMatchingCellsback to summary
private static ValueEval aggregateMatchingCells(Baseifs.Aggregator aggregator, AreaEval sumRange, AreaEval[] ranges, CountUtils.I_MatchPredicate[] predicates) throws EvaluationException
Parameters
sumRange:AreaEval

the range to sum, if used (uses 1 for each match if not present)

ranges:AreaEval[]

criteria ranges

predicates:CountUtils.I_MatchPredicate[]

array of predicates, a predicate for each value in ranges

Returns:ValueEval

the computed value

Exceptions
EvaluationException:
if there is an issue with eval
convertRangeArgback to summary
protected static AreaEval convertRangeArg(ValueEval eval) throws EvaluationException
createAggregatorback to summary
protected abstract Baseifs.Aggregator createAggregator()
evaluateback to summary
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec)

Implements org.apache.poi.ss.formula.functions.FreeRefFunction.evaluate.

Parameters
args:ValueEval[]

Doc from org.apache.poi.ss.formula.functions.FreeRefFunction.evaluate.

the pre-evaluated arguments for this function. args is never null, nor are any of its elements.

ec:OperationEvaluationContext

Doc from org.apache.poi.ss.formula.functions.FreeRefFunction.evaluate.

primarily used to identify the source cell containing the formula being evaluated. may also be used to dynamically create reference evals.

Returns:ValueEval

Doc from org.apache.poi.ss.formula.functions.FreeRefFunction.evaluate.

never null. Possibly an instance of ErrorEval in the case of a specified Excel error (Exceptions are never thrown to represent Excel errors).

hasInitialRangeback to summary
protected abstract boolean hasInitialRange()

Implementations must be stateless.

Returns:boolean

true if there should be a range argument before the criteria pairs

validateCriteriaback to summary
private static void validateCriteria(CountUtils.I_MatchPredicate[] criteria) throws EvaluationException

Verify that each criteria predicate is valid, i.e. not an error

Parameters
criteria:CountUtils.I_MatchPredicate[]

to check

Exceptions
EvaluationException:
if there are criteria which resulted in Errors.
validateCriteriaRangesback to summary
private static void validateCriteriaRanges(AreaEval sumRange, AreaEval[] criteriaRanges) throws EvaluationException

Verify that each criteriaRanges argument contains the same number of rows and columns including the sumRange argument if present

Parameters
sumRange:AreaEval

if used, it must match the shape of the criteriaRanges

criteriaRanges:AreaEval[]

to check

Exceptions
EvaluationException:
if the ranges do not match.
org.apache.poi.ss.formula.functions back to summary

protected Interface Baseifs.Aggregator


Implements the details of a specific aggregation function

Method Summary

Modifier and TypeMethod and Description
public void
public ValueEval

Method Detail

addValueback to summary
public void addValue(ValueEval d)
getResultback to summary
public ValueEval getResult()