From 06805b248dd27e79dc42d552eb967f7947933b6d Mon Sep 17 00:00:00 2001 From: Michael Will Date: Thu, 26 Nov 2009 14:11:19 +0000 Subject: [PATCH] add generics git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11422 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smackx/workgroup/agent/Agent.java | 2 +- .../smackx/workgroup/agent/AgentRoster.java | 46 +++++++++---------- .../smackx/workgroup/agent/AgentSession.java | 4 +- .../smackx/workgroup/packet/AgentStatus.java | 6 +-- .../workgroup/packet/AgentStatusRequest.java | 8 ++-- .../workgroup/packet/AgentWorkgroups.java | 14 +++--- .../smackx/workgroup/packet/QueueDetails.java | 8 ++-- .../smackx/workgroup/packet/Transcript.java | 12 ++--- .../workgroup/packet/TranscriptProvider.java | 3 +- 9 files changed, 52 insertions(+), 51 deletions(-) diff --git a/source/org/jivesoftware/smackx/workgroup/agent/Agent.java b/source/org/jivesoftware/smackx/workgroup/agent/Agent.java index 39c2fac6a..68d79bbd3 100644 --- a/source/org/jivesoftware/smackx/workgroup/agent/Agent.java +++ b/source/org/jivesoftware/smackx/workgroup/agent/Agent.java @@ -39,7 +39,7 @@ public class Agent { private XMPPConnection connection; private String workgroupJID; - public static Collection getWorkgroups(String serviceJID, String agentJID, XMPPConnection connection) throws XMPPException { + public static Collection getWorkgroups(String serviceJID, String agentJID, XMPPConnection connection) throws XMPPException { AgentWorkgroups request = new AgentWorkgroups(agentJID); request.setTo(serviceJID); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID())); diff --git a/source/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java b/source/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java index fb62f189c..6cc92df5d 100644 --- a/source/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java +++ b/source/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java @@ -52,9 +52,9 @@ public class AgentRoster { private XMPPConnection connection; private String workgroupJID; - private List entries; - private List listeners; - private Map presenceMap; + private List entries; + private List listeners; + private Map> presenceMap; // The roster is marked as initialized when at least a single roster packet // has been recieved and processed. boolean rosterInitialized = false; @@ -67,9 +67,9 @@ public class AgentRoster { AgentRoster(XMPPConnection connection, String workgroupJID) { this.connection = connection; this.workgroupJID = workgroupJID; - entries = new ArrayList(); - listeners = new ArrayList(); - presenceMap = new HashMap(); + entries = new ArrayList(); + listeners = new ArrayList(); + presenceMap = new HashMap>(); // Listen for any roster packets. PacketFilter rosterFilter = new PacketTypeFilter(AgentStatusRequest.class); connection.addPacketListener(new AgentStatusListener(), rosterFilter); @@ -106,19 +106,19 @@ public class AgentRoster { listeners.add(listener); // Fire events for the existing entries and presences in the roster - for (Iterator it = getAgents().iterator(); it.hasNext();) { - String jid = (String)it.next(); + for (Iterator it = getAgents().iterator(); it.hasNext();) { + String jid = it.next(); // Check again in case the agent is no longer in the roster (highly unlikely // but possible) if (entries.contains(jid)) { // Fire the agent added event listener.agentAdded(jid); - Map userPresences = (Map)presenceMap.get(jid); + Map userPresences = presenceMap.get(jid); if (userPresences != null) { - Iterator presences = userPresences.values().iterator(); + Iterator presences = userPresences.values().iterator(); while (presences.hasNext()) { // Fire the presence changed event - listener.presenceChanged((Presence)presences.next()); + listener.presenceChanged(presences.next()); } } } @@ -153,10 +153,10 @@ public class AgentRoster { * * @return all entries in the roster. */ - public Set getAgents() { - Set agents = new HashSet(); + public Set getAgents() { + Set agents = new HashSet(); synchronized (entries) { - for (Iterator i = entries.iterator(); i.hasNext();) { + for (Iterator i = entries.iterator(); i.hasNext();) { agents.add(i.next()); } } @@ -176,8 +176,8 @@ public class AgentRoster { return false; } synchronized (entries) { - for (Iterator i = entries.iterator(); i.hasNext();) { - String entry = (String)i.next(); + for (Iterator i = entries.iterator(); i.hasNext();) { + String entry = i.next(); if (entry.toLowerCase().equals(jid.toLowerCase())) { return true; } @@ -197,7 +197,7 @@ public class AgentRoster { */ public Presence getPresence(String user) { String key = getPresenceMapKey(user); - Map userPresences = (Map)presenceMap.get(key); + Map userPresences = presenceMap.get(key); if (userPresences == null) { Presence presence = new Presence(Presence.Type.unavailable); presence.setFrom(user); @@ -206,7 +206,7 @@ public class AgentRoster { else { // Find the resource with the highest priority // Might be changed to use the resource with the highest availability instead. - Iterator it = userPresences.keySet().iterator(); + Iterator it = userPresences.keySet().iterator(); Presence p; Presence presence = null; @@ -303,14 +303,14 @@ public class AgentRoster { else if (!workgroupJID.equals(agentStatus.getWorkgroupJID())) { return; } - Map userPresences; + Map userPresences; // Get the user presence map if (presenceMap.get(key) == null) { - userPresences = new HashMap(); + userPresences = new HashMap(); presenceMap.put(key, userPresences); } else { - userPresences = (Map)presenceMap.get(key); + userPresences = presenceMap.get(key); } // Add the new presence, using the resources as a key. synchronized (userPresences) { @@ -329,7 +329,7 @@ public class AgentRoster { // If an "unavailable" packet, remove any entries in the presence map. else if (presence.getType() == Presence.Type.unavailable) { if (presenceMap.get(key) != null) { - Map userPresences = (Map)presenceMap.get(key); + Map userPresences = presenceMap.get(key); synchronized (userPresences) { userPresences.remove(StringUtils.parseResource(from)); } @@ -339,7 +339,7 @@ public class AgentRoster { } // Fire an event. synchronized (entries) { - for (Iterator i = entries.iterator(); i.hasNext();) { + for (Iterator i = entries.iterator(); i.hasNext();) { String entry = (String)i.next(); if (entry.toLowerCase().equals(StringUtils.parseBareAddress(key).toLowerCase())) { fireEvent(EVENT_PRESENCE_CHANGED, packet); diff --git a/source/org/jivesoftware/smackx/workgroup/agent/AgentSession.java b/source/org/jivesoftware/smackx/workgroup/agent/AgentSession.java index 0d2d799dc..b44a728d6 100644 --- a/source/org/jivesoftware/smackx/workgroup/agent/AgentSession.java +++ b/source/org/jivesoftware/smackx/workgroup/agent/AgentSession.java @@ -60,7 +60,7 @@ public class AgentSession { private boolean online = false; private Presence.Mode presenceMode; private int maxChats; - private final Map metaData; + private final Map metaData; private Map queues; @@ -96,7 +96,7 @@ public class AgentSession { this.maxChats = -1; - this.metaData = new HashMap(); + this.metaData = new HashMap(); this.queues = new HashMap(); diff --git a/source/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java b/source/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java index 0878f878c..9f4903316 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java @@ -50,7 +50,7 @@ public class AgentStatus implements PacketExtension { public static final String NAMESPACE = "http://jabber.org/protocol/workgroup"; private String workgroupJID; - private List currentChats = new ArrayList(); + private List currentChats = new ArrayList(); private int maxChats = -1; AgentStatus() { @@ -67,7 +67,7 @@ public class AgentStatus implements PacketExtension { * @return a collection of ChatInfo where each ChatInfo represents a Chat where this agent * is participating. */ - public List getCurrentChats() { + public List getCurrentChats() { return Collections.unmodifiableList(currentChats); } @@ -96,7 +96,7 @@ public class AgentStatus implements PacketExtension { } if (!currentChats.isEmpty()) { buf.append(""); - for (Iterator it = currentChats.iterator(); it.hasNext();) { + for (Iterator it = currentChats.iterator(); it.hasNext();) { buf.append(((ChatInfo)it.next()).toXML()); } buf.append(""); diff --git a/source/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java b/source/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java index 541a6cfab..48549d22d 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java @@ -47,17 +47,17 @@ public class AgentStatusRequest extends IQ { */ public static final String NAMESPACE = "http://jabber.org/protocol/workgroup"; - private Set agents; + private Set agents; public AgentStatusRequest() { - agents = new HashSet(); + agents = new HashSet(); } public int getAgentCount() { return agents.size(); } - public Set getAgents() { + public Set getAgents() { return Collections.unmodifiableSet(agents); } @@ -73,7 +73,7 @@ public class AgentStatusRequest extends IQ { StringBuilder buf = new StringBuilder(); buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">"); synchronized (agents) { - for (Iterator i=agents.iterator(); i.hasNext(); ) { + for (Iterator i=agents.iterator(); i.hasNext(); ) { Item item = (Item) i.next(); buf.append(""); if (item.getName() != null) { diff --git a/source/org/jivesoftware/smackx/workgroup/packet/AgentWorkgroups.java b/source/org/jivesoftware/smackx/workgroup/packet/AgentWorkgroups.java index b1578fdc6..292a640d8 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/AgentWorkgroups.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/AgentWorkgroups.java @@ -38,7 +38,7 @@ import java.util.List; public class AgentWorkgroups extends IQ { private String agentJID; - private List workgroups; + private List workgroups; /** * Creates an AgentWorkgroups request for the given agent. This IQ will be sent and an answer @@ -48,7 +48,7 @@ public class AgentWorkgroups extends IQ { */ public AgentWorkgroups(String agentJID) { this.agentJID = agentJID; - this.workgroups = new ArrayList(); + this.workgroups = new ArrayList(); } /** @@ -58,7 +58,7 @@ public class AgentWorkgroups extends IQ { * @param agentJID the id of the agent that can work in the list of workgroups. * @param workgroups the list of workgroup JIDs where the agent can work. */ - public AgentWorkgroups(String agentJID, List workgroups) { + public AgentWorkgroups(String agentJID, List workgroups) { this.agentJID = agentJID; this.workgroups = workgroups; } @@ -72,7 +72,7 @@ public class AgentWorkgroups extends IQ { * * @return a list of workgroup JIDs where the agent can work. */ - public List getWorkgroups() { + public List getWorkgroups() { return Collections.unmodifiableList(workgroups); } @@ -83,8 +83,8 @@ public class AgentWorkgroups extends IQ { .append(agentJID) .append("\">"); - for (Iterator it=workgroups.iterator(); it.hasNext();) { - String workgroupJID = (String) it.next(); + for (Iterator it=workgroups.iterator(); it.hasNext();) { + String workgroupJID = it.next(); buf.append(""); } @@ -106,7 +106,7 @@ public class AgentWorkgroups extends IQ { public IQ parseIQ(XmlPullParser parser) throws Exception { String agentJID = parser.getAttributeValue("", "jid"); - List workgroups = new ArrayList(); + List workgroups = new ArrayList(); boolean done = false; while (!done) { diff --git a/source/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java b/source/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java index f5f27152d..f51c81fdb 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java @@ -51,13 +51,13 @@ public class QueueDetails implements PacketExtension { /** * The list of users in the queue. */ - private Set users; + private Set users; /** * Creates a new QueueDetails packet */ private QueueDetails() { - users = new HashSet(); + users = new HashSet(); } /** @@ -76,7 +76,7 @@ public class QueueDetails implements PacketExtension { * * @return a Set for the users waiting in a queue. */ - public Set getUsers() { + public Set getUsers() { synchronized (users) { return users; } @@ -106,7 +106,7 @@ public class QueueDetails implements PacketExtension { buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">"); synchronized (users) { - for (Iterator i=users.iterator(); i.hasNext(); ) { + for (Iterator i=users.iterator(); i.hasNext(); ) { QueueUser user = (QueueUser)i.next(); int position = user.getQueuePosition(); int timeRemaining = user.getEstimatedRemainingTime(); diff --git a/source/org/jivesoftware/smackx/workgroup/packet/Transcript.java b/source/org/jivesoftware/smackx/workgroup/packet/Transcript.java index 93d4ab890..7f8f29e58 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/Transcript.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/Transcript.java @@ -36,7 +36,7 @@ import java.util.List; */ public class Transcript extends IQ { private String sessionID; - private List packets; + private List packets; /** * Creates a transcript request for the given sessionID. @@ -45,7 +45,7 @@ public class Transcript extends IQ { */ public Transcript(String sessionID) { this.sessionID = sessionID; - this.packets = new ArrayList(); + this.packets = new ArrayList(); } /** @@ -55,7 +55,7 @@ public class Transcript extends IQ { * @param sessionID the id of the session that generated this conversation transcript. * @param packets the list of messages and presences send to the room. */ - public Transcript(String sessionID, List packets) { + public Transcript(String sessionID, List packets) { this.sessionID = sessionID; this.packets = packets; } @@ -75,7 +75,7 @@ public class Transcript extends IQ { * * @return the list of Messages and Presences that were sent to the room. */ - public List getPackets() { + public List getPackets() { return Collections.unmodifiableList(packets); } @@ -86,8 +86,8 @@ public class Transcript extends IQ { .append(sessionID) .append("\">"); - for (Iterator it=packets.iterator(); it.hasNext();) { - Packet packet = (Packet) it.next(); + for (Iterator it=packets.iterator(); it.hasNext();) { + Packet packet = it.next(); buf.append(packet.toXML()); } diff --git a/source/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java b/source/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java index 01ce83434..791b06ef2 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java @@ -21,6 +21,7 @@ package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; @@ -40,7 +41,7 @@ public class TranscriptProvider implements IQProvider { public IQ parseIQ(XmlPullParser parser) throws Exception { String sessionID = parser.getAttributeValue("", "sessionID"); - List packets = new ArrayList(); + List packets = new ArrayList(); boolean done = false; while (!done) {