/** @see DSum */
DSUM(DSum::new),
;
-
+
private final Supplier<IDStarAlgorithm> implSupplier;
- private DStarAlgorithmEnum(Supplier<IDStarAlgorithm> implSupplier) {
+ DStarAlgorithmEnum(Supplier<IDStarAlgorithm> implSupplier) {
this.implSupplier = implSupplier;
}
-
+
/**
* @return a new function implementation instance
*/
}
AreaEval db = (AreaEval)database;
AreaEval cdb = (AreaEval)conditionDatabase;
-
+
try {
filterColumn = OperandResolver.getSingleValue(filterColumn, srcRowIndex, srcColumnIndex);
} catch (EvaluationException e) {
}
/**
- *
+ *
*
* @param nameValueEval Must not be a RefEval or AreaEval. Thus make sure resolveReference() is called on the value first!
* @param db Database
*/
private static int getColumnForName(ValueEval nameValueEval, AreaEval db)
throws EvaluationException {
- String name = OperandResolver.coerceValueToString(nameValueEval);
- return getColumnForString(db, name);
+ if (nameValueEval instanceof NumericValueEval) {
+ int columnNo = OperandResolver.coerceValueToInt(nameValueEval) - 1;
+ if (columnNo < 0 || columnNo >= db.getWidth()) {
+ return -1;
+ }
+ return columnNo;
+ }
+ else {
+ String name = OperandResolver.coerceValueToString(nameValueEval);
+ return getColumnForString(db, name);
+ }
}
/**
* @param db Database.
* @param name Column heading.
* @return Corresponding column number.
- * @throws EvaluationException If it's not possible to turn all headings into strings.
*/
- private static int getColumnForString(AreaEval db,String name)
- throws EvaluationException {
+ private static int getColumnForString(AreaEval db,String name) {
int resultColumn = -1;
final int width = db.getWidth();
for(int column = 0; column < width; ++column) {
// special column that accepts formulas.
boolean columnCondition = true;
ValueEval condition;
-
+
// The condition to apply.
condition = resolveReference(cdb, conditionRow, column);
-
+
// If the condition is empty it matches.
if(condition instanceof BlankEval)
continue;
if(!(targetHeader instanceof StringValueEval)) {
throw new EvaluationException(ErrorEval.VALUE_INVALID);
}
-
+
if (getColumnForName(targetHeader, db) == -1)
// No column found, it's again a special column that accepts formulas.
columnCondition = false;
throws EvaluationException {
if(condition instanceof StringEval) {
String conditionString = ((StringEval)condition).getStringValue();
-
+
if(conditionString.startsWith("<")) { // It's a </<= condition.
String number = conditionString.substring(1);
if(number.startsWith("=")) {
}
return false; // Can not be reached.
}
-
+
private static Double getNumberFromValueEval(ValueEval value) {
if(value instanceof NumericValueEval) {
return ((NumericValueEval)value).getNumberValue();
return null;
}
}
-
+
/**
* Resolve a ValueEval that's in an AreaEval.
*
- * @param db AreaEval from which the cell to resolve is retrieved.
+ * @param db AreaEval from which the cell to resolve is retrieved.
* @param dbRow Relative row in the AreaEval.
* @param dbCol Relative column in the AreaEval.
* @return A ValueEval that is a NumberEval, StringEval, BoolEval, BlankEval or ErrorEval.