- made a producer for startpages per topic
[mir.git] / source / mircoders / global / MirGlobal.java
1 package mircoders.global;
2
3 import mir.misc.*;
4 import mircoders.localizer.*;
5
6 import mircoders.localizer.basic.*;
7
8
9 public class MirGlobal {
10   static private MirConfig configuration;
11   static private MirLocalizer localizer;
12   static private ProducerEngine producerEngine;
13
14   public static MirLocalizer localizer() {
15     if (localizer == null ) {
16       localizer = new MirCachingLocalizerDecorator(new MirBasicLocalizer());
17     }
18
19     return localizer;
20   };
21
22   public static MirConfig config() {
23     if (configuration == null) {
24       configuration = new MirConfig();
25     }
26
27     return configuration;
28   };
29
30   public static ProducerEngine producerEngine() {
31     if (producerEngine == null) {
32       producerEngine = new ProducerEngine();
33     }
34
35     return producerEngine;
36   }
37
38   public static String getConfigProperty(String aPropertyName) {
39     String result;
40
41     result = config().getProp(aPropertyName);
42
43     if (result==null)
44       throw new ConfigException("Property '" + aPropertyName + "' not present");
45
46     return result;
47   }
48
49   public static int getConfigIntegerProperty(String aPropertyName) {
50     String result;
51
52     result = config().getProp(aPropertyName);
53
54     return Integer.parseInt(result);
55   }
56
57   public static boolean getConfigBooleanProperty(String aPropertyName) {
58     String result;
59
60     result = config().getProp(aPropertyName);
61
62     if (result==null)
63       throw new ConfigException("Boolean property '" + aPropertyName + "' not present");
64
65     return (result.equals("yes") || result.equals("1"));
66   }
67 }