some code formatting. more property-keys to check.
authoridfx <idfx>
Fri, 28 Feb 2003 17:29:55 +0000 (17:29 +0000)
committeridfx <idfx>
Fri, 28 Feb 2003 17:29:55 +0000 (17:29 +0000)
source/mir/config/MirPropertiesConfiguration.java

index ecebd1c..0d79aaf 100755 (executable)
@@ -53,10 +53,18 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
   private static MirPropertiesConfiguration instance;
   private static ServletContext context;
   private static String contextPath;
-  
+
+  //if one of these properties is not present a new 
+  //emtpy property is added
+  private String[] needed =
+  {
+    "Producer.DocRoot", "Producer.ImageRoot", "Producer.Image.Path",
+    "Producer.Media.Path", "Producer.RealMedia.Path", "Producer.Image.IconPath"
+  };
+
   //if one of these properties is not present a new 
   //emtpy property is added
-  private String[] needed = {"Producer.DocRoot"};
+  private String[] neededWithValue = { "" };
 
   /**
    * Constructor for MirPropertiesConfiguration.
@@ -95,6 +103,18 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
     MirPropertiesConfiguration.context = context;
   }
 
+  /**
+   * Returns the context.
+   * @return ServletContext
+   */
+  public static ServletContext getContext() {
+    return context;
+  }
+
+       /**
+        * Returns all properties in a Map
+        * @return Map
+        */
   public Map allSettings() {
     Iterator iterator = this.getKeys();
     Map returnMap = new HashMap();
@@ -102,23 +122,24 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
     while (iterator.hasNext()) {
       String key = (String) iterator.next();
       Object o = this.getString(key);
-      if(o == null){        
-       o = new Object();
+
+      if (o == null) {
+        o = new Object();
       }
+
       returnMap.put(key, o);
     }
 
     return returnMap;
   }
 
+
   /**
-   * Returns the context.
-   * @return ServletContext
+   * Returns a String-property concatenated with the home-dir of the
+   * installation
+   * @param key
+   * @return String
    */
-  public static ServletContext getContext() {
-    return context;
-  }
-
   public String getStringWithHome(String key) {
     String returnString = getString(key);
 
@@ -129,14 +150,17 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
     return getString("Home") + returnString;
   }
 
-  private void checkMissing(){
-       for(int i = 0; i < needed.length; i++){           
-         if(super.getProperty(needed[i]) == null){
-               addProperty(needed[i],"");
-         }
-       }
+  /**
+   * Checks if one property is missing and adds a default value
+   */
+  private void checkMissing() {
+    for (int i = 0; i < needed.length; i++) {
+      if (super.getProperty(needed[i]) == null) {
+        addProperty(needed[i], "");
+      }
+    }
   }
-  
+
   public File getFile(String key) throws FileNotFoundException {
     String path = getStringWithHome(key);
     File returnFile = new File(path);
@@ -155,9 +179,10 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
     if (super.getString(key) == null) {
       return new String();
     }
+
     return super.getString(key);
   }
-  
+
   /**
    * @see org.apache.commons.configuration.Configuration#getString(java.lang.String)
    */
@@ -165,6 +190,7 @@ public class MirPropertiesConfiguration extends PropertiesConfiguration {
     if (super.getProperty(key) == null) {
       return new String();
     }
+
     return super.getProperty(key);
   }