2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: ConfMap.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.3 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2005/03/10 15:27:01 $ |
2 |
26 Feb 07 |
jari |
* $Author: braistedj $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.util; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.net.MalformedURLException; |
2 |
26 Feb 07 |
jari |
15 |
import java.net.URL; |
2 |
26 Feb 07 |
jari |
16 |
|
2 |
26 Feb 07 |
jari |
17 |
public class ConfMap extends java.util.Properties { |
2 |
26 Feb 07 |
jari |
18 |
|
2 |
26 Feb 07 |
jari |
19 |
public String getString(String key) { |
2 |
26 Feb 07 |
jari |
20 |
return getProperty(key); |
2 |
26 Feb 07 |
jari |
21 |
} |
2 |
26 Feb 07 |
jari |
22 |
|
2 |
26 Feb 07 |
jari |
23 |
public boolean getBoolean(String key) { |
2 |
26 Feb 07 |
jari |
24 |
return Boolean.valueOf(getProperty(key)).booleanValue(); |
2 |
26 Feb 07 |
jari |
25 |
} |
2 |
26 Feb 07 |
jari |
26 |
|
2 |
26 Feb 07 |
jari |
27 |
public boolean getBoolean(String key, boolean defValue) { |
2 |
26 Feb 07 |
jari |
28 |
String bool = getProperty(key); |
2 |
26 Feb 07 |
jari |
29 |
if (bool == null) |
2 |
26 Feb 07 |
jari |
30 |
return defValue; |
2 |
26 Feb 07 |
jari |
31 |
return Boolean.valueOf(bool).booleanValue(); |
2 |
26 Feb 07 |
jari |
32 |
} |
2 |
26 Feb 07 |
jari |
33 |
|
2 |
26 Feb 07 |
jari |
34 |
public int getInt(String key) { |
2 |
26 Feb 07 |
jari |
35 |
return Integer.parseInt(getProperty(key)); |
2 |
26 Feb 07 |
jari |
36 |
} |
2 |
26 Feb 07 |
jari |
37 |
|
2 |
26 Feb 07 |
jari |
38 |
public int getInt(String key, int defValue) { |
2 |
26 Feb 07 |
jari |
39 |
int value; |
2 |
26 Feb 07 |
jari |
40 |
try { |
2 |
26 Feb 07 |
jari |
41 |
value = Integer.parseInt(getProperty(key)); |
2 |
26 Feb 07 |
jari |
42 |
} catch (Exception nfe) { |
2 |
26 Feb 07 |
jari |
43 |
return defValue; |
2 |
26 Feb 07 |
jari |
44 |
} |
2 |
26 Feb 07 |
jari |
45 |
return value; |
2 |
26 Feb 07 |
jari |
46 |
} |
2 |
26 Feb 07 |
jari |
47 |
|
2 |
26 Feb 07 |
jari |
48 |
public long getLong(String key) { |
2 |
26 Feb 07 |
jari |
49 |
return Long.parseLong(getProperty(key)); |
2 |
26 Feb 07 |
jari |
50 |
} |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
public long getLong(String key, long defValue) { |
2 |
26 Feb 07 |
jari |
53 |
long value; |
2 |
26 Feb 07 |
jari |
54 |
try { |
2 |
26 Feb 07 |
jari |
55 |
value = Long.parseLong(getProperty(key)); |
2 |
26 Feb 07 |
jari |
56 |
} catch (Exception nfe) { |
2 |
26 Feb 07 |
jari |
57 |
return defValue; |
2 |
26 Feb 07 |
jari |
58 |
} |
2 |
26 Feb 07 |
jari |
59 |
return value; |
2 |
26 Feb 07 |
jari |
60 |
} |
2 |
26 Feb 07 |
jari |
61 |
|
2 |
26 Feb 07 |
jari |
62 |
public float getFloat(String key) { |
2 |
26 Feb 07 |
jari |
63 |
return Float.parseFloat( getProperty(key) ); |
2 |
26 Feb 07 |
jari |
64 |
} |
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
public float getFloat(String key, float defValue) { |
2 |
26 Feb 07 |
jari |
67 |
float value; |
2 |
26 Feb 07 |
jari |
68 |
try { |
2 |
26 Feb 07 |
jari |
69 |
value = Float.parseFloat( getProperty(key) ); |
2 |
26 Feb 07 |
jari |
70 |
} catch (Exception nfe) { |
2 |
26 Feb 07 |
jari |
71 |
return defValue; |
2 |
26 Feb 07 |
jari |
72 |
} |
2 |
26 Feb 07 |
jari |
73 |
return value; |
2 |
26 Feb 07 |
jari |
74 |
} |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
76 |
public URL getURL(String key) throws MalformedURLException { |
2 |
26 Feb 07 |
jari |
77 |
return new URL(getProperty(key)); |
2 |
26 Feb 07 |
jari |
78 |
} |
2 |
26 Feb 07 |
jari |
79 |
|
2 |
26 Feb 07 |
jari |
80 |
} |