Changeset 5296
- Timestamp:
- 2003-08-27T15:05:14+12:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Dictionary.java
r5164 r5296 36 36 *######################################################################## 37 37 */ 38 import java.io.*; 38 39 import java.util.*; 39 40 import javax.swing.*; … … 69 70 public class Dictionary 70 71 extends HashMap { 72 73 static final private boolean KEY_LIST_DEBUG = true; 74 static final private String KEY_LIST_FILENAME = "keylist.txt"; 75 71 76 /** A String which more explicitly states the Locale of this dictionary. */ 72 77 public String language = null; … … 79 84 /** The ResourceBundle which contains the raw key-value mappings. Loaded from a file named "dictionary<I>locale</I>.properties*/ 80 85 private ResourceBundle dictionary = null; 86 87 private TreeSet key_list = null;; 88 81 89 /** Constructs the Dictionary class by first checking if a Locale has been set. If not the default locale is used, and a ResourceBundle is created. Finally a single important String, Language, is made available outside the class so a more read-able version of the Locale of this Dictionary is present. 82 90 * @param locale The <strong>Locale</strong> used to load the desired dictionary resource bundle. … … 85 93 super(); 86 94 this.self = this; 95 96 if(KEY_LIST_DEBUG) { 97 // Reload the keylist 98 File file = new File(KEY_LIST_FILENAME); 99 key_list = new TreeSet(); 100 try { 101 BufferedReader br = new BufferedReader(new FileReader(file)); 102 String line; 103 while((line = br.readLine()) != null) { 104 key_list.add(line); 105 } 106 br.close(); 107 br = null; 108 } 109 catch(Exception error) { 110 error.printStackTrace(); 111 } 112 } 113 87 114 // Initialize. 88 115 this.font = font; … … 146 173 } 147 174 175 public void destroy() { 176 if(key_list != null) { 177 try { 178 FileOutputStream fos = new FileOutputStream(KEY_LIST_FILENAME); 179 for(Iterator iter = key_list.iterator(); iter.hasNext(); ) { 180 String value = (String) iter.next(); 181 fos.write(value.getBytes()); 182 fos.write('\n'); 183 value = null; 184 } 185 fos.close(); 186 fos = null; 187 } 188 catch(Exception error) { 189 error.printStackTrace(); 190 } 191 } 192 } 193 148 194 /** Overloaded to call get with both a key and an empty argument array. 149 195 * @param key A <strong>String</strong> which is mapped to a initial String within the ResourceBundle. … … 166 212 */ 167 213 public String get(String key, String args[]) { 214 if(key_list != null) { 215 synchronized(this) { 216 key_list.add(key); 217 } 218 } 168 219 try { 169 220 String initial = dictionary.getString(key); -
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r5253 r5296 341 341 // Save configuration. 342 342 saveConfig(); 343 344 // Flush dictionary 345 dictionary.destroy(); 346 343 347 // Flush debug 344 348 if(debug != null) { … … 593 597 // Splash screen. 594 598 Splash splash = new Splash(); 595 599 dictionary.destroy(); 596 600 gatherer.run(size, gsdl_path, exec_path, debug, perl_path, no_load, splash, filename); 597 601 }
Note:
See TracChangeset
for help on using the changeset viewer.