package jxl.read.biff;

import common.Assert;
import jxl.BooleanCell;
import jxl.CellType;
import jxl.biff.FormattingRecords;

class BooleanRecord extends CellValue implements BooleanCell {
  private boolean error;
  
  private boolean value;
  
  public BooleanRecord(Record t, FormattingRecords fr, SheetImpl si) {
    super(t, fr, si);
    this.error = false;
    this.value = false;
    byte[] data = getRecord().getData();
    this.error = (data[7] == 1);
    if (!this.error)
      this.value = (data[6] == 1); 
  }
  
  public boolean isError() {
    return this.error;
  }
  
  public boolean getValue() {
    return this.value;
  }
  
  public String getContents() {
    Assert.verify(!isError());
    return (new Boolean(this.value)).toString();
  }
  
  public CellType getType() {
    return CellType.BOOLEAN;
  }
  
  public Record getRecord() {
    return super.getRecord();
  }
}
