package net.sf.jasperreports.charts.base;

import java.io.Serializable;
import net.sf.jasperreports.charts.JRTimePeriodSeries;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRHyperlink;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;

public class JRBaseTimePeriodSeries implements JRTimePeriodSeries, Serializable {
  private static final long serialVersionUID = 608L;
  
  protected JRExpression seriesExpression;
  
  protected JRExpression startDateExpression;
  
  protected JRExpression endDateExpression;
  
  protected JRExpression valueExpression;
  
  protected JRExpression labelExpression;
  
  protected JRHyperlink itemHyperlink;
  
  protected JRBaseTimePeriodSeries() {}
  
  public JRBaseTimePeriodSeries(JRTimePeriodSeries timePeriodSeries, JRBaseObjectFactory factory) {
    factory.put(timePeriodSeries, factory);
    this.seriesExpression = factory.getExpression(timePeriodSeries.getSeriesExpression());
    this.startDateExpression = factory.getExpression(timePeriodSeries.getStartDateExpression());
    this.endDateExpression = factory.getExpression(timePeriodSeries.getEndDateExpression());
    this.valueExpression = factory.getExpression(timePeriodSeries.getValueExpression());
    this.labelExpression = factory.getExpression(timePeriodSeries.getLabelExpression());
    this.itemHyperlink = factory.getHyperlink(timePeriodSeries.getItemHyperlink());
  }
  
  public JRExpression getSeriesExpression() {
    return this.seriesExpression;
  }
  
  public JRExpression getStartDateExpression() {
    return this.startDateExpression;
  }
  
  public JRExpression getEndDateExpression() {
    return this.endDateExpression;
  }
  
  public JRExpression getValueExpression() {
    return this.valueExpression;
  }
  
  public JRExpression getLabelExpression() {
    return this.labelExpression;
  }
  
  public JRHyperlink getItemHyperlink() {
    return this.itemHyperlink;
  }
  
  public Object clone() {
    JRBaseTimePeriodSeries clone = null;
    try {
      clone = (JRBaseTimePeriodSeries)super.clone();
    } catch (CloneNotSupportedException e) {
      throw new JRRuntimeException(e);
    } 
    if (this.seriesExpression != null)
      clone.seriesExpression = (JRExpression)this.seriesExpression.clone(); 
    if (this.startDateExpression != null)
      clone.startDateExpression = (JRExpression)this.startDateExpression.clone(); 
    if (this.endDateExpression != null)
      clone.endDateExpression = (JRExpression)this.endDateExpression.clone(); 
    if (this.valueExpression != null)
      clone.valueExpression = (JRExpression)this.valueExpression.clone(); 
    if (this.labelExpression != null)
      clone.labelExpression = (JRExpression)this.labelExpression.clone(); 
    if (this.itemHyperlink != null)
      clone.itemHyperlink = (JRHyperlink)this.itemHyperlink.clone(); 
    return clone;
  }
}
