use of org.pentaho.reporting.libraries.formula.EvaluationException in project pentaho-kettle by pentaho.
the class RowForumulaContext method resolveReference.
/**
* We return the content of a Value with the given name. We cache the position of the field indexes.
*
* @see org.jfree.formula.FormulaContext#resolveReference(java.lang.Object)
*/
public Object resolveReference(Object name) throws EvaluationException {
if (name instanceof String) {
ValueMetaInterface valueMeta;
Integer idx = valueIndexMap.get(name);
if (idx != null) {
valueMeta = rowMeta.getValueMeta(idx.intValue());
} else {
int index = rowMeta.indexOfValue((String) name);
if (index < 0) {
ErrorValue errorValue = new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT);
throw new EvaluationException(errorValue);
}
valueMeta = rowMeta.getValueMeta(index);
idx = new Integer(index);
valueIndexMap.put((String) name, idx);
}
Object valueData = rowData[idx];
try {
return getPrimitive(valueMeta, valueData);
} catch (KettleValueException e) {
throw new EvaluationException(LibFormulaErrorValue.ERROR_ARITHMETIC_VALUE);
}
}
return null;
}
Aggregations