package net.sf.jasperreports.crosstabs.base;

import java.io.Serializable;
import net.sf.jasperreports.crosstabs.JRCellContents;
import net.sf.jasperreports.crosstabs.JRCrosstabCell;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;

public class JRBaseCrosstabCell implements JRCrosstabCell, Serializable {
  private static final long serialVersionUID = 10200L;
  
  protected Integer width;
  
  protected Integer height;
  
  protected String rowTotalGroup;
  
  protected String columnTotalGroup;
  
  protected JRCellContents contents;
  
  protected JRBaseCrosstabCell() {}
  
  public JRBaseCrosstabCell(JRCrosstabCell crosstabCell, JRBaseObjectFactory factory) {
    factory.put(crosstabCell, this);
    this.width = crosstabCell.getWidth();
    this.height = crosstabCell.getHeight();
    this.rowTotalGroup = crosstabCell.getRowTotalGroup();
    this.columnTotalGroup = crosstabCell.getColumnTotalGroup();
    this.contents = factory.getCell(crosstabCell.getContents());
  }
  
  public String getRowTotalGroup() {
    return this.rowTotalGroup;
  }
  
  public String getColumnTotalGroup() {
    return this.columnTotalGroup;
  }
  
  public JRCellContents getContents() {
    return this.contents;
  }
  
  public Integer getHeight() {
    return this.height;
  }
  
  public Integer getWidth() {
    return this.width;
  }
  
  public Object clone() {
    JRBaseCrosstabCell clone = null;
    try {
      clone = (JRBaseCrosstabCell)super.clone();
    } catch (CloneNotSupportedException e) {
      throw new JRRuntimeException(e);
    } 
    if (this.contents != null)
      clone.contents = (JRCellContents)this.contents.clone(); 
    return clone;
  }
}
