/**
* Evaluates the operator
*/
public ValueHolder evaluate(final FormulaContext ctx, final ValueHolder[] params) {
ValueHolder v1 = params[0]; // Fetch first element to determine operation
ValueHolder v2 = params[1]; // Fetch first element to determine operation
if (v1.dataType == DataType.ERROR) {
return v1;
}
if (v2.dataType == DataType.ERROR) {
return v2;
}
boolean multi = v1.size > 1 ? true : false;
if (v2.size > 1)
multi = true;
switch (v1.dataType) {
case DATETIME:
if (v2.dataType == DataType.DATETIME) {
if (multi)
return evaluateDateTime(ctx, params);
return evaluateDateTime(ctx, v1.getDateTime(0), v2.getDateTime(0));
}
break;
case INTEGER:
if (v2.dataType == DataType.INTEGER) {
if (multi)
return evaluateInt(ctx, params);
return evaluateInt(ctx, v1.getInt(0), v2.getInt(0));
}
//do not break - fall through. It may be integer & double
case DOUBLE:
if (v2.dataType.numeric) {
if (multi)
return evaluateNumber(ctx, params);
return evaluateNumber(ctx, v1.getDouble(0), v2.getDouble(0));
}
break;
case STRING:
if (v2.dataType == DataType.STRING) {
if (multi)
return evaluateString(ctx, params);
return evaluateString(ctx, v1.getString(0), v2.getString(0));
}
break;
case BOOLEAN:
if (v2.dataType == DataType.BOOLEAN) {
if (multi)
return evaluateBoolean(ctx, params);
return evaluateBoolean(ctx, v1.getBoolean(0), v2.getBoolean(0));
}
break;
case _UNSET:
break;