package net.sf.jasperreports.crosstabs.fill;

import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.fill.JREvaluator;
import net.sf.jasperreports.engine.fill.JRFillExpressionEvaluator;

public class JRCrosstabExpressionEvaluator implements JRFillExpressionEvaluator {
  private final JREvaluator evaluator;
  
  public JRCrosstabExpressionEvaluator(JREvaluator evaluator) {
    this.evaluator = evaluator;
  }
  
  public Object evaluate(JRExpression expression, byte evaluationType) throws JRException {
    if (evaluationType != 3)
      throw new JRException("The crosstab evaluator doesn't support old or estimated expression evaluation."); 
    return this.evaluator.evaluate(expression);
  }
  
  public void init(Map parametersMap, Map variablesMap, byte whenResourceMissingType) throws JRException {
    this.evaluator.init(parametersMap, null, variablesMap, whenResourceMissingType);
  }
}
