package net.sf.jasperreports.charts.base;

import net.sf.jasperreports.charts.JRXyDataset;
import net.sf.jasperreports.charts.JRXySeries;
import net.sf.jasperreports.engine.JRChartDataset;
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 JRBaseXyDataset extends JRBaseChartDataset implements JRXyDataset {
  private static final long serialVersionUID = 10200L;
  
  protected JRXySeries[] xySeries = null;
  
  public JRBaseXyDataset(JRChartDataset dataset) {
    super(dataset);
  }
  
  public JRBaseXyDataset(JRXyDataset dataset, JRBaseObjectFactory factory) {
    super((JRChartDataset)dataset, factory);
    JRXySeries[] srcXySeries = dataset.getSeries();
    if (srcXySeries != null && srcXySeries.length > 0) {
      this.xySeries = new JRXySeries[srcXySeries.length];
      for (int i = 0; i < this.xySeries.length; i++)
        this.xySeries[i] = factory.getXySeries(srcXySeries[i]); 
    } 
  }
  
  public JRXySeries[] getSeries() {
    return this.xySeries;
  }
  
  public byte getDatasetType() {
    return 3;
  }
  
  public void collectExpressions(JRExpressionCollector collector) {
    collector.collect(this);
  }
  
  public void validate(JRVerifier verifier) {
    verifier.verify(this);
  }
  
  public Object clone() {
    JRBaseXyDataset clone = (JRBaseXyDataset)super.clone();
    if (this.xySeries != null) {
      clone.xySeries = new JRXySeries[this.xySeries.length];
      for (int i = 0; i < this.xySeries.length; i++)
        this.xySeries[i] = (JRXySeries)this.xySeries[i].clone(); 
    } 
    return clone;
  }
}
