Commit 679fb3bb authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

JiveProperties now uses generics.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5075 b35dd754-fafc-0310-a699-88a17e54d16e
parent 53f441a1
...@@ -120,7 +120,7 @@ public class JiveGlobals { ...@@ -120,7 +120,7 @@ public class JiveGlobals {
public static TimeZone getTimeZone() { public static TimeZone getTimeZone() {
if (timeZone == null) { if (timeZone == null) {
if (properties != null) { if (properties != null) {
String timeZoneID = (String)properties.get("locale.timeZone"); String timeZoneID = properties.get("locale.timeZone");
if (timeZoneID == null) { if (timeZoneID == null) {
timeZone = TimeZone.getDefault(); timeZone = TimeZone.getDefault();
} }
...@@ -505,7 +505,7 @@ public class JiveGlobals { ...@@ -505,7 +505,7 @@ public class JiveGlobals {
} }
properties = JiveProperties.getInstance(); properties = JiveProperties.getInstance();
} }
return (String)properties.get(name); return properties.get(name);
} }
/** /**
...@@ -523,7 +523,7 @@ public class JiveGlobals { ...@@ -523,7 +523,7 @@ public class JiveGlobals {
} }
properties = JiveProperties.getInstance(); properties = JiveProperties.getInstance();
} }
String value = (String)properties.get(name); String value = properties.get(name);
if (value != null) { if (value != null) {
return value; return value;
} }
...@@ -696,7 +696,7 @@ public class JiveGlobals { ...@@ -696,7 +696,7 @@ public class JiveGlobals {
* *
* @param propertyMap a map of properties, keyed on property name. * @param propertyMap a map of properties, keyed on property name.
*/ */
public static void setProperties(Map propertyMap) { public static void setProperties(Map<String, String> propertyMap) {
if (properties == null) { if (properties == null) {
if (isSetupMode()) { if (isSetupMode()) {
return; return;
......
...@@ -22,7 +22,7 @@ import org.jivesoftware.database.DbConnectionManager; ...@@ -22,7 +22,7 @@ import org.jivesoftware.database.DbConnectionManager;
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
public class JiveProperties implements Map { public class JiveProperties implements Map<String, String> {
private static final String LOAD_PROPERTIES = "SELECT name, propValue FROM jiveProperty"; private static final String LOAD_PROPERTIES = "SELECT name, propValue FROM jiveProperty";
private static final String INSERT_PROPERTY = "INSERT INTO jiveProperty(name, propValue) VALUES(?,?)"; private static final String INSERT_PROPERTY = "INSERT INTO jiveProperty(name, propValue) VALUES(?,?)";
...@@ -87,26 +87,25 @@ public class JiveProperties implements Map { ...@@ -87,26 +87,25 @@ public class JiveProperties implements Map {
return properties.containsValue(value); return properties.containsValue(value);
} }
public Collection values() { public Collection<String> values() {
return Collections.unmodifiableCollection(properties.values()); return Collections.unmodifiableCollection(properties.values());
} }
public void putAll(Map t) { public void putAll(Map<? extends String, ? extends String> t) {
for (Iterator i=t.entrySet().iterator(); i.hasNext(); ) { for (Map.Entry<? extends String, ? extends String> entry : t.entrySet() ) {
Map.Entry entry = (Map.Entry)i.next();
put(entry.getKey(), entry.getValue()); put(entry.getKey(), entry.getValue());
} }
} }
public Set entrySet() { public Set<Map.Entry<String, String>> entrySet() {
return Collections.unmodifiableSet(properties.entrySet()); return Collections.unmodifiableSet(properties.entrySet());
} }
public Set keySet() { public Set<String> keySet() {
return Collections.unmodifiableSet(properties.keySet()); return Collections.unmodifiableSet(properties.keySet());
} }
public Object get(Object key) { public String get(Object key) {
return properties.get(key); return properties.get(key);
} }
...@@ -151,12 +150,11 @@ public class JiveProperties implements Map { ...@@ -151,12 +150,11 @@ public class JiveProperties implements Map {
return properties.keySet(); return properties.keySet();
} }
public synchronized Object remove(Object key) { public synchronized String remove(Object key) {
Object value = properties.remove(key); String value = properties.remove(key);
// Also remove any children. // Also remove any children.
Collection propNames = getPropertyNames(); Collection<String> propNames = getPropertyNames();
for (Iterator i=propNames.iterator(); i.hasNext(); ) { for (String name : propNames) {
String name = (String)i.next();
if (name.startsWith((String)key)) { if (name.startsWith((String)key)) {
properties.remove(name); properties.remove(name);
} }
...@@ -170,7 +168,7 @@ public class JiveProperties implements Map { ...@@ -170,7 +168,7 @@ public class JiveProperties implements Map {
return value; return value;
} }
public synchronized Object put(Object key, Object value) { public synchronized String put(String key, String value) {
if (key == null || value == null) { if (key == null || value == null) {
throw new NullPointerException("Key or value cannot be null. Key=" + throw new NullPointerException("Key or value cannot be null. Key=" +
key + ", value=" + value); key + ", value=" + value);
...@@ -178,24 +176,24 @@ public class JiveProperties implements Map { ...@@ -178,24 +176,24 @@ public class JiveProperties implements Map {
if (!(key instanceof String) || !(value instanceof String)) { if (!(key instanceof String) || !(value instanceof String)) {
throw new IllegalArgumentException("Key and value must be of type String."); throw new IllegalArgumentException("Key and value must be of type String.");
} }
if (((String)key).endsWith(".")) { if (key.endsWith(".")) {
key = ((String)key).substring(0, ((String)key).length()-1); key = key.substring(0, key.length()-1);
} }
key =((String)key).trim(); key = key.trim();
if (properties.containsKey(key)) { if (properties.containsKey(key)) {
if (!properties.get(key).equals(value)) { if (!properties.get(key).equals(value)) {
updateProperty((String)key, (String)value); updateProperty(key, value);
} }
} }
else { else {
insertProperty((String)key, (String)value); insertProperty(key, value);
} }
// Generate event. // Generate event.
Map params = new HashMap(); Map<String, String> params = new HashMap<String, String>();
params.put("value", value); params.put("value", value);
PropertyEventDispatcher.dispatchEvent((String)key, PropertyEventDispatcher.dispatchEvent(key, PropertyEventDispatcher.EventType.property_set,
PropertyEventDispatcher.EventType.property_set, params); params);
return properties.put((String)key, (String)value); return properties.put((String)key, (String)value);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment