56
56
* @version $Rev$
57
57
*/
58
58
public class Translator {
59
+
60
+ /**
61
+ * Filename of the KEGG cache file (implemented just
62
+ * like the browser cache). Must be loaded upon start
63
+ * and saved upon exit.
64
+ */
65
+ public final static String cacheFileName = "keggdb.dat" ;
66
+
67
+ /**
68
+ * Filename of the KEGG function cache file (implemented just
69
+ * like the browser cache). Must be loaded upon start
70
+ * and saved upon exit.
71
+ */
72
+ public final static String cacheFunctionFileName = "keggfc.dat" ;
73
+
74
+ /**
75
+ * The name of the application.
76
+ * Removed the final attribute, such that referencing applications can still change this.
77
+ */
78
+ public static String APPLICATION_NAME = "KEGGtranslator" ;
79
+
80
+ /**
81
+ * Version number of this translator
82
+ */
83
+ public static final String VERSION_NUMBER = "1.2.0" ;
84
+
85
+
59
86
/**
60
87
* The cache to be used by all KEGG interacting classes.
61
88
* Access via {@link #getManager()}.
62
89
*/
63
90
private static KeggInfoManagement manager =null ;
91
+
64
92
/**
65
93
* The cache to be used by all KEGG-Functions interacting classes.
66
94
* Access via {@link #getFunctionManager()}.
@@ -201,14 +229,14 @@ public static boolean translate(Format format, String input, String output)
201
229
public synchronized static KeggInfoManagement getManager () {
202
230
203
231
// Try to load from cache file
204
- if (manager ==null && new File (KEGGtranslator .cacheFileName ).exists () && new File (KEGGtranslator .cacheFileName ).length () > 0 ) {
232
+ if (manager ==null && new File (Translator .cacheFileName ).exists () && new File (Translator .cacheFileName ).length () > 0 ) {
205
233
try {
206
- manager = (KeggInfoManagement ) KeggInfoManagement .loadFromFilesystem (KEGGtranslator .cacheFileName );
234
+ manager = (KeggInfoManagement ) KeggInfoManagement .loadFromFilesystem (Translator .cacheFileName );
207
235
} catch (Throwable e ) { // IOException or class cast, if class is moved.
208
236
e .printStackTrace ();
209
237
// Delete invalid cache file
210
238
try {
211
- File f = new File (KEGGtranslator .cacheFileName );
239
+ File f = new File (Translator .cacheFileName );
212
240
if (f .exists () && f .canRead ()) {
213
241
System .out .println ("Deleting invalid cache file " + f .getName ());
214
242
f .delete ();
@@ -229,15 +257,15 @@ public synchronized static KeggInfoManagement getManager() {
229
257
public synchronized static KeggFunctionManagement getFunctionManager () {
230
258
231
259
// Try to load from cache file
232
- if (managerFunction ==null && new File (KEGGtranslator .cacheFunctionFileName ).exists () && new File (KEGGtranslator .cacheFunctionFileName ).length () > 0 ) {
260
+ if (managerFunction ==null && new File (Translator .cacheFunctionFileName ).exists () && new File (Translator .cacheFunctionFileName ).length () > 0 ) {
233
261
try {
234
- managerFunction = (KeggFunctionManagement ) KeggFunctionManagement .loadFromFilesystem (KEGGtranslator .cacheFunctionFileName );
262
+ managerFunction = (KeggFunctionManagement ) KeggFunctionManagement .loadFromFilesystem (Translator .cacheFunctionFileName );
235
263
} catch (Throwable e ) { // IOException or class cast, if class is moved.
236
264
e .printStackTrace ();
237
265
238
266
// Delete invalid cache file
239
267
try {
240
- File f = new File (KEGGtranslator .cacheFunctionFileName );
268
+ File f = new File (Translator .cacheFunctionFileName );
241
269
if (f .exists () && f .canRead ()) {
242
270
System .out .println ("Deleting invalid cache file " + f .getName ());
243
271
f .delete ();
@@ -259,10 +287,10 @@ public synchronized static KeggFunctionManagement getFunctionManager() {
259
287
*/
260
288
public synchronized static void saveCache () {
261
289
if (manager !=null && manager .hasChanged ()) {
262
- KeggInfoManagement .saveToFilesystem (KEGGtranslator .cacheFileName , manager );
290
+ KeggInfoManagement .saveToFilesystem (Translator .cacheFileName , manager );
263
291
}
264
292
if (managerFunction !=null && managerFunction .isCacheChangedSinceLastLoading ()) {
265
- KeggFunctionManagement .saveToFilesystem (KEGGtranslator .cacheFunctionFileName , managerFunction );
293
+ KeggFunctionManagement .saveToFilesystem (Translator .cacheFunctionFileName , managerFunction );
266
294
}
267
295
}
268
296
0 commit comments