From: Stefan F. <ste...@us...> - 2012-02-27 10:00:32
|
rails/common/Config.java | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) New commits: commit 954bbd4b1d2f4c90fe4105fb68dfe743df83c260 Author: Stefan Frey <ste...@we...> Date: Mon Feb 27 11:00:03 2012 +0100 another fix: forgot to commit config diff --git a/rails/common/Config.java b/rails/common/Config.java new file mode 100644 index 0000000..bce5142 --- /dev/null +++ b/rails/common/Config.java @@ -0,0 +1,47 @@ +package rails.common; + +import rails.game.GameManager; +import rails.util.Util; + +/** + * Proxy class to the ConfigManager + */ + +public class Config { + + /** + * Configuration option (default value is empty string) + */ + public static String get(String key) { + return ConfigManager.getInstance().getValue(key, ""); + } + + /** + * Configuration option with default value + */ + public static String get(String key, String defaultValue) { + return ConfigManager.getInstance().getValue(key, defaultValue); + } + + /** + * Configuration option: First tries to return {key}.{appendix}, if undefined returns {key} + */ + public static String getSpecific(String key, String appendix) { + String value = get(key + "." + appendix); + if (Util.hasValue(value)) { + return value; + } else { + return get(key); + } + } + + /** + * Configuration option: First tries to return {key}.{gameName}, if undefined returns {key} + */ + public static String getGameSpecific(String key) { + return getSpecific(key, GameManager.getInstance().getGameName()); + } + + + +} |