package net.sf.jasperreports.crosstabs.base;

import java.io.Serializable;
import net.sf.jasperreports.crosstabs.JRCellContents;
import net.sf.jasperreports.crosstabs.JRCrosstabBucket;
import net.sf.jasperreports.crosstabs.JRCrosstabGroup;
import net.sf.jasperreports.engine.JRVariable;
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;

public abstract class JRBaseCrosstabGroup implements JRCrosstabGroup, Serializable {
  protected String name;
  
  protected byte totalPosition = 0;
  
  protected JRCrosstabBucket bucket;
  
  protected JRCellContents header;
  
  protected JRCellContents totalHeader;
  
  protected JRVariable variable;
  
  protected JRBaseCrosstabGroup() {}
  
  public JRBaseCrosstabGroup(JRCrosstabGroup group, JRBaseObjectFactory factory) {
    factory.put(group, this);
    this.name = group.getName();
    this.totalPosition = group.getTotalPosition();
    this.bucket = factory.getCrosstabBucket(group.getBucket());
    this.header = factory.getCell(group.getHeader());
    this.totalHeader = factory.getCell(group.getTotalHeader());
    this.variable = (JRVariable)factory.getVariable(group.getVariable());
  }
  
  public String getName() {
    return this.name;
  }
  
  public JRCrosstabBucket getBucket() {
    return this.bucket;
  }
  
  public byte getTotalPosition() {
    return this.totalPosition;
  }
  
  public boolean hasTotal() {
    return (this.totalPosition != 0);
  }
  
  public JRCellContents getHeader() {
    return this.header;
  }
  
  public JRCellContents getTotalHeader() {
    return this.totalHeader;
  }
  
  public JRVariable getVariable() {
    return this.variable;
  }
  
  public Object clone() {
    return null;
  }
}
