X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=src%2Fde%2Fj32%2Fpimstuff%2Fconduit%2FConfig.java;h=4af9b6cbe0327854ea78761086ac8f1cdbe5100a;hb=e4126a1787b7045a53f6074e9ef15681c9f5fde4;hp=54708ce50ec8c58f4c89b947f2200b4abc442e84;hpb=276d9a69fa796728169c2992921a1e4bd875f549;p=jpim.git diff --git a/src/de/j32/pimstuff/conduit/Config.java b/src/de/j32/pimstuff/conduit/Config.java index 54708ce..4af9b6c 100644 --- a/src/de/j32/pimstuff/conduit/Config.java +++ b/src/de/j32/pimstuff/conduit/Config.java @@ -8,46 +8,43 @@ import java.util.Properties; public class Config { - static Config instance; - Properties config = new Properties(); - - public static String get(String key, String defaultValue) - { - load(); - - if (instance == null) - return defaultValue; - else { - String rv = instance.config.getProperty(key); - if (rv == null) - return defaultValue; - return rv; - } - } - - public static String get(String key) - { - String rv = get(key, null); - if (rv == null) - throw new ConfigurationException("missing configuration parameter: " + key); - return rv; - } - - static void load() - { - if (instance == null) - try { - instance = new Config(); - } - catch (InvalidPropertiesFormatException e) {} - catch (FileNotFoundException e) {} - catch (IOException e) {} - } - - Config() - throws InvalidPropertiesFormatException, FileNotFoundException, IOException - { - config.loadFromXML(new FileInputStream("config.xml")); - } - + static Config instance; + Properties config = new Properties(); + + public static String get(String key, String defaultValue) + { + load(); + + if (instance == null) return defaultValue; + else { + String rv = instance.config.getProperty(key); + if (rv == null) return defaultValue; + return rv; + } + } + + public static String get(String key) + { + String rv = get(key, null); + if (rv == null) throw new ConfigurationException( + "missing configuration parameter: " + key); + return rv; + } + + static void load() + { + if (instance == null) try { + instance = new Config(); + } + catch (InvalidPropertiesFormatException e) {} + catch (FileNotFoundException e) {} + catch (IOException e) {} + } + + Config() throws InvalidPropertiesFormatException, FileNotFoundException, + IOException + { + config.loadFromXML(new FileInputStream("config.xml")); + } + }