package net.sf.jasperreports.charts.base;

import net.sf.jasperreports.charts.JRValueDataset;
import net.sf.jasperreports.engine.JRChartDataset;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.base.JRBaseChartDataset;
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
import net.sf.jasperreports.engine.design.JRVerifier;

public class JRBaseValueDataset extends JRBaseChartDataset implements JRValueDataset {
  private static final long serialVersionUID = 10200L;
  
  protected JRExpression valueExpression = null;
  
  public JRBaseValueDataset(JRChartDataset dataset) {
    super(dataset);
  }
  
  public JRBaseValueDataset(JRValueDataset dataset, JRBaseObjectFactory factory) {
    super((JRChartDataset)dataset, factory);
    this.valueExpression = factory.getExpression(dataset.getValueExpression());
  }
  
  public JRExpression getValueExpression() {
    return this.valueExpression;
  }
  
  public byte getDatasetType() {
    return 8;
  }
  
  public void collectExpressions(JRExpressionCollector collector) {
    collector.collect(this);
  }
  
  public void validate(JRVerifier verifier) {
    verifier.verify(this);
  }
  
  public Object clone() {
    JRBaseValueDataset clone = (JRBaseValueDataset)super.clone();
    if (this.valueExpression != null)
      clone.valueExpression = (JRExpression)this.valueExpression.clone(); 
    return clone;
  }
}
