package net.sf.jasperreports.engine.fill;

import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.JRPropertiesHolder;
import net.sf.jasperreports.engine.JRPropertiesMap;

public class JRFillField implements JRField {
  protected JRField parent = null;
  
  private Object previousOldValue = null;
  
  private Object oldValue = null;
  
  private Object value = null;
  
  private Object savedValue;
  
  protected JRFillField(JRField field, JRFillObjectFactory factory) {
    factory.put(field, this);
    this.parent = field;
  }
  
  public String getName() {
    return this.parent.getName();
  }
  
  public String getDescription() {
    return this.parent.getDescription();
  }
  
  public void setDescription(String description) {}
  
  public Class getValueClass() {
    return this.parent.getValueClass();
  }
  
  public String getValueClassName() {
    return this.parent.getValueClassName();
  }
  
  public Object getOldValue() {
    return this.oldValue;
  }
  
  public void setOldValue(Object oldValue) {
    this.oldValue = oldValue;
  }
  
  public Object getValue() {
    return this.value;
  }
  
  public void setValue(Object value) {
    this.value = value;
  }
  
  public Object getValue(byte evaluation) {
    switch (evaluation) {
      case 1:
        returnValue = this.oldValue;
        return returnValue;
    } 
    Object returnValue = this.value;
    return returnValue;
  }
  
  public void overwriteValue(Object newValue, byte evaluation) {
    switch (evaluation) {
      case 1:
        this.savedValue = this.oldValue;
        this.oldValue = newValue;
        return;
    } 
    this.savedValue = this.value;
    this.value = newValue;
  }
  
  public void restoreValue(byte evaluation) {
    switch (evaluation) {
      case 1:
        this.oldValue = this.savedValue;
        break;
      default:
        this.value = this.savedValue;
        break;
    } 
    this.savedValue = null;
  }
  
  public Object getPreviousOldValue() {
    return this.previousOldValue;
  }
  
  public void setPreviousOldValue(Object previousOldValue) {
    this.previousOldValue = previousOldValue;
  }
  
  public boolean hasProperties() {
    return this.parent.hasProperties();
  }
  
  public JRPropertiesMap getPropertiesMap() {
    return this.parent.getPropertiesMap();
  }
  
  public JRPropertiesHolder getParentProperties() {
    return null;
  }
  
  public Object clone() {
    return null;
  }
}
