From 7c643b65f3613e30a14e8e9decc92fddb8bfd654 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 01 Jul 2011 17:42:56 -0400
Subject: [PATCH] Documentation. Include LICENSE and NOTICE files in both builds.
---
src/com/gitblit/IStoredSettings.java | 42 +++++++++++++++++++++++++++++-------------
1 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/src/com/gitblit/IStoredSettings.java b/src/com/gitblit/IStoredSettings.java
index 7108c06..e220a81 100644
--- a/src/com/gitblit/IStoredSettings.java
+++ b/src/com/gitblit/IStoredSettings.java
@@ -27,28 +27,40 @@
public abstract class IStoredSettings {
protected final Logger logger;
-
+
+ protected final Properties overrides = new Properties();
+
public IStoredSettings(Class<? extends IStoredSettings> clazz) {
logger = LoggerFactory.getLogger(clazz);
}
-
+
protected abstract Properties read();
- public List<String> getAllKeys(String startingWith) {
- startingWith = startingWith.toLowerCase();
- List<String> keys = new ArrayList<String>();
+ private Properties getSettings() {
Properties props = read();
- for (Object o : props.keySet()) {
- String key = o.toString();
- if (key.toLowerCase().startsWith(startingWith)) {
- keys.add(key);
+ props.putAll(overrides);
+ return props;
+ }
+
+ public List<String> getAllKeys(String startingWith) {
+ List<String> keys = new ArrayList<String>();
+ Properties props = getSettings();
+ if (StringUtils.isEmpty(startingWith)) {
+ keys.addAll(props.stringPropertyNames());
+ } else {
+ startingWith = startingWith.toLowerCase();
+ for (Object o : props.keySet()) {
+ String key = o.toString();
+ if (key.toLowerCase().startsWith(startingWith)) {
+ keys.add(key);
+ }
}
}
return keys;
}
public boolean getBoolean(String name, boolean defaultValue) {
- Properties props = read();
+ Properties props = getSettings();
if (props.containsKey(name)) {
String value = props.getProperty(name);
if (!StringUtils.isEmpty(value)) {
@@ -59,7 +71,7 @@
}
public int getInteger(String name, int defaultValue) {
- Properties props = read();
+ Properties props = getSettings();
if (props.containsKey(name)) {
try {
String value = props.getProperty(name);
@@ -75,7 +87,7 @@
}
public String getString(String name, String defaultValue) {
- Properties props = read();
+ Properties props = getSettings();
if (props.containsKey(name)) {
String value = props.getProperty(name);
if (value != null) {
@@ -91,11 +103,15 @@
public List<String> getStrings(String name, String separator) {
List<String> strings = new ArrayList<String>();
- Properties props = read();
+ Properties props = getSettings();
if (props.containsKey(name)) {
String value = props.getProperty(name);
strings = StringUtils.getStringsFromValue(value, separator);
}
return strings;
}
+
+ public void overrideSetting(String key, String value) {
+ overrides.put(key, value);
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1