mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02: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
|
@ -389,8 +389,8 @@ public class Form {
|
|||
public String getInstructions() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// Join the list of instructions together separated by newlines
|
||||
for (Iterator it = dataForm.getInstructions(); it.hasNext();) {
|
||||
sb.append((String) it.next());
|
||||
for (Iterator<String> it = dataForm.getInstructions(); it.hasNext();) {
|
||||
sb.append(it.next());
|
||||
// If this is not the last instruction then append a newline
|
||||
if (it.hasNext()) {
|
||||
sb.append("\n");
|
||||
|
|
|
@ -292,8 +292,8 @@ public class FormField {
|
|||
buf.append("<value>").append(i.next()).append("</value>");
|
||||
}
|
||||
// Loop through all the values and append them to the string buffer
|
||||
for (Iterator i = getOptions(); i.hasNext();) {
|
||||
buf.append(((Option) i.next()).toXML());
|
||||
for (Iterator<Option> i = getOptions(); i.hasNext();) {
|
||||
buf.append((i.next()).toXML());
|
||||
}
|
||||
buf.append("</field>");
|
||||
return buf.toString();
|
||||
|
|
|
@ -206,18 +206,18 @@ public class MessageEventManager {
|
|||
(MessageEvent) message.getExtension("x", "jabber:x:event");
|
||||
if (messageEvent.isMessageEventRequest()) {
|
||||
// Fire event for requests of message events
|
||||
for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
|
||||
for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
|
||||
fireMessageEventRequestListeners(
|
||||
message.getFrom(),
|
||||
message.getPacketID(),
|
||||
((String) it.next()).concat("NotificationRequested"));
|
||||
it.next().concat("NotificationRequested"));
|
||||
} else
|
||||
// Fire event for notifications of message events
|
||||
for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
|
||||
for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
|
||||
fireMessageEventNotificationListeners(
|
||||
message.getFrom(),
|
||||
messageEvent.getPacketID(),
|
||||
((String) it.next()).concat("Notification"));
|
||||
it.next().concat("Notification"));
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class MultipleRecipientInfo {
|
|||
*
|
||||
* @return list of primary recipients of the packet.
|
||||
*/
|
||||
public List getTOAddresses() {
|
||||
public List<MultipleAddresses.Address> getTOAddresses() {
|
||||
return extension.getAddressesOfType(MultipleAddresses.TO);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class MultipleRecipientInfo {
|
|||
*
|
||||
* @return list of secondary recipients of the packet.
|
||||
*/
|
||||
public List getCCAddresses() {
|
||||
public List<MultipleAddresses.Address> getCCAddresses() {
|
||||
return extension.getAddressesOfType(MultipleAddresses.CC);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class MultipleRecipientInfo {
|
|||
* no specific address was provided.
|
||||
*/
|
||||
public String getReplyRoom() {
|
||||
List replyRoom = extension.getAddressesOfType(MultipleAddresses.REPLY_ROOM);
|
||||
List<MultipleAddresses.Address> replyRoom = extension.getAddressesOfType(MultipleAddresses.REPLY_ROOM);
|
||||
return replyRoom.isEmpty() ? null : ((MultipleAddresses.Address) replyRoom.get(0)).getJid();
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class MultipleRecipientInfo {
|
|||
* no specific address was provided.
|
||||
*/
|
||||
public MultipleAddresses.Address getReplyAddress() {
|
||||
List replyTo = extension.getAddressesOfType(MultipleAddresses.REPLY_TO);
|
||||
List<MultipleAddresses.Address> replyTo = extension.getAddressesOfType(MultipleAddresses.REPLY_TO);
|
||||
return replyTo.isEmpty() ? null : (MultipleAddresses.Address) replyTo.get(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MultipleRecipientManager {
|
|||
* Create a cache to hold the 100 most recently accessed elements for a period of
|
||||
* 24 hours.
|
||||
*/
|
||||
private static Cache services = new Cache(100, 24 * 60 * 60 * 1000);
|
||||
private static Cache<String, String> services = new Cache<String, String>(100, 24 * 60 * 60 * 1000);
|
||||
|
||||
/**
|
||||
* Sends the specified packet to the list of specified recipients using the
|
||||
|
@ -67,7 +67,7 @@ public class MultipleRecipientManager {
|
|||
* @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
|
||||
* some JEP-33 specific features were requested.
|
||||
*/
|
||||
public static void send(Connection connection, Packet packet, List to, List cc, List bcc)
|
||||
public static void send(Connection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc)
|
||||
throws XMPPException {
|
||||
send(connection, packet, to, cc, bcc, null, null, false);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class MultipleRecipientManager {
|
|||
* @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
|
||||
* some JEP-33 specific features were requested.
|
||||
*/
|
||||
public static void send(Connection connection, Packet packet, List to, List cc, List bcc,
|
||||
public static void send(Connection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc,
|
||||
String replyTo, String replyRoom, boolean noReply) throws XMPPException {
|
||||
String serviceAddress = getMultipleRecipienServiceAddress(connection);
|
||||
if (serviceAddress != null) {
|
||||
|
@ -151,14 +151,14 @@ public class MultipleRecipientManager {
|
|||
}
|
||||
else {
|
||||
// Send reply to multiple recipients
|
||||
List to = new ArrayList();
|
||||
List cc = new ArrayList();
|
||||
for (Iterator it = info.getTOAddresses().iterator(); it.hasNext();) {
|
||||
String jid = ((MultipleAddresses.Address) it.next()).getJid();
|
||||
List<String> to = new ArrayList<String>();
|
||||
List<String> cc = new ArrayList<String>();
|
||||
for (Iterator<MultipleAddresses.Address> it = info.getTOAddresses().iterator(); it.hasNext();) {
|
||||
String jid = it.next().getJid();
|
||||
to.add(jid);
|
||||
}
|
||||
for (Iterator it = info.getCCAddresses().iterator(); it.hasNext();) {
|
||||
String jid = ((MultipleAddresses.Address) it.next()).getJid();
|
||||
for (Iterator<MultipleAddresses.Address> it = info.getCCAddresses().iterator(); it.hasNext();) {
|
||||
String jid = it.next().getJid();
|
||||
cc.add(jid);
|
||||
}
|
||||
// Add original sender as a 'to' address (if not already present)
|
||||
|
@ -202,50 +202,50 @@ public class MultipleRecipientManager {
|
|||
}
|
||||
|
||||
private static void sendToIndividualRecipients(Connection connection, Packet packet,
|
||||
List to, List cc, List bcc) {
|
||||
List<String> to, List<String> cc, List<String> bcc) {
|
||||
if (to != null) {
|
||||
for (Iterator it = to.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = to.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (cc != null) {
|
||||
for (Iterator it = cc.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = cc.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (bcc != null) {
|
||||
for (Iterator it = bcc.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = bcc.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendThroughService(Connection connection, Packet packet, List to,
|
||||
List cc, List bcc, String replyTo, String replyRoom, boolean noReply,
|
||||
private static void sendThroughService(Connection connection, Packet packet, List<String> to,
|
||||
List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply,
|
||||
String serviceAddress) {
|
||||
// Create multiple recipient extension
|
||||
MultipleAddresses multipleAddresses = new MultipleAddresses();
|
||||
if (to != null) {
|
||||
for (Iterator it = to.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = to.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
multipleAddresses.addAddress(MultipleAddresses.TO, jid, null, null, false, null);
|
||||
}
|
||||
}
|
||||
if (cc != null) {
|
||||
for (Iterator it = cc.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = cc.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
multipleAddresses.addAddress(MultipleAddresses.CC, jid, null, null, false, null);
|
||||
}
|
||||
}
|
||||
if (bcc != null) {
|
||||
for (Iterator it = bcc.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = bcc.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
multipleAddresses.addAddress(MultipleAddresses.BCC, jid, null, null, false, null);
|
||||
}
|
||||
}
|
||||
|
@ -300,8 +300,8 @@ public class MultipleRecipientManager {
|
|||
// Get the disco items and send the disco packet to each server item
|
||||
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection)
|
||||
.discoverItems(serviceName);
|
||||
for (Iterator it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = (DiscoverItems.Item) it.next();
|
||||
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = it.next();
|
||||
info = ServiceDiscoveryManager.getInstanceFor(connection)
|
||||
.discoverInfo(item.getEntityID(), item.getNode());
|
||||
if (info.containsFeature("http://jabber.org/protocol/address")) {
|
||||
|
|
|
@ -113,8 +113,8 @@ public class OfflineMessageManager {
|
|||
List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>();
|
||||
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
|
||||
null, namespace);
|
||||
for (Iterator it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = (DiscoverItems.Item) it.next();
|
||||
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = it.next();
|
||||
answer.add(new OfflineMessageHeader(item));
|
||||
}
|
||||
return answer.iterator();
|
||||
|
|
|
@ -62,7 +62,7 @@ public class PrivateDataManager {
|
|||
/**
|
||||
* Map of provider instances.
|
||||
*/
|
||||
private static Map privateDataProviders = new Hashtable();
|
||||
private static Map<String, PrivateDataProvider> privateDataProviders = new Hashtable<String, PrivateDataProvider>();
|
||||
|
||||
/**
|
||||
* Returns the private data provider registered to the specified XML element name and namespace.
|
||||
|
|
|
@ -77,7 +77,7 @@ public class RemoteRosterEntry {
|
|||
*
|
||||
* @return an Iterator for the group names.
|
||||
*/
|
||||
public Iterator getGroupNames() {
|
||||
public Iterator<String> getGroupNames() {
|
||||
synchronized (groupNames) {
|
||||
return Collections.unmodifiableList(groupNames).iterator();
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ public interface RosterExchangeListener {
|
|||
* @param remoteRosterEntries the entries sent by the user. The entries are instances of
|
||||
* RemoteRosterEntry.
|
||||
*/
|
||||
public void entriesReceived(String from, Iterator remoteRosterEntries);
|
||||
public void entriesReceived(String from, Iterator<RemoteRosterEntry> remoteRosterEntries);
|
||||
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public class RosterExchangeManager {
|
|||
/**
|
||||
* Fires roster exchange listeners.
|
||||
*/
|
||||
private void fireRosterExchangeListeners(String from, Iterator remoteRosterEntries) {
|
||||
private void fireRosterExchangeListeners(String from, Iterator<RemoteRosterEntry> remoteRosterEntries) {
|
||||
RosterExchangeListener[] listeners = null;
|
||||
synchronized (rosterExchangeListeners) {
|
||||
listeners = new RosterExchangeListener[rosterExchangeListeners.size()];
|
||||
|
|
|
@ -27,7 +27,7 @@ public class SharedGroupManager {
|
|||
* @param connection connection to use to get the user's shared groups.
|
||||
* @return collection with the shared groups' name of the logged user.
|
||||
*/
|
||||
public static List getSharedGroups(Connection connection) throws XMPPException {
|
||||
public static List<String> getSharedGroups(Connection connection) throws XMPPException {
|
||||
// Discover the shared groups of the logged user
|
||||
SharedGroupsInfo info = new SharedGroupsInfo();
|
||||
info.setType(IQ.Type.GET);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class XHTMLManager {
|
|||
* @param message an XHTML message
|
||||
* @return an Iterator for the bodies in the message or null if none.
|
||||
*/
|
||||
public static Iterator getBodies(Message message) {
|
||||
public static Iterator<String> getBodies(Message message) {
|
||||
XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
|
||||
if (xhtmlExtension != null)
|
||||
return xhtmlExtension.getBodies();
|
||||
|
|
|
@ -138,10 +138,10 @@ public class AdHocCommandManager {
|
|||
* @param name the human readable name of the command.
|
||||
* @param clazz the class of the command, which must extend {@link LocalCommand}.
|
||||
*/
|
||||
public void registerCommand(String node, String name, final Class clazz) {
|
||||
public void registerCommand(String node, String name, final Class<? extends LocalCommand> clazz) {
|
||||
registerCommand(node, name, new LocalCommandFactory() {
|
||||
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException {
|
||||
return (LocalCommand)clazz.newInstance();
|
||||
return clazz.newInstance();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
return false;
|
||||
}
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
if (columnIndex == 2 || columnIndex == 3) {
|
||||
return Icon.class;
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ public class EnhancedDebuggerWindow {
|
|||
Vector<String> providers = new Vector<String>();
|
||||
for (Object provider : ProviderManager.getInstance().getIQProviders()) {
|
||||
if (provider.getClass() == Class.class) {
|
||||
providers.add(((Class) provider).getName());
|
||||
providers.add(((Class<?>) provider).getName());
|
||||
}
|
||||
else {
|
||||
providers.add(provider.getClass().getName());
|
||||
|
@ -245,7 +245,7 @@ public class EnhancedDebuggerWindow {
|
|||
providers = new Vector<String>();
|
||||
for (Object provider : ProviderManager.getInstance().getExtensionProviders()) {
|
||||
if (provider.getClass() == Class.class) {
|
||||
providers.add(((Class) provider).getName());
|
||||
providers.add(((Class<?>) provider).getName());
|
||||
}
|
||||
else {
|
||||
providers.add(provider.getClass().getName());
|
||||
|
|
|
@ -1703,8 +1703,8 @@ public class MultiUserChat {
|
|||
}
|
||||
// Get the list of affiliates from the server's answer
|
||||
List<Affiliate> affiliates = new ArrayList<Affiliate>();
|
||||
for (Iterator it = answer.getItems(); it.hasNext();) {
|
||||
affiliates.add(new Affiliate((MUCOwner.Item) it.next()));
|
||||
for (Iterator<MUCOwner.Item> it = answer.getItems(); it.hasNext();) {
|
||||
affiliates.add(new Affiliate(it.next()));
|
||||
}
|
||||
return affiliates;
|
||||
}
|
||||
|
@ -1744,8 +1744,8 @@ public class MultiUserChat {
|
|||
}
|
||||
// Get the list of affiliates from the server's answer
|
||||
List<Affiliate> affiliates = new ArrayList<Affiliate>();
|
||||
for (Iterator it = answer.getItems(); it.hasNext();) {
|
||||
affiliates.add(new Affiliate((MUCAdmin.Item) it.next()));
|
||||
for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
|
||||
affiliates.add(new Affiliate(it.next()));
|
||||
}
|
||||
return affiliates;
|
||||
}
|
||||
|
@ -1806,8 +1806,8 @@ public class MultiUserChat {
|
|||
}
|
||||
// Get the list of participants from the server's answer
|
||||
List<Occupant> participants = new ArrayList<Occupant>();
|
||||
for (Iterator it = answer.getItems(); it.hasNext();) {
|
||||
participants.add(new Occupant((MUCAdmin.Item) it.next()));
|
||||
for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
|
||||
participants.add(new Occupant(it.next()));
|
||||
}
|
||||
return participants;
|
||||
}
|
||||
|
@ -2035,7 +2035,7 @@ public class MultiUserChat {
|
|||
userStatusListeners.toArray(listeners);
|
||||
}
|
||||
// Get the classes of the method parameters
|
||||
Class[] paramClasses = new Class[params.length];
|
||||
Class<?>[] paramClasses = new Class[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
paramClasses[i] = params[i].getClass();
|
||||
}
|
||||
|
@ -2088,7 +2088,7 @@ public class MultiUserChat {
|
|||
}
|
||||
try {
|
||||
// Get the method to execute based on the requested methodName and parameter
|
||||
Class[] classes = new Class[params.size()];
|
||||
Class<?>[] classes = new Class[params.size()];
|
||||
for (int i=0;i<params.size(); i++) {
|
||||
classes[i] = String.class;
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ public class DataForm implements PacketExtension {
|
|||
if (getTitle() != null) {
|
||||
buf.append("<title>").append(getTitle()).append("</title>");
|
||||
}
|
||||
for (Iterator it=getInstructions(); it.hasNext();) {
|
||||
for (Iterator<String> it=getInstructions(); it.hasNext();) {
|
||||
buf.append("<instructions>").append(it.next()).append("</instructions>");
|
||||
}
|
||||
// Append the list of fields returned from a search
|
||||
|
@ -210,13 +210,13 @@ public class DataForm implements PacketExtension {
|
|||
buf.append(getReportedData().toXML());
|
||||
}
|
||||
// Loop through all the items returned from a search and append them to the string buffer
|
||||
for (Iterator i = getItems(); i.hasNext();) {
|
||||
Item item = (Item) i.next();
|
||||
for (Iterator<Item> i = getItems(); i.hasNext();) {
|
||||
Item item = i.next();
|
||||
buf.append(item.toXML());
|
||||
}
|
||||
// Loop through all the form fields and append them to the string buffer
|
||||
for (Iterator i = getFields(); i.hasNext();) {
|
||||
FormField field = (FormField) i.next();
|
||||
for (Iterator<FormField> i = getFields(); i.hasNext();) {
|
||||
FormField field = i.next();
|
||||
buf.append(field.toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
|
@ -250,8 +250,8 @@ public class DataForm implements PacketExtension {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<reported>");
|
||||
// Loop through all the form items and append them to the string buffer
|
||||
for (Iterator i = getFields(); i.hasNext();) {
|
||||
FormField field = (FormField) i.next();
|
||||
for (Iterator<FormField> i = getFields(); i.hasNext();) {
|
||||
FormField field = i.next();
|
||||
buf.append(field.toXML());
|
||||
}
|
||||
buf.append("</reported>");
|
||||
|
@ -285,8 +285,8 @@ public class DataForm implements PacketExtension {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<item>");
|
||||
// Loop through all the form items and append them to the string buffer
|
||||
for (Iterator i = getFields(); i.hasNext();) {
|
||||
FormField field = (FormField) i.next();
|
||||
for (Iterator<FormField> i = getFields(); i.hasNext();) {
|
||||
FormField field = i.next();
|
||||
buf.append(field.toXML());
|
||||
}
|
||||
buf.append("</item>");
|
||||
|
|
|
@ -51,7 +51,7 @@ public class DefaultPrivateData implements PrivateData {
|
|||
|
||||
private String elementName;
|
||||
private String namespace;
|
||||
private Map map;
|
||||
private Map<String, String> map;
|
||||
|
||||
/**
|
||||
* Creates a new generic private data object.
|
||||
|
@ -85,8 +85,8 @@ public class DefaultPrivateData implements PrivateData {
|
|||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\">");
|
||||
for (Iterator i=getNames(); i.hasNext(); ) {
|
||||
String name = (String)i.next();
|
||||
for (Iterator<String> i=getNames(); i.hasNext(); ) {
|
||||
String name = i.next();
|
||||
String value = getValue(name);
|
||||
buf.append("<").append(name).append(">");
|
||||
buf.append(value);
|
||||
|
@ -102,11 +102,11 @@ public class DefaultPrivateData implements PrivateData {
|
|||
*
|
||||
* @return an Iterator for the names.
|
||||
*/
|
||||
public synchronized Iterator getNames() {
|
||||
public synchronized Iterator<String> getNames() {
|
||||
if (map == null) {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
return Collections.<String>emptyList().iterator();
|
||||
}
|
||||
return Collections.unmodifiableMap(new HashMap(map)).keySet().iterator();
|
||||
return Collections.unmodifiableSet(map.keySet()).iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,7 +130,7 @@ public class DefaultPrivateData implements PrivateData {
|
|||
*/
|
||||
public synchronized void setValue(String name, String value) {
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String,String>();
|
||||
}
|
||||
map.put(name, value);
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
*/
|
||||
|
||||
package org.jivesoftware.smackx.packet;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
/**
|
||||
* IQ packet that serves for kicking users, granting and revoking voice, banning users,
|
||||
* modifying the ban list, granting and revoking membership and granting and revoking
|
||||
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
*/
|
||||
public class MUCAdmin extends IQ {
|
||||
|
||||
private List items = new ArrayList();
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
|
||||
/**
|
||||
* Returns an Iterator for item childs that holds information about roles, affiliation,
|
||||
|
@ -45,9 +45,9 @@ public class MUCAdmin extends IQ {
|
|||
* @return an Iterator for item childs that holds information about roles, affiliation,
|
||||
* jids and nicks.
|
||||
*/
|
||||
public Iterator getItems() {
|
||||
public Iterator<Item> getItems() {
|
||||
synchronized (items) {
|
||||
return Collections.unmodifiableList(new ArrayList(items)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class MUCAdmin extends IQ {
|
|||
buf.append("<query xmlns=\"http://jabber.org/protocol/muc#admin\">");
|
||||
synchronized (items) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Item item = (Item) items.get(i);
|
||||
Item item = items.get(i);
|
||||
buf.append(item.toXML());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.util.List;
|
|||
*/
|
||||
public class MUCOwner extends IQ {
|
||||
|
||||
private List items = new ArrayList();
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
private Destroy destroy;
|
||||
|
||||
/**
|
||||
|
@ -45,9 +45,9 @@ public class MUCOwner extends IQ {
|
|||
* @return an Iterator for item childs that holds information about affiliation,
|
||||
* jids and nicks.
|
||||
*/
|
||||
public Iterator getItems() {
|
||||
public Iterator<Item> getItems() {
|
||||
synchronized (items) {
|
||||
return Collections.unmodifiableList(new ArrayList(items)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ public class MessageEvent implements PacketExtension {
|
|||
*
|
||||
* @return an iterator over all the types of events of the MessageEvent.
|
||||
*/
|
||||
public Iterator getEventTypes() {
|
||||
ArrayList allEvents = new ArrayList();
|
||||
public Iterator<String> getEventTypes() {
|
||||
ArrayList<String> allEvents = new ArrayList<String>();
|
||||
if (isDelivered()) {
|
||||
allEvents.add(MessageEvent.DELIVERED);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class MultipleAddresses implements PacketExtension {
|
|||
public static final String TO = "to";
|
||||
|
||||
|
||||
private List addresses = new ArrayList();
|
||||
private List<Address> addresses = new ArrayList<Address>();
|
||||
|
||||
/**
|
||||
* Adds a new address to which the packet is going to be sent or was sent.
|
||||
|
@ -84,9 +84,9 @@ public class MultipleAddresses implements PacketExtension {
|
|||
* @param type Examples of address type are: TO, CC, BCC, etc.
|
||||
* @return the list of addresses that matches the specified type.
|
||||
*/
|
||||
public List getAddressesOfType(String type) {
|
||||
List answer = new ArrayList(addresses.size());
|
||||
for (Iterator it = addresses.iterator(); it.hasNext();) {
|
||||
public List<Address> getAddressesOfType(String type) {
|
||||
List<Address> answer = new ArrayList<Address>(addresses.size());
|
||||
for (Iterator<Address> it = addresses.iterator(); it.hasNext();) {
|
||||
Address address = (Address) it.next();
|
||||
if (address.getType().equals(type)) {
|
||||
answer.add(address);
|
||||
|
@ -109,7 +109,7 @@ public class MultipleAddresses implements PacketExtension {
|
|||
buf.append("<").append(getElementName());
|
||||
buf.append(" xmlns=\"").append(getNamespace()).append("\">");
|
||||
// Loop through all the addresses and append them to the string buffer
|
||||
for (Iterator i = addresses.iterator(); i.hasNext();) {
|
||||
for (Iterator<Address> i = addresses.iterator(); i.hasNext();) {
|
||||
Address address = (Address) i.next();
|
||||
buf.append(address.toXML());
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.util.List;
|
|||
*/
|
||||
public class OfflineMessageRequest extends IQ {
|
||||
|
||||
private List items = new ArrayList();
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
private boolean purge = false;
|
||||
private boolean fetch = false;
|
||||
|
||||
|
@ -48,9 +48,9 @@ public class OfflineMessageRequest extends IQ {
|
|||
* @return an Iterator for item childs that holds information about offline messages to
|
||||
* view or delete.
|
||||
*/
|
||||
public Iterator getItems() {
|
||||
public Iterator<Item> getItems() {
|
||||
synchronized (items) {
|
||||
return Collections.unmodifiableList(new ArrayList(items)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class OfflineMessageRequest extends IQ {
|
|||
buf.append("<offline xmlns=\"http://jabber.org/protocol/offline\">");
|
||||
synchronized (items) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Item item = (Item) items.get(i);
|
||||
Item item = items.get(i);
|
||||
buf.append(item.toXML());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ import java.util.List;
|
|||
*/
|
||||
public class RosterExchange implements PacketExtension {
|
||||
|
||||
private List remoteRosterEntries = new ArrayList();
|
||||
private List<RemoteRosterEntry> remoteRosterEntries = new ArrayList<RemoteRosterEntry>();
|
||||
|
||||
/**
|
||||
* Creates a new empty roster exchange package.
|
||||
|
@ -132,9 +132,9 @@ public class RosterExchange implements PacketExtension {
|
|||
*
|
||||
* @return an Iterator for the roster entries in the packet.
|
||||
*/
|
||||
public Iterator getRosterEntries() {
|
||||
public Iterator<RemoteRosterEntry> getRosterEntries() {
|
||||
synchronized (remoteRosterEntries) {
|
||||
List entries = Collections.unmodifiableList(new ArrayList(remoteRosterEntries));
|
||||
List<RemoteRosterEntry> entries = Collections.unmodifiableList(new ArrayList<RemoteRosterEntry>(remoteRosterEntries));
|
||||
return entries.iterator();
|
||||
}
|
||||
}
|
||||
|
@ -170,8 +170,8 @@ public class RosterExchange implements PacketExtension {
|
|||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||
"\">");
|
||||
// Loop through all roster entries and append them to the string buffer
|
||||
for (Iterator i = getRosterEntries(); i.hasNext();) {
|
||||
RemoteRosterEntry remoteRosterEntry = (RemoteRosterEntry) i.next();
|
||||
for (Iterator<RemoteRosterEntry> i = getRosterEntries(); i.hasNext();) {
|
||||
RemoteRosterEntry remoteRosterEntry = i.next();
|
||||
buf.append(remoteRosterEntry.toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
|
|
|
@ -19,21 +19,21 @@ import java.util.List;
|
|||
*/
|
||||
public class SharedGroupsInfo extends IQ {
|
||||
|
||||
private List groups = new ArrayList();
|
||||
private List<String> groups = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Returns a collection with the shared group names returned from the server.
|
||||
*
|
||||
* @return collection with the shared group names returned from the server.
|
||||
*/
|
||||
public List getGroups() {
|
||||
public List<String> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<sharedgroup xmlns=\"http://www.jivesoftware.org/protocol/sharedgroup\">");
|
||||
for (Iterator it=groups.iterator(); it.hasNext();) {
|
||||
for (Iterator<String> it=groups.iterator(); it.hasNext();) {
|
||||
buf.append("<group>").append(it.next()).append("</group>");
|
||||
}
|
||||
buf.append("</sharedgroup>");
|
||||
|
|
|
@ -20,16 +20,6 @@
|
|||
|
||||
package org.jivesoftware.smackx.packet;
|
||||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -42,6 +32,17 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
/**
|
||||
* A VCard class for use with the
|
||||
|
@ -740,14 +741,14 @@ public class VCard extends IQ {
|
|||
}
|
||||
|
||||
private void appendPhones(Map<String, String> phones, final String code) {
|
||||
Iterator it = phones.entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> it = phones.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
final Map.Entry entry = (Map.Entry) it.next();
|
||||
final Map.Entry<String,String> entry = it.next();
|
||||
appendTag("TEL", true, new ContentBuilder() {
|
||||
public void addTagContent() {
|
||||
appendEmptyTag(entry.getKey());
|
||||
appendEmptyTag(code);
|
||||
appendTag("NUMBER", StringUtils.escapeForXML((String) entry.getValue()));
|
||||
appendTag("NUMBER", StringUtils.escapeForXML(entry.getValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -759,10 +760,10 @@ public class VCard extends IQ {
|
|||
public void addTagContent() {
|
||||
appendEmptyTag(code);
|
||||
|
||||
Iterator it = addr.entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> it = addr.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
final Map.Entry entry = (Map.Entry) it.next();
|
||||
appendTag((String) entry.getKey(), StringUtils.escapeForXML((String) entry.getValue()));
|
||||
final Entry<String, String> entry = it.next();
|
||||
appendTag(entry.getKey(), StringUtils.escapeForXML(entry.getValue()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -774,17 +775,17 @@ public class VCard extends IQ {
|
|||
}
|
||||
|
||||
private void appendGenericFields() {
|
||||
Iterator it = otherSimpleFields.entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> it = otherSimpleFields.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
Map.Entry<String, String> entry = it.next();
|
||||
appendTag(entry.getKey().toString(),
|
||||
StringUtils.escapeForXML((String) entry.getValue()));
|
||||
StringUtils.escapeForXML(entry.getValue()));
|
||||
}
|
||||
|
||||
it = otherUnescapableFields.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
appendTag(entry.getKey().toString(), (String) entry.getValue());
|
||||
Map.Entry<String, String> entry = it.next();
|
||||
appendTag(entry.getKey().toString(),entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||
*/
|
||||
public class XHTMLExtension implements PacketExtension {
|
||||
|
||||
private List bodies = new ArrayList();
|
||||
private List<String> bodies = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Returns the XML element name of the extension sub-packet root element.
|
||||
|
@ -85,8 +85,8 @@ public class XHTMLExtension implements PacketExtension {
|
|||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||
"\">");
|
||||
// Loop through all the bodies and append them to the string buffer
|
||||
for (Iterator i = getBodies(); i.hasNext();) {
|
||||
buf.append((String) i.next());
|
||||
for (Iterator<String> i = getBodies(); i.hasNext();) {
|
||||
buf.append(i.next());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
return buf.toString();
|
||||
|
@ -97,9 +97,9 @@ public class XHTMLExtension implements PacketExtension {
|
|||
*
|
||||
* @return an Iterator for the bodies in the packet.
|
||||
*/
|
||||
public Iterator getBodies() {
|
||||
public Iterator<String> getBodies() {
|
||||
synchronized (bodies) {
|
||||
return Collections.unmodifiableList(new ArrayList(bodies)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<String>(bodies)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public class DataFormProvider implements PacketExtensionProvider {
|
|||
|
||||
private DataForm.Item parseItem(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
List fields = new ArrayList();
|
||||
List<FormField> fields = new ArrayList<FormField>();
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
|
@ -123,7 +123,7 @@ public class DataFormProvider implements PacketExtensionProvider {
|
|||
|
||||
private DataForm.ReportedData parseReported(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
List fields = new ArrayList();
|
||||
List<FormField> fields = new ArrayList<FormField>();
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
|
|
|
@ -57,13 +57,13 @@ public class RosterExchangeProvider implements PacketExtensionProvider {
|
|||
RemoteRosterEntry remoteRosterEntry = null;
|
||||
String jid = "";
|
||||
String name = "";
|
||||
ArrayList groupsName = new ArrayList();
|
||||
ArrayList<String> groupsName = new ArrayList<String>();
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
// Reset this variable since they are optional for each item
|
||||
groupsName = new ArrayList();
|
||||
groupsName = new ArrayList<String>();
|
||||
// Initialize the variables from the parsed XML
|
||||
jid = parser.getAttributeValue("", "jid");
|
||||
name = parser.getAttributeValue("", "name");
|
||||
|
|
|
@ -184,8 +184,8 @@ public class VCardProvider implements IQProvider {
|
|||
Element addressNode = (Element) allAddresses.item(i);
|
||||
|
||||
String type = null;
|
||||
List code = new ArrayList();
|
||||
List value = new ArrayList();
|
||||
List<String> code = new ArrayList<String>();
|
||||
List<String> value = new ArrayList<String>();
|
||||
NodeList childNodes = addressNode.getChildNodes();
|
||||
for (int j = 0; j < childNodes.getLength(); j++) {
|
||||
Node node = childNodes.item(j);
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract public class Node
|
|||
protected String id;
|
||||
protected String to;
|
||||
|
||||
protected ConcurrentHashMap<ItemEventListener, PacketListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener, PacketListener>();
|
||||
protected ConcurrentHashMap<ItemEventListener<Item>, PacketListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, PacketListener>();
|
||||
protected ConcurrentHashMap<ItemDeleteListener, PacketListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, PacketListener>();
|
||||
protected ConcurrentHashMap<NodeConfigListener, PacketListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, PacketListener>();
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smackx.Form;
|
||||
import org.jivesoftware.smackx.FormField;
|
||||
import org.jivesoftware.smackx.ServiceDiscoveryManager;
|
||||
|
@ -149,7 +149,7 @@ final public class PubSubManager
|
|||
* @return the node
|
||||
* @throws XMPPException The node does not exist
|
||||
*/
|
||||
public Node getNode(String id)
|
||||
public <T extends Node> T getNode(String id)
|
||||
throws XMPPException
|
||||
{
|
||||
Node node = nodeMap.get(id);
|
||||
|
@ -169,7 +169,7 @@ final public class PubSubManager
|
|||
node.setTo(to);
|
||||
nodeMap.put(id, node);
|
||||
}
|
||||
return node;
|
||||
return (T) node;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -122,9 +122,9 @@ class SimpleUserSearch extends IQ {
|
|||
fields.add(field);
|
||||
|
||||
boolean exists = false;
|
||||
Iterator cols = data.getColumns();
|
||||
Iterator<ReportedData.Column> cols = data.getColumns();
|
||||
while (cols.hasNext()) {
|
||||
ReportedData.Column column = (ReportedData.Column) cols.next();
|
||||
ReportedData.Column column = cols.next();
|
||||
if (column.getVariable().equals(name)) {
|
||||
exists = true;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class UserSearchManager {
|
|||
* @return a Collection of search services found on the server.
|
||||
* @throws XMPPException thrown if a server error has occurred.
|
||||
*/
|
||||
public Collection getSearchServices() throws XMPPException {
|
||||
public Collection<String> getSearchServices() throws XMPPException {
|
||||
final List<String> searchServices = new ArrayList<String>();
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
|
||||
DiscoverItems items = discoManager.discoverItems(con.getServiceName());
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.util.MetaDataUtils;
|
||||
|
@ -40,16 +41,16 @@ public class MetaData implements PacketExtension {
|
|||
*/
|
||||
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
||||
|
||||
private Map metaData;
|
||||
private Map<String, List<String>> metaData;
|
||||
|
||||
public MetaData(Map metaData) {
|
||||
public MetaData(Map<String, List<String>> metaData) {
|
||||
this.metaData = metaData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Map of metadata contained by this instance
|
||||
*/
|
||||
public Map getMetaData() {
|
||||
public Map<String, List<String>> getMetaData() {
|
||||
return metaData;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +37,7 @@ public class WorkgroupInvitation {
|
|||
protected String issuingWorkgroupName;
|
||||
protected String messageBody;
|
||||
protected String invitationSender;
|
||||
protected Map metaData;
|
||||
protected Map<String, List<String>> metaData;
|
||||
|
||||
/**
|
||||
* This calls the 5-argument constructor with a null MetaData argument value
|
||||
|
@ -65,7 +66,7 @@ public class WorkgroupInvitation {
|
|||
* @param metaData the metadata sent with the invitation
|
||||
*/
|
||||
public WorkgroupInvitation (String jid, String group, String workgroup, String sessID, String msgBody,
|
||||
String from, Map metaData) {
|
||||
String from, Map<String, List<String>> metaData) {
|
||||
super();
|
||||
|
||||
this.uniqueID = jid;
|
||||
|
@ -126,7 +127,7 @@ public class WorkgroupInvitation {
|
|||
* @return the meta data associated with the invitation, or null if this instance was
|
||||
* constructed with none
|
||||
*/
|
||||
public Map getMetaData () {
|
||||
public Map<String, List<String>> getMetaData () {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,8 +318,8 @@ public class AgentRoster {
|
|||
}
|
||||
// Fire an event.
|
||||
synchronized (entries) {
|
||||
for (Iterator i = entries.iterator(); i.hasNext();) {
|
||||
String entry = (String)i.next();
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = i.next();
|
||||
if (entry.toLowerCase().equals(StringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
fireEvent(EVENT_PRESENCE_CHANGED, packet);
|
||||
}
|
||||
|
@ -358,8 +358,8 @@ public class AgentRoster {
|
|||
public void processPacket(Packet packet) {
|
||||
if (packet instanceof AgentStatusRequest) {
|
||||
AgentStatusRequest statusRequest = (AgentStatusRequest)packet;
|
||||
for (Iterator i = statusRequest.getAgents().iterator(); i.hasNext();) {
|
||||
AgentStatusRequest.Item item = (AgentStatusRequest.Item)i.next();
|
||||
for (Iterator<AgentStatusRequest.Item> i = statusRequest.getAgents().iterator(); i.hasNext();) {
|
||||
AgentStatusRequest.Item item = i.next();
|
||||
String agentJID = item.getJID();
|
||||
if ("remove".equals(item.getType())) {
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.jivesoftware.smackx.workgroup.agent;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.MetaData;
|
||||
import org.jivesoftware.smackx.workgroup.QueueUser;
|
||||
import org.jivesoftware.smackx.workgroup.WorkgroupInvitation;
|
||||
import org.jivesoftware.smackx.workgroup.WorkgroupInvitationListener;
|
||||
import org.jivesoftware.smackx.workgroup.ext.history.AgentChatHistory;
|
||||
|
@ -60,7 +61,7 @@ public class AgentSession {
|
|||
private boolean online = false;
|
||||
private Presence.Mode presenceMode;
|
||||
private int maxChats;
|
||||
private final Map<String, String> metaData;
|
||||
private final Map<String, List<String>> metaData;
|
||||
|
||||
private Map<String, WorkgroupQueue> queues;
|
||||
|
||||
|
@ -96,7 +97,7 @@ public class AgentSession {
|
|||
|
||||
this.maxChats = -1;
|
||||
|
||||
this.metaData = new HashMap<String, String>();
|
||||
this.metaData = new HashMap<String, List<String>>();
|
||||
|
||||
this.queues = new HashMap<String, WorkgroupQueue>();
|
||||
|
||||
|
@ -199,10 +200,10 @@ public class AgentSession {
|
|||
*/
|
||||
public void setMetaData(String key, String val) throws XMPPException {
|
||||
synchronized (this.metaData) {
|
||||
String oldVal = (String)this.metaData.get(key);
|
||||
List<String> oldVals = metaData.get(key);
|
||||
|
||||
if ((oldVal == null) || (!oldVal.equals(val))) {
|
||||
metaData.put(key, val);
|
||||
if ((oldVals == null) || (!oldVals.get(0).equals(val))) {
|
||||
oldVals.set(0, val);
|
||||
|
||||
setStatus(presenceMode, maxChats);
|
||||
}
|
||||
|
@ -218,7 +219,7 @@ public class AgentSession {
|
|||
*/
|
||||
public void removeMetaData(String key) throws XMPPException {
|
||||
synchronized (this.metaData) {
|
||||
String oldVal = (String)metaData.remove(key);
|
||||
List<String> oldVal = metaData.remove(key);
|
||||
|
||||
if (oldVal != null) {
|
||||
setStatus(presenceMode, maxChats);
|
||||
|
@ -233,8 +234,8 @@ public class AgentSession {
|
|||
* @return the meta data value associated with the key or <tt>null</tt> if the meta-data
|
||||
* doesn't exist..
|
||||
*/
|
||||
public String getMetaData(String key) {
|
||||
return (String)metaData.get(key);
|
||||
public List<String> getMetaData(String key) {
|
||||
return metaData.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -642,7 +643,7 @@ public class AgentSession {
|
|||
}
|
||||
|
||||
private void fireInvitationEvent(String groupChatJID, String sessionID, String body,
|
||||
String from, Map metaData) {
|
||||
String from, Map<String, List<String>> metaData) {
|
||||
WorkgroupInvitation invitation = new WorkgroupInvitation(connection.getUser(), groupChatJID,
|
||||
workgroupJID, sessionID, body, from, metaData);
|
||||
|
||||
|
@ -654,7 +655,7 @@ public class AgentSession {
|
|||
}
|
||||
|
||||
private void fireQueueUsersEvent(WorkgroupQueue queue, WorkgroupQueue.Status status,
|
||||
int averageWaitTime, Date oldestEntry, Set users) {
|
||||
int averageWaitTime, Date oldestEntry, Set<QueueUser> users) {
|
||||
synchronized (queueUsersListeners) {
|
||||
for (QueueUsersListener listener : queueUsersListeners) {
|
||||
if (status != null) {
|
||||
|
@ -754,7 +755,7 @@ public class AgentSession {
|
|||
MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null;
|
||||
if (invite != null && workgroupJID.equals(invite.getFrom())) {
|
||||
String sessionID = null;
|
||||
Map metaData = null;
|
||||
Map<String, List<String>> metaData = null;
|
||||
|
||||
SessionID sessionIDExt = (SessionID)message.getExtension(SessionID.ELEMENT_NAME,
|
||||
SessionID.NAMESPACE);
|
||||
|
@ -980,7 +981,7 @@ public class AgentSession {
|
|||
* @return Map a map of all metadata associated with the sessionID.
|
||||
* @throws XMPPException if an error occurs while getting information from the server.
|
||||
*/
|
||||
public Map getChatMetadata(String sessionID) throws XMPPException {
|
||||
public Map<String, List<String>> getChatMetadata(String sessionID) throws XMPPException {
|
||||
ChatMetadata request = new ChatMetadata();
|
||||
request.setType(IQ.Type.GET);
|
||||
request.setTo(workgroupJID);
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +45,7 @@ public class Offer {
|
|||
private String userID;
|
||||
private String workgroupName;
|
||||
private Date expiresDate;
|
||||
private Map metaData;
|
||||
private Map<String, List<String>> metaData;
|
||||
private OfferContent content;
|
||||
|
||||
private boolean accepted = false;
|
||||
|
@ -66,7 +67,7 @@ public class Offer {
|
|||
*/
|
||||
Offer(Connection conn, AgentSession agentSession, String userID,
|
||||
String userJID, String workgroupName, Date expiresDate,
|
||||
String sessionID, Map metaData, OfferContent content)
|
||||
String sessionID, Map<String, List<String>> metaData, OfferContent content)
|
||||
{
|
||||
this.connection = conn;
|
||||
this.session = agentSession;
|
||||
|
@ -155,7 +156,7 @@ public class Offer {
|
|||
*
|
||||
* @return the offer meta-data.
|
||||
*/
|
||||
public Map getMetaData() {
|
||||
public Map<String, List<String>> getMetaData() {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ package org.jivesoftware.smackx.workgroup.agent;
|
|||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.QueueUser;
|
||||
|
||||
public interface QueueUsersListener {
|
||||
|
||||
/**
|
||||
|
@ -54,5 +56,5 @@ public interface QueueUsersListener {
|
|||
* @param queue the workgroup queue.
|
||||
* @param users the list of users waiting in the queue.
|
||||
*/
|
||||
public void usersUpdated(WorkgroupQueue queue, Set users);
|
||||
public void usersUpdated(WorkgroupQueue queue, Set<QueueUser> users);
|
||||
}
|
|
@ -21,6 +21,8 @@ package org.jivesoftware.smackx.workgroup.agent;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.QueueUser;
|
||||
|
||||
/**
|
||||
* A queue in a workgroup, which is a pool of agents that are routed a specific type of
|
||||
* chat request.
|
||||
|
@ -32,7 +34,7 @@ public class WorkgroupQueue {
|
|||
|
||||
private int averageWaitTime = -1;
|
||||
private Date oldestEntry = null;
|
||||
private Set users = Collections.EMPTY_SET;
|
||||
private Set<QueueUser> users = Collections.emptySet();
|
||||
|
||||
private int maxChats = 0;
|
||||
private int currentChats = 0;
|
||||
|
@ -87,14 +89,14 @@ public class WorkgroupQueue {
|
|||
*
|
||||
* @return an Iterator for the users waiting in the queue.
|
||||
*/
|
||||
public Iterator getUsers() {
|
||||
public Iterator<QueueUser> getUsers() {
|
||||
if (users == null) {
|
||||
return Collections.EMPTY_SET.iterator();
|
||||
return new HashSet<QueueUser>().iterator();
|
||||
}
|
||||
return Collections.unmodifiableSet(users).iterator();
|
||||
}
|
||||
|
||||
void setUsers(Set users) {
|
||||
void setUsers(Set<QueueUser> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class AgentChatHistory extends IQ {
|
|||
private int maxSessions;
|
||||
private long startDate;
|
||||
|
||||
private List agentChatSessions = new ArrayList();
|
||||
private List<AgentChatSession> agentChatSessions = new ArrayList<AgentChatSession>();
|
||||
|
||||
public AgentChatHistory(String agentJID, int maxSessions, Date startDate) {
|
||||
this.agentJID = agentJID;
|
||||
|
@ -58,7 +58,7 @@ public class AgentChatHistory extends IQ {
|
|||
agentChatSessions.add(chatSession);
|
||||
}
|
||||
|
||||
public Collection getAgentChatSessions() {
|
||||
public Collection<AgentChatSession> getAgentChatSessions() {
|
||||
return agentChatSessions;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jivesoftware.smack.provider.IQProvider;
|
|||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatMetadata extends IQ {
|
||||
|
@ -51,13 +52,13 @@ public class ChatMetadata extends IQ {
|
|||
}
|
||||
|
||||
|
||||
private Map map = new HashMap();
|
||||
private Map<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
|
||||
public void setMetadata(Map metadata){
|
||||
public void setMetadata(Map<String, List<String>> metadata){
|
||||
this.map = metadata;
|
||||
}
|
||||
|
||||
public Map getMetadata(){
|
||||
public Map<String, List<String>> getMetadata(){
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -94,7 +95,7 @@ public class ChatMetadata extends IQ {
|
|||
chatM.setSessionID(parser.nextText());
|
||||
}
|
||||
else if (parser.getName().equals("metadata")) {
|
||||
Map map = MetaDataUtils.parseMetaData(parser);
|
||||
Map<String, List<String>> map = MetaDataUtils.parseMetaData(parser);
|
||||
chatM.setMetadata(map);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.MetaData;
|
||||
|
@ -41,7 +42,7 @@ public class MetaDataProvider implements PacketExtensionProvider {
|
|||
*/
|
||||
public PacketExtension parseExtension (XmlPullParser parser)
|
||||
throws Exception {
|
||||
Map metaData = MetaDataUtils.parseMetaData(parser);
|
||||
Map<String, List<String>> metaData = MetaDataUtils.parseMetaData(parser);
|
||||
|
||||
return new MetaData(metaData);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +50,7 @@ public class OfferRequestProvider implements IQProvider {
|
|||
int timeout = -1;
|
||||
OfferContent content = null;
|
||||
boolean done = false;
|
||||
Map metaData = new HashMap();
|
||||
Map<String, List<String>> metaData = new HashMap<String, List<String>>();
|
||||
|
||||
if (eventType != XmlPullParser.START_TAG) {
|
||||
// throw exception
|
||||
|
@ -111,11 +112,11 @@ public class OfferRequestProvider implements IQProvider {
|
|||
private int timeout;
|
||||
private String userID;
|
||||
private String userJID;
|
||||
private Map metaData;
|
||||
private Map<String, List<String>> metaData;
|
||||
private String sessionID;
|
||||
private OfferContent content;
|
||||
|
||||
public OfferRequestPacket(String userJID, String userID, int timeout, Map metaData,
|
||||
public OfferRequestPacket(String userJID, String userID, int timeout, Map<String, List<String>> metaData,
|
||||
String sessionID, OfferContent content)
|
||||
{
|
||||
this.userJID = userJID;
|
||||
|
@ -174,7 +175,7 @@ public class OfferRequestProvider implements IQProvider {
|
|||
*
|
||||
* @return meta-data associated with the offer.
|
||||
*/
|
||||
public Map getMetaData() {
|
||||
public Map<String, List<String>> getMetaData() {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@ public class ChatSettings extends IQ {
|
|||
*/
|
||||
public static final int BOT_SETTINGS = 2;
|
||||
|
||||
private List settings;
|
||||
private List<ChatSetting> settings;
|
||||
private String key;
|
||||
private int type = -1;
|
||||
|
||||
public ChatSettings() {
|
||||
settings = new ArrayList();
|
||||
settings = new ArrayList<ChatSetting>();
|
||||
}
|
||||
|
||||
public ChatSettings(String key) {
|
||||
|
@ -69,16 +69,16 @@ public class ChatSettings extends IQ {
|
|||
settings.add(setting);
|
||||
}
|
||||
|
||||
public Collection getSettings() {
|
||||
public Collection<ChatSetting> getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public ChatSetting getChatSetting(String key) {
|
||||
Collection col = getSettings();
|
||||
Collection<ChatSetting> col = getSettings();
|
||||
if (col != null) {
|
||||
Iterator iter = col.iterator();
|
||||
Iterator<ChatSetting> iter = col.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ChatSetting chatSetting = (ChatSetting)iter.next();
|
||||
ChatSetting chatSetting = iter.next();
|
||||
if (chatSetting.getKey().equals(key)) {
|
||||
return chatSetting;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
|||
|
||||
public class GenericSettings extends IQ {
|
||||
|
||||
private Map map = new HashMap();
|
||||
private Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
private String query;
|
||||
|
||||
|
@ -41,11 +41,11 @@ public class GenericSettings extends IQ {
|
|||
this.query = query;
|
||||
}
|
||||
|
||||
public Map getMap() {
|
||||
public Map<String, String> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(Map map) {
|
||||
public void setMap(Map<String, String> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,9 +58,8 @@ public class Workgroup {
|
|||
private String workgroupJID;
|
||||
private Connection connection;
|
||||
private boolean inQueue;
|
||||
private List invitationListeners;
|
||||
private List queueListeners;
|
||||
private List siteInviteListeners;
|
||||
private List<WorkgroupInvitationListener> invitationListeners;
|
||||
private List<QueueListener> queueListeners;
|
||||
|
||||
private int queuePosition = -1;
|
||||
private int queueRemainingTime = -1;
|
||||
|
@ -84,9 +83,8 @@ public class Workgroup {
|
|||
this.workgroupJID = workgroupJID;
|
||||
this.connection = connection;
|
||||
inQueue = false;
|
||||
invitationListeners = new ArrayList();
|
||||
queueListeners = new ArrayList();
|
||||
siteInviteListeners = new ArrayList();
|
||||
invitationListeners = new ArrayList<WorkgroupInvitationListener>();
|
||||
queueListeners = new ArrayList<QueueListener>();
|
||||
|
||||
// Register as a queue listener for internal usage by this instance.
|
||||
addQueueListener(new QueueListener() {
|
||||
|
@ -378,7 +376,7 @@ public class Workgroup {
|
|||
* that a connection failure occured or that the server explicitly rejected the
|
||||
* request to join the queue.
|
||||
*/
|
||||
public void joinQueue(Map metadata, String userID) throws XMPPException {
|
||||
public void joinQueue(Map<String,Object> metadata, String userID) throws XMPPException {
|
||||
// If already in the queue ignore the join request.
|
||||
if (inQueue) {
|
||||
throw new IllegalStateException("Already in queue " + workgroupJID);
|
||||
|
@ -386,10 +384,10 @@ public class Workgroup {
|
|||
|
||||
// Build dataform from metadata
|
||||
Form form = new Form(Form.TYPE_SUBMIT);
|
||||
Iterator iter = metadata.keySet().iterator();
|
||||
Iterator<String> iter = metadata.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
String name = (String)iter.next();
|
||||
String value = (String)metadata.get(name).toString();
|
||||
String name = iter.next();
|
||||
String value = metadata.get(name).toString();
|
||||
|
||||
String escapedName = StringUtils.escapeForXML(name);
|
||||
String escapedValue = StringUtils.escapeForXML(value);
|
||||
|
@ -489,8 +487,8 @@ public class Workgroup {
|
|||
|
||||
private void fireInvitationEvent(WorkgroupInvitation invitation) {
|
||||
synchronized (invitationListeners) {
|
||||
for (Iterator i = invitationListeners.iterator(); i.hasNext();) {
|
||||
WorkgroupInvitationListener listener = (WorkgroupInvitationListener)i.next();
|
||||
for (Iterator<WorkgroupInvitationListener> i = invitationListeners.iterator(); i.hasNext();) {
|
||||
WorkgroupInvitationListener listener = i.next();
|
||||
listener.invitationReceived(invitation);
|
||||
}
|
||||
}
|
||||
|
@ -498,8 +496,8 @@ public class Workgroup {
|
|||
|
||||
private void fireQueueJoinedEvent() {
|
||||
synchronized (queueListeners) {
|
||||
for (Iterator i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = (QueueListener)i.next();
|
||||
for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = i.next();
|
||||
listener.joinedQueue();
|
||||
}
|
||||
}
|
||||
|
@ -507,8 +505,8 @@ public class Workgroup {
|
|||
|
||||
private void fireQueueDepartedEvent() {
|
||||
synchronized (queueListeners) {
|
||||
for (Iterator i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = (QueueListener)i.next();
|
||||
for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = i.next();
|
||||
listener.departedQueue();
|
||||
}
|
||||
}
|
||||
|
@ -516,8 +514,8 @@ public class Workgroup {
|
|||
|
||||
private void fireQueuePositionEvent(int currentPosition) {
|
||||
synchronized (queueListeners) {
|
||||
for (Iterator i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = (QueueListener)i.next();
|
||||
for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = i.next();
|
||||
listener.queuePositionUpdated(currentPosition);
|
||||
}
|
||||
}
|
||||
|
@ -525,8 +523,8 @@ public class Workgroup {
|
|||
|
||||
private void fireQueueTimeEvent(int secondsRemaining) {
|
||||
synchronized (queueListeners) {
|
||||
for (Iterator i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = (QueueListener)i.next();
|
||||
for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = i.next();
|
||||
listener.queueWaitTimeUpdated(secondsRemaining);
|
||||
}
|
||||
}
|
||||
|
@ -560,7 +558,7 @@ public class Workgroup {
|
|||
MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null;
|
||||
if (invite != null && workgroupJID.equals(invite.getFrom())) {
|
||||
String sessionID = null;
|
||||
Map metaData = null;
|
||||
Map<String, List<String>> metaData = null;
|
||||
|
||||
pe = msg.getExtension(SessionID.ELEMENT_NAME,
|
||||
SessionID.NAMESPACE);
|
||||
|
|
|
@ -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