package net.sf.jasperreports.charts.base;

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

public class JRBasePieDataset extends JRBaseChartDataset implements JRPieDataset {
  private static final long serialVersionUID = 10200L;
  
  protected JRExpression keyExpression = null;
  
  protected JRExpression valueExpression = null;
  
  protected JRExpression labelExpression = null;
  
  private JRHyperlink sectionHyperlink;
  
  public JRBasePieDataset(JRChartDataset dataset) {
    super(dataset);
  }
  
  public JRBasePieDataset(JRPieDataset dataset, JRBaseObjectFactory factory) {
    super((JRChartDataset)dataset, factory);
    this.keyExpression = factory.getExpression(dataset.getKeyExpression());
    this.valueExpression = factory.getExpression(dataset.getValueExpression());
    this.labelExpression = factory.getExpression(dataset.getLabelExpression());
    this.sectionHyperlink = factory.getHyperlink(dataset.getSectionHyperlink());
  }
  
  public JRExpression getKeyExpression() {
    return this.keyExpression;
  }
  
  public JRExpression getValueExpression() {
    return this.valueExpression;
  }
  
  public JRExpression getLabelExpression() {
    return this.labelExpression;
  }
  
  public byte getDatasetType() {
    return 1;
  }
  
  public void collectExpressions(JRExpressionCollector collector) {
    collector.collect(this);
  }
  
  public JRHyperlink getSectionHyperlink() {
    return this.sectionHyperlink;
  }
  
  public void validate(JRVerifier verifier) {
    verifier.verify(this);
  }
  
  public Object clone() {
    JRBasePieDataset clone = (JRBasePieDataset)super.clone();
    if (this.keyExpression != null)
      clone.keyExpression = (JRExpression)this.keyExpression.clone(); 
    if (this.valueExpression != null)
      clone.valueExpression = (JRExpression)this.valueExpression.clone(); 
    if (this.labelExpression != null)
      clone.labelExpression = (JRExpression)this.labelExpression.clone(); 
    if (this.sectionHyperlink != null)
      clone.sectionHyperlink = (JRHyperlink)this.sectionHyperlink.clone(); 
    return clone;
  }
}
