1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-06-16 00:24:49 +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:
rcollier 2012-10-26 10:47:55 +00:00
parent 6dc64671e2
commit e08c8afe44
109 changed files with 577 additions and 605 deletions

View file

@ -10,6 +10,7 @@ import org.jivesoftware.smackx.packet.JingleError;
* @author Alvaro Saurin <alvaro.saurin@gmail.com> * @author Alvaro Saurin <alvaro.saurin@gmail.com>
*/ */
public class JingleException extends XMPPException { public class JingleException extends XMPPException {
private static final long serialVersionUID = -1521230401958103382L;
private final JingleError error; private final JingleError error;

View file

@ -215,13 +215,13 @@ public class JingleManager implements JingleSessionListener {
connection.getRoster().addRosterListener(new RosterListener() { connection.getRoster().addRosterListener(new RosterListener() {
public void entriesAdded(Collection addresses) { public void entriesAdded(Collection<String> addresses) {
} }
public void entriesUpdated(Collection addresses) { public void entriesUpdated(Collection<String> addresses) {
} }
public void entriesDeleted(Collection addresses) { public void entriesDeleted(Collection<String> addresses) {
} }
public void presenceChanged(Presence presence) { public void presenceChanged(Presence presence) {

View file

@ -96,7 +96,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
private static final SmackLogger LOGGER = SmackLogger.getLogger(JingleSession.class); private static final SmackLogger LOGGER = SmackLogger.getLogger(JingleSession.class);
// static // static
private static final HashMap sessions = new HashMap(); private static final HashMap<Connection, JingleSession> sessions = new HashMap<Connection, JingleSession>();
private static final Random randomGenerator = new Random(); private static final Random randomGenerator = new Random();
@ -116,14 +116,10 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
protected List<JingleMediaManager> jingleMediaManagers = null; protected List<JingleMediaManager> jingleMediaManagers = null;
private boolean closed = false;
private JingleSessionState sessionState; private JingleSessionState sessionState;
private List<ContentNegotiator> contentNegotiators; private List<ContentNegotiator> contentNegotiators;
private JingleSessionRequest sessionRequest;
private Connection connection; private Connection connection;
private String sessionInitPacketID; private String sessionInitPacketID;
@ -181,7 +177,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
public JingleSession(Connection conn, JingleSessionRequest request, String initiator, String responder, public JingleSession(Connection conn, JingleSessionRequest request, String initiator, String responder,
List<JingleMediaManager> jingleMediaManagers) { List<JingleMediaManager> jingleMediaManagers) {
this(conn, initiator, responder, generateSessionId(), jingleMediaManagers); this(conn, initiator, responder, generateSessionId(), jingleMediaManagers);
sessionRequest = request; //sessionRequest = request; // unused
} }
/** /**
@ -525,29 +521,6 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
// throw new IllegalStateException("Only session-initiate allowed in the UNKNOWN state."); // throw new IllegalStateException("Only session-initiate allowed in the UNKNOWN state.");
// } // }
// } // }
/**
* @param inJingle
* @param inAction
*/
private void sendPendingStateAction(Jingle inJingle, JingleActionEnum inAction) {
}
/**
* @param inJingle
* @param inAction
*/
private void sendActiveStateAction(Jingle inJingle, JingleActionEnum inAction) {
}
/**
* @param inJingle
* @param inAction
*/
private void sendEndedStateAction(Jingle inJingle, JingleActionEnum inAction) {
}
/** /**
* Acknowledge a IQ packet. * Acknowledge a IQ packet.
@ -670,7 +643,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
JingleSession result = null; JingleSession result = null;
synchronized (sessions) { synchronized (sessions) {
if (sessions.containsKey(con)) { if (sessions.containsKey(con)) {
result = (JingleSession) sessions.get(con); result = sessions.get(con);
} }
} }

View file

@ -44,7 +44,7 @@ public class SmackLogger {
* @param classToLog This is the class that wants to log. (This gives commons-logging a means to control log-level by class.) * @param classToLog This is the class that wants to log. (This gives commons-logging a means to control log-level by class.)
* @return An instance of a SmackLogger for the class that wants logging. * @return An instance of a SmackLogger for the class that wants logging.
*/ */
public static SmackLogger getLogger(Class classToLog) { public static SmackLogger getLogger(Class<?> classToLog) {
return new SmackLogger(classToLog); return new SmackLogger(classToLog);
} }
@ -53,7 +53,7 @@ public class SmackLogger {
* This is private to make it impossible to instantiate a new SmackLogger outside of the getLogger() static method. * This is private to make it impossible to instantiate a new SmackLogger outside of the getLogger() static method.
* @param classToLog This is the class that wants to log. (This gives commons-logging a means to control log-level by class.) * @param classToLog This is the class that wants to log. (This gives commons-logging a means to control log-level by class.)
*/ */
public SmackLogger(Class classToLog) { public SmackLogger(Class<?> classToLog) {
setupSmackLogger(classToLog); setupSmackLogger(classToLog);
} }
@ -63,9 +63,9 @@ public class SmackLogger {
* @param classToLog * @param classToLog
* @return * @return
*/ */
private void setupSmackLogger(Class classToLog) { private void setupSmackLogger(Class<?> classToLog) {
try { try {
Class logFactoryClass = SmackLogger.class.getClassLoader().loadClass("org.apache.commons.logging.LogFactory"); Class<?> logFactoryClass = SmackLogger.class.getClassLoader().loadClass("org.apache.commons.logging.LogFactory");
Method method = logFactoryClass.getMethod("getLog", Class.class); Method method = logFactoryClass.getMethod("getLog", Class.class);
//Constructor<Log> constructor = Log.class.getConstructor(new Class[] { Object.class }); //Constructor<Log> constructor = Log.class.getConstructor(new Class[] { Object.class });
commonsLogger = (Log) method.invoke(null, classToLog); commonsLogger = (Log) method.invoke(null, classToLog);

View file

@ -310,7 +310,7 @@ public class MediaNegotiator extends JingleNegotiator {
private IQ receiveSessionAcceptAction(Jingle jingle, JingleDescription description) throws JingleException { private IQ receiveSessionAcceptAction(Jingle jingle, JingleDescription description) throws JingleException {
IQ response = null; IQ response = null;
PayloadType.Audio agreedCommonAudioPt; PayloadType.Audio agreedCommonAudioPt;
List offeredPayloads = new ArrayList(); List<PayloadType> offeredPayloads = new ArrayList<PayloadType>();
if (bestCommonAudioPt == null) { if (bestCommonAudioPt == null) {
// Update the best common audio PT // Update the best common audio PT
@ -358,7 +358,7 @@ public class MediaNegotiator extends JingleNegotiator {
// Payload types // Payload types
private PayloadType calculateBestCommonAudioPt(List remoteAudioPts) { private PayloadType calculateBestCommonAudioPt(List<PayloadType> remoteAudioPts) {
final ArrayList<PayloadType> commonAudioPtsHere = new ArrayList<PayloadType>(); final ArrayList<PayloadType> commonAudioPtsHere = new ArrayList<PayloadType>();
final ArrayList<PayloadType> commonAudioPtsThere = new ArrayList<PayloadType>(); final ArrayList<PayloadType> commonAudioPtsThere = new ArrayList<PayloadType>();
PayloadType result = null; PayloadType result = null;

View file

@ -17,6 +17,8 @@ import com.sun.media.util.Registry;
public class JMFInit extends Frame implements Runnable { public class JMFInit extends Frame implements Runnable {
private static final long serialVersionUID = 6476412003260641680L;
private static final SmackLogger LOGGER = SmackLogger.getLogger(JMFInit.class); private static final SmackLogger LOGGER = SmackLogger.getLogger(JMFInit.class);
private String tempDir = "/tmp"; private String tempDir = "/tmp";
@ -89,7 +91,7 @@ public class JMFInit extends Frame implements Runnable {
private void detectCaptureDevices() { private void detectCaptureDevices() {
// check if JavaSound capture is available // check if JavaSound capture is available
message("Looking for Audio capturer"); message("Looking for Audio capturer");
Class dsauto; Class<?> dsauto;
try { try {
dsauto = Class.forName("DirectSoundAuto"); dsauto = Class.forName("DirectSoundAuto");
dsauto.newInstance(); dsauto.newInstance();
@ -102,7 +104,7 @@ public class JMFInit extends Frame implements Runnable {
//Do nothing //Do nothing
} }
Class jsauto; Class<?> jsauto;
try { try {
jsauto = Class.forName("JavaSoundAuto"); jsauto = Class.forName("JavaSoundAuto");
jsauto.newInstance(); jsauto.newInstance();
@ -166,7 +168,7 @@ public class JMFInit extends Frame implements Runnable {
} }
private void detectDirectAudio() { private void detectDirectAudio() {
Class cls; Class<?> cls;
int plType = PlugInManager.RENDERER; int plType = PlugInManager.RENDERER;
String dar = "com.sun.media.renderer.audio.DirectAudioRenderer"; String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
try { try {
@ -190,7 +192,7 @@ public class JMFInit extends Frame implements Runnable {
PlugInManager.addPlugIn(dar, inputFormats, new Format[0], PlugInManager.addPlugIn(dar, inputFormats, new Format[0],
plType); plType);
// Move it to the top of the list // Move it to the top of the list
Vector rendList = PlugInManager.getPlugInList(null, null, Vector<String> rendList = PlugInManager.getPlugInList(null, null,
plType); plType);
int listSize = rendList.size(); int listSize = rendList.size();
if (rendList.elementAt(listSize - 1).equals(dar)) { if (rendList.elementAt(listSize - 1).equals(dar)) {
@ -212,7 +214,7 @@ public class JMFInit extends Frame implements Runnable {
} }
private void detectS8DirectAudio() { private void detectS8DirectAudio() {
Class cls; Class<?> cls;
int plType = PlugInManager.RENDERER; int plType = PlugInManager.RENDERER;
String dar = "com.sun.media.renderer.audio.DirectAudioRenderer"; String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
try { try {
@ -227,7 +229,7 @@ public class JMFInit extends Frame implements Runnable {
if (rend instanceof ExclusiveUse if (rend instanceof ExclusiveUse
&& !((ExclusiveUse) rend).isExclusive()) { && !((ExclusiveUse) rend).isExclusive()) {
// sol8+, DAR supports mixing // sol8+, DAR supports mixing
Vector rendList = PlugInManager.getPlugInList(null, null, Vector<String> rendList = PlugInManager.getPlugInList(null, null,
plType); plType);
int listSize = rendList.size(); int listSize = rendList.size();
boolean found = false; boolean found = false;

View file

@ -43,6 +43,7 @@ import java.util.List;
*/ */
public class Demo extends JFrame { public class Demo extends JFrame {
private static final long serialVersionUID = -6584021277434403855L;
private JingleTransportManager transportManager = null; private JingleTransportManager transportManager = null;
private Connection xmppConnection = null; private Connection xmppConnection = null;
@ -117,6 +118,8 @@ public class Demo extends JFrame {
jPanel.add(jid); jPanel.add(jid);
jPanel.add(new JButton(new AbstractAction("Call") { jPanel.add(new JButton(new AbstractAction("Call") {
private static final long serialVersionUID = 4308448034795312815L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (outgoing != null) return; if (outgoing != null) return;
try { try {
@ -130,6 +133,8 @@ public class Demo extends JFrame {
})); }));
jPanel.add(new JButton(new AbstractAction("Hangup") { jPanel.add(new JButton(new AbstractAction("Hangup") {
private static final long serialVersionUID = -4508007389146723587L;
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (outgoing != null) if (outgoing != null)
try { try {

View file

@ -17,6 +17,7 @@ import java.net.SocketException;
*/ */
public class ImageReceiver extends Canvas { public class ImageReceiver extends Canvas {
private static final long serialVersionUID = -7000112305305269025L;
private boolean on = true; private boolean on = true;
private DatagramSocket socket; private DatagramSocket socket;
private BufferedImage tiles[][]; private BufferedImage tiles[][];

View file

@ -72,13 +72,13 @@ public class OctTreeQuantizer implements Quantizer {
private int reduceColors; private int reduceColors;
private int maximumColors; private int maximumColors;
private int colors = 0; private int colors = 0;
private Vector[] colorList; private Vector<OctTreeNode>[] colorList;
public OctTreeQuantizer() { public OctTreeQuantizer() {
setup(256); setup(256);
colorList = new Vector[MAX_LEVEL+1]; colorList = new Vector[MAX_LEVEL+1];
for (int i = 0; i < MAX_LEVEL+1; i++) for (int i = 0; i < MAX_LEVEL+1; i++)
colorList[i] = new Vector(); colorList[i] = new Vector<OctTreeNode>();
root = new OctTreeNode(); root = new OctTreeNode();
} }
@ -200,10 +200,10 @@ public class OctTreeQuantizer implements Quantizer {
private void reduceTree(int numColors) { private void reduceTree(int numColors) {
for (int level = MAX_LEVEL-1; level >= 0; level--) { for (int level = MAX_LEVEL-1; level >= 0; level--) {
Vector v = colorList[level]; Vector<OctTreeNode> v = colorList[level];
if (v != null && v.size() > 0) { if (v != null && v.size() > 0) {
for (int j = 0; j < v.size(); j++) { for (int j = 0; j < v.size(); j++) {
OctTreeNode node = (OctTreeNode)v.elementAt(j); OctTreeNode node = v.elementAt(j);
if (node.children > 0) { if (node.children > 0) {
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
OctTreeNode child = node.leaf[i]; OctTreeNode child = node.leaf[i];

View file

@ -54,7 +54,7 @@ public class BasicResolver extends TransportResolver {
clearCandidates(); clearCandidates();
Enumeration ifaces = null; Enumeration<NetworkInterface> ifaces = null;
try { try {
ifaces = NetworkInterface.getNetworkInterfaces(); ifaces = NetworkInterface.getNetworkInterfaces();
@ -64,11 +64,11 @@ public class BasicResolver extends TransportResolver {
while (ifaces.hasMoreElements()) { while (ifaces.hasMoreElements()) {
NetworkInterface iface = (NetworkInterface) ifaces.nextElement(); NetworkInterface iface = ifaces.nextElement();
Enumeration iaddresses = iface.getInetAddresses(); Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
while (iaddresses.hasMoreElements()) { while (iaddresses.hasMoreElements()) {
InetAddress iaddress = (InetAddress) iaddresses.nextElement(); InetAddress iaddress = iaddresses.nextElement();
if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress() && !iaddress.isSiteLocalAddress()) { if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress() && !iaddress.isSiteLocalAddress()) {
TransportCandidate tr = new TransportCandidate.Fixed(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName(), getFreePort()); TransportCandidate tr = new TransportCandidate.Fixed(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName(), getFreePort());
tr.setLocalIp(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName()); tr.setLocalIp(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName());
@ -87,11 +87,11 @@ public class BasicResolver extends TransportResolver {
while (ifaces.hasMoreElements()) { while (ifaces.hasMoreElements()) {
NetworkInterface iface = (NetworkInterface) ifaces.nextElement(); NetworkInterface iface = ifaces.nextElement();
Enumeration iaddresses = iface.getInetAddresses(); Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
while (iaddresses.hasMoreElements()) { while (iaddresses.hasMoreElements()) {
InetAddress iaddress = (InetAddress) iaddresses.nextElement(); InetAddress iaddress = iaddresses.nextElement();
if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress()) { if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress()) {
TransportCandidate tr = new TransportCandidate.Fixed(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName(), getFreePort()); TransportCandidate tr = new TransportCandidate.Fixed(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName(), getFreePort());
tr.setLocalIp(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName()); tr.setLocalIp(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName());

View file

@ -114,7 +114,7 @@ public class BridgedResolver extends TransportResolver {
} }
public static String getLocalHost() { public static String getLocalHost() {
Enumeration ifaces = null; Enumeration<NetworkInterface> ifaces = null;
try { try {
ifaces = NetworkInterface.getNetworkInterfaces(); ifaces = NetworkInterface.getNetworkInterfaces();
@ -125,11 +125,11 @@ public class BridgedResolver extends TransportResolver {
while (ifaces.hasMoreElements()) { while (ifaces.hasMoreElements()) {
NetworkInterface iface = (NetworkInterface) ifaces.nextElement(); NetworkInterface iface = ifaces.nextElement();
Enumeration iaddresses = iface.getInetAddresses(); Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
while (iaddresses.hasMoreElements()) { while (iaddresses.hasMoreElements()) {
InetAddress iaddress = (InetAddress) iaddresses.nextElement(); InetAddress iaddress = iaddresses.nextElement();
if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress() && !iaddress.isSiteLocalAddress() && !(iaddress instanceof Inet6Address)) { if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress() && !iaddress.isSiteLocalAddress() && !(iaddress instanceof Inet6Address)) {
return iaddress.getHostAddress(); return iaddress.getHostAddress();
} }

View file

@ -65,7 +65,7 @@ import org.jivesoftware.smackx.jingle.SmackLogger;
* *
* @author Thiago Camargo * @author Thiago Camargo
*/ */
public class ICECandidate extends TransportCandidate implements Comparable { public class ICECandidate extends TransportCandidate implements Comparable<ICECandidate> {
private static final SmackLogger LOGGER = SmackLogger.getLogger(ICECandidate.class); private static final SmackLogger LOGGER = SmackLogger.getLogger(ICECandidate.class);
@ -438,16 +438,12 @@ public class ICECandidate extends TransportCandidate implements Comparable {
* object is less than, equal to, or greater than the specified * object is less than, equal to, or greater than the specified
* object * object
*/ */
public int compareTo(Object arg) { public int compareTo(ICECandidate arg) {
if (arg instanceof ICECandidate) { if (getPreference() < arg.getPreference()) {
ICECandidate tc = (ICECandidate) arg;
if (getPreference() < tc.getPreference()) {
return -1; return -1;
} } else if (getPreference() > arg.getPreference()) {
else if (getPreference() > tc.getPreference()) {
return 1; return 1;
} }
}
return 0; return 0;
} }

View file

@ -136,7 +136,6 @@ public class ICEResolver extends TransportResolver {
i++; i++;
} }
} catch (SocketException e1) { } catch (SocketException e1) {
// TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
@ -225,7 +224,7 @@ public class ICEResolver extends TransportResolver {
if (publicIp != null && !publicIp.equals("")) { if (publicIp != null && !publicIp.equals("")) {
Enumeration ifaces = null; Enumeration<NetworkInterface> ifaces = null;
try { try {
ifaces = NetworkInterface.getNetworkInterfaces(); ifaces = NetworkInterface.getNetworkInterfaces();
@ -240,11 +239,11 @@ public class ICEResolver extends TransportResolver {
while (ifaces.hasMoreElements() && !false) { while (ifaces.hasMoreElements() && !false) {
NetworkInterface iface = (NetworkInterface) ifaces.nextElement(); NetworkInterface iface = ifaces.nextElement();
Enumeration iaddresses = iface.getInetAddresses(); Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
while (iaddresses.hasMoreElements()) { while (iaddresses.hasMoreElements()) {
InetAddress iaddress = (InetAddress) iaddresses.nextElement(); InetAddress iaddress = iaddresses.nextElement();
if (iaddress.getHostAddress().indexOf(publicIp) > -1) { if (iaddress.getHostAddress().indexOf(publicIp) > -1) {
found = true; found = true;
break; break;

View file

@ -442,9 +442,9 @@ public class RTPBridge extends IQ {
// } // }
DiscoverInfo discoInfo = disco.discoverInfo(connection.getServiceName()); DiscoverInfo discoInfo = disco.discoverInfo(connection.getServiceName());
Iterator iter = discoInfo.getIdentities(); Iterator<DiscoverInfo.Identity> iter = discoInfo.getIdentities();
while (iter.hasNext()) { while (iter.hasNext()) {
DiscoverInfo.Identity identity = (DiscoverInfo.Identity) iter.next(); DiscoverInfo.Identity identity = iter.next();
if ((identity.getName() != null) && (identity.getName().startsWith("rtpbridge"))) { if ((identity.getName() != null) && (identity.getName().startsWith("rtpbridge"))) {
return true; return true;
} }
@ -528,7 +528,7 @@ public class RTPBridge extends IQ {
if (response.getIp() == null || response.getIp().equals("")) return null; if (response.getIp() == null || response.getIp().equals("")) return null;
Enumeration ifaces = null; Enumeration<NetworkInterface> ifaces = null;
try { try {
ifaces = NetworkInterface.getNetworkInterfaces(); ifaces = NetworkInterface.getNetworkInterfaces();
} }
@ -537,11 +537,11 @@ public class RTPBridge extends IQ {
} }
while (ifaces!=null&&ifaces.hasMoreElements()) { while (ifaces!=null&&ifaces.hasMoreElements()) {
NetworkInterface iface = (NetworkInterface) ifaces.nextElement(); NetworkInterface iface = ifaces.nextElement();
Enumeration iaddresses = iface.getInetAddresses(); Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
while (iaddresses.hasMoreElements()) { while (iaddresses.hasMoreElements()) {
InetAddress iaddress = (InetAddress) iaddresses.nextElement(); InetAddress iaddress = iaddresses.nextElement();
if (!iaddress.isLoopbackAddress()) if (!iaddress.isLoopbackAddress())
if (iaddress.getHostAddress().indexOf(response.getIp()) >= 0) if (iaddress.getHostAddress().indexOf(response.getIp()) >= 0)
return null; return null;

View file

@ -230,9 +230,9 @@ public class STUN extends IQ {
try { try {
DiscoverItems items = disco.discoverItems(connection.getServiceName()); DiscoverItems items = disco.discoverItems(connection.getServiceName());
Iterator iter = items.getItems(); Iterator<DiscoverItems.Item> iter = items.getItems();
while (iter.hasNext()) { while (iter.hasNext()) {
DiscoverItems.Item item = (DiscoverItems.Item) iter.next(); DiscoverItems.Item item = iter.next();
DiscoverInfo info = disco.discoverInfo(item.getEntityID()); DiscoverInfo info = disco.discoverInfo(item.getEntityID());
Iterator<DiscoverInfo.Identity> iter2 = info.getIdentities(); Iterator<DiscoverInfo.Identity> iter2 = info.getIdentities();

View file

@ -134,8 +134,8 @@ public class STUNResolver extends TransportResolver {
* @param stunConfigStream An InputStream with the configuration file. * @param stunConfigStream An InputStream with the configuration file.
* @return A list of loaded servers * @return A list of loaded servers
*/ */
public ArrayList loadSTUNServers(java.io.InputStream stunConfigStream) { public ArrayList<STUNService> loadSTUNServers(java.io.InputStream stunConfigStream) {
ArrayList serversList = new ArrayList(); ArrayList<STUNService> serversList = new ArrayList<STUNService>();
String serverName; String serverName;
int serverPort; int serverPort;
@ -216,8 +216,8 @@ public class STUNResolver extends TransportResolver {
* *
* @return a list of services * @return a list of services
*/ */
public ArrayList loadSTUNServers() { public ArrayList<STUNService> loadSTUNServers() {
ArrayList serversList = new ArrayList(); ArrayList<STUNService> serversList = new ArrayList<STUNService>();
// Load the STUN configuration // Load the STUN configuration
try { try {
@ -228,11 +228,11 @@ public class STUNResolver extends TransportResolver {
classLoaders[1] = Thread.currentThread().getContextClassLoader(); classLoaders[1] = Thread.currentThread().getContextClassLoader();
for (int i = 0; i < classLoaders.length; i++) { for (int i = 0; i < classLoaders.length; i++) {
Enumeration stunConfigEnum = classLoaders[i] Enumeration<URL> stunConfigEnum = classLoaders[i]
.getResources(STUNSERVERS_FILENAME); .getResources(STUNSERVERS_FILENAME);
while (stunConfigEnum.hasMoreElements() && serversList.isEmpty()) { while (stunConfigEnum.hasMoreElements() && serversList.isEmpty()) {
URL url = (URL) stunConfigEnum.nextElement(); URL url = stunConfigEnum.nextElement();
java.io.InputStream stunConfigStream = null; java.io.InputStream stunConfigStream = null;
stunConfigStream = url.openStream(); stunConfigStream = url.openStream();
@ -253,12 +253,12 @@ public class STUNResolver extends TransportResolver {
* *
* @return the best STUN server that can be used. * @return the best STUN server that can be used.
*/ */
private STUNService bestSTUNServer(ArrayList listServers) { private STUNService bestSTUNServer(ArrayList<STUNService> listServers) {
if (listServers.isEmpty()) { if (listServers.isEmpty()) {
return null; return null;
} else { } else {
// TODO: this should use some more advanced criteria... // TODO: this should use some more advanced criteria...
return (STUNService) listServers.get(0); return listServers.get(0);
} }
} }
@ -305,19 +305,17 @@ public class STUNResolver extends TransportResolver {
// Iterate through the list of interfaces, and ask // Iterate through the list of interfaces, and ask
// to the STUN server for our address. // to the STUN server for our address.
try { try {
Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
String candAddress; String candAddress;
int candPort; int candPort;
while (ifaces.hasMoreElements()) { while (ifaces.hasMoreElements()) {
NetworkInterface iface = (NetworkInterface) ifaces NetworkInterface iface = ifaces.nextElement();
.nextElement(); Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
Enumeration iaddresses = iface.getInetAddresses();
while (iaddresses.hasMoreElements()) { while (iaddresses.hasMoreElements()) {
InetAddress iaddress = (InetAddress) iaddresses InetAddress iaddress = iaddresses.nextElement();
.nextElement();
if (!iaddress.isLoopbackAddress() if (!iaddress.isLoopbackAddress()
&& !iaddress.isLinkLocalAddress()) { && !iaddress.isLinkLocalAddress()) {

View file

@ -66,6 +66,7 @@ import java.util.List;
import org.jivesoftware.smack.Connection; import org.jivesoftware.smack.Connection;
import org.jivesoftware.smackx.jingle.JingleSession; import org.jivesoftware.smackx.jingle.JingleSession;
import org.jivesoftware.smackx.jingle.SmackLogger; import org.jivesoftware.smackx.jingle.SmackLogger;
import org.jivesoftware.smackx.jingle.nat.TransportResolverListener.Checker;
/** /**
* Transport candidate. * Transport candidate.
@ -103,7 +104,7 @@ public abstract class TransportCandidate {
private Thread echoThread = null; private Thread echoThread = null;
// Listeners for events // Listeners for events
private final List<TransportResolverListener.Checker> listeners = new ArrayList(); private final List<TransportResolverListener.Checker> listeners = new ArrayList<Checker>();
public void addCandidateEcho(JingleSession session) throws SocketException, UnknownHostException { public void addCandidateEcho(JingleSession session) throws SocketException, UnknownHostException {
candidateEcho = new CandidateEcho(this, session); candidateEcho = new CandidateEcho(this, session);
@ -387,9 +388,9 @@ public abstract class TransportCandidate {
public void run() { public void run() {
boolean isUsable; boolean isUsable;
InetAddress candAddress;
try { try {
candAddress = InetAddress.getByName(getIp()); InetAddress candAddress = InetAddress.getByName(getIp());
isUsable = true;//candAddress.isReachable(TransportResolver.CHECK_TIMEOUT); isUsable = true;//candAddress.isReachable(TransportResolver.CHECK_TIMEOUT);
} }
catch (Exception e) { catch (Exception e) {
@ -425,7 +426,7 @@ public abstract class TransportCandidate {
*/ */
public List<TransportResolverListener.Checker> getListenersList() { public List<TransportResolverListener.Checker> getListenersList() {
synchronized (listeners) { synchronized (listeners) {
return new ArrayList(listeners); return new ArrayList<Checker>(listeners);
} }
} }

View file

@ -449,9 +449,9 @@ public abstract class TransportNegotiator extends JingleNegotiator {
* *
* @return The list of valid (ie, already checked) remote candidates. * @return The list of valid (ie, already checked) remote candidates.
*/ */
final ArrayList getValidRemoteCandidatesList() { final ArrayList<TransportCandidate> getValidRemoteCandidatesList() {
synchronized (validRemoteCandidates) { synchronized (validRemoteCandidates) {
return new ArrayList(validRemoteCandidates); return new ArrayList<TransportCandidate>(validRemoteCandidates);
} }
} }
@ -461,7 +461,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
* @return The iterator for the list of valid (ie, already checked) remote * @return The iterator for the list of valid (ie, already checked) remote
* candidates. * candidates.
*/ */
public final Iterator getValidRemoteCandidates() { public final Iterator<TransportCandidate> getValidRemoteCandidates() {
return Collections.unmodifiableList(getRemoteCandidates()).iterator(); return Collections.unmodifiableList(getRemoteCandidates()).iterator();
} }
@ -471,11 +471,11 @@ public abstract class TransportNegotiator extends JingleNegotiator {
* *
* @param rc the remote candidate to add. * @param rc the remote candidate to add.
*/ */
private void addRemoteCandidates(List rc) { private void addRemoteCandidates(List<TransportCandidate> rc) {
if (rc != null) { if (rc != null) {
if (rc.size() > 0) { if (rc.size() > 0) {
for (Object aRc : rc) { for (TransportCandidate aRc : rc) {
addRemoteCandidate((TransportCandidate) aRc); addRemoteCandidate(aRc);
} }
} }
} }
@ -829,7 +829,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
*/ */
public TransportCandidate getBestRemoteCandidate() { public TransportCandidate getBestRemoteCandidate() {
// Hopefully, we only have one validRemoteCandidate // Hopefully, we only have one validRemoteCandidate
ArrayList cands = getValidRemoteCandidatesList(); ArrayList<TransportCandidate> cands = getValidRemoteCandidatesList();
if (!cands.isEmpty()) { if (!cands.isEmpty()) {
LOGGER.debug("RAW CAND"); LOGGER.debug("RAW CAND");
return (TransportCandidate) cands.get(0); return (TransportCandidate) cands.get(0);
@ -883,14 +883,17 @@ public abstract class TransportNegotiator extends JingleNegotiator {
public TransportCandidate getBestRemoteCandidate() { public TransportCandidate getBestRemoteCandidate() {
ICECandidate result = null; ICECandidate result = null;
ArrayList<ICECandidate> cands = getValidRemoteCandidatesList(); ArrayList<TransportCandidate> cands = getValidRemoteCandidatesList();
if (!cands.isEmpty()) { if (!cands.isEmpty()) {
int highest = -1; int highest = -1;
ICECandidate chose = null; ICECandidate chose = null;
for (ICECandidate transportCandidate : cands) { for (TransportCandidate transportCandidate : cands) {
if (transportCandidate.getPreference() > highest) { if (transportCandidate instanceof ICECandidate) {
chose = transportCandidate; ICECandidate icecandidate = (ICECandidate) transportCandidate;
highest = transportCandidate.getPreference(); if (icecandidate.getPreference() > highest) {
chose = icecandidate;
highest = icecandidate.getPreference();
}
} }
} }
result = chose; result = chose;

View file

@ -233,9 +233,9 @@ public abstract class TransportResolver {
* *
* @return the list of listeners * @return the list of listeners
*/ */
public ArrayList getListenersList() { public ArrayList<TransportResolverListener> getListenersList() {
synchronized (listeners) { synchronized (listeners) {
return new ArrayList(listeners); return new ArrayList<TransportResolverListener>(listeners);
} }
} }
@ -245,9 +245,9 @@ public abstract class TransportResolver {
* @param cand The candidate added to the list of candidates. * @param cand The candidate added to the list of candidates.
*/ */
protected void triggerCandidateAdded(TransportCandidate cand) { protected void triggerCandidateAdded(TransportCandidate cand) {
Iterator iter = getListenersList().iterator(); Iterator<TransportResolverListener> iter = getListenersList().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
TransportResolverListener trl = (TransportResolverListener) iter.next(); TransportResolverListener trl = iter.next();
if (trl instanceof TransportResolverListener.Resolver) { if (trl instanceof TransportResolverListener.Resolver) {
TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl; TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl;
LOGGER.debug("triggerCandidateAdded : " + cand.getLocalIp()); LOGGER.debug("triggerCandidateAdded : " + cand.getLocalIp());
@ -260,9 +260,9 @@ public abstract class TransportResolver {
* Trigger a event notifying the initialization of the resolution process. * Trigger a event notifying the initialization of the resolution process.
*/ */
private void triggerResolveInit() { private void triggerResolveInit() {
Iterator iter = getListenersList().iterator(); Iterator<TransportResolverListener> iter = getListenersList().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
TransportResolverListener trl = (TransportResolverListener) iter.next(); TransportResolverListener trl = iter.next();
if (trl instanceof TransportResolverListener.Resolver) { if (trl instanceof TransportResolverListener.Resolver) {
TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl; TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl;
li.init(); li.init();
@ -274,9 +274,9 @@ public abstract class TransportResolver {
* Trigger a event notifying the obtention of all the candidates. * Trigger a event notifying the obtention of all the candidates.
*/ */
private void triggerResolveEnd() { private void triggerResolveEnd() {
Iterator iter = getListenersList().iterator(); Iterator<TransportResolverListener> iter = getListenersList().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
TransportResolverListener trl = (TransportResolverListener) iter.next(); TransportResolverListener trl = iter.next();
if (trl instanceof TransportResolverListener.Resolver) { if (trl instanceof TransportResolverListener.Resolver) {
TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl; TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl;
li.end(); li.end();
@ -315,9 +315,9 @@ public abstract class TransportResolver {
* *
* @return an iterator * @return an iterator
*/ */
public Iterator getCandidates() { public Iterator<TransportCandidate> getCandidates() {
synchronized (candidates) { synchronized (candidates) {
return Collections.unmodifiableList(new ArrayList(candidates)).iterator(); return Collections.unmodifiableList(new ArrayList<TransportCandidate>(candidates)).iterator();
} }
} }
@ -329,7 +329,13 @@ public abstract class TransportResolver {
public TransportCandidate getPreferredCandidate() { public TransportCandidate getPreferredCandidate() {
TransportCandidate result = null; TransportCandidate result = null;
ArrayList cands = (ArrayList) getCandidatesList(); ArrayList<ICECandidate> cands = new ArrayList<ICECandidate>();
for (TransportCandidate tpcan : getCandidatesList()) {
if (tpcan instanceof ICECandidate)
cands.add((ICECandidate) tpcan);
}
// (ArrayList<ICECandidate>) getCandidatesList();
if (cands.size() > 0) { if (cands.size() > 0) {
Collections.sort(cands); Collections.sort(cands);
// Return the last candidate // Return the last candidate

View file

@ -218,7 +218,7 @@ public class Jingle extends IQ {
*/ */
public Iterator<JingleContent> getContents() { public Iterator<JingleContent> getContents() {
synchronized (contents) { synchronized (contents) {
return Collections.unmodifiableList(new ArrayList(contents)).iterator(); return Collections.unmodifiableList(new ArrayList<JingleContent>(contents)).iterator();
} }
} }

View file

@ -40,7 +40,7 @@ public abstract class JingleContentDescription implements PacketExtension {
// non-static // non-static
private final List payloads = new ArrayList(); private final List<JinglePayloadType> payloads = new ArrayList<JinglePayloadType>();
/** /**
* Creates a content description.. * Creates a content description..
@ -81,11 +81,11 @@ public abstract class JingleContentDescription implements PacketExtension {
* *
* @param pts the payloads to add. * @param pts the payloads to add.
*/ */
public void addAudioPayloadTypes(final List pts) { public void addAudioPayloadTypes(final List<PayloadType.Audio> pts) {
synchronized (payloads) { synchronized (payloads) {
Iterator ptIter = pts.iterator(); Iterator<PayloadType.Audio> ptIter = pts.iterator();
while (ptIter.hasNext()) { while (ptIter.hasNext()) {
PayloadType.Audio pt = (PayloadType.Audio) ptIter.next(); PayloadType.Audio pt = ptIter.next();
addJinglePayloadType(new JinglePayloadType.Audio(pt)); addJinglePayloadType(new JinglePayloadType.Audio(pt));
} }
} }
@ -96,7 +96,7 @@ public abstract class JingleContentDescription implements PacketExtension {
* *
* @return an Iterator for the audio payloads in the packet. * @return an Iterator for the audio payloads in the packet.
*/ */
public Iterator getJinglePayloadTypes() { public Iterator<JinglePayloadType> getJinglePayloadTypes() {
return Collections.unmodifiableList(getJinglePayloadTypesList()).iterator(); return Collections.unmodifiableList(getJinglePayloadTypesList()).iterator();
} }
@ -105,9 +105,9 @@ public abstract class JingleContentDescription implements PacketExtension {
* *
* @return a list for the audio payloads in the packet. * @return a list for the audio payloads in the packet.
*/ */
public ArrayList getJinglePayloadTypesList() { public ArrayList<JinglePayloadType> getJinglePayloadTypesList() {
synchronized (payloads) { synchronized (payloads) {
return new ArrayList(payloads); return new ArrayList<JinglePayloadType>(payloads);
} }
} }
@ -116,15 +116,15 @@ public abstract class JingleContentDescription implements PacketExtension {
* *
* @return a list of PayloadType.Audio * @return a list of PayloadType.Audio
*/ */
public ArrayList getAudioPayloadTypesList() { public ArrayList<PayloadType.Audio> getAudioPayloadTypesList() {
ArrayList result = new ArrayList(); ArrayList<PayloadType.Audio> result = new ArrayList<PayloadType.Audio>();
Iterator jinglePtsIter = getJinglePayloadTypes(); Iterator<JinglePayloadType> jinglePtsIter = getJinglePayloadTypes();
while (jinglePtsIter.hasNext()) { while (jinglePtsIter.hasNext()) {
JinglePayloadType jpt = (JinglePayloadType) jinglePtsIter.next(); JinglePayloadType jpt = jinglePtsIter.next();
if (jpt instanceof JinglePayloadType.Audio) { if (jpt instanceof JinglePayloadType.Audio) {
JinglePayloadType.Audio jpta = (JinglePayloadType.Audio) jpt; JinglePayloadType.Audio jpta = (JinglePayloadType.Audio) jpt;
result.add(jpta.getPayloadType()); result.add((PayloadType.Audio)jpta.getPayloadType());
} }
} }
@ -155,9 +155,9 @@ public abstract class JingleContentDescription implements PacketExtension {
buf.append("<").append(getElementName()); buf.append("<").append(getElementName());
buf.append(" xmlns=\"").append(getNamespace()).append("\" >"); buf.append(" xmlns=\"").append(getNamespace()).append("\" >");
Iterator pt = payloads.listIterator(); Iterator<JinglePayloadType> pt = payloads.listIterator();
while (pt.hasNext()) { while (pt.hasNext()) {
JinglePayloadType pte = (JinglePayloadType) pt.next(); JinglePayloadType pte = pt.next();
buf.append(pte.toXML()); buf.append(pte.toXML());
} }
buf.append("</").append(getElementName()).append(">"); buf.append("</").append(getElementName()).append(">");

View file

@ -90,7 +90,7 @@ public abstract class JingleDescription implements PacketExtension {
*/ */
public void addAudioPayloadTypes(final List<PayloadType> pts) { public void addAudioPayloadTypes(final List<PayloadType> pts) {
synchronized (payloads) { synchronized (payloads) {
Iterator ptIter = pts.iterator(); Iterator<PayloadType> ptIter = pts.iterator();
while (ptIter.hasNext()) { while (ptIter.hasNext()) {
PayloadType.Audio pt = (PayloadType.Audio) ptIter.next(); PayloadType.Audio pt = (PayloadType.Audio) ptIter.next();
addPayloadType(new PayloadType.Audio(pt)); addPayloadType(new PayloadType.Audio(pt));

View file

@ -95,7 +95,7 @@ public class JingleTransport implements PacketExtension {
* *
* @return an iterator * @return an iterator
*/ */
public Iterator getCandidates() { public Iterator<JingleTransportCandidate> getCandidates() {
return Collections.unmodifiableList(getCandidatesList()).iterator(); return Collections.unmodifiableList(getCandidatesList()).iterator();
} }
@ -160,11 +160,10 @@ public class JingleTransport implements PacketExtension {
synchronized (candidates) { synchronized (candidates) {
if (getCandidatesCount() > 0) { if (getCandidatesCount() > 0) {
buf.append(">"); buf.append(">");
Iterator iter = getCandidates(); Iterator<JingleTransportCandidate> iter = getCandidates();
while (iter.hasNext()) { while (iter.hasNext()) {
JingleTransportCandidate candidate = (JingleTransportCandidate) iter JingleTransportCandidate candidate = iter.next();
.next();
buf.append(candidate.toXML()); buf.append(candidate.toXML());
} }
buf.append("</").append(getElementName()).append(">"); buf.append("</").append(getElementName()).append(">");

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import org.jivesoftware.smack.test.SmackTestCase; import org.jivesoftware.smack.test.SmackTestCase;
import org.jivesoftware.smackx.jingle.media.PayloadType; import org.jivesoftware.smackx.jingle.media.PayloadType;
import org.jivesoftware.smackx.jingle.media.PayloadType.Audio;
public class PayloadTypeTest extends SmackTestCase { public class PayloadTypeTest extends SmackTestCase {
@ -21,8 +22,8 @@ public class PayloadTypeTest extends SmackTestCase {
* Test for the difference of payloads. * Test for the difference of payloads.
*/ */
public void testDifference() { public void testDifference() {
ArrayList set1 = new ArrayList(); ArrayList<Audio> set1 = new ArrayList<Audio>();
ArrayList set2 = new ArrayList(); ArrayList<Audio> set2 = new ArrayList<Audio>();
PayloadType.Audio common1 = new PayloadType.Audio(34, "supercodec-1", 2, 14000); PayloadType.Audio common1 = new PayloadType.Audio(34, "supercodec-1", 2, 14000);
PayloadType.Audio common2 = new PayloadType.Audio(56, "supercodec-2", 1, 44000); PayloadType.Audio common2 = new PayloadType.Audio(56, "supercodec-2", 1, 44000);
@ -38,7 +39,7 @@ public class PayloadTypeTest extends SmackTestCase {
set2.add(common1); set2.add(common1);
// Get the difference // Get the difference
ArrayList commonSet = new ArrayList(); ArrayList<Audio> commonSet = new ArrayList<Audio>();
commonSet.addAll(set1); commonSet.addAll(set1);
commonSet.retainAll(set2); commonSet.retainAll(set2);
@ -54,8 +55,8 @@ public class PayloadTypeTest extends SmackTestCase {
* Test for the difference of payloads when we are handling the same sets. * Test for the difference of payloads when we are handling the same sets.
*/ */
public void testDifferenceSameSet() { public void testDifferenceSameSet() {
ArrayList set1 = new ArrayList(); ArrayList<Audio> set1 = new ArrayList<Audio>();
ArrayList set2 = new ArrayList(); ArrayList<Audio> set2 = new ArrayList<Audio>();
PayloadType.Audio common1 = new PayloadType.Audio(34, "supercodec-1", 2, 14000); PayloadType.Audio common1 = new PayloadType.Audio(34, "supercodec-1", 2, 14000);
PayloadType.Audio common2 = new PayloadType.Audio(56, "supercodec-2", 1, 44000); PayloadType.Audio common2 = new PayloadType.Audio(56, "supercodec-2", 1, 44000);
@ -73,7 +74,7 @@ public class PayloadTypeTest extends SmackTestCase {
set2.add(common4); set2.add(common4);
// Get the difference // Get the difference
ArrayList commonSet = new ArrayList(); ArrayList<Audio> commonSet = new ArrayList<Audio>();
commonSet.addAll(set1); commonSet.addAll(set1);
commonSet.retainAll(set2); commonSet.retainAll(set2);

View file

@ -1,5 +1,6 @@
package org.jivesoftware.smackx.jingle.nat; package org.jivesoftware.smackx.jingle.nat;
import de.javawi.jstun.test.demo.StunServer;
import de.javawi.jstun.test.demo.ice.Candidate; import de.javawi.jstun.test.demo.ice.Candidate;
import de.javawi.jstun.test.demo.ice.ICENegociator; import de.javawi.jstun.test.demo.ice.ICENegociator;
import de.javawi.jstun.util.UtilityException; import de.javawi.jstun.util.UtilityException;
@ -13,6 +14,7 @@ import org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener;
import org.jivesoftware.smackx.jingle.media.JingleMediaManager; import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
import org.jivesoftware.smackx.jingle.media.PayloadType; import org.jivesoftware.smackx.jingle.media.PayloadType;
import org.jivesoftware.smackx.jingle.mediaimpl.test.TestMediaManager; import org.jivesoftware.smackx.jingle.mediaimpl.test.TestMediaManager;
import org.jivesoftware.smackx.jingle.nat.STUNResolver.STUNService;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.net.SocketException; import java.net.SocketException;
@ -182,7 +184,7 @@ public class STUNResolverTest extends SmackTestCase {
public void testLoadSTUNServers() throws Exception { public void testLoadSTUNServers() throws Exception {
STUNResolver stunResolver = new STUNResolver() { STUNResolver stunResolver = new STUNResolver() {
}; };
ArrayList stunServers = stunResolver.loadSTUNServers(); ArrayList<STUNService> stunServers = stunResolver.loadSTUNServers();
assertTrue(stunServers.size() > 0); assertTrue(stunServers.size() > 0);
System.out.println(stunServers.size() + " servers loaded"); System.out.println(stunServers.size() + " servers loaded");
@ -244,8 +246,8 @@ public class STUNResolverTest extends SmackTestCase {
* *
* @return A testing list * @return A testing list
*/ */
private ArrayList getTestPayloads1() { private ArrayList<PayloadType> getTestPayloads1() {
ArrayList result = new ArrayList(); ArrayList<PayloadType> result = new ArrayList<PayloadType>();
result.add(new PayloadType.Audio(34, "supercodec-1", 2, 14000)); result.add(new PayloadType.Audio(34, "supercodec-1", 2, 14000));
result.add(new PayloadType.Audio(56, "supercodec-2", 1, 44000)); result.add(new PayloadType.Audio(56, "supercodec-2", 1, 44000));
@ -255,8 +257,8 @@ public class STUNResolverTest extends SmackTestCase {
return result; return result;
} }
private ArrayList getTestPayloads2() { private ArrayList<PayloadType> getTestPayloads2() {
ArrayList result = new ArrayList(); ArrayList<PayloadType> result = new ArrayList<PayloadType>();
result.add(new PayloadType.Audio(27, "supercodec-3", 2, 28000)); result.add(new PayloadType.Audio(27, "supercodec-3", 2, 28000));
result.add(new PayloadType.Audio(56, "supercodec-2", 1, 44000)); result.add(new PayloadType.Audio(56, "supercodec-2", 1, 44000));

View file

@ -2,9 +2,6 @@ package org.jivesoftware.smackx.jingle.nat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.net.InetAddress;
import org.jivesoftware.smack.test.SmackTestCase; import org.jivesoftware.smack.test.SmackTestCase;
@ -35,18 +32,18 @@ public class TransportCandidateTest extends SmackTestCase {
public void testCompareTo() { public void testCompareTo() {
int highestPref = 100; int highestPref = 100;
TransportCandidate cand1 = new ICECandidate("192.168.2.1", 3, 2, ICECandidate cand1 = new ICECandidate("192.168.2.1", 3, 2,
"password", 3468, "username", 1, ICECandidate.Type.prflx); "password", 3468, "username", 1, ICECandidate.Type.prflx);
TransportCandidate cand2 = new ICECandidate("192.168.5.1", 2, 10, ICECandidate cand2 = new ICECandidate("192.168.5.1", 2, 10,
"password", 3469, "username", 15,ICECandidate.Type.prflx); "password", 3469, "username", 15,ICECandidate.Type.prflx);
TransportCandidate candH = new ICECandidate("192.168.2.1", 1, 2, ICECandidate candH = new ICECandidate("192.168.2.1", 1, 2,
"password", 3468, "username", highestPref, ICECandidate.Type.prflx); "password", 3468, "username", highestPref, ICECandidate.Type.prflx);
TransportCandidate cand3 = new ICECandidate("192.168.2.10", 2, 10, ICECandidate cand3 = new ICECandidate("192.168.2.10", 2, 10,
"password", 3469, "username", 2, ICECandidate.Type.prflx); "password", 3469, "username", 2, ICECandidate.Type.prflx);
TransportCandidate cand4 = new ICECandidate("192.168.4.1", 3, 2, ICECandidate cand4 = new ICECandidate("192.168.4.1", 3, 2,
"password", 3468, "username", 78, ICECandidate.Type.prflx); "password", 3468, "username", 78, ICECandidate.Type.prflx);
ArrayList candList = new ArrayList(); ArrayList<ICECandidate> candList = new ArrayList<ICECandidate>();
candList.add(cand1); candList.add(cand1);
candList.add(cand2); candList.add(cand2);
candList.add(candH); candList.add(candH);

View file

@ -63,7 +63,7 @@ import java.util.*;
*/ */
public class SASLAuthentication implements UserAuthentication { public class SASLAuthentication implements UserAuthentication {
private static Map<String, Class> implementedMechanisms = new HashMap<String, Class>(); private static Map<String, Class<? extends SASLMechanism>> implementedMechanisms = new HashMap<String, Class<? extends SASLMechanism>>();
private static List<String> mechanismsPreferences = new ArrayList<String>(); private static List<String> mechanismsPreferences = new ArrayList<String>();
private Connection connection; private Connection connection;
@ -109,7 +109,7 @@ public class SASLAuthentication implements UserAuthentication {
* @param name common name of the SASL mechanism. E.g.: PLAIN, DIGEST-MD5 or KERBEROS_V4. * @param name common name of the SASL mechanism. E.g.: PLAIN, DIGEST-MD5 or KERBEROS_V4.
* @param mClass a SASLMechanism subclass. * @param mClass a SASLMechanism subclass.
*/ */
public static void registerSASLMechanism(String name, Class mClass) { public static void registerSASLMechanism(String name, Class<? extends SASLMechanism> mClass) {
implementedMechanisms.put(name, mClass); implementedMechanisms.put(name, mClass);
} }
@ -167,8 +167,8 @@ public class SASLAuthentication implements UserAuthentication {
* *
* @return the registerd SASLMechanism classes sorted by the level of preference. * @return the registerd SASLMechanism classes sorted by the level of preference.
*/ */
public static List<Class> getRegisterSASLMechanisms() { public static List<Class<? extends SASLMechanism>> getRegisterSASLMechanisms() {
List<Class> answer = new ArrayList<Class>(); List<Class<? extends SASLMechanism>> answer = new ArrayList<Class<? extends SASLMechanism>>();
for (String mechanismsPreference : mechanismsPreferences) { for (String mechanismsPreference : mechanismsPreferences) {
answer.add(implementedMechanisms.get(mechanismsPreference)); answer.add(implementedMechanisms.get(mechanismsPreference));
} }
@ -228,9 +228,9 @@ public class SASLAuthentication implements UserAuthentication {
// A SASL mechanism was found. Authenticate using the selected mechanism and then // A SASL mechanism was found. Authenticate using the selected mechanism and then
// proceed to bind a resource // proceed to bind a resource
try { try {
Class mechanismClass = implementedMechanisms.get(selectedMechanism); Class<? extends SASLMechanism> mechanismClass = implementedMechanisms.get(selectedMechanism);
Constructor constructor = mechanismClass.getConstructor(SASLAuthentication.class); Constructor<? extends SASLMechanism> constructor = mechanismClass.getConstructor(SASLAuthentication.class);
currentMechanism = (SASLMechanism) constructor.newInstance(this); currentMechanism = constructor.newInstance(this);
// Trigger SASL authentication with the selected mechanism. We use // Trigger SASL authentication with the selected mechanism. We use
// connection.getHost() since GSAPI requires the FQDN of the server, which // connection.getHost() since GSAPI requires the FQDN of the server, which
// may not match the XMPP domain. // may not match the XMPP domain.
@ -310,9 +310,9 @@ public class SASLAuthentication implements UserAuthentication {
// A SASL mechanism was found. Authenticate using the selected mechanism and then // A SASL mechanism was found. Authenticate using the selected mechanism and then
// proceed to bind a resource // proceed to bind a resource
try { try {
Class mechanismClass = implementedMechanisms.get(selectedMechanism); Class<? extends SASLMechanism> mechanismClass = implementedMechanisms.get(selectedMechanism);
Constructor constructor = mechanismClass.getConstructor(SASLAuthentication.class); Constructor<? extends SASLMechanism> constructor = mechanismClass.getConstructor(SASLAuthentication.class);
currentMechanism = (SASLMechanism) constructor.newInstance(this); currentMechanism = constructor.newInstance(this);
// Trigger SASL authentication with the selected mechanism. We use // Trigger SASL authentication with the selected mechanism. We use
// connection.getHost() since GSAPI requires the FQDN of the server, which // connection.getHost() since GSAPI requires the FQDN of the server, which
// may not match the XMPP domain. // may not match the XMPP domain.

View file

@ -69,9 +69,9 @@ public final class SmackConfiguration {
// Get an array of class loaders to try loading the providers files from. // Get an array of class loaders to try loading the providers files from.
ClassLoader[] classLoaders = getClassLoaders(); ClassLoader[] classLoaders = getClassLoaders();
for (ClassLoader classLoader : classLoaders) { for (ClassLoader classLoader : classLoaders) {
Enumeration configEnum = classLoader.getResources("META-INF/smack-config.xml"); Enumeration<URL> configEnum = classLoader.getResources("META-INF/smack-config.xml");
while (configEnum.hasMoreElements()) { while (configEnum.hasMoreElements()) {
URL url = (URL) configEnum.nextElement(); URL url = configEnum.nextElement();
InputStream systemStream = null; InputStream systemStream = null;
try { try {
systemStream = url.openStream(); systemStream = url.openStream();

View file

@ -743,7 +743,7 @@ public class XMPPConnection extends Connection {
} }
else if(config.getKeystoreType().equals("PKCS11")) { else if(config.getKeystoreType().equals("PKCS11")) {
try { try {
Constructor c = Class.forName("sun.security.pkcs11.SunPKCS11").getConstructor(InputStream.class); Constructor<?> c = Class.forName("sun.security.pkcs11.SunPKCS11").getConstructor(InputStream.class);
String pkcs11Config = "name = SmartCard\nlibrary = "+config.getPKCS11Library(); String pkcs11Config = "name = SmartCard\nlibrary = "+config.getPKCS11Library();
ByteArrayInputStream config = new ByteArrayInputStream(pkcs11Config.getBytes()); ByteArrayInputStream config = new ByteArrayInputStream(pkcs11Config.getBytes());
Provider p = (Provider)c.newInstance(config); Provider p = (Provider)c.newInstance(config);

View file

@ -35,7 +35,7 @@ import org.jivesoftware.smack.packet.Packet;
*/ */
public class PacketTypeFilter implements PacketFilter { public class PacketTypeFilter implements PacketFilter {
Class packetType; Class<? extends Packet> packetType;
/** /**
* Creates a new packet type filter that will filter for packets that are the * Creates a new packet type filter that will filter for packets that are the
@ -43,7 +43,7 @@ public class PacketTypeFilter implements PacketFilter {
* *
* @param packetType the Class type. * @param packetType the Class type.
*/ */
public PacketTypeFilter(Class packetType) { public PacketTypeFilter(Class<? extends Packet> packetType) {
// Ensure the packet type is a sub-class of Packet. // Ensure the packet type is a sub-class of Packet.
if (!Packet.class.isAssignableFrom(packetType)) { if (!Packet.class.isAssignableFrom(packetType)) {
throw new IllegalArgumentException("Packet type must be a sub-class of Packet."); throw new IllegalArgumentException("Packet type must be a sub-class of Packet.");

View file

@ -58,7 +58,7 @@ public class Privacy extends IQ {
* @param listItem the {@link PrivacyItem} that rules the list. * @param listItem the {@link PrivacyItem} that rules the list.
* @return the privacy List. * @return the privacy List.
*/ */
public List setPrivacyList(String listName, List<PrivacyItem> listItem) { public List<PrivacyItem> setPrivacyList(String listName, List<PrivacyItem> listItem) {
// Add new list to the itemLists // Add new list to the itemLists
this.getItemLists().put(listName, listItem); this.getItemLists().put(listName, listItem);
return listItem; return listItem;

View file

@ -157,10 +157,10 @@ public class ProviderManager {
// Get an array of class loaders to try loading the providers files from. // Get an array of class loaders to try loading the providers files from.
ClassLoader[] classLoaders = getClassLoaders(); ClassLoader[] classLoaders = getClassLoaders();
for (ClassLoader classLoader : classLoaders) { for (ClassLoader classLoader : classLoaders) {
Enumeration providerEnum = classLoader.getResources( Enumeration<URL> providerEnum = classLoader.getResources(
"META-INF/smack.providers"); "META-INF/smack.providers");
while (providerEnum.hasMoreElements()) { while (providerEnum.hasMoreElements()) {
URL url = (URL) providerEnum.nextElement(); URL url = providerEnum.nextElement();
InputStream providerStream = null; InputStream providerStream = null;
try { try {
providerStream = url.openStream(); providerStream = url.openStream();
@ -190,7 +190,7 @@ public class ProviderManager {
// reflection later to create instances of the class. // reflection later to create instances of the class.
try { try {
// Add the provider to the map. // Add the provider to the map.
Class provider = Class.forName(className); Class<?> provider = Class.forName(className);
if (IQProvider.class.isAssignableFrom(provider)) { if (IQProvider.class.isAssignableFrom(provider)) {
iqProviders.put(key, provider.newInstance()); iqProviders.put(key, provider.newInstance());
} }
@ -224,7 +224,7 @@ public class ProviderManager {
// of the class. // of the class.
try { try {
// Add the provider to the map. // Add the provider to the map.
Class provider = Class.forName(className); Class<?> provider = Class.forName(className);
if (PacketExtensionProvider.class.isAssignableFrom( if (PacketExtensionProvider.class.isAssignableFrom(
provider)) { provider)) {
extensionProviders.put(key, provider.newInstance()); extensionProviders.put(key, provider.newInstance());
@ -309,7 +309,7 @@ public class ProviderManager {
Object provider) Object provider)
{ {
if (!(provider instanceof IQProvider || (provider instanceof Class && if (!(provider instanceof IQProvider || (provider instanceof Class &&
IQ.class.isAssignableFrom((Class)provider)))) IQ.class.isAssignableFrom((Class<?>)provider))))
{ {
throw new IllegalArgumentException("Provider must be an IQProvider " + throw new IllegalArgumentException("Provider must be an IQProvider " +
"or a Class instance."); "or a Class instance.");

View file

@ -26,7 +26,6 @@ import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import javax.security.sasl.Sasl; import javax.security.sasl.Sasl;
import javax.security.sasl.SaslClient;
import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.CallbackHandler;
/** /**
@ -61,7 +60,7 @@ public class SASLGSSAPIMechanism extends SASLMechanism {
*/ */
public void authenticate(String username, String host, CallbackHandler cbh) throws IOException, XMPPException { public void authenticate(String username, String host, CallbackHandler cbh) throws IOException, XMPPException {
String[] mechanisms = { getName() }; String[] mechanisms = { getName() };
Map props = new HashMap(); Map<String,String> props = new HashMap<String,String>();
props.put(Sasl.SERVER_AUTH,"TRUE"); props.put(Sasl.SERVER_AUTH,"TRUE");
sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, cbh); sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, cbh);
authenticate(); authenticate();
@ -80,7 +79,7 @@ public class SASLGSSAPIMechanism extends SASLMechanism {
*/ */
public void authenticate(String username, String host, String password) throws IOException, XMPPException { public void authenticate(String username, String host, String password) throws IOException, XMPPException {
String[] mechanisms = { getName() }; String[] mechanisms = { getName() };
Map props = new HashMap(); Map<String,String> props = new HashMap<String, String>();
props.put(Sasl.SERVER_AUTH,"TRUE"); props.put(Sasl.SERVER_AUTH,"TRUE");
sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, this); sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, this);
authenticate(); authenticate();

View file

@ -477,7 +477,7 @@ public class Cache<K, V> implements Map<K, V> {
return false; return false;
} }
final CacheObject cacheObject = (CacheObject) o; final CacheObject<?> cacheObject = (CacheObject<?>) o;
return object.equals(cacheObject.object); return object.equals(cacheObject.object);

View file

@ -28,6 +28,7 @@ import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext; import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext; import javax.naming.directory.InitialDirContext;
/** /**
* Utilty class to perform DNS lookups for XMPP services. * Utilty class to perform DNS lookups for XMPP services.
* *
@ -39,13 +40,13 @@ public class DNSUtil {
* Create a cache to hold the 100 most recently accessed DNS lookups for a period of * Create a cache to hold the 100 most recently accessed DNS lookups for a period of
* 10 minutes. * 10 minutes.
*/ */
private static Map cache = new Cache(100, 1000*60*10); private static Map<String, HostAddress> cache = new Cache<String, HostAddress>(100, 1000*60*10);
private static DirContext context; private static DirContext context;
static { static {
try { try {
Hashtable env = new Hashtable(); Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
context = new InitialDirContext(env); context = new InitialDirContext(env);
} }
@ -97,9 +98,9 @@ public class DNSUtil {
try { try {
Attributes dnsLookup = context.getAttributes("_xmpp-client._tcp." + domain, new String[]{"SRV"}); Attributes dnsLookup = context.getAttributes("_xmpp-client._tcp." + domain, new String[]{"SRV"});
Attribute srvAttribute = dnsLookup.get("SRV"); Attribute srvAttribute = dnsLookup.get("SRV");
NamingEnumeration srvRecords = srvAttribute.getAll(); NamingEnumeration<String> srvRecords = (NamingEnumeration<String>) srvAttribute.getAll();
while(srvRecords.hasMore()) { while(srvRecords.hasMore()) {
String srvRecord = (String) srvRecords.next(); String srvRecord = srvRecords.next();
String [] srvRecordEntries = srvRecord.split(" "); String [] srvRecordEntries = srvRecord.split(" ");
int priority = Integer.parseInt(srvRecordEntries[srvRecordEntries.length - 4]); int priority = Integer.parseInt(srvRecordEntries[srvRecordEntries.length - 4]);
int port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]); int port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]);

View file

@ -32,7 +32,7 @@ import java.util.*;
public class ObservableReader extends Reader { public class ObservableReader extends Reader {
Reader wrappedReader = null; Reader wrappedReader = null;
List listeners = new ArrayList(); List<ReaderListener> listeners = new ArrayList<ReaderListener>();
public ObservableReader(Reader wrappedReader) { public ObservableReader(Reader wrappedReader) {
this.wrappedReader = wrappedReader; this.wrappedReader = wrappedReader;

View file

@ -32,7 +32,7 @@ import java.util.*;
public class ObservableWriter extends Writer { public class ObservableWriter extends Writer {
Writer wrappedWriter = null; Writer wrappedWriter = null;
List listeners = new ArrayList(); List<WriterListener> listeners = new ArrayList<WriterListener>();
public ObservableWriter(Writer wrappedWriter) { public ObservableWriter(Writer wrappedWriter) {
this.wrappedWriter = wrappedWriter; this.wrappedWriter = wrappedWriter;

View file

@ -307,7 +307,7 @@ public class PacketParserUtils {
} }
else if (provider instanceof Class) { else if (provider instanceof Class) {
iqPacket = (IQ)PacketParserUtils.parseWithIntrospection(elementName, iqPacket = (IQ)PacketParserUtils.parseWithIntrospection(elementName,
(Class)provider, parser); (Class<?>)provider, parser);
} }
} }
} }
@ -769,7 +769,7 @@ public class PacketParserUtils {
} }
else if (provider instanceof Class) { else if (provider instanceof Class) {
return (PacketExtension)parseWithIntrospection( return (PacketExtension)parseWithIntrospection(
elementName, (Class)provider, parser); elementName, (Class<?>)provider, parser);
} }
} }
// No providers registered, so use a default extension. // No providers registered, so use a default extension.
@ -814,7 +814,7 @@ public class PacketParserUtils {
} }
public static Object parseWithIntrospection(String elementName, public static Object parseWithIntrospection(String elementName,
Class objectClass, XmlPullParser parser) throws Exception Class<?> objectClass, XmlPullParser parser) throws Exception
{ {
boolean done = false; boolean done = false;
Object object = objectClass.newInstance(); Object object = objectClass.newInstance();
@ -825,7 +825,7 @@ public class PacketParserUtils {
String stringValue = parser.nextText(); String stringValue = parser.nextText();
PropertyDescriptor descriptor = new PropertyDescriptor(name, objectClass); PropertyDescriptor descriptor = new PropertyDescriptor(name, objectClass);
// Load the class type of the property. // Load the class type of the property.
Class propertyType = descriptor.getPropertyType(); Class<?> propertyType = descriptor.getPropertyType();
// Get the value of the property by converting it from a // Get the value of the property by converting it from a
// String to the correct object type. // String to the correct object type.
Object value = decode(propertyType, stringValue); Object value = decode(propertyType, stringValue);
@ -850,7 +850,7 @@ public class PacketParserUtils {
* @return the String value decoded into the specified type. * @return the String value decoded into the specified type.
* @throws Exception If decoding failed due to an error. * @throws Exception If decoding failed due to an error.
*/ */
private static Object decode(Class type, String value) throws Exception { private static Object decode(Class<?> type, String value) throws Exception {
if (type.getName().equals("java.lang.String")) { if (type.getName().equals("java.lang.String")) {
return value; return value;
} }

View file

@ -389,8 +389,8 @@ public class Form {
public String getInstructions() { public String getInstructions() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// Join the list of instructions together separated by newlines // Join the list of instructions together separated by newlines
for (Iterator it = dataForm.getInstructions(); it.hasNext();) { for (Iterator<String> it = dataForm.getInstructions(); it.hasNext();) {
sb.append((String) it.next()); sb.append(it.next());
// If this is not the last instruction then append a newline // If this is not the last instruction then append a newline
if (it.hasNext()) { if (it.hasNext()) {
sb.append("\n"); sb.append("\n");

View file

@ -292,8 +292,8 @@ public class FormField {
buf.append("<value>").append(i.next()).append("</value>"); buf.append("<value>").append(i.next()).append("</value>");
} }
// Loop through all the values and append them to the string buffer // Loop through all the values and append them to the string buffer
for (Iterator i = getOptions(); i.hasNext();) { for (Iterator<Option> i = getOptions(); i.hasNext();) {
buf.append(((Option) i.next()).toXML()); buf.append((i.next()).toXML());
} }
buf.append("</field>"); buf.append("</field>");
return buf.toString(); return buf.toString();

View file

@ -206,18 +206,18 @@ public class MessageEventManager {
(MessageEvent) message.getExtension("x", "jabber:x:event"); (MessageEvent) message.getExtension("x", "jabber:x:event");
if (messageEvent.isMessageEventRequest()) { if (messageEvent.isMessageEventRequest()) {
// Fire event for requests of message events // Fire event for requests of message events
for (Iterator it = messageEvent.getEventTypes(); it.hasNext();) for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
fireMessageEventRequestListeners( fireMessageEventRequestListeners(
message.getFrom(), message.getFrom(),
message.getPacketID(), message.getPacketID(),
((String) it.next()).concat("NotificationRequested")); it.next().concat("NotificationRequested"));
} else } else
// Fire event for notifications of message events // Fire event for notifications of message events
for (Iterator it = messageEvent.getEventTypes(); it.hasNext();) for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
fireMessageEventNotificationListeners( fireMessageEventNotificationListeners(
message.getFrom(), message.getFrom(),
messageEvent.getPacketID(), messageEvent.getPacketID(),
((String) it.next()).concat("Notification")); it.next().concat("Notification"));
}; };

View file

@ -44,7 +44,7 @@ public class MultipleRecipientInfo {
* *
* @return list of primary recipients of the packet. * @return list of primary recipients of the packet.
*/ */
public List getTOAddresses() { public List<MultipleAddresses.Address> getTOAddresses() {
return extension.getAddressesOfType(MultipleAddresses.TO); return extension.getAddressesOfType(MultipleAddresses.TO);
} }
@ -54,7 +54,7 @@ public class MultipleRecipientInfo {
* *
* @return list of secondary recipients of the packet. * @return list of secondary recipients of the packet.
*/ */
public List getCCAddresses() { public List<MultipleAddresses.Address> getCCAddresses() {
return extension.getAddressesOfType(MultipleAddresses.CC); return extension.getAddressesOfType(MultipleAddresses.CC);
} }
@ -68,7 +68,7 @@ public class MultipleRecipientInfo {
* no specific address was provided. * no specific address was provided.
*/ */
public String getReplyRoom() { 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(); return replyRoom.isEmpty() ? null : ((MultipleAddresses.Address) replyRoom.get(0)).getJid();
} }
@ -92,7 +92,7 @@ public class MultipleRecipientInfo {
* no specific address was provided. * no specific address was provided.
*/ */
public MultipleAddresses.Address getReplyAddress() { 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); return replyTo.isEmpty() ? null : (MultipleAddresses.Address) replyTo.get(0);
} }
} }

View file

@ -47,7 +47,7 @@ public class MultipleRecipientManager {
* Create a cache to hold the 100 most recently accessed elements for a period of * Create a cache to hold the 100 most recently accessed elements for a period of
* 24 hours. * 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 * 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 * @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
* some JEP-33 specific features were requested. * 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 { throws XMPPException {
send(connection, packet, to, cc, bcc, null, null, false); 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 * @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
* some JEP-33 specific features were requested. * 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 replyTo, String replyRoom, boolean noReply) throws XMPPException {
String serviceAddress = getMultipleRecipienServiceAddress(connection); String serviceAddress = getMultipleRecipienServiceAddress(connection);
if (serviceAddress != null) { if (serviceAddress != null) {
@ -151,14 +151,14 @@ public class MultipleRecipientManager {
} }
else { else {
// Send reply to multiple recipients // Send reply to multiple recipients
List to = new ArrayList(); List<String> to = new ArrayList<String>();
List cc = new ArrayList(); List<String> cc = new ArrayList<String>();
for (Iterator it = info.getTOAddresses().iterator(); it.hasNext();) { for (Iterator<MultipleAddresses.Address> it = info.getTOAddresses().iterator(); it.hasNext();) {
String jid = ((MultipleAddresses.Address) it.next()).getJid(); String jid = it.next().getJid();
to.add(jid); to.add(jid);
} }
for (Iterator it = info.getCCAddresses().iterator(); it.hasNext();) { for (Iterator<MultipleAddresses.Address> it = info.getCCAddresses().iterator(); it.hasNext();) {
String jid = ((MultipleAddresses.Address) it.next()).getJid(); String jid = it.next().getJid();
cc.add(jid); cc.add(jid);
} }
// Add original sender as a 'to' address (if not already present) // 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, 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) { if (to != null) {
for (Iterator it = to.iterator(); it.hasNext();) { for (Iterator<String> it = to.iterator(); it.hasNext();) {
String jid = (String) it.next(); String jid = it.next();
packet.setTo(jid); packet.setTo(jid);
connection.sendPacket(new PacketCopy(packet.toXML())); connection.sendPacket(new PacketCopy(packet.toXML()));
} }
} }
if (cc != null) { if (cc != null) {
for (Iterator it = cc.iterator(); it.hasNext();) { for (Iterator<String> it = cc.iterator(); it.hasNext();) {
String jid = (String) it.next(); String jid = it.next();
packet.setTo(jid); packet.setTo(jid);
connection.sendPacket(new PacketCopy(packet.toXML())); connection.sendPacket(new PacketCopy(packet.toXML()));
} }
} }
if (bcc != null) { if (bcc != null) {
for (Iterator it = bcc.iterator(); it.hasNext();) { for (Iterator<String> it = bcc.iterator(); it.hasNext();) {
String jid = (String) it.next(); String jid = it.next();
packet.setTo(jid); packet.setTo(jid);
connection.sendPacket(new PacketCopy(packet.toXML())); connection.sendPacket(new PacketCopy(packet.toXML()));
} }
} }
} }
private static void sendThroughService(Connection connection, Packet packet, List to, private static void sendThroughService(Connection connection, Packet packet, List<String> to,
List cc, List bcc, String replyTo, String replyRoom, boolean noReply, List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply,
String serviceAddress) { String serviceAddress) {
// Create multiple recipient extension // Create multiple recipient extension
MultipleAddresses multipleAddresses = new MultipleAddresses(); MultipleAddresses multipleAddresses = new MultipleAddresses();
if (to != null) { if (to != null) {
for (Iterator it = to.iterator(); it.hasNext();) { for (Iterator<String> it = to.iterator(); it.hasNext();) {
String jid = (String) it.next(); String jid = it.next();
multipleAddresses.addAddress(MultipleAddresses.TO, jid, null, null, false, null); multipleAddresses.addAddress(MultipleAddresses.TO, jid, null, null, false, null);
} }
} }
if (cc != null) { if (cc != null) {
for (Iterator it = cc.iterator(); it.hasNext();) { for (Iterator<String> it = cc.iterator(); it.hasNext();) {
String jid = (String) it.next(); String jid = it.next();
multipleAddresses.addAddress(MultipleAddresses.CC, jid, null, null, false, null); multipleAddresses.addAddress(MultipleAddresses.CC, jid, null, null, false, null);
} }
} }
if (bcc != null) { if (bcc != null) {
for (Iterator it = bcc.iterator(); it.hasNext();) { for (Iterator<String> it = bcc.iterator(); it.hasNext();) {
String jid = (String) it.next(); String jid = it.next();
multipleAddresses.addAddress(MultipleAddresses.BCC, jid, null, null, false, null); 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 // Get the disco items and send the disco packet to each server item
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection) DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection)
.discoverItems(serviceName); .discoverItems(serviceName);
for (Iterator it = items.getItems(); it.hasNext();) { for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
DiscoverItems.Item item = (DiscoverItems.Item) it.next(); DiscoverItems.Item item = it.next();
info = ServiceDiscoveryManager.getInstanceFor(connection) info = ServiceDiscoveryManager.getInstanceFor(connection)
.discoverInfo(item.getEntityID(), item.getNode()); .discoverInfo(item.getEntityID(), item.getNode());
if (info.containsFeature("http://jabber.org/protocol/address")) { if (info.containsFeature("http://jabber.org/protocol/address")) {

View file

@ -113,8 +113,8 @@ public class OfflineMessageManager {
List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>(); List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>();
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems( DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
null, namespace); null, namespace);
for (Iterator it = items.getItems(); it.hasNext();) { for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
DiscoverItems.Item item = (DiscoverItems.Item) it.next(); DiscoverItems.Item item = it.next();
answer.add(new OfflineMessageHeader(item)); answer.add(new OfflineMessageHeader(item));
} }
return answer.iterator(); return answer.iterator();

View file

@ -62,7 +62,7 @@ public class PrivateDataManager {
/** /**
* Map of provider instances. * 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. * Returns the private data provider registered to the specified XML element name and namespace.

View file

@ -77,7 +77,7 @@ public class RemoteRosterEntry {
* *
* @return an Iterator for the group names. * @return an Iterator for the group names.
*/ */
public Iterator getGroupNames() { public Iterator<String> getGroupNames() {
synchronized (groupNames) { synchronized (groupNames) {
return Collections.unmodifiableList(groupNames).iterator(); return Collections.unmodifiableList(groupNames).iterator();
} }

View file

@ -37,6 +37,6 @@ public interface RosterExchangeListener {
* @param remoteRosterEntries the entries sent by the user. The entries are instances of * @param remoteRosterEntries the entries sent by the user. The entries are instances of
* RemoteRosterEntry. * RemoteRosterEntry.
*/ */
public void entriesReceived(String from, Iterator remoteRosterEntries); public void entriesReceived(String from, Iterator<RemoteRosterEntry> remoteRosterEntries);
} }

View file

@ -149,7 +149,7 @@ public class RosterExchangeManager {
/** /**
* Fires roster exchange listeners. * Fires roster exchange listeners.
*/ */
private void fireRosterExchangeListeners(String from, Iterator remoteRosterEntries) { private void fireRosterExchangeListeners(String from, Iterator<RemoteRosterEntry> remoteRosterEntries) {
RosterExchangeListener[] listeners = null; RosterExchangeListener[] listeners = null;
synchronized (rosterExchangeListeners) { synchronized (rosterExchangeListeners) {
listeners = new RosterExchangeListener[rosterExchangeListeners.size()]; listeners = new RosterExchangeListener[rosterExchangeListeners.size()];

View file

@ -27,7 +27,7 @@ public class SharedGroupManager {
* @param connection connection to use to get the user's shared groups. * @param connection connection to use to get the user's shared groups.
* @return collection with the shared groups' name of the logged user. * @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 // Discover the shared groups of the logged user
SharedGroupsInfo info = new SharedGroupsInfo(); SharedGroupsInfo info = new SharedGroupsInfo();
info.setType(IQ.Type.GET); info.setType(IQ.Type.GET);

View file

@ -57,7 +57,7 @@ public class XHTMLManager {
* @param message an XHTML message * @param message an XHTML message
* @return an Iterator for the bodies in the message or null if none. * @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); XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
if (xhtmlExtension != null) if (xhtmlExtension != null)
return xhtmlExtension.getBodies(); return xhtmlExtension.getBodies();

View file

@ -138,10 +138,10 @@ public class AdHocCommandManager {
* @param name the human readable name of the command. * @param name the human readable name of the command.
* @param clazz the class of the command, which must extend {@link LocalCommand}. * @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() { registerCommand(node, name, new LocalCommandFactory() {
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException { public LocalCommand getInstance() throws InstantiationException, IllegalAccessException {
return (LocalCommand)clazz.newInstance(); return clazz.newInstance();
} }
}); });
} }

View file

@ -258,7 +258,7 @@ public class EnhancedDebugger implements SmackDebugger {
return false; return false;
} }
public Class getColumnClass(int columnIndex) { public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == 2 || columnIndex == 3) { if (columnIndex == 2 || columnIndex == 3) {
return Icon.class; return Icon.class;
} }

View file

@ -226,7 +226,7 @@ public class EnhancedDebuggerWindow {
Vector<String> providers = new Vector<String>(); Vector<String> providers = new Vector<String>();
for (Object provider : ProviderManager.getInstance().getIQProviders()) { for (Object provider : ProviderManager.getInstance().getIQProviders()) {
if (provider.getClass() == Class.class) { if (provider.getClass() == Class.class) {
providers.add(((Class) provider).getName()); providers.add(((Class<?>) provider).getName());
} }
else { else {
providers.add(provider.getClass().getName()); providers.add(provider.getClass().getName());
@ -245,7 +245,7 @@ public class EnhancedDebuggerWindow {
providers = new Vector<String>(); providers = new Vector<String>();
for (Object provider : ProviderManager.getInstance().getExtensionProviders()) { for (Object provider : ProviderManager.getInstance().getExtensionProviders()) {
if (provider.getClass() == Class.class) { if (provider.getClass() == Class.class) {
providers.add(((Class) provider).getName()); providers.add(((Class<?>) provider).getName());
} }
else { else {
providers.add(provider.getClass().getName()); providers.add(provider.getClass().getName());

View file

@ -1703,8 +1703,8 @@ public class MultiUserChat {
} }
// Get the list of affiliates from the server's answer // Get the list of affiliates from the server's answer
List<Affiliate> affiliates = new ArrayList<Affiliate>(); List<Affiliate> affiliates = new ArrayList<Affiliate>();
for (Iterator it = answer.getItems(); it.hasNext();) { for (Iterator<MUCOwner.Item> it = answer.getItems(); it.hasNext();) {
affiliates.add(new Affiliate((MUCOwner.Item) it.next())); affiliates.add(new Affiliate(it.next()));
} }
return affiliates; return affiliates;
} }
@ -1744,8 +1744,8 @@ public class MultiUserChat {
} }
// Get the list of affiliates from the server's answer // Get the list of affiliates from the server's answer
List<Affiliate> affiliates = new ArrayList<Affiliate>(); List<Affiliate> affiliates = new ArrayList<Affiliate>();
for (Iterator it = answer.getItems(); it.hasNext();) { for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
affiliates.add(new Affiliate((MUCAdmin.Item) it.next())); affiliates.add(new Affiliate(it.next()));
} }
return affiliates; return affiliates;
} }
@ -1806,8 +1806,8 @@ public class MultiUserChat {
} }
// Get the list of participants from the server's answer // Get the list of participants from the server's answer
List<Occupant> participants = new ArrayList<Occupant>(); List<Occupant> participants = new ArrayList<Occupant>();
for (Iterator it = answer.getItems(); it.hasNext();) { for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
participants.add(new Occupant((MUCAdmin.Item) it.next())); participants.add(new Occupant(it.next()));
} }
return participants; return participants;
} }
@ -2035,7 +2035,7 @@ public class MultiUserChat {
userStatusListeners.toArray(listeners); userStatusListeners.toArray(listeners);
} }
// Get the classes of the method parameters // 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++) { for (int i = 0; i < params.length; i++) {
paramClasses[i] = params[i].getClass(); paramClasses[i] = params[i].getClass();
} }
@ -2088,7 +2088,7 @@ public class MultiUserChat {
} }
try { try {
// Get the method to execute based on the requested methodName and parameter // 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++) { for (int i=0;i<params.size(); i++) {
classes[i] = String.class; classes[i] = String.class;
} }

View file

@ -202,7 +202,7 @@ public class DataForm implements PacketExtension {
if (getTitle() != null) { if (getTitle() != null) {
buf.append("<title>").append(getTitle()).append("</title>"); 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>"); buf.append("<instructions>").append(it.next()).append("</instructions>");
} }
// Append the list of fields returned from a search // Append the list of fields returned from a search
@ -210,13 +210,13 @@ public class DataForm implements PacketExtension {
buf.append(getReportedData().toXML()); buf.append(getReportedData().toXML());
} }
// Loop through all the items returned from a search and append them to the string buffer // Loop through all the items returned from a search and append them to the string buffer
for (Iterator i = getItems(); i.hasNext();) { for (Iterator<Item> i = getItems(); i.hasNext();) {
Item item = (Item) i.next(); Item item = i.next();
buf.append(item.toXML()); buf.append(item.toXML());
} }
// Loop through all the form fields and append them to the string buffer // Loop through all the form fields and append them to the string buffer
for (Iterator i = getFields(); i.hasNext();) { for (Iterator<FormField> i = getFields(); i.hasNext();) {
FormField field = (FormField) i.next(); FormField field = i.next();
buf.append(field.toXML()); buf.append(field.toXML());
} }
buf.append("</").append(getElementName()).append(">"); buf.append("</").append(getElementName()).append(">");
@ -250,8 +250,8 @@ public class DataForm implements PacketExtension {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<reported>"); buf.append("<reported>");
// Loop through all the form items and append them to the string buffer // Loop through all the form items and append them to the string buffer
for (Iterator i = getFields(); i.hasNext();) { for (Iterator<FormField> i = getFields(); i.hasNext();) {
FormField field = (FormField) i.next(); FormField field = i.next();
buf.append(field.toXML()); buf.append(field.toXML());
} }
buf.append("</reported>"); buf.append("</reported>");
@ -285,8 +285,8 @@ public class DataForm implements PacketExtension {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<item>"); buf.append("<item>");
// Loop through all the form items and append them to the string buffer // Loop through all the form items and append them to the string buffer
for (Iterator i = getFields(); i.hasNext();) { for (Iterator<FormField> i = getFields(); i.hasNext();) {
FormField field = (FormField) i.next(); FormField field = i.next();
buf.append(field.toXML()); buf.append(field.toXML());
} }
buf.append("</item>"); buf.append("</item>");

View file

@ -51,7 +51,7 @@ public class DefaultPrivateData implements PrivateData {
private String elementName; private String elementName;
private String namespace; private String namespace;
private Map map; private Map<String, String> map;
/** /**
* Creates a new generic private data object. * Creates a new generic private data object.
@ -85,8 +85,8 @@ public class DefaultPrivateData implements PrivateData {
public String toXML() { public String toXML() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\">"); buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\">");
for (Iterator i=getNames(); i.hasNext(); ) { for (Iterator<String> i=getNames(); i.hasNext(); ) {
String name = (String)i.next(); String name = i.next();
String value = getValue(name); String value = getValue(name);
buf.append("<").append(name).append(">"); buf.append("<").append(name).append(">");
buf.append(value); buf.append(value);
@ -102,11 +102,11 @@ public class DefaultPrivateData implements PrivateData {
* *
* @return an Iterator for the names. * @return an Iterator for the names.
*/ */
public synchronized Iterator getNames() { public synchronized Iterator<String> getNames() {
if (map == null) { 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) { public synchronized void setValue(String name, String value) {
if (map == null) { if (map == null) {
map = new HashMap(); map = new HashMap<String,String>();
} }
map.put(name, value); map.put(name, value);
} }

View file

@ -19,13 +19,13 @@
*/ */
package org.jivesoftware.smackx.packet; package org.jivesoftware.smackx.packet;
import org.jivesoftware.smack.packet.IQ;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.jivesoftware.smack.packet.IQ;
/** /**
* IQ packet that serves for kicking users, granting and revoking voice, banning users, * 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 * 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 { 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, * 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, * @return an Iterator for item childs that holds information about roles, affiliation,
* jids and nicks. * jids and nicks.
*/ */
public Iterator getItems() { public Iterator<Item> getItems() {
synchronized (items) { 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\">"); buf.append("<query xmlns=\"http://jabber.org/protocol/muc#admin\">");
synchronized (items) { synchronized (items) {
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
Item item = (Item) items.get(i); Item item = items.get(i);
buf.append(item.toXML()); buf.append(item.toXML());
} }
} }

View file

@ -35,7 +35,7 @@ import java.util.List;
*/ */
public class MUCOwner extends IQ { public class MUCOwner extends IQ {
private List items = new ArrayList(); private List<Item> items = new ArrayList<Item>();
private Destroy destroy; private Destroy destroy;
/** /**
@ -45,9 +45,9 @@ public class MUCOwner extends IQ {
* @return an Iterator for item childs that holds information about affiliation, * @return an Iterator for item childs that holds information about affiliation,
* jids and nicks. * jids and nicks.
*/ */
public Iterator getItems() { public Iterator<Item> getItems() {
synchronized (items) { synchronized (items) {
return Collections.unmodifiableList(new ArrayList(items)).iterator(); return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
} }
} }

View file

@ -167,8 +167,8 @@ public class MessageEvent implements PacketExtension {
* *
* @return an iterator over all the types of events of the MessageEvent. * @return an iterator over all the types of events of the MessageEvent.
*/ */
public Iterator getEventTypes() { public Iterator<String> getEventTypes() {
ArrayList allEvents = new ArrayList(); ArrayList<String> allEvents = new ArrayList<String>();
if (isDelivered()) { if (isDelivered()) {
allEvents.add(MessageEvent.DELIVERED); allEvents.add(MessageEvent.DELIVERED);
} }

View file

@ -41,7 +41,7 @@ public class MultipleAddresses implements PacketExtension {
public static final String TO = "to"; 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. * 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. * @param type Examples of address type are: TO, CC, BCC, etc.
* @return the list of addresses that matches the specified type. * @return the list of addresses that matches the specified type.
*/ */
public List getAddressesOfType(String type) { public List<Address> getAddressesOfType(String type) {
List answer = new ArrayList(addresses.size()); List<Address> answer = new ArrayList<Address>(addresses.size());
for (Iterator it = addresses.iterator(); it.hasNext();) { for (Iterator<Address> it = addresses.iterator(); it.hasNext();) {
Address address = (Address) it.next(); Address address = (Address) it.next();
if (address.getType().equals(type)) { if (address.getType().equals(type)) {
answer.add(address); answer.add(address);
@ -109,7 +109,7 @@ public class MultipleAddresses implements PacketExtension {
buf.append("<").append(getElementName()); buf.append("<").append(getElementName());
buf.append(" xmlns=\"").append(getNamespace()).append("\">"); buf.append(" xmlns=\"").append(getNamespace()).append("\">");
// Loop through all the addresses and append them to the string buffer // 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(); Address address = (Address) i.next();
buf.append(address.toXML()); buf.append(address.toXML());
} }

View file

@ -37,7 +37,7 @@ import java.util.List;
*/ */
public class OfflineMessageRequest extends IQ { public class OfflineMessageRequest extends IQ {
private List items = new ArrayList(); private List<Item> items = new ArrayList<Item>();
private boolean purge = false; private boolean purge = false;
private boolean fetch = 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 * @return an Iterator for item childs that holds information about offline messages to
* view or delete. * view or delete.
*/ */
public Iterator getItems() { public Iterator<Item> getItems() {
synchronized (items) { 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\">"); buf.append("<offline xmlns=\"http://jabber.org/protocol/offline\">");
synchronized (items) { synchronized (items) {
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
Item item = (Item) items.get(i); Item item = items.get(i);
buf.append(item.toXML()); buf.append(item.toXML());
} }
} }

View file

@ -52,7 +52,7 @@ import java.util.List;
*/ */
public class RosterExchange implements PacketExtension { public class RosterExchange implements PacketExtension {
private List remoteRosterEntries = new ArrayList(); private List<RemoteRosterEntry> remoteRosterEntries = new ArrayList<RemoteRosterEntry>();
/** /**
* Creates a new empty roster exchange package. * 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. * @return an Iterator for the roster entries in the packet.
*/ */
public Iterator getRosterEntries() { public Iterator<RemoteRosterEntry> getRosterEntries() {
synchronized (remoteRosterEntries) { synchronized (remoteRosterEntries) {
List entries = Collections.unmodifiableList(new ArrayList(remoteRosterEntries)); List<RemoteRosterEntry> entries = Collections.unmodifiableList(new ArrayList<RemoteRosterEntry>(remoteRosterEntries));
return entries.iterator(); return entries.iterator();
} }
} }
@ -170,8 +170,8 @@ public class RosterExchange implements PacketExtension {
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append( buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
"\">"); "\">");
// Loop through all roster entries and append them to the string buffer // Loop through all roster entries and append them to the string buffer
for (Iterator i = getRosterEntries(); i.hasNext();) { for (Iterator<RemoteRosterEntry> i = getRosterEntries(); i.hasNext();) {
RemoteRosterEntry remoteRosterEntry = (RemoteRosterEntry) i.next(); RemoteRosterEntry remoteRosterEntry = i.next();
buf.append(remoteRosterEntry.toXML()); buf.append(remoteRosterEntry.toXML());
} }
buf.append("</").append(getElementName()).append(">"); buf.append("</").append(getElementName()).append(">");

View file

@ -19,21 +19,21 @@ import java.util.List;
*/ */
public class SharedGroupsInfo extends IQ { 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. * Returns a collection with the shared group names returned from the server.
* *
* @return 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; return groups;
} }
public String getChildElementXML() { public String getChildElementXML() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<sharedgroup xmlns=\"http://www.jivesoftware.org/protocol/sharedgroup\">"); 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("<group>").append(it.next()).append("</group>");
} }
buf.append("</sharedgroup>"); buf.append("</sharedgroup>");

View file

@ -20,16 +20,6 @@
package org.jivesoftware.smackx.packet; 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.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -42,6 +32,17 @@ import java.security.NoSuchAlgorithmException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; 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 * 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) { 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()) { while (it.hasNext()) {
final Map.Entry entry = (Map.Entry) it.next(); final Map.Entry<String,String> entry = it.next();
appendTag("TEL", true, new ContentBuilder() { appendTag("TEL", true, new ContentBuilder() {
public void addTagContent() { public void addTagContent() {
appendEmptyTag(entry.getKey()); appendEmptyTag(entry.getKey());
appendEmptyTag(code); 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() { public void addTagContent() {
appendEmptyTag(code); appendEmptyTag(code);
Iterator it = addr.entrySet().iterator(); Iterator<Map.Entry<String, String>> it = addr.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
final Map.Entry entry = (Map.Entry) it.next(); final Entry<String, String> entry = it.next();
appendTag((String) entry.getKey(), StringUtils.escapeForXML((String) entry.getValue())); appendTag(entry.getKey(), StringUtils.escapeForXML(entry.getValue()));
} }
} }
}); });
@ -774,17 +775,17 @@ public class VCard extends IQ {
} }
private void appendGenericFields() { private void appendGenericFields() {
Iterator it = otherSimpleFields.entrySet().iterator(); Iterator<Map.Entry<String, String>> it = otherSimpleFields.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next(); Map.Entry<String, String> entry = it.next();
appendTag(entry.getKey().toString(), appendTag(entry.getKey().toString(),
StringUtils.escapeForXML((String) entry.getValue())); StringUtils.escapeForXML(entry.getValue()));
} }
it = otherUnescapableFields.entrySet().iterator(); it = otherUnescapableFields.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next(); Map.Entry<String, String> entry = it.next();
appendTag(entry.getKey().toString(), (String) entry.getValue()); appendTag(entry.getKey().toString(),entry.getValue());
} }
} }

View file

@ -42,7 +42,7 @@ import java.util.List;
*/ */
public class XHTMLExtension implements PacketExtension { 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. * 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( buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
"\">"); "\">");
// Loop through all the bodies and append them to the string buffer // Loop through all the bodies and append them to the string buffer
for (Iterator i = getBodies(); i.hasNext();) { for (Iterator<String> i = getBodies(); i.hasNext();) {
buf.append((String) i.next()); buf.append(i.next());
} }
buf.append("</").append(getElementName()).append(">"); buf.append("</").append(getElementName()).append(">");
return buf.toString(); return buf.toString();
@ -97,9 +97,9 @@ public class XHTMLExtension implements PacketExtension {
* *
* @return an Iterator for the bodies in the packet. * @return an Iterator for the bodies in the packet.
*/ */
public Iterator getBodies() { public Iterator<String> getBodies() {
synchronized (bodies) { synchronized (bodies) {
return Collections.unmodifiableList(new ArrayList(bodies)).iterator(); return Collections.unmodifiableList(new ArrayList<String>(bodies)).iterator();
} }
} }

View file

@ -105,7 +105,7 @@ public class DataFormProvider implements PacketExtensionProvider {
private DataForm.Item parseItem(XmlPullParser parser) throws Exception { private DataForm.Item parseItem(XmlPullParser parser) throws Exception {
boolean done = false; boolean done = false;
List fields = new ArrayList(); List<FormField> fields = new ArrayList<FormField>();
while (!done) { while (!done) {
int eventType = parser.next(); int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) { if (eventType == XmlPullParser.START_TAG) {
@ -123,7 +123,7 @@ public class DataFormProvider implements PacketExtensionProvider {
private DataForm.ReportedData parseReported(XmlPullParser parser) throws Exception { private DataForm.ReportedData parseReported(XmlPullParser parser) throws Exception {
boolean done = false; boolean done = false;
List fields = new ArrayList(); List<FormField> fields = new ArrayList<FormField>();
while (!done) { while (!done) {
int eventType = parser.next(); int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) { if (eventType == XmlPullParser.START_TAG) {

View file

@ -57,13 +57,13 @@ public class RosterExchangeProvider implements PacketExtensionProvider {
RemoteRosterEntry remoteRosterEntry = null; RemoteRosterEntry remoteRosterEntry = null;
String jid = ""; String jid = "";
String name = ""; String name = "";
ArrayList groupsName = new ArrayList(); ArrayList<String> groupsName = new ArrayList<String>();
while (!done) { while (!done) {
int eventType = parser.next(); int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) { if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("item")) { if (parser.getName().equals("item")) {
// Reset this variable since they are optional for each 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 // Initialize the variables from the parsed XML
jid = parser.getAttributeValue("", "jid"); jid = parser.getAttributeValue("", "jid");
name = parser.getAttributeValue("", "name"); name = parser.getAttributeValue("", "name");

View file

@ -184,8 +184,8 @@ public class VCardProvider implements IQProvider {
Element addressNode = (Element) allAddresses.item(i); Element addressNode = (Element) allAddresses.item(i);
String type = null; String type = null;
List code = new ArrayList(); List<String> code = new ArrayList<String>();
List value = new ArrayList(); List<String> value = new ArrayList<String>();
NodeList childNodes = addressNode.getChildNodes(); NodeList childNodes = addressNode.getChildNodes();
for (int j = 0; j < childNodes.getLength(); j++) { for (int j = 0; j < childNodes.getLength(); j++) {
Node node = childNodes.item(j); Node node = childNodes.item(j);

View file

@ -37,7 +37,7 @@ abstract public class Node
protected String id; protected String id;
protected String to; 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<ItemDeleteListener, PacketListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, PacketListener>();
protected ConcurrentHashMap<NodeConfigListener, PacketListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, PacketListener>(); protected ConcurrentHashMap<NodeConfigListener, PacketListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, PacketListener>();

View file

@ -19,9 +19,9 @@ import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.Connection; import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.Form; import org.jivesoftware.smackx.Form;
import org.jivesoftware.smackx.FormField; import org.jivesoftware.smackx.FormField;
import org.jivesoftware.smackx.ServiceDiscoveryManager; import org.jivesoftware.smackx.ServiceDiscoveryManager;
@ -149,7 +149,7 @@ final public class PubSubManager
* @return the node * @return the node
* @throws XMPPException The node does not exist * @throws XMPPException The node does not exist
*/ */
public Node getNode(String id) public <T extends Node> T getNode(String id)
throws XMPPException throws XMPPException
{ {
Node node = nodeMap.get(id); Node node = nodeMap.get(id);
@ -169,7 +169,7 @@ final public class PubSubManager
node.setTo(to); node.setTo(to);
nodeMap.put(id, node); nodeMap.put(id, node);
} }
return node; return (T) node;
} }
/** /**

View file

@ -122,9 +122,9 @@ class SimpleUserSearch extends IQ {
fields.add(field); fields.add(field);
boolean exists = false; boolean exists = false;
Iterator cols = data.getColumns(); Iterator<ReportedData.Column> cols = data.getColumns();
while (cols.hasNext()) { while (cols.hasNext()) {
ReportedData.Column column = (ReportedData.Column) cols.next(); ReportedData.Column column = cols.next();
if (column.getVariable().equals(name)) { if (column.getVariable().equals(name)) {
exists = true; exists = true;
} }

View file

@ -93,7 +93,7 @@ public class UserSearchManager {
* @return a Collection of search services found on the server. * @return a Collection of search services found on the server.
* @throws XMPPException thrown if a server error has occurred. * @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>(); final List<String> searchServices = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
DiscoverItems items = discoManager.discoverItems(con.getServiceName()); DiscoverItems items = discoManager.discoverItems(con.getServiceName());

View file

@ -19,6 +19,7 @@
package org.jivesoftware.smackx.workgroup; package org.jivesoftware.smackx.workgroup;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; 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"; 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; this.metaData = metaData;
} }
/** /**
* @return the Map of metadata contained by this instance * @return the Map of metadata contained by this instance
*/ */
public Map getMetaData() { public Map<String, List<String>> getMetaData() {
return metaData; return metaData;
} }

View file

@ -19,6 +19,7 @@
package org.jivesoftware.smackx.workgroup; package org.jivesoftware.smackx.workgroup;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -36,7 +37,7 @@ public class WorkgroupInvitation {
protected String issuingWorkgroupName; protected String issuingWorkgroupName;
protected String messageBody; protected String messageBody;
protected String invitationSender; protected String invitationSender;
protected Map metaData; protected Map<String, List<String>> metaData;
/** /**
* This calls the 5-argument constructor with a null MetaData argument value * 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 * @param metaData the metadata sent with the invitation
*/ */
public WorkgroupInvitation (String jid, String group, String workgroup, String sessID, String msgBody, public WorkgroupInvitation (String jid, String group, String workgroup, String sessID, String msgBody,
String from, Map metaData) { String from, Map<String, List<String>> metaData) {
super(); super();
this.uniqueID = jid; this.uniqueID = jid;
@ -126,7 +127,7 @@ public class WorkgroupInvitation {
* @return the meta data associated with the invitation, or null if this instance was * @return the meta data associated with the invitation, or null if this instance was
* constructed with none * constructed with none
*/ */
public Map getMetaData () { public Map<String, List<String>> getMetaData () {
return this.metaData; return this.metaData;
} }

View file

@ -318,8 +318,8 @@ public class AgentRoster {
} }
// Fire an event. // Fire an event.
synchronized (entries) { synchronized (entries) {
for (Iterator i = entries.iterator(); i.hasNext();) { for (Iterator<String> i = entries.iterator(); i.hasNext();) {
String entry = (String)i.next(); String entry = i.next();
if (entry.toLowerCase().equals(StringUtils.parseBareAddress(key).toLowerCase())) { if (entry.toLowerCase().equals(StringUtils.parseBareAddress(key).toLowerCase())) {
fireEvent(EVENT_PRESENCE_CHANGED, packet); fireEvent(EVENT_PRESENCE_CHANGED, packet);
} }
@ -358,8 +358,8 @@ public class AgentRoster {
public void processPacket(Packet packet) { public void processPacket(Packet packet) {
if (packet instanceof AgentStatusRequest) { if (packet instanceof AgentStatusRequest) {
AgentStatusRequest statusRequest = (AgentStatusRequest)packet; AgentStatusRequest statusRequest = (AgentStatusRequest)packet;
for (Iterator i = statusRequest.getAgents().iterator(); i.hasNext();) { for (Iterator<AgentStatusRequest.Item> i = statusRequest.getAgents().iterator(); i.hasNext();) {
AgentStatusRequest.Item item = (AgentStatusRequest.Item)i.next(); AgentStatusRequest.Item item = i.next();
String agentJID = item.getJID(); String agentJID = item.getJID();
if ("remove".equals(item.getType())) { if ("remove".equals(item.getType())) {

View file

@ -20,6 +20,7 @@
package org.jivesoftware.smackx.workgroup.agent; package org.jivesoftware.smackx.workgroup.agent;
import org.jivesoftware.smackx.workgroup.MetaData; import org.jivesoftware.smackx.workgroup.MetaData;
import org.jivesoftware.smackx.workgroup.QueueUser;
import org.jivesoftware.smackx.workgroup.WorkgroupInvitation; import org.jivesoftware.smackx.workgroup.WorkgroupInvitation;
import org.jivesoftware.smackx.workgroup.WorkgroupInvitationListener; import org.jivesoftware.smackx.workgroup.WorkgroupInvitationListener;
import org.jivesoftware.smackx.workgroup.ext.history.AgentChatHistory; import org.jivesoftware.smackx.workgroup.ext.history.AgentChatHistory;
@ -60,7 +61,7 @@ public class AgentSession {
private boolean online = false; private boolean online = false;
private Presence.Mode presenceMode; private Presence.Mode presenceMode;
private int maxChats; private int maxChats;
private final Map<String, String> metaData; private final Map<String, List<String>> metaData;
private Map<String, WorkgroupQueue> queues; private Map<String, WorkgroupQueue> queues;
@ -96,7 +97,7 @@ public class AgentSession {
this.maxChats = -1; this.maxChats = -1;
this.metaData = new HashMap<String, String>(); this.metaData = new HashMap<String, List<String>>();
this.queues = new HashMap<String, WorkgroupQueue>(); this.queues = new HashMap<String, WorkgroupQueue>();
@ -199,10 +200,10 @@ public class AgentSession {
*/ */
public void setMetaData(String key, String val) throws XMPPException { public void setMetaData(String key, String val) throws XMPPException {
synchronized (this.metaData) { synchronized (this.metaData) {
String oldVal = (String)this.metaData.get(key); List<String> oldVals = metaData.get(key);
if ((oldVal == null) || (!oldVal.equals(val))) { if ((oldVals == null) || (!oldVals.get(0).equals(val))) {
metaData.put(key, val); oldVals.set(0, val);
setStatus(presenceMode, maxChats); setStatus(presenceMode, maxChats);
} }
@ -218,7 +219,7 @@ public class AgentSession {
*/ */
public void removeMetaData(String key) throws XMPPException { public void removeMetaData(String key) throws XMPPException {
synchronized (this.metaData) { synchronized (this.metaData) {
String oldVal = (String)metaData.remove(key); List<String> oldVal = metaData.remove(key);
if (oldVal != null) { if (oldVal != null) {
setStatus(presenceMode, maxChats); 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 * @return the meta data value associated with the key or <tt>null</tt> if the meta-data
* doesn't exist.. * doesn't exist..
*/ */
public String getMetaData(String key) { public List<String> getMetaData(String key) {
return (String)metaData.get(key); return metaData.get(key);
} }
/** /**
@ -642,7 +643,7 @@ public class AgentSession {
} }
private void fireInvitationEvent(String groupChatJID, String sessionID, String body, 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, WorkgroupInvitation invitation = new WorkgroupInvitation(connection.getUser(), groupChatJID,
workgroupJID, sessionID, body, from, metaData); workgroupJID, sessionID, body, from, metaData);
@ -654,7 +655,7 @@ public class AgentSession {
} }
private void fireQueueUsersEvent(WorkgroupQueue queue, WorkgroupQueue.Status status, private void fireQueueUsersEvent(WorkgroupQueue queue, WorkgroupQueue.Status status,
int averageWaitTime, Date oldestEntry, Set users) { int averageWaitTime, Date oldestEntry, Set<QueueUser> users) {
synchronized (queueUsersListeners) { synchronized (queueUsersListeners) {
for (QueueUsersListener listener : queueUsersListeners) { for (QueueUsersListener listener : queueUsersListeners) {
if (status != null) { if (status != null) {
@ -754,7 +755,7 @@ public class AgentSession {
MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null; MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null;
if (invite != null && workgroupJID.equals(invite.getFrom())) { if (invite != null && workgroupJID.equals(invite.getFrom())) {
String sessionID = null; String sessionID = null;
Map metaData = null; Map<String, List<String>> metaData = null;
SessionID sessionIDExt = (SessionID)message.getExtension(SessionID.ELEMENT_NAME, SessionID sessionIDExt = (SessionID)message.getExtension(SessionID.ELEMENT_NAME,
SessionID.NAMESPACE); SessionID.NAMESPACE);
@ -980,7 +981,7 @@ public class AgentSession {
* @return Map a map of all metadata associated with the sessionID. * @return Map a map of all metadata associated with the sessionID.
* @throws XMPPException if an error occurs while getting information from the server. * @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(); ChatMetadata request = new ChatMetadata();
request.setType(IQ.Type.GET); request.setType(IQ.Type.GET);
request.setTo(workgroupJID); request.setTo(workgroupJID);

View file

@ -24,6 +24,7 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Packet;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -44,7 +45,7 @@ public class Offer {
private String userID; private String userID;
private String workgroupName; private String workgroupName;
private Date expiresDate; private Date expiresDate;
private Map metaData; private Map<String, List<String>> metaData;
private OfferContent content; private OfferContent content;
private boolean accepted = false; private boolean accepted = false;
@ -66,7 +67,7 @@ public class Offer {
*/ */
Offer(Connection conn, AgentSession agentSession, String userID, Offer(Connection conn, AgentSession agentSession, String userID,
String userJID, String workgroupName, Date expiresDate, 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.connection = conn;
this.session = agentSession; this.session = agentSession;
@ -155,7 +156,7 @@ public class Offer {
* *
* @return the offer meta-data. * @return the offer meta-data.
*/ */
public Map getMetaData() { public Map<String, List<String>> getMetaData() {
return this.metaData; return this.metaData;
} }

View file

@ -22,6 +22,8 @@ package org.jivesoftware.smackx.workgroup.agent;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
import org.jivesoftware.smackx.workgroup.QueueUser;
public interface QueueUsersListener { public interface QueueUsersListener {
/** /**
@ -54,5 +56,5 @@ public interface QueueUsersListener {
* @param queue the workgroup queue. * @param queue the workgroup queue.
* @param users the list of users waiting in the 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);
} }

View file

@ -21,6 +21,8 @@ package org.jivesoftware.smackx.workgroup.agent;
import java.util.*; 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 * A queue in a workgroup, which is a pool of agents that are routed a specific type of
* chat request. * chat request.
@ -32,7 +34,7 @@ public class WorkgroupQueue {
private int averageWaitTime = -1; private int averageWaitTime = -1;
private Date oldestEntry = null; private Date oldestEntry = null;
private Set users = Collections.EMPTY_SET; private Set<QueueUser> users = Collections.emptySet();
private int maxChats = 0; private int maxChats = 0;
private int currentChats = 0; private int currentChats = 0;
@ -87,14 +89,14 @@ public class WorkgroupQueue {
* *
* @return an Iterator for the users waiting in the queue. * @return an Iterator for the users waiting in the queue.
*/ */
public Iterator getUsers() { public Iterator<QueueUser> getUsers() {
if (users == null) { if (users == null) {
return Collections.EMPTY_SET.iterator(); return new HashSet<QueueUser>().iterator();
} }
return Collections.unmodifiableSet(users).iterator(); return Collections.unmodifiableSet(users).iterator();
} }
void setUsers(Set users) { void setUsers(Set<QueueUser> users) {
this.users = users; this.users = users;
} }

View file

@ -37,7 +37,7 @@ public class AgentChatHistory extends IQ {
private int maxSessions; private int maxSessions;
private long startDate; private long startDate;
private List agentChatSessions = new ArrayList(); private List<AgentChatSession> agentChatSessions = new ArrayList<AgentChatSession>();
public AgentChatHistory(String agentJID, int maxSessions, Date startDate) { public AgentChatHistory(String agentJID, int maxSessions, Date startDate) {
this.agentJID = agentJID; this.agentJID = agentJID;
@ -58,7 +58,7 @@ public class AgentChatHistory extends IQ {
agentChatSessions.add(chatSession); agentChatSessions.add(chatSession);
} }
public Collection getAgentChatSessions() { public Collection<AgentChatSession> getAgentChatSessions() {
return agentChatSessions; return agentChatSessions;
} }

View file

@ -25,6 +25,7 @@ import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
public class ChatMetadata extends IQ { 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; this.map = metadata;
} }
public Map getMetadata(){ public Map<String, List<String>> getMetadata(){
return map; return map;
} }
@ -94,7 +95,7 @@ public class ChatMetadata extends IQ {
chatM.setSessionID(parser.nextText()); chatM.setSessionID(parser.nextText());
} }
else if (parser.getName().equals("metadata")) { else if (parser.getName().equals("metadata")) {
Map map = MetaDataUtils.parseMetaData(parser); Map<String, List<String>> map = MetaDataUtils.parseMetaData(parser);
chatM.setMetadata(map); chatM.setMetadata(map);
} }
} }

View file

@ -19,6 +19,7 @@
package org.jivesoftware.smackx.workgroup.packet; package org.jivesoftware.smackx.workgroup.packet;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.jivesoftware.smackx.workgroup.MetaData; import org.jivesoftware.smackx.workgroup.MetaData;
@ -41,7 +42,7 @@ public class MetaDataProvider implements PacketExtensionProvider {
*/ */
public PacketExtension parseExtension (XmlPullParser parser) public PacketExtension parseExtension (XmlPullParser parser)
throws Exception { throws Exception {
Map metaData = MetaDataUtils.parseMetaData(parser); Map<String, List<String>> metaData = MetaDataUtils.parseMetaData(parser);
return new MetaData(metaData); return new MetaData(metaData);
} }

View file

@ -31,6 +31,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -49,7 +50,7 @@ public class OfferRequestProvider implements IQProvider {
int timeout = -1; int timeout = -1;
OfferContent content = null; OfferContent content = null;
boolean done = false; boolean done = false;
Map metaData = new HashMap(); Map<String, List<String>> metaData = new HashMap<String, List<String>>();
if (eventType != XmlPullParser.START_TAG) { if (eventType != XmlPullParser.START_TAG) {
// throw exception // throw exception
@ -111,11 +112,11 @@ public class OfferRequestProvider implements IQProvider {
private int timeout; private int timeout;
private String userID; private String userID;
private String userJID; private String userJID;
private Map metaData; private Map<String, List<String>> metaData;
private String sessionID; private String sessionID;
private OfferContent content; 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) String sessionID, OfferContent content)
{ {
this.userJID = userJID; this.userJID = userJID;
@ -174,7 +175,7 @@ public class OfferRequestProvider implements IQProvider {
* *
* @return meta-data associated with the offer. * @return meta-data associated with the offer.
*/ */
public Map getMetaData() { public Map<String, List<String>> getMetaData() {
return this.metaData; return this.metaData;
} }

View file

@ -45,12 +45,12 @@ public class ChatSettings extends IQ {
*/ */
public static final int BOT_SETTINGS = 2; public static final int BOT_SETTINGS = 2;
private List settings; private List<ChatSetting> settings;
private String key; private String key;
private int type = -1; private int type = -1;
public ChatSettings() { public ChatSettings() {
settings = new ArrayList(); settings = new ArrayList<ChatSetting>();
} }
public ChatSettings(String key) { public ChatSettings(String key) {
@ -69,16 +69,16 @@ public class ChatSettings extends IQ {
settings.add(setting); settings.add(setting);
} }
public Collection getSettings() { public Collection<ChatSetting> getSettings() {
return settings; return settings;
} }
public ChatSetting getChatSetting(String key) { public ChatSetting getChatSetting(String key) {
Collection col = getSettings(); Collection<ChatSetting> col = getSettings();
if (col != null) { if (col != null) {
Iterator iter = col.iterator(); Iterator<ChatSetting> iter = col.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
ChatSetting chatSetting = (ChatSetting)iter.next(); ChatSetting chatSetting = iter.next();
if (chatSetting.getKey().equals(key)) { if (chatSetting.getKey().equals(key)) {
return chatSetting; return chatSetting;
} }

View file

@ -29,7 +29,7 @@ import java.util.Map;
public class GenericSettings extends IQ { public class GenericSettings extends IQ {
private Map map = new HashMap(); private Map<String, String> map = new HashMap<String, String>();
private String query; private String query;
@ -41,11 +41,11 @@ public class GenericSettings extends IQ {
this.query = query; this.query = query;
} }
public Map getMap() { public Map<String, String> getMap() {
return map; return map;
} }
public void setMap(Map map) { public void setMap(Map<String, String> map) {
this.map = map; this.map = map;
} }

View file

@ -58,9 +58,8 @@ public class Workgroup {
private String workgroupJID; private String workgroupJID;
private Connection connection; private Connection connection;
private boolean inQueue; private boolean inQueue;
private List invitationListeners; private List<WorkgroupInvitationListener> invitationListeners;
private List queueListeners; private List<QueueListener> queueListeners;
private List siteInviteListeners;
private int queuePosition = -1; private int queuePosition = -1;
private int queueRemainingTime = -1; private int queueRemainingTime = -1;
@ -84,9 +83,8 @@ public class Workgroup {
this.workgroupJID = workgroupJID; this.workgroupJID = workgroupJID;
this.connection = connection; this.connection = connection;
inQueue = false; inQueue = false;
invitationListeners = new ArrayList(); invitationListeners = new ArrayList<WorkgroupInvitationListener>();
queueListeners = new ArrayList(); queueListeners = new ArrayList<QueueListener>();
siteInviteListeners = new ArrayList();
// Register as a queue listener for internal usage by this instance. // Register as a queue listener for internal usage by this instance.
addQueueListener(new QueueListener() { addQueueListener(new QueueListener() {
@ -378,7 +376,7 @@ public class Workgroup {
* that a connection failure occured or that the server explicitly rejected the * that a connection failure occured or that the server explicitly rejected the
* request to join the queue. * 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 already in the queue ignore the join request.
if (inQueue) { if (inQueue) {
throw new IllegalStateException("Already in queue " + workgroupJID); throw new IllegalStateException("Already in queue " + workgroupJID);
@ -386,10 +384,10 @@ public class Workgroup {
// Build dataform from metadata // Build dataform from metadata
Form form = new Form(Form.TYPE_SUBMIT); Form form = new Form(Form.TYPE_SUBMIT);
Iterator iter = metadata.keySet().iterator(); Iterator<String> iter = metadata.keySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
String name = (String)iter.next(); String name = iter.next();
String value = (String)metadata.get(name).toString(); String value = metadata.get(name).toString();
String escapedName = StringUtils.escapeForXML(name); String escapedName = StringUtils.escapeForXML(name);
String escapedValue = StringUtils.escapeForXML(value); String escapedValue = StringUtils.escapeForXML(value);
@ -489,8 +487,8 @@ public class Workgroup {
private void fireInvitationEvent(WorkgroupInvitation invitation) { private void fireInvitationEvent(WorkgroupInvitation invitation) {
synchronized (invitationListeners) { synchronized (invitationListeners) {
for (Iterator i = invitationListeners.iterator(); i.hasNext();) { for (Iterator<WorkgroupInvitationListener> i = invitationListeners.iterator(); i.hasNext();) {
WorkgroupInvitationListener listener = (WorkgroupInvitationListener)i.next(); WorkgroupInvitationListener listener = i.next();
listener.invitationReceived(invitation); listener.invitationReceived(invitation);
} }
} }
@ -498,8 +496,8 @@ public class Workgroup {
private void fireQueueJoinedEvent() { private void fireQueueJoinedEvent() {
synchronized (queueListeners) { synchronized (queueListeners) {
for (Iterator i = queueListeners.iterator(); i.hasNext();) { for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
QueueListener listener = (QueueListener)i.next(); QueueListener listener = i.next();
listener.joinedQueue(); listener.joinedQueue();
} }
} }
@ -507,8 +505,8 @@ public class Workgroup {
private void fireQueueDepartedEvent() { private void fireQueueDepartedEvent() {
synchronized (queueListeners) { synchronized (queueListeners) {
for (Iterator i = queueListeners.iterator(); i.hasNext();) { for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
QueueListener listener = (QueueListener)i.next(); QueueListener listener = i.next();
listener.departedQueue(); listener.departedQueue();
} }
} }
@ -516,8 +514,8 @@ public class Workgroup {
private void fireQueuePositionEvent(int currentPosition) { private void fireQueuePositionEvent(int currentPosition) {
synchronized (queueListeners) { synchronized (queueListeners) {
for (Iterator i = queueListeners.iterator(); i.hasNext();) { for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
QueueListener listener = (QueueListener)i.next(); QueueListener listener = i.next();
listener.queuePositionUpdated(currentPosition); listener.queuePositionUpdated(currentPosition);
} }
} }
@ -525,8 +523,8 @@ public class Workgroup {
private void fireQueueTimeEvent(int secondsRemaining) { private void fireQueueTimeEvent(int secondsRemaining) {
synchronized (queueListeners) { synchronized (queueListeners) {
for (Iterator i = queueListeners.iterator(); i.hasNext();) { for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
QueueListener listener = (QueueListener)i.next(); QueueListener listener = i.next();
listener.queueWaitTimeUpdated(secondsRemaining); listener.queueWaitTimeUpdated(secondsRemaining);
} }
} }
@ -560,7 +558,7 @@ public class Workgroup {
MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null; MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null;
if (invite != null && workgroupJID.equals(invite.getFrom())) { if (invite != null && workgroupJID.equals(invite.getFrom())) {
String sessionID = null; String sessionID = null;
Map metaData = null; Map<String, List<String>> metaData = null;
pe = msg.getExtension(SessionID.ELEMENT_NAME, pe = msg.getExtension(SessionID.ELEMENT_NAME,
SessionID.NAMESPACE); SessionID.NAMESPACE);

View file

@ -17,7 +17,8 @@
package org.jivesoftware.smackx.workgroup.util; package org.jivesoftware.smackx.workgroup.util;
import java.lang.reflect.Method; 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 * 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 public class ListenerEventDispatcher
implements Runnable { implements Runnable {
protected transient ArrayList triplets; protected transient ArrayList<TripletContainer> triplets;
protected transient boolean hasFinishedDispatching; protected transient boolean hasFinishedDispatching;
protected transient boolean isRunning; protected transient boolean isRunning;
@ -42,7 +43,7 @@ public class ListenerEventDispatcher
public ListenerEventDispatcher () { public ListenerEventDispatcher () {
super(); super();
this.triplets = new ArrayList(); this.triplets = new ArrayList<TripletContainer>();
this.hasFinishedDispatching = false; this.hasFinishedDispatching = false;
this.isRunning = false; this.isRunning = false;
@ -81,13 +82,13 @@ public class ListenerEventDispatcher
} }
public void run() { public void run() {
ListIterator li = null; ListIterator<TripletContainer> li = null;
this.isRunning = true; this.isRunning = true;
li = this.triplets.listIterator(); li = this.triplets.listIterator();
while (li.hasNext()) { while (li.hasNext()) {
TripletContainer tc = (TripletContainer)li.next(); TripletContainer tc = li.next();
try { try {
tc.getListenerMethod().invoke(tc.getListenerInstance(), tc.getMethodArguments()); tc.getListenerMethod().invoke(tc.getListenerInstance(), tc.getMethodArguments());

View file

@ -40,14 +40,14 @@ public class MetaDataUtils {
* @throws XmlPullParserException if an error occurs while parsing the XML. * @throws XmlPullParserException if an error occurs while parsing the XML.
* @throws IOException 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(); int eventType = parser.getEventType();
// If correctly positioned on an opening meta-data tag, parse meta-data. // If correctly positioned on an opening meta-data tag, parse meta-data.
if ((eventType == XmlPullParser.START_TAG) if ((eventType == XmlPullParser.START_TAG)
&& parser.getName().equals(MetaData.ELEMENT_NAME) && parser.getName().equals(MetaData.ELEMENT_NAME)
&& parser.getNamespace().equals(MetaData.NAMESPACE)) { && parser.getNamespace().equals(MetaData.NAMESPACE)) {
Map metaData = new Hashtable(); Map<String, List<String>> metaData = new Hashtable<String, List<String>>();
eventType = parser.nextTag(); eventType = parser.nextTag();
@ -58,11 +58,11 @@ public class MetaDataUtils {
String value = parser.nextText(); String value = parser.nextText();
if (metaData.containsKey(name)) { if (metaData.containsKey(name)) {
List values = (List)metaData.get(name); List<String> values = metaData.get(name);
values.add(value); values.add(value);
} }
else { else {
List values = new ArrayList(); List<String> values = new ArrayList<String>();
values.add(value); values.add(value);
metaData.put(name, values); metaData.put(name, values);
} }
@ -73,37 +73,29 @@ public class MetaDataUtils {
return metaData; return metaData;
} }
return Collections.EMPTY_MAP; return Collections.emptyMap();
} }
/** /**
* Serializes a Map of String name/value pairs into the meta-data XML format. * 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&lt;String,List&lt;String>>
* @return the meta-data values in XML form. * @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(); StringBuilder buf = new StringBuilder();
if (metaData != null && metaData.size() > 0) { if (metaData != null && metaData.size() > 0) {
buf.append("<metadata xmlns=\"http://jivesoftware.com/protocol/workgroup\">"); buf.append("<metadata xmlns=\"http://jivesoftware.com/protocol/workgroup\">");
for (Iterator i = metaData.keySet().iterator(); i.hasNext();) { for (Iterator<String> i = metaData.keySet().iterator(); i.hasNext();) {
Object key = i.next(); String key = i.next();
Object value = metaData.get(key); List<String> value = metaData.get(key);
if (value instanceof List) { for (Iterator<String> it = value.iterator(); it.hasNext();) {
List values = (List)metaData.get(key); String v = it.next();
for (Iterator it = values.iterator(); it.hasNext();) {
String v = (String)it.next();
buf.append("<value name=\"").append(key).append("\">"); buf.append("<value name=\"").append(key).append("\">");
buf.append(StringUtils.escapeForXML(v)); buf.append(StringUtils.escapeForXML(v));
buf.append("</value>"); buf.append("</value>");
} }
} }
else if (value instanceof String) {
buf.append("<value name=\"").append(key).append("\">");
buf.append(StringUtils.escapeForXML((String)value));
buf.append("</value>");
}
}
buf.append("</metadata>"); buf.append("</metadata>");
} }
return buf.toString(); return buf.toString();

View file

@ -240,8 +240,6 @@ public final class ModelUtil {
final long MS_IN_AN_HOUR = 1000 * 60 * 60; final long MS_IN_AN_HOUR = 1000 * 60 * 60;
final long MS_IN_A_MINUTE = 1000 * 60; final long MS_IN_A_MINUTE = 1000 * 60;
final long MS_IN_A_SECOND = 1000; final long MS_IN_A_SECOND = 1000;
Date currentTime = new Date();
long numDays = diff / MS_IN_A_DAY;
diff = diff % MS_IN_A_DAY; diff = diff % MS_IN_A_DAY;
long numHours = diff / MS_IN_AN_HOUR; long numHours = diff / MS_IN_AN_HOUR;
diff = 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; diff = diff % MS_IN_A_MINUTE;
long numSeconds = diff / MS_IN_A_SECOND; long numSeconds = diff / MS_IN_A_SECOND;
diff = diff % MS_IN_A_SECOND; diff = diff % MS_IN_A_SECOND;
long numMilliseconds = diff;
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
if (numHours > 0) { if (numHours > 0) {
@ -270,8 +267,8 @@ public final class ModelUtil {
/** /**
* Build a List of all elements in an Iterator. * Build a List of all elements in an Iterator.
*/ */
public static List iteratorAsList(Iterator i) { public static <T> List<T> iteratorAsList(Iterator<T> i) {
ArrayList list = new ArrayList(10); ArrayList<T> list = new ArrayList<T>(10);
while (i.hasNext()) { while (i.hasNext()) {
list.add(i.next()); list.add(i.next());
} }
@ -281,18 +278,18 @@ public final class ModelUtil {
/** /**
* Creates an Iterator that is the reverse of a ListIterator. * Creates an Iterator that is the reverse of a ListIterator.
*/ */
public static Iterator reverseListIterator(ListIterator i) { public static <T> Iterator<T> reverseListIterator(ListIterator<T> i) {
return new ReverseListIterator(i); return new ReverseListIterator<T>(i);
} }
} }
/** /**
* An Iterator that is the reverse of a ListIterator. * An Iterator that is the reverse of a ListIterator.
*/ */
class ReverseListIterator implements Iterator { class ReverseListIterator<T> implements Iterator<T> {
private ListIterator _i; private ListIterator<T> _i;
ReverseListIterator(ListIterator i) { ReverseListIterator(ListIterator<T> i) {
_i = i; _i = i;
while (_i.hasNext()) while (_i.hasNext())
_i.next(); _i.next();
@ -302,13 +299,14 @@ class ReverseListIterator implements Iterator {
return _i.hasPrevious(); return _i.hasPrevious();
} }
public Object next() { public T next() {
return _i.previous(); return _i.previous();
} }
public void remove() { public void remove() {
_i.remove(); _i.remove();
} }
} }

View file

@ -1,32 +0,0 @@
package org.jivesoftware.smack;
import org.junit.Test;
import static org.junit.Assert.*;
public class SmackConfigTest
{
@Test
public void validatePacketCollectorSize()
{
assertEquals(10000, SmackConfiguration.getPacketCollectorSize());
}
@Test
public void validateKeepAliveInterval()
{
assertEquals(30000, SmackConfiguration.getKeepAliveInterval());
}
@Test
public void validateLocalSocks5ProxyPort()
{
assertEquals(7777, SmackConfiguration.getLocalSocks5ProxyPort());
}
@Test
public void validateIsLocalSocks5Proxy()
{
assertTrue(SmackConfiguration.isLocalSocks5ProxyEnabled());
}
}

View file

@ -142,9 +142,9 @@ public class Protocol {
} }
} }
Verification<?, ?>[] verifications = verificationList.get(i); Verification<Packet, Packet>[] verifications = (Verification<Packet, Packet>[]) verificationList.get(i);
if (verifications != null) { if (verifications != null) {
for (Verification verification : verifications) { for (Verification<Packet, Packet> verification : verifications) {
verification.verify(request, response); verification.verify(request, response);
} }
} }

View file

@ -3,12 +3,12 @@
<testcase> <testcase>
<!-- Host and port of the XMPP server to use --> <!-- Host and port of the XMPP server to use -->
<host>localhost</host> <host>sanctuary</host>
<port>5222</port> <port>5222</port>
<!-- Username prefix to use for creating accounts. Same value will be used for passwords. --> <!-- Username prefix to use for creating accounts. Same value will be used for passwords. -->
<username>user</username> <username>user</username>
<password same='true'>passw0rd</password>
<!-- Chat and MUC domain names to use --> <!-- Chat and MUC domain names to use -->
<chat>chat</chat> <chat>chat</chat>
<muc>conference</muc> <muc>conference</muc>

View file

@ -3,6 +3,7 @@ package org.jivesoftware.smack;
import java.util.List; import java.util.List;
import org.jivesoftware.smack.packet.Privacy; import org.jivesoftware.smack.packet.Privacy;
import org.jivesoftware.smack.packet.PrivacyItem;
/** /**
* This class supports automated tests about privacy communication from the * This class supports automated tests about privacy communication from the
@ -27,7 +28,7 @@ public class PrivacyClient implements PrivacyListListener {
super(); super();
} }
public void setPrivacyList(String listName, List listItem) { public void setPrivacyList(String listName, List<PrivacyItem> listItem) {
privacy.setPrivacyList(listName, listItem); privacy.setPrivacyList(listName, listItem);
} }

View file

@ -60,8 +60,6 @@ import org.jivesoftware.smack.packet.*;
*/ */
public class PacketTypeFilterTest extends TestCase { public class PacketTypeFilterTest extends TestCase {
private class Dummy {}
private class InnerClassDummy { private class InnerClassDummy {
public class DummyPacket extends Packet { public class DummyPacket extends Packet {
public String toXML() { public String toXML() {
@ -88,12 +86,13 @@ public class PacketTypeFilterTest extends TestCase {
* Test case for the constructor of PacketTypeFilter objects. * Test case for the constructor of PacketTypeFilter objects.
*/ */
public void testConstructor() { public void testConstructor() {
// We dont need to test this since PacketTypeFilter(Class<? extends Packet> packetType) only excepts Packets
// Test a class that is not a subclass of Packet // Test a class that is not a subclass of Packet
try { // try {
new PacketTypeFilter(Dummy.class); // new PacketTypeFilter(Dummy.class);
fail("Parameter must be a subclass of Packet."); // fail("Parameter must be a subclass of Packet.");
} // }
catch (IllegalArgumentException e) {} // catch (IllegalArgumentException e) {}
// Test a class that is a subclass of Packet // Test a class that is a subclass of Packet
try { try {

View file

@ -52,8 +52,6 @@
package org.jivesoftware.smack.packet; package org.jivesoftware.smack.packet;
import java.util.*;
/** /**
* A mock implementation of the Packet abstract class. Implements toXML() by returning null. * A mock implementation of the Packet abstract class. Implements toXML() by returning null.
*/ */

View file

@ -45,11 +45,11 @@ public class PrivacyTest extends SmackTestCase {
// Assert the list composition. // Assert the list composition.
assertEquals(listName, privacyManager.getActiveList().toString()); assertEquals(listName, privacyManager.getActiveList().toString());
List privacyItems = privacyManager.getPrivacyList(listName).getItems(); List<PrivacyItem> privacyItems = privacyManager.getPrivacyList(listName).getItems();
assertEquals(1, privacyItems.size()); assertEquals(1, privacyItems.size());
// Assert the privacy item composition // Assert the privacy item composition
PrivacyItem receivedItem = (PrivacyItem) privacyItems.get(0); PrivacyItem receivedItem = privacyItems.get(0);
assertEquals(1, receivedItem.getOrder()); assertEquals(1, receivedItem.getOrder());
assertEquals(PrivacyItem.Type.jid, receivedItem.getType()); assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
assertEquals(true, receivedItem.isAllow()); assertEquals(true, receivedItem.isAllow());
@ -278,11 +278,11 @@ public class PrivacyTest extends SmackTestCase {
// Assert the list composition. // Assert the list composition.
assertEquals(listName, privacyManager.getDefaultList().toString()); assertEquals(listName, privacyManager.getDefaultList().toString());
List privacyItems = privacyManager.getPrivacyList(listName).getItems(); List<PrivacyItem> privacyItems = privacyManager.getPrivacyList(listName).getItems();
assertEquals(1, privacyItems.size()); assertEquals(1, privacyItems.size());
// Assert the privacy item composition // Assert the privacy item composition
PrivacyItem receivedItem = (PrivacyItem) privacyItems.get(0); PrivacyItem receivedItem = privacyItems.get(0);
assertEquals(1, receivedItem.getOrder()); assertEquals(1, receivedItem.getOrder());
assertEquals(PrivacyItem.Type.jid, receivedItem.getType()); assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
assertEquals(true, receivedItem.isAllow()); assertEquals(true, receivedItem.isAllow());
@ -427,7 +427,7 @@ public class PrivacyTest extends SmackTestCase {
Thread.sleep(500); Thread.sleep(500);
// Assert the server list composition. // Assert the server list composition.
List privacyItems = privacyManager.getPrivacyList(listName).getItems(); List<PrivacyItem> privacyItems = privacyManager.getPrivacyList(listName).getItems();
assertEquals(originalPrivacyItems.length, privacyItems.size()); assertEquals(originalPrivacyItems.length, privacyItems.size());
// Assert the local and server privacy item composition // Assert the local and server privacy item composition
@ -436,7 +436,7 @@ public class PrivacyTest extends SmackTestCase {
int index; int index;
for (int j = 0; j < originalPrivacyItems.length; j++) { for (int j = 0; j < originalPrivacyItems.length; j++) {
// Look for the same server and original items // Look for the same server and original items
receivedItem = (PrivacyItem) privacyItems.get(j); receivedItem = privacyItems.get(j);
index = 0; index = 0;
while ((index < originalPrivacyItems.length) while ((index < originalPrivacyItems.length)
&& (originalPrivacyItems[index].getOrder() != receivedItem.getOrder())) { && (originalPrivacyItems[index].getOrder() != receivedItem.getOrder())) {

View file

@ -353,17 +353,17 @@ public abstract class SmackTestCase extends TestCase {
try { try {
boolean found = false; boolean found = false;
// Try to load the configutation from an XML file specific for this test case // Try to load the configutation from an XML file specific for this test case
Enumeration resources = Enumeration<URL> resources =
ClassLoader.getSystemClassLoader().getResources(getConfigurationFilename()); ClassLoader.getSystemClassLoader().getResources(getConfigurationFilename());
while (resources.hasMoreElements()) { while (resources.hasMoreElements()) {
found = parseURL((URL) resources.nextElement()); found = parseURL(resources.nextElement());
} }
// If none was found then try to load the configuration from the default configuration // If none was found then try to load the configuration from the default configuration
// file (i.e. "config/test-case.xml") // file (i.e. "config/test-case.xml")
if (!found) { if (!found) {
resources = ClassLoader.getSystemClassLoader().getResources("config/test-case.xml"); resources = ClassLoader.getSystemClassLoader().getResources("config/test-case.xml");
while (resources.hasMoreElements()) { while (resources.hasMoreElements()) {
found = parseURL((URL) resources.nextElement()); found = parseURL(resources.nextElement());
} }
} }
if (!found) { if (!found) {

View file

@ -57,9 +57,9 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
Message message = new Message(); Message message = new Message();
message.setBody("Hola"); message.setBody("Hola");
List to = Arrays.asList(new String[]{getBareJID(1)}); List<String> to = Arrays.asList(new String[]{getBareJID(1)});
List cc = Arrays.asList(new String[]{getBareJID(2)}); List<String> cc = Arrays.asList(new String[]{getBareJID(2)});
List bcc = Arrays.asList(new String[]{getBareJID(3)}); List<String> bcc = Arrays.asList(new String[]{getBareJID(3)});
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc); MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc);
Packet message1 = collector1.nextResult(SmackConfiguration.getPacketReplyTimeout()); Packet message1 = collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
@ -67,7 +67,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
MultipleRecipientInfo info1 = MultipleRecipientManager.getMultipleRecipientInfo(message1); MultipleRecipientInfo info1 = MultipleRecipientManager.getMultipleRecipientInfo(message1);
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info1); assertNotNull("Message 1 does not contain MultipleRecipientInfo", info1);
assertFalse("Message 1 should be 'replyable'", info1.shouldNotReply()); assertFalse("Message 1 should be 'replyable'", info1.shouldNotReply());
List addresses1 = info1.getTOAddresses(); List<?> addresses1 = info1.getTOAddresses();
assertEquals("Incorrect number of TO addresses", 1, addresses1.size()); assertEquals("Incorrect number of TO addresses", 1, addresses1.size());
String address1 = ((MultipleAddresses.Address) addresses1.get(0)).getJid(); String address1 = ((MultipleAddresses.Address) addresses1.get(0)).getJid();
assertEquals("Incorrect TO address", getBareJID(1), address1); assertEquals("Incorrect TO address", getBareJID(1), address1);
@ -81,7 +81,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
MultipleRecipientInfo info2 = MultipleRecipientManager.getMultipleRecipientInfo(message2); MultipleRecipientInfo info2 = MultipleRecipientManager.getMultipleRecipientInfo(message2);
assertNotNull("Message 2 does not contain MultipleRecipientInfo", info2); assertNotNull("Message 2 does not contain MultipleRecipientInfo", info2);
assertFalse("Message 2 should be 'replyable'", info2.shouldNotReply()); assertFalse("Message 2 should be 'replyable'", info2.shouldNotReply());
List addresses2 = info2.getTOAddresses(); List<MultipleAddresses.Address> addresses2 = info2.getTOAddresses();
assertEquals("Incorrect number of TO addresses", 1, addresses2.size()); assertEquals("Incorrect number of TO addresses", 1, addresses2.size());
String address2 = ((MultipleAddresses.Address) addresses2.get(0)).getJid(); String address2 = ((MultipleAddresses.Address) addresses2.get(0)).getJid();
assertEquals("Incorrect TO address", getBareJID(1), address2); assertEquals("Incorrect TO address", getBareJID(1), address2);
@ -95,7 +95,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
MultipleRecipientInfo info3 = MultipleRecipientManager.getMultipleRecipientInfo(message3); MultipleRecipientInfo info3 = MultipleRecipientManager.getMultipleRecipientInfo(message3);
assertNotNull("Message 3 does not contain MultipleRecipientInfo", info3); assertNotNull("Message 3 does not contain MultipleRecipientInfo", info3);
assertFalse("Message 3 should be 'replyable'", info3.shouldNotReply()); assertFalse("Message 3 should be 'replyable'", info3.shouldNotReply());
List addresses3 = info3.getTOAddresses(); List<MultipleAddresses.Address> addresses3 = info3.getTOAddresses();
assertEquals("Incorrect number of TO addresses", 1, addresses3.size()); assertEquals("Incorrect number of TO addresses", 1, addresses3.size());
String address3 = ((MultipleAddresses.Address) addresses3.get(0)).getJid(); String address3 = ((MultipleAddresses.Address) addresses3.get(0)).getJid();
assertEquals("Incorrect TO address", getBareJID(1), address3); assertEquals("Incorrect TO address", getBareJID(1), address3);
@ -125,9 +125,9 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
// Send the intial message with multiple recipients // Send the intial message with multiple recipients
Message message = new Message(); Message message = new Message();
message.setBody("Hola"); message.setBody("Hola");
List to = Arrays.asList(new String[]{getBareJID(1)}); List<String> to = Arrays.asList(new String[]{getBareJID(1)});
List cc = Arrays.asList(new String[]{getBareJID(2)}); List<String> cc = Arrays.asList(new String[]{getBareJID(2)});
List bcc = Arrays.asList(new String[]{getBareJID(3)}); List<String> bcc = Arrays.asList(new String[]{getBareJID(3)});
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc); MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc);
// Get the message and ensure it's ok // Get the message and ensure it's ok
@ -205,9 +205,9 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
// Send the intial message with multiple recipients // Send the intial message with multiple recipients
Message message = new Message(); Message message = new Message();
message.setBody("Hola"); message.setBody("Hola");
List to = Arrays.asList(new String[]{getBareJID(1)}); List<String> to = Arrays.asList(new String[]{getBareJID(1)});
List cc = Arrays.asList(new String[]{getBareJID(2)}); List<String> cc = Arrays.asList(new String[]{getBareJID(2)});
List bcc = Arrays.asList(new String[]{getBareJID(3)}); List<String> bcc = Arrays.asList(new String[]{getBareJID(3)});
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc, null, null, true); MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc, null, null, true);
// Get the message and ensure it's ok // Get the message and ensure it's ok

View file

@ -74,22 +74,22 @@ public class OfflineMessageManagerTest extends SmackTestCase {
OfflineMessageManager offlineManager = new OfflineMessageManager(getConnection(1)); OfflineMessageManager offlineManager = new OfflineMessageManager(getConnection(1));
assertEquals("Wrong number of offline messages", 2, offlineManager.getMessageCount()); assertEquals("Wrong number of offline messages", 2, offlineManager.getMessageCount());
// Check the message headers // Check the message headers
Iterator headers = offlineManager.getHeaders(); Iterator<OfflineMessageHeader> headers = offlineManager.getHeaders();
assertTrue("No message header was found", headers.hasNext()); assertTrue("No message header was found", headers.hasNext());
List<String> stamps = new ArrayList<String>(); List<String> stamps = new ArrayList<String>();
while (headers.hasNext()) { while (headers.hasNext()) {
OfflineMessageHeader header = (OfflineMessageHeader) headers.next(); OfflineMessageHeader header = headers.next();
assertEquals("Incorrect sender", getFullJID(0), header.getJid()); assertEquals("Incorrect sender", getFullJID(0), header.getJid());
assertNotNull("No stamp was found in the message header", header.getStamp()); assertNotNull("No stamp was found in the message header", header.getStamp());
stamps.add(header.getStamp()); stamps.add(header.getStamp());
} }
assertEquals("Wrong number of headers", 2, stamps.size()); assertEquals("Wrong number of headers", 2, stamps.size());
// Get the offline messages // Get the offline messages
Iterator messages = offlineManager.getMessages(stamps); Iterator<Message> messages = offlineManager.getMessages(stamps);
assertTrue("No message was found", messages.hasNext()); assertTrue("No message was found", messages.hasNext());
stamps = new ArrayList<String>(); stamps = new ArrayList<String>();
while (messages.hasNext()) { while (messages.hasNext()) {
Message message = (Message) messages.next(); Message message = messages.next();
OfflineMessageInfo info = (OfflineMessageInfo) message.getExtension("offline", OfflineMessageInfo info = (OfflineMessageInfo) message.getExtension("offline",
"http://jabber.org/protocol/offline"); "http://jabber.org/protocol/offline");
assertNotNull("No offline information was included in the offline message", info); assertNotNull("No offline information was included in the offline message", info);
@ -143,11 +143,11 @@ public class OfflineMessageManagerTest extends SmackTestCase {
OfflineMessageManager offlineManager = new OfflineMessageManager(getConnection(1)); OfflineMessageManager offlineManager = new OfflineMessageManager(getConnection(1));
assertEquals("Wrong number of offline messages", 2, offlineManager.getMessageCount()); assertEquals("Wrong number of offline messages", 2, offlineManager.getMessageCount());
// Get all offline messages // Get all offline messages
Iterator messages = offlineManager.getMessages(); Iterator<Message> messages = offlineManager.getMessages();
assertTrue("No message was found", messages.hasNext()); assertTrue("No message was found", messages.hasNext());
List<String> stamps = new ArrayList<String>(); List<String> stamps = new ArrayList<String>();
while (messages.hasNext()) { while (messages.hasNext()) {
Message message = (Message) messages.next(); Message message = messages.next();
OfflineMessageInfo info = (OfflineMessageInfo) message.getExtension("offline", OfflineMessageInfo info = (OfflineMessageInfo) message.getExtension("offline",
"http://jabber.org/protocol/offline"); "http://jabber.org/protocol/offline");
assertNotNull("No offline information was included in the offline message", info); assertNotNull("No offline information was included in the offline message", info);

View file

@ -128,14 +128,14 @@ public class RosterExchangeManagerTest extends SmackTestCase {
// Create a RosterExchangeListener that will iterate over the received roster entries // Create a RosterExchangeListener that will iterate over the received roster entries
RosterExchangeListener rosterExchangeListener = new RosterExchangeListener() { RosterExchangeListener rosterExchangeListener = new RosterExchangeListener() {
public void entriesReceived(String from, Iterator remoteRosterEntries) { public void entriesReceived(String from, Iterator<RemoteRosterEntry> remoteRosterEntries) {
int received = 0; int received = 0;
assertNotNull("From is null", from); assertNotNull("From is null", from);
assertNotNull("rosterEntries is null", remoteRosterEntries); assertNotNull("rosterEntries is null", remoteRosterEntries);
assertTrue("Roster without entries", remoteRosterEntries.hasNext()); assertTrue("Roster without entries", remoteRosterEntries.hasNext());
while (remoteRosterEntries.hasNext()) { while (remoteRosterEntries.hasNext()) {
received++; received++;
RemoteRosterEntry remoteEntry = (RemoteRosterEntry) remoteRosterEntries.next(); RemoteRosterEntry remoteEntry = remoteRosterEntries.next();
System.out.println(remoteEntry); System.out.println(remoteEntry);
} }
entriesReceived = received; entriesReceived = received;
@ -178,7 +178,7 @@ public class RosterExchangeManagerTest extends SmackTestCase {
// Create a RosterExchangeListener that will accept all the received roster entries // Create a RosterExchangeListener that will accept all the received roster entries
RosterExchangeListener rosterExchangeListener = new RosterExchangeListener() { RosterExchangeListener rosterExchangeListener = new RosterExchangeListener() {
public void entriesReceived(String from, Iterator remoteRosterEntries) { public void entriesReceived(String from, Iterator<RemoteRosterEntry> remoteRosterEntries) {
int received = 0; int received = 0;
assertNotNull("From is null", from); assertNotNull("From is null", from);
assertNotNull("remoteRosterEntries is null", remoteRosterEntries); assertNotNull("remoteRosterEntries is null", remoteRosterEntries);
@ -186,8 +186,7 @@ public class RosterExchangeManagerTest extends SmackTestCase {
while (remoteRosterEntries.hasNext()) { while (remoteRosterEntries.hasNext()) {
received++; received++;
try { try {
RemoteRosterEntry remoteRosterEntry = RemoteRosterEntry remoteRosterEntry = remoteRosterEntries.next();
(RemoteRosterEntry) remoteRosterEntries.next();
getConnection(1).getRoster().createEntry( getConnection(1).getRoster().createEntry(
remoteRosterEntry.getUser(), remoteRosterEntry.getUser(),
remoteRosterEntry.getName(), remoteRosterEntry.getName(),

Some files were not shown because too many files have changed in this diff Show more