1 13 14 package org.ejbca.core.model; 15 16 import java.util.HashMap ; 17 18 19 20 28 public abstract class UpgradeableDataHashMap implements IUpgradeableData, java.io.Serializable { 29 38 private static final long serialVersionUID = -1766329888474901945L; 39 40 43 public UpgradeableDataHashMap() { 44 data = new HashMap (); 45 data.put(VERSION, new Float (getLatestVersion())); 46 } 47 48 53 public abstract float getLatestVersion(); 54 55 60 public float getVersion() { 61 return ((Float ) data.get(VERSION)).floatValue(); 62 } 63 64 69 public Object saveData() { 70 return data; 71 } 72 73 78 public void loadData(Object data) { 79 this.data = (HashMap ) data; 80 81 if(Float.compare(getLatestVersion(), getVersion()) > 0) { 82 upgrade(); 83 } 84 } 85 86 90 public abstract void upgrade(); 91 92 protected HashMap data; 93 public static final String VERSION = "version"; 94 } 95 | Popular Tags |