1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

SMACK-363 Applied code cleanup patches for many generics related issues.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13325 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
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,8 +10,9 @@ import org.jivesoftware.smackx.packet.JingleError;
* @author Alvaro Saurin <alvaro.saurin@gmail.com>
*/
public class JingleException extends XMPPException {
private final JingleError error;
private static final long serialVersionUID = -1521230401958103382L;
private final JingleError error;
/**
* Default constructor.

View file

@ -215,13 +215,13 @@ public class JingleManager implements JingleSessionListener {
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) {

View file

@ -96,7 +96,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
private static final SmackLogger LOGGER = SmackLogger.getLogger(JingleSession.class);
// 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();
@ -116,14 +116,10 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
protected List<JingleMediaManager> jingleMediaManagers = null;
private boolean closed = false;
private JingleSessionState sessionState;
private List<ContentNegotiator> contentNegotiators;
private JingleSessionRequest sessionRequest;
private Connection connection;
private String sessionInitPacketID;
@ -181,7 +177,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
public JingleSession(Connection conn, JingleSessionRequest request, String initiator, String responder,
List<JingleMediaManager> 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.");
// }
// }
/**
* @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.
@ -670,7 +643,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
JingleSession result = null;
synchronized (sessions) {
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.)
* @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);
}
@ -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.
* @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);
}
@ -63,9 +63,9 @@ public class SmackLogger {
* @param classToLog
* @return
*/
private void setupSmackLogger(Class classToLog) {
private void setupSmackLogger(Class<?> classToLog) {
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);
//Constructor<Log> constructor = Log.class.getConstructor(new Class[] { Object.class });
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 {
IQ response = null;
PayloadType.Audio agreedCommonAudioPt;
List offeredPayloads = new ArrayList();
List<PayloadType> offeredPayloads = new ArrayList<PayloadType>();
if (bestCommonAudioPt == null) {
// Update the best common audio PT
@ -358,7 +358,7 @@ public class MediaNegotiator extends JingleNegotiator {
// Payload types
private PayloadType calculateBestCommonAudioPt(List remoteAudioPts) {
private PayloadType calculateBestCommonAudioPt(List<PayloadType> remoteAudioPts) {
final ArrayList<PayloadType> commonAudioPtsHere = new ArrayList<PayloadType>();
final ArrayList<PayloadType> commonAudioPtsThere = new ArrayList<PayloadType>();
PayloadType result = null;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -65,7 +65,7 @@ import org.jivesoftware.smackx.jingle.SmackLogger;
*
* @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);
@ -438,18 +438,14 @@ public class ICECandidate extends TransportCandidate implements Comparable {
* object is less than, equal to, or greater than the specified
* object
*/
public int compareTo(Object arg) {
if (arg instanceof ICECandidate) {
ICECandidate tc = (ICECandidate) arg;
if (getPreference() < tc.getPreference()) {
return -1;
}
else if (getPreference() > tc.getPreference()) {
return 1;
}
}
return 0;
}
public int compareTo(ICECandidate arg) {
if (getPreference() < arg.getPreference()) {
return -1;
} else if (getPreference() > arg.getPreference()) {
return 1;
}
return 0;
}
}

View file

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

View file

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

View file

@ -230,9 +230,9 @@ public class STUN extends IQ {
try {
DiscoverItems items = disco.discoverItems(connection.getServiceName());
Iterator iter = items.getItems();
Iterator<DiscoverItems.Item> iter = items.getItems();
while (iter.hasNext()) {
DiscoverItems.Item item = (DiscoverItems.Item) iter.next();
DiscoverItems.Item item = iter.next();
DiscoverInfo info = disco.discoverInfo(item.getEntityID());
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.
* @return A list of loaded servers
*/
public ArrayList loadSTUNServers(java.io.InputStream stunConfigStream) {
ArrayList serversList = new ArrayList();
public ArrayList<STUNService> loadSTUNServers(java.io.InputStream stunConfigStream) {
ArrayList<STUNService> serversList = new ArrayList<STUNService>();
String serverName;
int serverPort;
@ -216,8 +216,8 @@ public class STUNResolver extends TransportResolver {
*
* @return a list of services
*/
public ArrayList loadSTUNServers() {
ArrayList serversList = new ArrayList();
public ArrayList<STUNService> loadSTUNServers() {
ArrayList<STUNService> serversList = new ArrayList<STUNService>();
// Load the STUN configuration
try {
@ -228,11 +228,11 @@ public class STUNResolver extends TransportResolver {
classLoaders[1] = Thread.currentThread().getContextClassLoader();
for (int i = 0; i < classLoaders.length; i++) {
Enumeration stunConfigEnum = classLoaders[i]
Enumeration<URL> stunConfigEnum = classLoaders[i]
.getResources(STUNSERVERS_FILENAME);
while (stunConfigEnum.hasMoreElements() && serversList.isEmpty()) {
URL url = (URL) stunConfigEnum.nextElement();
URL url = stunConfigEnum.nextElement();
java.io.InputStream stunConfigStream = null;
stunConfigStream = url.openStream();
@ -253,12 +253,12 @@ public class STUNResolver extends TransportResolver {
*
* @return the best STUN server that can be used.
*/
private STUNService bestSTUNServer(ArrayList listServers) {
private STUNService bestSTUNServer(ArrayList<STUNService> listServers) {
if (listServers.isEmpty()) {
return null;
} else {
// 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
// to the STUN server for our address.
try {
Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
String candAddress;
int candPort;
while (ifaces.hasMoreElements()) {
NetworkInterface iface = (NetworkInterface) ifaces
.nextElement();
Enumeration iaddresses = iface.getInetAddresses();
NetworkInterface iface = ifaces.nextElement();
Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
while (iaddresses.hasMoreElements()) {
InetAddress iaddress = (InetAddress) iaddresses
.nextElement();
InetAddress iaddress = iaddresses.nextElement();
if (!iaddress.isLoopbackAddress()
&& !iaddress.isLinkLocalAddress()) {

View file

@ -66,6 +66,7 @@ import java.util.List;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smackx.jingle.JingleSession;
import org.jivesoftware.smackx.jingle.SmackLogger;
import org.jivesoftware.smackx.jingle.nat.TransportResolverListener.Checker;
/**
* Transport candidate.
@ -103,7 +104,7 @@ public abstract class TransportCandidate {
private Thread echoThread = null;
// 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 {
candidateEcho = new CandidateEcho(this, session);
@ -387,9 +388,9 @@ public abstract class TransportCandidate {
public void run() {
boolean isUsable;
InetAddress candAddress;
try {
candAddress = InetAddress.getByName(getIp());
InetAddress candAddress = InetAddress.getByName(getIp());
isUsable = true;//candAddress.isReachable(TransportResolver.CHECK_TIMEOUT);
}
catch (Exception e) {
@ -425,7 +426,7 @@ public abstract class TransportCandidate {
*/
public List<TransportResolverListener.Checker> getListenersList() {
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.
*/
final ArrayList getValidRemoteCandidatesList() {
final ArrayList<TransportCandidate> getValidRemoteCandidatesList() {
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
* candidates.
*/
public final Iterator getValidRemoteCandidates() {
public final Iterator<TransportCandidate> getValidRemoteCandidates() {
return Collections.unmodifiableList(getRemoteCandidates()).iterator();
}
@ -471,11 +471,11 @@ public abstract class TransportNegotiator extends JingleNegotiator {
*
* @param rc the remote candidate to add.
*/
private void addRemoteCandidates(List rc) {
private void addRemoteCandidates(List<TransportCandidate> rc) {
if (rc != null) {
if (rc.size() > 0) {
for (Object aRc : rc) {
addRemoteCandidate((TransportCandidate) aRc);
for (TransportCandidate aRc : rc) {
addRemoteCandidate(aRc);
}
}
}
@ -829,7 +829,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
*/
public TransportCandidate getBestRemoteCandidate() {
// Hopefully, we only have one validRemoteCandidate
ArrayList cands = getValidRemoteCandidatesList();
ArrayList<TransportCandidate> cands = getValidRemoteCandidatesList();
if (!cands.isEmpty()) {
LOGGER.debug("RAW CAND");
return (TransportCandidate) cands.get(0);
@ -883,14 +883,17 @@ public abstract class TransportNegotiator extends JingleNegotiator {
public TransportCandidate getBestRemoteCandidate() {
ICECandidate result = null;
ArrayList<ICECandidate> cands = getValidRemoteCandidatesList();
ArrayList<TransportCandidate> cands = getValidRemoteCandidatesList();
if (!cands.isEmpty()) {
int highest = -1;
ICECandidate chose = null;
for (ICECandidate transportCandidate : cands) {
if (transportCandidate.getPreference() > highest) {
chose = transportCandidate;
highest = transportCandidate.getPreference();
for (TransportCandidate transportCandidate : cands) {
if (transportCandidate instanceof ICECandidate) {
ICECandidate icecandidate = (ICECandidate) transportCandidate;
if (icecandidate.getPreference() > highest) {
chose = icecandidate;
highest = icecandidate.getPreference();
}
}
}
result = chose;

View file

@ -233,9 +233,9 @@ public abstract class TransportResolver {
*
* @return the list of listeners
*/
public ArrayList getListenersList() {
public ArrayList<TransportResolverListener> getListenersList() {
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.
*/
protected void triggerCandidateAdded(TransportCandidate cand) {
Iterator iter = getListenersList().iterator();
Iterator<TransportResolverListener> iter = getListenersList().iterator();
while (iter.hasNext()) {
TransportResolverListener trl = (TransportResolverListener) iter.next();
TransportResolverListener trl = iter.next();
if (trl instanceof TransportResolverListener.Resolver) {
TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl;
LOGGER.debug("triggerCandidateAdded : " + cand.getLocalIp());
@ -260,9 +260,9 @@ public abstract class TransportResolver {
* Trigger a event notifying the initialization of the resolution process.
*/
private void triggerResolveInit() {
Iterator iter = getListenersList().iterator();
Iterator<TransportResolverListener> iter = getListenersList().iterator();
while (iter.hasNext()) {
TransportResolverListener trl = (TransportResolverListener) iter.next();
TransportResolverListener trl = iter.next();
if (trl instanceof TransportResolverListener.Resolver) {
TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl;
li.init();
@ -274,9 +274,9 @@ public abstract class TransportResolver {
* Trigger a event notifying the obtention of all the candidates.
*/
private void triggerResolveEnd() {
Iterator iter = getListenersList().iterator();
Iterator<TransportResolverListener> iter = getListenersList().iterator();
while (iter.hasNext()) {
TransportResolverListener trl = (TransportResolverListener) iter.next();
TransportResolverListener trl = iter.next();
if (trl instanceof TransportResolverListener.Resolver) {
TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl;
li.end();
@ -315,9 +315,9 @@ public abstract class TransportResolver {
*
* @return an iterator
*/
public Iterator getCandidates() {
public Iterator<TransportCandidate> getCandidates() {
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() {
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) {
Collections.sort(cands);
// Return the last candidate

View file

@ -218,7 +218,7 @@ public class Jingle extends IQ {
*/
public Iterator<JingleContent> getContents() {
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
private final List payloads = new ArrayList();
private final List<JinglePayloadType> payloads = new ArrayList<JinglePayloadType>();
/**
* Creates a content description..
@ -81,11 +81,11 @@ public abstract class JingleContentDescription implements PacketExtension {
*
* @param pts the payloads to add.
*/
public void addAudioPayloadTypes(final List pts) {
public void addAudioPayloadTypes(final List<PayloadType.Audio> pts) {
synchronized (payloads) {
Iterator ptIter = pts.iterator();
Iterator<PayloadType.Audio> ptIter = pts.iterator();
while (ptIter.hasNext()) {
PayloadType.Audio pt = (PayloadType.Audio) ptIter.next();
PayloadType.Audio pt = ptIter.next();
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.
*/
public Iterator getJinglePayloadTypes() {
public Iterator<JinglePayloadType> getJinglePayloadTypes() {
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.
*/
public ArrayList getJinglePayloadTypesList() {
public ArrayList<JinglePayloadType> getJinglePayloadTypesList() {
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
*/
public ArrayList getAudioPayloadTypesList() {
ArrayList result = new ArrayList();
Iterator jinglePtsIter = getJinglePayloadTypes();
public ArrayList<PayloadType.Audio> getAudioPayloadTypesList() {
ArrayList<PayloadType.Audio> result = new ArrayList<PayloadType.Audio>();
Iterator<JinglePayloadType> jinglePtsIter = getJinglePayloadTypes();
while (jinglePtsIter.hasNext()) {
JinglePayloadType jpt = (JinglePayloadType) jinglePtsIter.next();
JinglePayloadType jpt = jinglePtsIter.next();
if (jpt instanceof JinglePayloadType.Audio) {
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(" xmlns=\"").append(getNamespace()).append("\" >");
Iterator pt = payloads.listIterator();
Iterator<JinglePayloadType> pt = payloads.listIterator();
while (pt.hasNext()) {
JinglePayloadType pte = (JinglePayloadType) pt.next();
JinglePayloadType pte = pt.next();
buf.append(pte.toXML());
}
buf.append("</").append(getElementName()).append(">");

View file

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

View file

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

View file

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

View file

@ -1,5 +1,6 @@
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.ICENegociator;
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.PayloadType;
import org.jivesoftware.smackx.jingle.mediaimpl.test.TestMediaManager;
import org.jivesoftware.smackx.jingle.nat.STUNResolver.STUNService;
import java.net.NetworkInterface;
import java.net.SocketException;
@ -182,7 +184,7 @@ public class STUNResolverTest extends SmackTestCase {
public void testLoadSTUNServers() throws Exception {
STUNResolver stunResolver = new STUNResolver() {
};
ArrayList stunServers = stunResolver.loadSTUNServers();
ArrayList<STUNService> stunServers = stunResolver.loadSTUNServers();
assertTrue(stunServers.size() > 0);
System.out.println(stunServers.size() + " servers loaded");
@ -244,8 +246,8 @@ public class STUNResolverTest extends SmackTestCase {
*
* @return A testing list
*/
private ArrayList getTestPayloads1() {
ArrayList result = new ArrayList();
private ArrayList<PayloadType> getTestPayloads1() {
ArrayList<PayloadType> result = new ArrayList<PayloadType>();
result.add(new PayloadType.Audio(34, "supercodec-1", 2, 14000));
result.add(new PayloadType.Audio(56, "supercodec-2", 1, 44000));
@ -255,8 +257,8 @@ public class STUNResolverTest extends SmackTestCase {
return result;
}
private ArrayList getTestPayloads2() {
ArrayList result = new ArrayList();
private ArrayList<PayloadType> getTestPayloads2() {
ArrayList<PayloadType> result = new ArrayList<PayloadType>();
result.add(new PayloadType.Audio(27, "supercodec-3", 2, 28000));
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.Collections;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.net.InetAddress;
import org.jivesoftware.smack.test.SmackTestCase;
@ -35,18 +32,18 @@ public class TransportCandidateTest extends SmackTestCase {
public void testCompareTo() {
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);
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);
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);
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);
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);
ArrayList candList = new ArrayList();
ArrayList<ICECandidate> candList = new ArrayList<ICECandidate>();
candList.add(cand1);
candList.add(cand2);
candList.add(candH);