import multex.Failure;
import org.apache.commons.collections.ExtendedProperties;
-import org.apache.commons.configuration.PropertiesConfiguration;
import java.io.File;
import java.io.FileNotFoundException;
}
/**
+ * @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) {
return super.getProperty(key);
}
-
+
/**
* @author idefix
*/