mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-06 05:01:12 +01:00
SMACK-363 Applied code cleanup patches for many generics related issues.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13325 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
6dc64671e2
commit
e08c8afe44
109 changed files with 577 additions and 605 deletions
|
|
@ -17,7 +17,8 @@
|
|||
package org.jivesoftware.smackx.workgroup.util;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* This class is a very flexible event dispatcher which implements Runnable so that it can
|
||||
|
|
@ -34,7 +35,7 @@ import java.util.*;
|
|||
public class ListenerEventDispatcher
|
||||
implements Runnable {
|
||||
|
||||
protected transient ArrayList triplets;
|
||||
protected transient ArrayList<TripletContainer> triplets;
|
||||
|
||||
protected transient boolean hasFinishedDispatching;
|
||||
protected transient boolean isRunning;
|
||||
|
|
@ -42,7 +43,7 @@ public class ListenerEventDispatcher
|
|||
public ListenerEventDispatcher () {
|
||||
super();
|
||||
|
||||
this.triplets = new ArrayList();
|
||||
this.triplets = new ArrayList<TripletContainer>();
|
||||
|
||||
this.hasFinishedDispatching = false;
|
||||
this.isRunning = false;
|
||||
|
|
@ -81,13 +82,13 @@ public class ListenerEventDispatcher
|
|||
}
|
||||
|
||||
public void run() {
|
||||
ListIterator li = null;
|
||||
ListIterator<TripletContainer> li = null;
|
||||
|
||||
this.isRunning = true;
|
||||
|
||||
li = this.triplets.listIterator();
|
||||
while (li.hasNext()) {
|
||||
TripletContainer tc = (TripletContainer)li.next();
|
||||
TripletContainer tc = li.next();
|
||||
|
||||
try {
|
||||
tc.getListenerMethod().invoke(tc.getListenerInstance(), tc.getMethodArguments());
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ public class MetaDataUtils {
|
|||
* @throws XmlPullParserException if an error occurs while parsing the XML.
|
||||
* @throws IOException if an error occurs while parsing the XML.
|
||||
*/
|
||||
public static Map parseMetaData(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
public static Map<String, List<String>> parseMetaData(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
int eventType = parser.getEventType();
|
||||
|
||||
// If correctly positioned on an opening meta-data tag, parse meta-data.
|
||||
if ((eventType == XmlPullParser.START_TAG)
|
||||
&& parser.getName().equals(MetaData.ELEMENT_NAME)
|
||||
&& parser.getNamespace().equals(MetaData.NAMESPACE)) {
|
||||
Map metaData = new Hashtable();
|
||||
Map<String, List<String>> metaData = new Hashtable<String, List<String>>();
|
||||
|
||||
eventType = parser.nextTag();
|
||||
|
||||
|
|
@ -58,11 +58,11 @@ public class MetaDataUtils {
|
|||
String value = parser.nextText();
|
||||
|
||||
if (metaData.containsKey(name)) {
|
||||
List values = (List)metaData.get(name);
|
||||
List<String> values = metaData.get(name);
|
||||
values.add(value);
|
||||
}
|
||||
else {
|
||||
List values = new ArrayList();
|
||||
List<String> values = new ArrayList<String>();
|
||||
values.add(value);
|
||||
metaData.put(name, values);
|
||||
}
|
||||
|
|
@ -73,34 +73,26 @@ public class MetaDataUtils {
|
|||
return metaData;
|
||||
}
|
||||
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes a Map of String name/value pairs into the meta-data XML format.
|
||||
*
|
||||
* @param metaData the Map of meta-data.
|
||||
* @param metaData the Map of meta-data as Map<String,List<String>>
|
||||
* @return the meta-data values in XML form.
|
||||
*/
|
||||
public static String serializeMetaData(Map metaData) {
|
||||
public static String serializeMetaData(Map<String, List<String>> metaData) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (metaData != null && metaData.size() > 0) {
|
||||
buf.append("<metadata xmlns=\"http://jivesoftware.com/protocol/workgroup\">");
|
||||
for (Iterator i = metaData.keySet().iterator(); i.hasNext();) {
|
||||
Object key = i.next();
|
||||
Object value = metaData.get(key);
|
||||
if (value instanceof List) {
|
||||
List values = (List)metaData.get(key);
|
||||
for (Iterator it = values.iterator(); it.hasNext();) {
|
||||
String v = (String)it.next();
|
||||
buf.append("<value name=\"").append(key).append("\">");
|
||||
buf.append(StringUtils.escapeForXML(v));
|
||||
buf.append("</value>");
|
||||
}
|
||||
}
|
||||
else if (value instanceof String) {
|
||||
for (Iterator<String> i = metaData.keySet().iterator(); i.hasNext();) {
|
||||
String key = i.next();
|
||||
List<String> value = metaData.get(key);
|
||||
for (Iterator<String> it = value.iterator(); it.hasNext();) {
|
||||
String v = it.next();
|
||||
buf.append("<value name=\"").append(key).append("\">");
|
||||
buf.append(StringUtils.escapeForXML((String)value));
|
||||
buf.append(StringUtils.escapeForXML(v));
|
||||
buf.append("</value>");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,8 +240,6 @@ public final class ModelUtil {
|
|||
final long MS_IN_AN_HOUR = 1000 * 60 * 60;
|
||||
final long MS_IN_A_MINUTE = 1000 * 60;
|
||||
final long MS_IN_A_SECOND = 1000;
|
||||
Date currentTime = new Date();
|
||||
long numDays = diff / MS_IN_A_DAY;
|
||||
diff = diff % MS_IN_A_DAY;
|
||||
long numHours = diff / MS_IN_AN_HOUR;
|
||||
diff = diff % MS_IN_AN_HOUR;
|
||||
|
|
@ -249,7 +247,6 @@ public final class ModelUtil {
|
|||
diff = diff % MS_IN_A_MINUTE;
|
||||
long numSeconds = diff / MS_IN_A_SECOND;
|
||||
diff = diff % MS_IN_A_SECOND;
|
||||
long numMilliseconds = diff;
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (numHours > 0) {
|
||||
|
|
@ -270,8 +267,8 @@ public final class ModelUtil {
|
|||
/**
|
||||
* Build a List of all elements in an Iterator.
|
||||
*/
|
||||
public static List iteratorAsList(Iterator i) {
|
||||
ArrayList list = new ArrayList(10);
|
||||
public static <T> List<T> iteratorAsList(Iterator<T> i) {
|
||||
ArrayList<T> list = new ArrayList<T>(10);
|
||||
while (i.hasNext()) {
|
||||
list.add(i.next());
|
||||
}
|
||||
|
|
@ -281,18 +278,18 @@ public final class ModelUtil {
|
|||
/**
|
||||
* Creates an Iterator that is the reverse of a ListIterator.
|
||||
*/
|
||||
public static Iterator reverseListIterator(ListIterator i) {
|
||||
return new ReverseListIterator(i);
|
||||
public static <T> Iterator<T> reverseListIterator(ListIterator<T> i) {
|
||||
return new ReverseListIterator<T>(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An Iterator that is the reverse of a ListIterator.
|
||||
*/
|
||||
class ReverseListIterator implements Iterator {
|
||||
private ListIterator _i;
|
||||
class ReverseListIterator<T> implements Iterator<T> {
|
||||
private ListIterator<T> _i;
|
||||
|
||||
ReverseListIterator(ListIterator i) {
|
||||
ReverseListIterator(ListIterator<T> i) {
|
||||
_i = i;
|
||||
while (_i.hasNext())
|
||||
_i.next();
|
||||
|
|
@ -302,13 +299,14 @@ class ReverseListIterator implements Iterator {
|
|||
return _i.hasPrevious();
|
||||
}
|
||||
|
||||
public Object next() {
|
||||
public T next() {
|
||||
return _i.previous();
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
_i.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue