From: idfx Date: Fri, 28 Feb 2003 17:29:55 +0000 (+0000) Subject: some code formatting. more property-keys to check. X-Git-Tag: BEFORE_MERGE_1_1~253 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=aa85e439a4d3923dd613733aaf2f6b9a15825b87;p=mir.git some code formatting. more property-keys to check. --- diff --git a/source/mir/config/MirPropertiesConfiguration.java b/source/mir/config/MirPropertiesConfiguration.java index ecebd1c7..0d79aaf2 100755 --- a/source/mir/config/MirPropertiesConfiguration.java +++ b/source/mir/config/MirPropertiesConfiguration.java @@ -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); }