package net.sf.jasperreports.charts.base;

import java.io.Serializable;
import net.sf.jasperreports.charts.JRXySeries;
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 JRBaseXySeries implements JRXySeries, Serializable {
  private static final long serialVersionUID = 10200L;
  
  protected JRExpression seriesExpression = null;
  
  protected JRExpression xValueExpression = null;
  
  protected JRExpression yValueExpression = null;
  
  protected JRExpression labelExpression = null;
  
  protected JRHyperlink itemHyperlink;
  
  protected JRBaseXySeries() {}
  
  public JRBaseXySeries(JRXySeries xySeries, JRBaseObjectFactory factory) {
    factory.put(xySeries, this);
    this.seriesExpression = factory.getExpression(xySeries.getSeriesExpression());
    this.xValueExpression = factory.getExpression(xySeries.getXValueExpression());
    this.yValueExpression = factory.getExpression(xySeries.getYValueExpression());
    this.labelExpression = factory.getExpression(xySeries.getLabelExpression());
    this.itemHyperlink = factory.getHyperlink(xySeries.getItemHyperlink());
  }
  
  public JRExpression getSeriesExpression() {
    return this.seriesExpression;
  }
  
  public JRExpression getXValueExpression() {
    return this.xValueExpression;
  }
  
  public JRExpression getYValueExpression() {
    return this.yValueExpression;
  }
  
  public JRExpression getLabelExpression() {
    return this.labelExpression;
  }
  
  public JRHyperlink getItemHyperlink() {
    return this.itemHyperlink;
  }
  
  public Object clone() {
    JRBaseXySeries clone = null;
    try {
      clone = (JRBaseXySeries)super.clone();
    } catch (CloneNotSupportedException e) {
      throw new JRRuntimeException(e);
    } 
    if (this.seriesExpression != null)
      clone.seriesExpression = (JRExpression)this.seriesExpression.clone(); 
    if (this.xValueExpression != null)
      clone.xValueExpression = (JRExpression)this.xValueExpression.clone(); 
    if (this.yValueExpression != null)
      clone.yValueExpression = (JRExpression)this.yValueExpression.clone(); 
    if (this.labelExpression != null)
      clone.labelExpression = (JRExpression)this.labelExpression.clone(); 
    if (this.itemHyperlink != null)
      clone.itemHyperlink = (JRHyperlink)this.itemHyperlink.clone(); 
    return clone;
  }
}
