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