Search in sources :

Example 1 with ErrorValue

use of org.pentaho.reporting.libraries.formula.ErrorValue 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;
}
Also used : LibFormulaErrorValue(org.pentaho.reporting.libraries.formula.LibFormulaErrorValue) LibFormulaErrorValue(org.pentaho.reporting.libraries.formula.LibFormulaErrorValue) ErrorValue(org.pentaho.reporting.libraries.formula.ErrorValue) EvaluationException(org.pentaho.reporting.libraries.formula.EvaluationException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

KettleValueException (org.pentaho.di.core.exception.KettleValueException)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 ErrorValue (org.pentaho.reporting.libraries.formula.ErrorValue)1 EvaluationException (org.pentaho.reporting.libraries.formula.EvaluationException)1 LibFormulaErrorValue (org.pentaho.reporting.libraries.formula.LibFormulaErrorValue)1