Commit 567ca2b9 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Modified to use generics.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@7175 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3c15a677
......@@ -11,11 +11,14 @@
package org.jivesoftware.util;
import org.jivesoftware.database.DbConnectionManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.sql.*;
import org.jivesoftware.database.DbConnectionManager;
/**
* Retrieves and stores Jive properties. Properties are stored in the database.
......@@ -162,8 +165,8 @@ public class JiveProperties implements Map<String, String> {
deleteProperty((String)key);
// Generate event.
PropertyEventDispatcher.dispatchEvent((String)key,
PropertyEventDispatcher.EventType.property_deleted, Collections.emptyMap());
Map<String, Object> params = Collections.emptyMap();
PropertyEventDispatcher.dispatchEvent((String)key, PropertyEventDispatcher.EventType.property_deleted, params);
return value;
}
......@@ -189,13 +192,12 @@ public class JiveProperties implements Map<String, String> {
insertProperty(key, value);
}
String result = properties.put((String)key, (String)value);
String result = properties.put(key, value);
// Generate event.
Map<String, String> params = new HashMap<String, String>();
Map<String, Object> params = new HashMap<String, Object>();
params.put("value", value);
PropertyEventDispatcher.dispatchEvent(key, PropertyEventDispatcher.EventType.property_set,
params);
PropertyEventDispatcher.dispatchEvent(key, PropertyEventDispatcher.EventType.property_set, params);
return result;
}
......
......@@ -11,8 +11,6 @@
package org.jivesoftware.util;
import org.jivesoftware.util.Log;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
......@@ -70,7 +68,7 @@ public class PropertyEventDispatcher {
* @param eventType the event type.
* @param params event parameters.
*/
public static void dispatchEvent(String property, EventType eventType, Map params) {
public static void dispatchEvent(String property, EventType eventType, Map<String, Object> params) {
for (PropertyEventListener listener : listeners) {
try {
switch (eventType) {
......
......@@ -29,7 +29,7 @@ public interface PropertyEventListener {
* @param property the name of the property.
* @param params event parameters.
*/
public void propertySet(String property, Map params);
public void propertySet(String property, Map<String, Object> params);
/**
* A property was deleted.
......@@ -37,7 +37,7 @@ public interface PropertyEventListener {
* @param property the name of the property deleted.
* @param params event parameters.
*/
public void propertyDeleted(String property, Map params);
public void propertyDeleted(String property, Map<String, Object> params);
/**
* An XML property was set. The parameter map <tt>params</tt> will contain the
......@@ -46,7 +46,7 @@ public interface PropertyEventListener {
* @param property the name of the property.
* @param params event parameters.
*/
public void xmlPropertySet(String property, Map params);
public void xmlPropertySet(String property, Map<String, Object> params);
/**
* An XML property was deleted.
......@@ -54,6 +54,6 @@ public interface PropertyEventListener {
* @param property the name of the property.
* @param params event parameters.
*/
public void xmlPropertyDeleted(String property, Map params);
public void xmlPropertyDeleted(String property, Map<String, Object> params);
}
\ No newline at end of file
......@@ -127,8 +127,8 @@ public class XMLProperties {
String[] propName = parsePropertyName(name);
// Search for this property by traversing down the XML heirarchy.
Element element = document.getRootElement();
for (int i = 0; i < propName.length; i++) {
element = element.element(propName[i]);
for (String aPropName : propName) {
element = element.element(aPropName);
if (element == null) {
// This node doesn't match this part of the property name which
// indicates this property doesn't exist so return null.
......@@ -256,8 +256,7 @@ public class XMLProperties {
String[] propName = parsePropertyName(name);
// Search for this property by traversing down the XML heirarchy.
Element element = document.getRootElement();
for (int i = 0; i < propName.length; i++) {
String child = propName[i];
for (String child : propName) {
element = element.element(child);
if (element == null) {
// This node doesn't match this part of the property name which
......@@ -305,10 +304,10 @@ public class XMLProperties {
}
String childName = propName[propName.length - 1];
// We found matching property, clear all children.
List toRemove = new ArrayList();
List<Element> toRemove = new ArrayList<Element>();
Iterator iter = element.elementIterator(childName);
while (iter.hasNext()) {
toRemove.add(iter.next());
toRemove.add((Element) iter.next());
}
for (iter = toRemove.iterator(); iter.hasNext();) {
element.remove((Element)iter.next());
......@@ -354,8 +353,8 @@ public class XMLProperties {
String[] propName = parsePropertyName(parent);
// Search for this property by traversing down the XML heirarchy.
Element element = document.getRootElement();
for (int i = 0; i < propName.length; i++) {
element = element.element(propName[i]);
for (String aPropName : propName) {
element = element.element(aPropName);
if (element == null) {
// This node doesn't match this part of the property name which
// indicates this property doesn't exist so return empty array.
......@@ -393,13 +392,13 @@ public class XMLProperties {
String[] propName = parsePropertyName(name);
// Search for this property by traversing down the XML heirarchy.
Element element = document.getRootElement();
for (int i = 0; i < propName.length; i++) {
for (String aPropName : propName) {
// If we don't find this part of the property in the XML heirarchy
// we add it as a new node
if (element.element(propName[i]) == null) {
element.addElement(propName[i]);
if (element.element(aPropName) == null) {
element.addElement(aPropName);
}
element = element.element(propName[i]);
element = element.element(aPropName);
}
// Set the value of the property in this node.
if (value.startsWith("<![CDATA[")) {
......@@ -420,7 +419,7 @@ public class XMLProperties {
saveProperties();
// Generate event.
Map<String, String> params = new HashMap<String,String>();
Map<String, Object> params = new HashMap<String, Object>();
params.put("value", value);
PropertyEventDispatcher.dispatchEvent(name,
PropertyEventDispatcher.EventType.xml_property_set, params);
......@@ -451,8 +450,8 @@ public class XMLProperties {
saveProperties();
// Generate event.
PropertyEventDispatcher.dispatchEvent(name,
PropertyEventDispatcher.EventType.xml_property_deleted, Collections.emptyMap());
Map<String, Object> params = Collections.emptyMap();
PropertyEventDispatcher.dispatchEvent(name, PropertyEventDispatcher.EventType.xml_property_deleted, params);
}
/**
......
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