a bit nicer
authoridfx <idfx>
Thu, 13 Mar 2003 22:02:25 +0000 (22:02 +0000)
committeridfx <idfx>
Thu, 13 Mar 2003 22:02:25 +0000 (22:02 +0000)
source/mir/config/MirPropertiesConfiguration.java

index 52c3fc1..9c2c020 100755 (executable)
@@ -34,7 +34,6 @@ import multex.Exc;
 import multex.Failure;
 
 import org.apache.commons.collections.ExtendedProperties;
-import org.apache.commons.configuration.PropertiesConfiguration;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -173,22 +172,39 @@ public class MirPropertiesConfiguration extends ExtendedProperties {
   }
 
   /**
+   * @return the vlaue of this property as String
+   * @param key the key of this property
    * @see org.apache.commons.configuration.Configuration#getString(java.lang.String)
    */
   public String getString(String key) {
-       Object object = getProperty(key);       
-       if(object != null){
-               if (object instanceof String) {
-                       return (String)object;
-               } else {
-                       return object.toString();
-               }
-       } else {
-      return new String();
-    }
+       return getString(key, "");
+  }
+  
+  
+  /** 
+   * @return the value of this property as String
+   * @param key the key of the property
+   * @param defaultValue the default value of this property if it is null
+   * @see org.apache.commons.collections.ExtendedProperties#getString(java.lang.String, java.lang.String)
+   */
+  public String getString(String key, String defaultValue) {
+               Object object = getProperty(key);       
+               if(object == null){
+                       if (defaultValue == null) {
+                               return new String();
+                       }
+                 return defaultValue;
+               }                       
+               if (object instanceof String) {
+                       return (String)object;
+               }
+               return object.toString();
   }
 
   /**
+   * Returns a property according to the given key
+   * @param key the key of the property
+   * @return the value of the property as Object, if no property available it returns a empty String
    * @see org.apache.commons.configuration.Configuration#getString(java.lang.String)
    */
   public Object getProperty(String key) {
@@ -198,7 +214,7 @@ public class MirPropertiesConfiguration extends ExtendedProperties {
 
     return super.getProperty(key);
   }
-
+  
   /**
    * @author idefix
    */