package net.sf.jasperreports.engine.fill;

import java.util.HashMap;
import java.util.Map;

public class JRFillCloneFactory {
  private Map cloneMap = new HashMap();
  
  protected JRFillCloneable getCached(JRFillCloneable original) {
    return (JRFillCloneable)this.cloneMap.get(original);
  }
  
  public void put(JRFillCloneable original, JRFillCloneable clone) {
    this.cloneMap.put(original, clone);
  }
  
  public JRFillCloneable getClone(JRFillCloneable original) {
    JRFillCloneable clone;
    if (original == null) {
      clone = null;
    } else {
      clone = getCached(original);
      if (clone == null)
        clone = original.createClone(this); 
    } 
    return clone;
  }
}
