1 5 6 7 package com.raptus.owxv3; 8 9 10 import java.util.*; 11 12 13 46 public class PropertiesConfigManager extends Object implements ConfigManagerIFace 47 { 48 49 50 56 public static final String PARAM_PREFIX = "PropertiesConfigManager."; 57 58 63 protected static final String FILENAME_KEY = "FileName"; 64 65 66 67 70 protected String myFileName; 71 72 76 protected Configuration myConfiguration; 77 78 79 80 81 84 public PropertiesConfigManager() 85 { 86 } 87 88 89 90 93 public boolean initialize(Hashtable hash) 94 { 95 myFileName = (String ) hash.get(ConfigManager.PARAM_PREFIX + PARAM_PREFIX + FILENAME_KEY); 96 return load(); 97 } 98 99 102 public void refresh() 103 { 104 load(); 105 } 106 107 110 public boolean saveConfiguration(Configuration cfg) 111 { 112 PropertiesFile pf = new PropertiesFile(myFileName); 113 if(!pf.load()) 114 return false; 115 116 pf.setPropertiesHash(myConfiguration.getConfigHash()); 117 118 if(!pf.store()) 119 return false; 120 121 return true; 122 } 123 124 127 public Configuration getConfiguration() 128 { 129 return myConfiguration; 130 } 131 132 138 public boolean load() 139 { 140 PropertiesFile pf = new PropertiesFile(myFileName); 141 if(pf.load()) 142 { 143 myConfiguration = new Configuration(pf.getPropertiesHash()); 144 return true; 145 } 146 147 return false; 148 } 149 } 150 | Popular Tags |