1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-27 00:32:07 +01:00

add generics

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11422 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Michael Will 2009-11-26 14:11:19 +00:00 committed by michael.will
parent 0b7421eae3
commit 06805b248d
9 changed files with 52 additions and 51 deletions

View file

@ -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<String> 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()));

View file

@ -52,9 +52,9 @@ public class AgentRoster {
private XMPPConnection connection;
private String workgroupJID;
private List entries;
private List listeners;
private Map presenceMap;
private List<String> entries;
private List<AgentRosterListener> listeners;
private Map<String, Map<String, Presence>> 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<String>();
listeners = new ArrayList<AgentRosterListener>();
presenceMap = new HashMap<String, Map<String, Presence>>();
// 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<String> 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<String,Presence> userPresences = presenceMap.get(jid);
if (userPresences != null) {
Iterator presences = userPresences.values().iterator();
Iterator<Presence> 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<String> getAgents() {
Set<String> agents = new HashSet<String>();
synchronized (entries) {
for (Iterator i = entries.iterator(); i.hasNext();) {
for (Iterator<String> 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<String> 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<String, Presence> 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<String> 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<String, Presence> userPresences;
// Get the user presence map
if (presenceMap.get(key) == null) {
userPresences = new HashMap();
userPresences = new HashMap<String, Presence>();
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<String,Presence> 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<String> i = entries.iterator(); i.hasNext();) {
String entry = (String)i.next();
if (entry.toLowerCase().equals(StringUtils.parseBareAddress(key).toLowerCase())) {
fireEvent(EVENT_PRESENCE_CHANGED, packet);

View file

@ -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<String, String> metaData;
private Map<String, WorkgroupQueue> queues;
@ -96,7 +96,7 @@ public class AgentSession {
this.maxChats = -1;
this.metaData = new HashMap();
this.metaData = new HashMap<String, String>();
this.queues = new HashMap<String, WorkgroupQueue>();

View file

@ -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<ChatInfo> currentChats = new ArrayList<ChatInfo>();
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<ChatInfo> getCurrentChats() {
return Collections.unmodifiableList(currentChats);
}
@ -96,7 +96,7 @@ public class AgentStatus implements PacketExtension {
}
if (!currentChats.isEmpty()) {
buf.append("<current-chats xmlns= \"http://jivesoftware.com/protocol/workgroup\">");
for (Iterator it = currentChats.iterator(); it.hasNext();) {
for (Iterator<ChatInfo> it = currentChats.iterator(); it.hasNext();) {
buf.append(((ChatInfo)it.next()).toXML());
}
buf.append("</current-chats>");

View file

@ -47,17 +47,17 @@ public class AgentStatusRequest extends IQ {
*/
public static final String NAMESPACE = "http://jabber.org/protocol/workgroup";
private Set agents;
private Set<Item> agents;
public AgentStatusRequest() {
agents = new HashSet();
agents = new HashSet<Item>();
}
public int getAgentCount() {
return agents.size();
}
public Set getAgents() {
public Set<Item> 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<Item> i=agents.iterator(); i.hasNext(); ) {
Item item = (Item) i.next();
buf.append("<agent jid=\"").append(item.getJID()).append("\">");
if (item.getName() != null) {

View file

@ -38,7 +38,7 @@ import java.util.List;
public class AgentWorkgroups extends IQ {
private String agentJID;
private List workgroups;
private List<String> 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<String>();
}
/**
@ -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<String> 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<String> 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<String> it=workgroups.iterator(); it.hasNext();) {
String workgroupJID = it.next();
buf.append("<workgroup jid=\"" + workgroupJID + "\"/>");
}
@ -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<String> workgroups = new ArrayList<String>();
boolean done = false;
while (!done) {

View file

@ -51,13 +51,13 @@ public class QueueDetails implements PacketExtension {
/**
* The list of users in the queue.
*/
private Set users;
private Set<QueueUser> users;
/**
* Creates a new QueueDetails packet
*/
private QueueDetails() {
users = new HashSet();
users = new HashSet<QueueUser>();
}
/**
@ -76,7 +76,7 @@ public class QueueDetails implements PacketExtension {
*
* @return a Set for the users waiting in a queue.
*/
public Set getUsers() {
public Set<QueueUser> 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<QueueUser> i=users.iterator(); i.hasNext(); ) {
QueueUser user = (QueueUser)i.next();
int position = user.getQueuePosition();
int timeRemaining = user.getEstimatedRemainingTime();

View file

@ -36,7 +36,7 @@ import java.util.List;
*/
public class Transcript extends IQ {
private String sessionID;
private List packets;
private List<Packet> 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<Packet>();
}
/**
@ -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<Packet> 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<Packet> 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<Packet> it=packets.iterator(); it.hasNext();) {
Packet packet = it.next();
buf.append(packet.toXML());
}

View file

@ -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<Packet> packets = new ArrayList<Packet>();
boolean done = false;
while (!done) {