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 {
public static TimeZone getTimeZone() {
if (timeZone == null) {
if (properties != null) {
String timeZoneID = (String)properties.get("locale.timeZone");
String timeZoneID = properties.get("locale.timeZone");
if (timeZoneID == null) {
timeZone = TimeZone.getDefault();
}
......@@ -505,7 +505,7 @@ public class JiveGlobals {
}
properties = JiveProperties.getInstance();
}
return (String)properties.get(name);
return properties.get(name);
}
/**
......@@ -523,7 +523,7 @@ public class JiveGlobals {
}
properties = JiveProperties.getInstance();
}
String value = (String)properties.get(name);
String value = properties.get(name);
if (value != null) {
return value;
}
......@@ -696,7 +696,7 @@ public class JiveGlobals {
*
* @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 (isSetupMode()) {
return;
......
......@@ -22,7 +22,7 @@ import org.jivesoftware.database.DbConnectionManager;
*
* @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 INSERT_PROPERTY = "INSERT INTO jiveProperty(name, propValue) VALUES(?,?)";
......@@ -87,26 +87,25 @@ public class JiveProperties implements Map {
return properties.containsValue(value);
}
public Collection values() {
public Collection<String> values() {
return Collections.unmodifiableCollection(properties.values());
}
public void putAll(Map t) {
for (Iterator i=t.entrySet().iterator(); i.hasNext(); ) {
Map.Entry entry = (Map.Entry)i.next();
public void putAll(Map<? extends String, ? extends String> t) {
for (Map.Entry<? extends String, ? extends String> entry : t.entrySet() ) {
put(entry.getKey(), entry.getValue());
}
}
public Set entrySet() {
public Set<Map.Entry<String, String>> entrySet() {
return Collections.unmodifiableSet(properties.entrySet());
}
public Set keySet() {
public Set<String> keySet() {
return Collections.unmodifiableSet(properties.keySet());
}
public Object get(Object key) {
public String get(Object key) {
return properties.get(key);
}
......@@ -151,12 +150,11 @@ public class JiveProperties implements Map {
return properties.keySet();
}
public synchronized Object remove(Object key) {
Object value = properties.remove(key);
public synchronized String remove(Object key) {
String value = properties.remove(key);
// Also remove any children.
Collection propNames = getPropertyNames();
for (Iterator i=propNames.iterator(); i.hasNext(); ) {
String name = (String)i.next();
Collection<String> propNames = getPropertyNames();
for (String name : propNames) {
if (name.startsWith((String)key)) {
properties.remove(name);
}
......@@ -170,7 +168,7 @@ public class JiveProperties implements Map {
return value;
}
public synchronized Object put(Object key, Object value) {
public synchronized String put(String key, String value) {
if (key == null || value == null) {
throw new NullPointerException("Key or value cannot be null. Key=" +
key + ", value=" + value);
......@@ -178,24 +176,24 @@ public class JiveProperties implements Map {
if (!(key instanceof String) || !(value instanceof String)) {
throw new IllegalArgumentException("Key and value must be of type String.");
}
if (((String)key).endsWith(".")) {
key = ((String)key).substring(0, ((String)key).length()-1);
if (key.endsWith(".")) {
key = key.substring(0, key.length()-1);
}
key =((String)key).trim();
key = key.trim();
if (properties.containsKey(key)) {
if (!properties.get(key).equals(value)) {
updateProperty((String)key, (String)value);
updateProperty(key, value);
}
}
else {
insertProperty((String)key, (String)value);
insertProperty(key, value);
}
// Generate event.
Map params = new HashMap();
Map<String, String> params = new HashMap<String, String>();
params.put("value", value);
PropertyEventDispatcher.dispatchEvent((String)key,
PropertyEventDispatcher.EventType.property_set, params);
PropertyEventDispatcher.dispatchEvent(key, PropertyEventDispatcher.EventType.property_set,
params);
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