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

public final Class Countif

extends Fixed2ArgFunction
Class Inheritance
Imports
java.util.regex.Pattern, org.apache.poi.ss.formula.ThreeDEval, org.apache.poi.ss.formula.eval.BlankEval, .BoolEval, .ErrorEval, .EvaluationException, .NumberEval, .OperandResolver, .RefEval, .StringEval, .ValueEval, org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate, org.apache.poi.ss.usermodel.FormulaError

Implementation for the function COUNTIF

Syntax: COUNTIF ( range, criteria )

Parameter descriptions
range   is the range of cells to be counted based on the criteria
criteriais used to determine which cells to count

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
public static class
private abstract static class
private static class
public static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private double

Returns:

the number of evaluated cells in the range that match the specified criteria
countMatchingCellsInArea
(ValueEval rangeArg, CountUtils.I_MatchPredicate criteriaPredicate)

pack-priv static CountUtils.I_MatchPredicate

Returns:

null if the arg evaluates to blank.
createCriteriaPredicate
(ValueEval arg, int srcRowIndex, int srcColumnIndex)

Creates a criteria predicate object for the supplied criteria arg

private static CountUtils.I_MatchPredicate
createGeneralMatchPredicate(StringEval stringEval)

When the second argument is a string, many things are possible

public ValueEval
private static ValueEval

Returns:

the de-referenced criteria arg (possibly ErrorEval)
evaluateCriteriaArg
(ValueEval arg, int srcRowIndex, int srcColumnIndex)

pack-priv static Boolean

Returns:

null to represent blank values
parseBoolean
(String strRep)

Boolean literals ('TRUE', 'FALSE') treated similarly but NOT same as numbers.

private static ErrorEval
Inherited from org.apache.poi.ss.formula.functions.Fixed2ArgFunction:
evaluate

Constructor Detail

Countifback to summary
public Countif()

Method Detail

countMatchingCellsInAreaback to summary
private double countMatchingCellsInArea(ValueEval rangeArg, CountUtils.I_MatchPredicate criteriaPredicate)
Returns:double

the number of evaluated cells in the range that match the specified criteria

createCriteriaPredicateback to summary
pack-priv static CountUtils.I_MatchPredicate createCriteriaPredicate(ValueEval arg, int srcRowIndex, int srcColumnIndex)

Creates a criteria predicate object for the supplied criteria arg

Returns:CountUtils.I_MatchPredicate

null if the arg evaluates to blank.

createGeneralMatchPredicateback to summary
private static CountUtils.I_MatchPredicate createGeneralMatchPredicate(StringEval stringEval)

When the second argument is a string, many things are possible

evaluateback to summary
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1)

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

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

see Function#evaluate(ValueEval[], int, int)

Annotations
@Override
evaluateCriteriaArgback to summary
private static ValueEval evaluateCriteriaArg(ValueEval arg, int srcRowIndex, int srcColumnIndex)
Returns:ValueEval

the de-referenced criteria arg (possibly ErrorEval)

parseBooleanback to summary
pack-priv static Boolean parseBoolean(String strRep)

Boolean literals ('TRUE', 'FALSE') treated similarly but NOT same as numbers.

Returns:Boolean

null to represent blank values

parseErrorback to summary
private static ErrorEval parseError(String value)
org.apache.poi.ss.formula.functions back to summary

private final Class Countif.BooleanMatcher

extends MatcherBase
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int

Constructor Summary

AccessConstructor and Description
public
BooleanMatcher(boolean value, Countif.CmpOp operator)

Method Summary

Modifier and TypeMethod and Description
private static int
boolToInt(boolean value)

protected String
public boolean
Inherited from org.apache.poi.ss.formula.functions.Countif.MatcherBase:
evaluateevaluategetCodetoString

Field Detail

_valueback to summary
private final int _value

Constructor Detail

BooleanMatcherback to summary
public BooleanMatcher(boolean value, Countif.CmpOp operator)

Method Detail

boolToIntback to summary
private static int boolToInt(boolean value)
getValueTextback to summary
protected String getValueText()

Implements abstract org.apache.poi.ss.formula.functions.Countif.MatcherBase.getValueText.

Annotations
@Override
matchesback to summary
public boolean matches(ValueEval x)

Implements org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate.matches.

Annotations
@Override
org.apache.poi.ss.formula.functions back to summary

private final Class Countif.CmpOp

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int
private final String
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final Countif.CmpOp
public static final Countif.CmpOp
public static final Countif.CmpOp
public static final Countif.CmpOp
public static final Countif.CmpOp
public static final Countif.CmpOp
public static final Countif.CmpOp

Constructor Summary

AccessConstructor and Description
private
CmpOp(String representation, int code)

Method Summary

Modifier and TypeMethod and Description
public boolean
evaluate(boolean cmpResult)

public boolean
evaluate(int cmpResult)

public int
public int

Returns:

number of characters used to represent this operator
getLength
()

public static Countif.CmpOp
public String
private static Countif.CmpOp
op(String rep, int code)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_codeback to summary
private final int _code
_representationback to summary
private final String _representation
EQback to summary
public static final int EQ
GEback to summary
public static final int GE
GTback to summary
public static final int GT
LEback to summary
public static final int LE
LTback to summary
public static final int LT
NEback to summary
public static final int NE
NONEback to summary
public static final int NONE
OP_EQback to summary
public static final Countif.CmpOp OP_EQ
OP_GEback to summary
public static final Countif.CmpOp OP_GE
OP_GTback to summary
public static final Countif.CmpOp OP_GT
OP_LEback to summary
public static final Countif.CmpOp OP_LE
OP_LTback to summary
public static final Countif.CmpOp OP_LT
OP_NEback to summary
public static final Countif.CmpOp OP_NE
OP_NONEback to summary
public static final Countif.CmpOp OP_NONE

Constructor Detail

CmpOpback to summary
private CmpOp(String representation, int code)

Method Detail

evaluateback to summary
public boolean evaluate(boolean cmpResult)
evaluateback to summary
public boolean evaluate(int cmpResult)
getCodeback to summary
public int getCode()
getLengthback to summary
public int getLength()
Returns:int

number of characters used to represent this operator

getOperatorback to summary
public static Countif.CmpOp getOperator(String value)
getRepresentationback to summary
public String getRepresentation()
opback to summary
private static Countif.CmpOp op(String rep, int code)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.apache.poi.ss.formula.functions back to summary

public final Class Countif.ErrorMatcher

extends MatcherBase
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int

Constructor Summary

AccessConstructor and Description
public
ErrorMatcher(int errorCode, Countif.CmpOp operator)

Method Summary

Modifier and TypeMethod and Description
public int
protected String
public boolean
Inherited from org.apache.poi.ss.formula.functions.Countif.MatcherBase:
evaluateevaluategetCodetoString

Field Detail

_valueback to summary
private final int _value

Constructor Detail

ErrorMatcherback to summary
public ErrorMatcher(int errorCode, Countif.CmpOp operator)

Method Detail

getValueback to summary
public int getValue()
getValueTextback to summary
protected String getValueText()

Implements abstract org.apache.poi.ss.formula.functions.Countif.MatcherBase.getValueText.

Annotations
@Override
matchesback to summary
public boolean matches(ValueEval x)

Implements org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate.matches.

Annotations
@Override
org.apache.poi.ss.formula.functions back to summary

private abstract Class Countif.MatcherBase

extends Object
implements I_MatchPredicate
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate
Known Direct Subclasses
org.apache.poi.ss.formula.functions.Countif.NumberMatcher, org.apache.poi.ss.formula.functions.Countif.BooleanMatcher, org.apache.poi.ss.formula.functions.Countif.ErrorMatcher, org.apache.poi.ss.formula.functions.Countif.StringMatcher

Field Summary

Modifier and TypeField and Description
private final Countif.CmpOp

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected final boolean
evaluate(int cmpResult)

protected final boolean
evaluate(boolean cmpResult)

protected final int
protected abstract String
public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_operatorback to summary
private final Countif.CmpOp _operator

Constructor Detail

MatcherBaseback to summary
pack-priv MatcherBase(Countif.CmpOp operator)

Method Detail

evaluateback to summary
protected final boolean evaluate(int cmpResult)
evaluateback to summary
protected final boolean evaluate(boolean cmpResult)
getCodeback to summary
protected final int getCode()
getValueTextback to summary
protected abstract String getValueText()
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.apache.poi.ss.formula.functions back to summary

private final Class Countif.NumberMatcher

extends MatcherBase
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final double

Constructor Summary

AccessConstructor and Description
public
NumberMatcher(double value, Countif.CmpOp operator)

Method Summary

Modifier and TypeMethod and Description
protected String
public boolean
Inherited from org.apache.poi.ss.formula.functions.Countif.MatcherBase:
evaluateevaluategetCodetoString

Field Detail

_valueback to summary
private final double _value

Constructor Detail

NumberMatcherback to summary
public NumberMatcher(double value, Countif.CmpOp operator)

Method Detail

getValueTextback to summary
protected String getValueText()

Implements abstract org.apache.poi.ss.formula.functions.Countif.MatcherBase.getValueText.

Annotations
@Override
matchesback to summary
public boolean matches(ValueEval x)

Implements org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate.matches.

Annotations
@Override
org.apache.poi.ss.formula.functions back to summary

public final Class Countif.StringMatcher

extends MatcherBase
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Pattern
private final String

Constructor Summary

AccessConstructor and Description
public
StringMatcher(String value, Countif.CmpOp operator)

Method Summary

Modifier and TypeMethod and Description
protected String
public static Pattern

Returns:

null if the specified value contains no special wildcard characters.
getWildCardPattern
(String value)

Translates Excel countif wildcard strings into java regex strings

public boolean
Inherited from org.apache.poi.ss.formula.functions.Countif.MatcherBase:
evaluateevaluategetCodetoString

Field Detail

_patternback to summary
private final Pattern _pattern
_valueback to summary
private final String _value

Constructor Detail

StringMatcherback to summary
public StringMatcher(String value, Countif.CmpOp operator)

Method Detail

getValueTextback to summary
protected String getValueText()

Implements abstract org.apache.poi.ss.formula.functions.Countif.MatcherBase.getValueText.

Annotations
@Override
getWildCardPatternback to summary
public static Pattern getWildCardPattern(String value)

Translates Excel countif wildcard strings into java regex strings

Returns:Pattern

null if the specified value contains no special wildcard characters.

matchesback to summary
public boolean matches(ValueEval x)

Implements org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate.matches.

Annotations
@Override