package net.sf.jasperreports.engine.design;

import java.util.List;
import java.util.Map;
import net.sf.jasperreports.crosstabs.JRCrosstab;
import net.sf.jasperreports.crosstabs.design.JRDesignCrosstab;
import net.sf.jasperreports.engine.JRDataset;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRVariable;

public class JRSourceCompileTask {
  private JasperDesign jasperDesign;
  
  private String unitName;
  
  private JRExpressionCollector expressionCollector;
  
  private Map parametersMap;
  
  private Map fieldsMap;
  
  private Map variablesMap;
  
  private JRVariable[] variables;
  
  private List expressions;
  
  private boolean onlyDefaultEvaluation;
  
  protected JRSourceCompileTask(JasperDesign jasperDesign, String unitName, JRExpressionCollector expressionCollector, Map parametersMap, Map fieldsMap, Map variablesMap, JRVariable[] variables, boolean onlyDefaultEvaluation) {
    this.jasperDesign = jasperDesign;
    this.unitName = unitName;
    this.expressionCollector = expressionCollector;
    this.parametersMap = parametersMap;
    this.fieldsMap = fieldsMap;
    this.variablesMap = variablesMap;
    this.variables = variables;
    this.expressions = expressionCollector.getExpressions();
    this.onlyDefaultEvaluation = onlyDefaultEvaluation;
  }
  
  public JRSourceCompileTask(JasperDesign jasperDesign, JRDesignDataset dataset, JRExpressionCollector expressionCollector, String unitName) {
    this(jasperDesign, unitName, expressionCollector.getCollector((JRDataset)dataset), dataset.getParametersMap(), dataset.getFieldsMap(), dataset.getVariablesMap(), dataset.getVariables(), false);
  }
  
  public JRSourceCompileTask(JasperDesign jasperDesign, JRDesignCrosstab crosstab, JRExpressionCollector expressionCollector, String unitName) {
    this(jasperDesign, unitName, expressionCollector.getCollector((JRCrosstab)crosstab), crosstab.getParametersMap(), null, crosstab.getVariablesMap(), crosstab.getVariables(), true);
  }
  
  public List getExpressions() {
    return this.expressions;
  }
  
  public Map getFieldsMap() {
    return this.fieldsMap;
  }
  
  public JasperDesign getJasperDesign() {
    return this.jasperDesign;
  }
  
  public String[] getImports() {
    return this.jasperDesign.getImports();
  }
  
  public boolean isOnlyDefaultEvaluation() {
    return this.onlyDefaultEvaluation;
  }
  
  public Map getParametersMap() {
    return this.parametersMap;
  }
  
  public String getUnitName() {
    return this.unitName;
  }
  
  public JRVariable[] getVariables() {
    return this.variables;
  }
  
  public Map getVariablesMap() {
    return this.variablesMap;
  }
  
  public Integer getExpressionId(JRExpression expression) {
    return this.expressionCollector.getExpressionId(expression);
  }
  
  public JRExpression getExpression(int expressionId) {
    return this.expressionCollector.getExpression(expressionId);
  }
}
