Fixes Eclipse warnings as a part of issue #637. There's more work on some of these classes but I need to go to bed now :).

cusax-fix
Emil Ivov 17 years ago
parent 63411f94a6
commit a0c5f9fb3d

@ -38,7 +38,8 @@ public class HistoryImpl implements History {
private HistoryWriter writer;
private SortedMap historyDocuments = new TreeMap();
private SortedMap<String, Object> historyDocuments
= new TreeMap<String, Object>();
protected HistoryImpl(HistoryID id, File directory,
HistoryRecordStructure historyRecordStructure,
@ -194,7 +195,7 @@ protected void writeFile(String filename, Document doc)
}
}
protected Iterator getFileList()
protected Iterator<String> getFileList()
{
return this.historyDocuments.keySet().iterator();
}

@ -22,7 +22,8 @@ public class HistoryReaderImpl
implements HistoryReader
{
private HistoryImpl historyImpl;
private Vector progressListeners = new Vector();
private Vector<HistorySearchProgressListener> progressListeners
= new Vector<HistorySearchProgressListener>();
// regexp used for index of case(in)sensitive impl
private static String REGEXP_END = ".*$";
@ -146,10 +147,11 @@ public synchronized QueryResultSet findByPeriod(Date startDate, Date endDate,
public synchronized QueryResultSet findLast(int count) throws RuntimeException
{
// the files are supposed to be ordered from oldest to newest
Vector filelist =
Vector<String> filelist =
filterFilesByDate(this.historyImpl.getFileList(), null, null);
TreeSet result = new TreeSet(new HistoryRecordComparator());
TreeSet<HistoryRecord> result
= new TreeSet<HistoryRecord>(new HistoryRecordComparator());
int leftCount = count;
int currentFile = filelist.size() - 1;
@ -166,14 +168,14 @@ public synchronized QueryResultSet findLast(int count) throws RuntimeException
// will get nodes and construct a List of nodes
// so we can easyly get sublist of it
List nodes = new ArrayList();
List<Node> nodes = new ArrayList<Node>();
NodeList nodesList = doc.getElementsByTagName("record");
for (int i = 0; i < nodesList.getLength(); i++)
{
nodes.add(nodesList.item(i));
}
List lNodes = null;
List<Node> lNodes = null;
if (nodes.size() > leftCount)
{
@ -186,7 +188,7 @@ public synchronized QueryResultSet findLast(int count) throws RuntimeException
leftCount -= nodes.size();
}
Iterator i = lNodes.iterator();
Iterator<Node> i = lNodes.iterator();
while (i.hasNext())
{
Node node = (Node) i.next();
@ -197,7 +199,7 @@ public synchronized QueryResultSet findLast(int count) throws RuntimeException
.getNodeValue();
Date timestamp = new Date(Long.parseLong(ts));
ArrayList nameVals = new ArrayList();
ArrayList<String> nameVals = new ArrayList<String>();
boolean isRecordOK = true;
int len = propertyNodes.getLength();
@ -312,9 +314,10 @@ public synchronized QueryResultSet findByPeriod(Date startDate, Date endDate,
public QueryResultSet findFirstRecordsAfter(Date date, int count) throws
RuntimeException
{
TreeSet result = new TreeSet(new HistoryRecordComparator());
TreeSet<HistoryRecord> result
= new TreeSet<HistoryRecord>(new HistoryRecordComparator());
Vector filelist =
Vector<String> filelist =
filterFilesByDate(this.historyImpl.getFileList(), date, null);
int leftCount = count;
@ -347,7 +350,7 @@ public QueryResultSet findFirstRecordsAfter(Date date, int count) throws
if(!isInPeriod(timestamp, date, null))
continue;
ArrayList nameVals = new ArrayList();
ArrayList<String> nameVals = new ArrayList<String>();
boolean isRecordOK = true;
int len = propertyNodes.getLength();
@ -406,10 +409,11 @@ public QueryResultSet findLastRecordsBefore(Date date, int count) throws
RuntimeException
{
// the files are supposed to be ordered from oldest to newest
Vector filelist =
Vector<String> filelist =
filterFilesByDate(this.historyImpl.getFileList(), null, date);
TreeSet result = new TreeSet(new HistoryRecordComparator());
TreeSet<HistoryRecord> result
= new TreeSet<HistoryRecord>(new HistoryRecordComparator());
int leftCount = count;
int currentFile = filelist.size() - 1;
@ -440,7 +444,7 @@ public QueryResultSet findLastRecordsBefore(Date date, int count) throws
if(!isInPeriod(timestamp, null, date))
continue;
ArrayList nameVals = new ArrayList();
ArrayList<String> nameVals = new ArrayList<String>();
boolean isRecordOK = true;
int len = propertyNodes.getLength();
@ -491,9 +495,10 @@ private QueryResultSet find(
Date startDate, Date endDate,
String[] keywords, String field, boolean caseSensitive)
{
TreeSet result = new TreeSet(new HistoryRecordComparator());
TreeSet<HistoryRecord> result
= new TreeSet<HistoryRecord>(new HistoryRecordComparator());
Vector filelist =
Vector<String> filelist =
filterFilesByDate(this.historyImpl.getFileList(), startDate, endDate);
double currentProgress = HistorySearchProgressListener.PROGRESS_MINIMUM_VALUE;
@ -507,10 +512,10 @@ private QueryResultSet find(
fireProgressStateChanged(startDate, endDate,
keywords, HistorySearchProgressListener.PROGRESS_MINIMUM_VALUE);
Iterator fileIterator = filelist.iterator();
Iterator<String> fileIterator = filelist.iterator();
while (fileIterator.hasNext())
{
String filename = (String) fileIterator.next();
String filename = fileIterator.next();
Document doc = this.historyImpl.getDocumentForFile(filename);
@ -609,7 +614,7 @@ private HistoryRecord filterByKeyword(NodeList propertyNodes,
String field,
boolean caseSensitive)
{
ArrayList nameVals = new ArrayList();
ArrayList<String> nameVals = new ArrayList<String>();
int len = propertyNodes.getLength();
for (int j = 0; j < len; j++)
{
@ -695,13 +700,13 @@ private boolean matchKeyword(String value, String[] keywords,
* @param endDate Date
* @return Iterator
*/
private Vector filterFilesByDate(
Iterator filelist, Date startDate, Date endDate)
private Vector<String> filterFilesByDate(
Iterator<String> filelist, Date startDate, Date endDate)
{
if(startDate == null && endDate == null)
{
// no filtering needed then just return the same list
Vector result = new Vector();
Vector<String> result = new Vector<String>();
while (filelist.hasNext())
{
result.add(filelist.next());
@ -709,7 +714,7 @@ private Vector filterFilesByDate(
return result;
}
// first convert all files to long
TreeSet files = new TreeSet();
TreeSet<Long> files = new TreeSet<Long>();
while (filelist.hasNext())
{
String filename = (String)filelist.next();
@ -717,22 +722,22 @@ private Vector filterFilesByDate(
files.add(
Long.parseLong(filename.substring(0, filename.length() - 4)));
}
TreeSet resultAsLong = new TreeSet();
TreeSet<Long> resultAsLong = new TreeSet<Long>();
// Temporary fix of a NoSuchElementException
if(files.size() == 0)
{
Vector result = new Vector();
Iterator iter = resultAsLong.iterator();
{
Vector<String> result = new Vector<String>();
Iterator<Long> iter = resultAsLong.iterator();
while (iter.hasNext())
{
Long item = (Long) iter.next();
result.add(item.toString() + ".xml");
}
return result;
}
}
// if there is no startDate limit only to end date
if(startDate == null)
@ -762,7 +767,7 @@ else if(endDate == null)
resultAsLong.addAll(files.subSet(startLong, files.last()));
resultAsLong.add(files.last());
// here we must get and the element before startLong
resultAsLong.add(files.subSet(files.first(), startLong).last());
resultAsLong.remove(startLong);
@ -780,7 +785,8 @@ else if(endDate == null)
resultAsLong.addAll(files.subSet(startLong, endLong));
// here we must get and the element before startLong
SortedSet theFirstToStart = files.subSet(files.first(), startLong);
SortedSet<Long> theFirstToStart
= files.subSet(files.first(), startLong);
if(!theFirstToStart.isEmpty())
resultAsLong.add(theFirstToStart.last());
@ -788,12 +794,12 @@ else if(endDate == null)
resultAsLong.remove(endLong);
}
Vector result = new Vector();
Vector<String> result = new Vector<String>();
Iterator iter = resultAsLong.iterator();
Iterator<Long> iter = resultAsLong.iterator();
while (iter.hasNext())
{
Long item = (Long) iter.next();
Long item = iter.next();
result.add(item.toString() + ".xml");
}
@ -808,7 +814,8 @@ private void fireProgressStateChanged(Date startDate, Date endDate,
synchronized(progressListeners)
{
Iterator iter = progressListeners.iterator();
Iterator<HistorySearchProgressListener> iter
= progressListeners.iterator();
while (iter.hasNext())
{
HistorySearchProgressListener item =
@ -843,16 +850,16 @@ public void removeSearchProgressListener(HistorySearchProgressListener
progressListeners.remove(listener);
}
}
/**
* Count the number of messages that a search will return
* Actually only the last file is parsed and its nodes are counted.
* We accept that the other files are full with max records,
* this way we escape parsing all files which will significantly
* We accept that the other files are full with max records,
* this way we escape parsing all files which will significantly
* slow the process and for one search will parse the files twice.
*
*
* @return the number of searched messages
* @throws UnsupportedOperationException
* @throws UnsupportedOperationException
* Thrown if an exception occurs during the execution of the
* query, such as internal IO error.
*/
@ -861,7 +868,7 @@ public int countRecords()
{
int result = 0;
String lastFile = null;
Iterator filelistIter = this.historyImpl.getFileList();
Iterator<String> filelistIter = this.historyImpl.getFileList();
while (filelistIter.hasNext())
{
lastFile = (String)filelistIter.next();
@ -870,7 +877,7 @@ public int countRecords()
if(lastFile == null)
return result;
Document doc = this.historyImpl.getDocumentForFile(lastFile);
if(doc == null)
@ -879,7 +886,7 @@ public int countRecords()
NodeList nodes = doc.getElementsByTagName("record");
result += nodes.getLength();
return result;
}
@ -888,17 +895,12 @@ public int countRecords()
* ant to be ordered in TreeSet
*/
private static class HistoryRecordComparator
implements Comparator
implements Comparator<HistoryRecord>
{
public int compare(Object o1, Object o2)
public int compare(HistoryRecord h1, HistoryRecord h2)
{
if(o1 instanceof HistoryRecord && o2 instanceof HistoryRecord)
{
return ((HistoryRecord)o1).getTimestamp().
compareTo(((HistoryRecord)o2).getTimestamp());
}
else
return 0;
return h1.getTimestamp().
compareTo(h2.getTimestamp());
}
}
}

@ -39,13 +39,14 @@ public class ChatRoomMsnImpl
/**
* List of unresolved member names.
*/
private ArrayList<String> pendingInvitations = new ArrayList();
private ArrayList<String> pendingInvitations = new ArrayList<String>();
/**
* List of the users that are banned. Note: Not possible inside the MSN
* protocol, the list is always empty.
*/
private Hashtable banList = new Hashtable();
private Hashtable<String, ChatRoomMemberMsnImpl> banList
= new Hashtable<String, ChatRoomMemberMsnImpl>();
/**
* The chat rooms name.
@ -63,13 +64,6 @@ public class ChatRoomMsnImpl
*/
private String chatSubject = null;
/**
* The old chat room subject.
*
* @see chatSubject.
*/
private String oldSubject;
/**
* The corresponding switchboard for the chat room. Each chat room has its
* own switchboard and if it is closed the user cannot reconnect to it, see
@ -86,52 +80,52 @@ public class ChatRoomMsnImpl
* Listeners that will be notified of changes in member status in the room
* such as member joined, left or being kicked or dropped.
*/
private Vector memberListeners = new Vector();
private Vector<ChatRoomMemberPresenceListener> memberListeners
= new Vector<ChatRoomMemberPresenceListener>();
/**
* Listeners that will be notified of changes in member role in the room
* such as member being granted admin permissions, or revoked admin
* permissions.
*/
private Vector memberRoleListeners = new Vector();
private Vector<ChatRoomMemberRoleListener> memberRoleListeners
= new Vector<ChatRoomMemberRoleListener>();
/**
* Listeners that will be notified of changes in local user role in the room
* such as member being granted administrator permissions, or revoked
* administrator permissions.
*/
private Vector localUserRoleListeners = new Vector();
private Vector<ChatRoomLocalUserRoleListener> localUserRoleListeners
= new Vector<ChatRoomLocalUserRoleListener>();
/**
* Listeners that will be notified every time a new message is received on
* this chat room.
*/
private Vector messageListeners = new Vector();
private Vector<ChatRoomMessageListener> messageListeners
= new Vector<ChatRoomMessageListener>();
/**
* Listeners that will be notified every time a chat room property has been
* changed.
*/
private Vector propertyChangeListeners = new Vector();
private Vector<ChatRoomPropertyChangeListener> propertyChangeListeners
= new Vector<ChatRoomPropertyChangeListener>();
/**
* Listeners that will be notified every time a chat room member property
* has been changed.
*/
private Vector memberPropChangeListeners = new Vector();
private Vector<ChatRoomMemberPropertyChangeListener>
memberPropChangeListeners
= new Vector<ChatRoomMemberPropertyChangeListener>();
/**
* A Message buffer, will keep all messages until the msn chatroom is ready.
*/
public Vector<EventObject> messageBuffer = new Vector<EventObject>();
private String invitationMessage = "";
/**
* Default Invitation message.
*/
private final String DEFAULT_INVITATION = "Please join my chat room!";
/**
* Creates an instance of <tt>ChatRoomMsnImpl</tt>, by specifying the name
* of the chat room and the protocol provider.
@ -438,9 +432,9 @@ public Message createMessage(String messageText)
/**
* Returns the list of banned users.
*/
public Iterator getBanList() throws OperationFailedException
public Iterator<ChatRoomMember> getBanList() throws OperationFailedException
{
return banList.values().iterator();
return new LinkedList<ChatRoomMember>(banList.values()).iterator();
}
/**
@ -479,9 +473,9 @@ public String getIdentifier()
* @return a <tt>List</tt> of <tt>Contact</tt> corresponding to all room
* members.
*/
public List getMembers()
public List<ChatRoomMember> getMembers()
{
return new LinkedList(members.values());
return new LinkedList<ChatRoomMember>(members.values());
}
/**
@ -725,7 +719,8 @@ public void leave()
switchboard = null;
}
Iterator membersIter = members.values().iterator();
Iterator<ChatRoomMemberMsnImpl> membersIter
= members.values().iterator();
while (membersIter.hasNext())
{
@ -806,10 +801,11 @@ public ChatRoomMemberMsnImpl getChatRoomMember(String id)
*/
public void fireMessageEvent(EventObject evt)
{
Iterator listeners = null;
Iterator<ChatRoomMessageListener> listeners = null;
synchronized (messageListeners)
{
listeners = new ArrayList(messageListeners).iterator();
listeners = new ArrayList<ChatRoomMessageListener>(
messageListeners).iterator();
}
if (!listeners.hasNext())
@ -896,10 +892,11 @@ private void fireMemberPresenceEvent( ChatRoomMember member,
logger.trace("Will dispatch the following ChatRoom event: " + evt);
Iterator listeners = null;
Iterator<ChatRoomMemberPresenceListener> listeners = null;
synchronized (memberListeners)
{
listeners = new ArrayList(memberListeners).iterator();
listeners = new ArrayList<ChatRoomMemberPresenceListener>(
memberListeners).iterator();
}
while (listeners.hasNext())

@ -30,39 +30,46 @@ public class ChatRoomYahooImpl implements ChatRoom
* Listeners that will be notified of changes in member status in the room
* such as member joined, left or being kicked or dropped.
*/
private Vector memberListeners = new Vector();
private Vector<ChatRoomMemberPresenceListener> memberListeners
= new Vector<ChatRoomMemberPresenceListener>();
/**
* Listeners that will be notified of changes in member role in the room
* such as member being granted admin permissions, or revoked admin
* permissions.
*/
private Vector memberRoleListeners = new Vector();
private Vector<ChatRoomMemberRoleListener> memberRoleListeners
= new Vector<ChatRoomMemberRoleListener>();
/**
* Listeners that will be notified of changes in local user role in the room
* such as member being granted admin permissions, or revoked admin
* permissions.
*/
private Vector localUserRoleListeners = new Vector();
private Vector<ChatRoomLocalUserRoleListener> localUserRoleListeners
= new Vector<ChatRoomLocalUserRoleListener>();
/**
* Listeners that will be notified every time a new message is received on
* this chat room.
*/
private Vector messageListeners = new Vector();
private Vector<ChatRoomMessageListener> messageListeners
= new Vector<ChatRoomMessageListener>();
/**
* Listeners that will be notified every time a chat room property has been
* changed.
*/
private Vector propertyChangeListeners = new Vector();
private Vector<ChatRoomPropertyChangeListener> propertyChangeListeners
= new Vector<ChatRoomPropertyChangeListener>();
/**
* Listeners that will be notified every time a chat room member property
* has been changed.
*/
private Vector memberPropChangeListeners = new Vector();
private Vector<ChatRoomMemberPropertyChangeListener>
memberPropChangeListeners
= new Vector<ChatRoomMemberPropertyChangeListener>();
/**
* The protocol provider that created us
@ -77,12 +84,14 @@ public class ChatRoomYahooImpl implements ChatRoom
/**
* The list of members of this chat room.
*/
private Hashtable members = new Hashtable();
private Hashtable<String, ChatRoomMemberYahooImpl> members
= new Hashtable<String, ChatRoomMemberYahooImpl>();
/**
* The list of members of this chat room.
*/
private Hashtable banList = new Hashtable();
private Hashtable<String, ChatRoomMemberYahooImpl> banList
= new Hashtable<String, ChatRoomMemberYahooImpl>();
/**
* The nickname of this chat room local user participant.
@ -305,12 +314,12 @@ public List getMembers()
public void updateMemberList()
{
Vector memberList = yahooConference.getMembers();
Iterator it = memberList.iterator();
Vector<YahooUser> memberList = yahooConference.getMembers();
Iterator<YahooUser> it = memberList.iterator();
while (it.hasNext())
{
YahooUser user = (YahooUser) it.next();
YahooUser user = it.next();
ChatRoomMemberYahooImpl member = new ChatRoomMemberYahooImpl(this,
user.getId(), user.getId(), ChatRoomMemberRole.MEMBER);
@ -377,9 +386,9 @@ public void banParticipant(ChatRoomMember chatRoomMember, String reason)
* Returns the list of banned users, since it is not possible to
*/
public Iterator getBanList() throws OperationFailedException
public Iterator<ChatRoomMember> getBanList() throws OperationFailedException
{
return banList.values().iterator();
return new LinkedList<ChatRoomMember>(banList.values()).iterator();
}
/**
@ -643,11 +652,14 @@ public void leave()
{
provider.getYahooSession().leaveConference(yahooConference);
Iterator membersSet = members.entrySet().iterator();
Iterator< Map.Entry<String, ChatRoomMemberYahooImpl>> membersSet
= members.entrySet().iterator();
while (membersSet.hasNext())
{
Map.Entry memberEntry = (Map.Entry) membersSet.next();
Map.Entry<String, ChatRoomMemberYahooImpl> memberEntry
= (Map.Entry<String, ChatRoomMemberYahooImpl>) membersSet
.next();
ChatRoomMember member = (ChatRoomMember) memberEntry.getValue();
@ -773,7 +785,7 @@ public void setUserNickname(String nickname)
*/
public ChatRoomMemberYahooImpl getChatRoomMember(String userAddress)
{
Iterator it = members.values().iterator();
Iterator<ChatRoomMemberYahooImpl> it = members.values().iterator();
while (it.hasNext())
{
@ -797,10 +809,11 @@ public ChatRoomMemberYahooImpl getChatRoomMember(String userAddress)
*/
public void fireMessageEvent(EventObject evt)
{
Iterator listeners = null;
Iterator<ChatRoomMessageListener> listeners = null;
synchronized (messageListeners)
{
listeners = new ArrayList(messageListeners).iterator();
listeners = new ArrayList<ChatRoomMessageListener>(
messageListeners).iterator();
}
while (listeners.hasNext())
@ -842,10 +855,11 @@ public void fireMemberPresenceEvent(ChatRoomMember member, String eventID,
logger.trace("Will dispatch the following ChatRoom event: " + evt);
Iterator listeners = null;
Iterator<ChatRoomMemberPresenceListener> listeners = null;
synchronized (memberListeners)
{
listeners = new ArrayList(memberListeners).iterator();
listeners = new ArrayList<ChatRoomMemberPresenceListener>(
memberListeners).iterator();
}
while (listeners.hasNext())

@ -18,11 +18,11 @@
* when iterating over entries in the cache. Here's how to iterate over
* all entries in the cache:
* <pre>
* for (Iterator i=dnscache.iterator(); i.hasNext(); )
* for (Iterator i=dnscache.iterator(); i.hasNext(); )
* {
* for ( DNSCache.CacheNode n = (DNSCache.CacheNode) i.next();
* n != null;
* n.next())
* for ( DNSCache.CacheNode n = (DNSCache.CacheNode) i.next();
* n != null;
* n.next())
* {
* DNSEntry entry = n.getValue();
* ...do something with entry...
@ -32,9 +32,9 @@
* <p/>
* And here's how to iterate over all entries having a given name:
* <pre>
* for ( DNSCache.CacheNode n = (DNSCache.CacheNode) dnscache.find(name);
* n != null;
* n.next())
* for ( DNSCache.CacheNode n = (DNSCache.CacheNode) dnscache.find(name);
* n != null;
* n.next())
* {
* DNSEntry entry = n.getValue();
* ...do something with entry...
@ -55,9 +55,9 @@ class DNSCache
// Since DNSCache is not a public class, it does not seem worth the effort
// to clean its API up that much.
// [PJYF Oct 15 2004] This should implements Collections
// [PJYF Oct 15 2004] This should implements Collections
// that would be amuch cleaner implementation
/**
* The number of DNSEntry's in the cache.
*/
@ -86,7 +86,7 @@ public CacheNode(DNSEntry value)
this.value = value;
String SLevel = System.getProperty("jmdns.debug");
if (SLevel == null) SLevel = "INFO";
this.logger.setLevel(Level.parse(SLevel));
this.logger.setLevel(Level.parse(SLevel));
}
public CacheNode next()
@ -108,10 +108,10 @@ public DNSEntry getValue()
public DNSCache(final int size)
{
hashtable = new HashMap(size);
String SLevel = System.getProperty("jmdns.debug");
if (SLevel == null) SLevel = "INFO";
logger.setLevel(Level.parse(SLevel));
logger.setLevel(Level.parse(SLevel));
}
/**
@ -145,7 +145,7 @@ public synchronized void add(final DNSEntry entry)
}
/**
* Remove a specific entry from the table.
* Remove a specific entry from the table.
* @param entry removed from table.
* @return Returns true if the entry was found.
*/
@ -205,9 +205,9 @@ public synchronized DNSEntry get(DNSEntry entry)
/**
* Get a matching DNS entry from the table.
* @param name
* @param type
* @param clazz
* @param name
* @param type
* @param clazz
* @return Return the entry if found, null otherwise.
*/
public synchronized DNSEntry get(String name, int type, int clazz)
@ -230,7 +230,7 @@ public synchronized DNSEntry get(String name, int type, int clazz)
* code snippets in the header of the class.
* @return Returns iterator with instances of DNSCache.CacheNode.
*/
public Iterator iterator()
public Iterator<DNSCache.CacheNode> iterator()
{
return Collections.unmodifiableCollection(hashtable.values()).iterator();
}

@ -3,14 +3,10 @@
//Original license LGPL
package net.java.sip.communicator.impl.protocol.zeroconf.jmdns;
import java.io.IOException;
import java.net.DatagramPacket;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.logging.*;
/**
* Parse an incoming DNS message into its components.
@ -26,7 +22,7 @@ final class DNSIncoming
// we get undesired results. To fix this, we have to migrate to
// the Collections API of Java 1.2. i.e we replace Vector by List.
// final static Vector EMPTY = new Vector();
private DatagramPacket packet;
private int off;
private int len;
@ -40,8 +36,8 @@ final class DNSIncoming
private int numAdditionals;
private long receivedTime;
List questions;
List answers;
List<DNSEntry> questions;
List<DNSRecord> answers;
/**
* Parse a message from a datagram packet.
@ -50,14 +46,14 @@ final class DNSIncoming
{
String SLevel = System.getProperty("jmdns.debug");
if (SLevel == null) SLevel = "INFO";
logger.setLevel(Level.parse(SLevel));
logger.setLevel(Level.parse(SLevel));
this.packet = packet;
this.data = packet.getData();
this.len = packet.getLength();
this.off = packet.getOffset();
this.questions = Collections.EMPTY_LIST;
this.answers = Collections.EMPTY_LIST;
this.questions = new LinkedList<DNSEntry>();
this.answers = new LinkedList<DNSRecord>();
this.receivedTime = System.currentTimeMillis();
try
@ -72,16 +68,17 @@ final class DNSIncoming
// parse questions
if (numQuestions > 0)
{
questions =
Collections.synchronizedList(new ArrayList(numQuestions));
questions =
Collections.synchronizedList(
new ArrayList<DNSEntry>(numQuestions));
for (int i = 0; i < numQuestions; i++)
{
DNSQuestion question =
DNSQuestion question =
new DNSQuestion(
readName(),
readUnsignedShort(),
readName(),
readUnsignedShort(),
readUnsignedShort());
questions.add(question);
}
}
@ -91,7 +88,8 @@ final class DNSIncoming
if (n > 0)
{
//System.out.println("JMDNS received "+n+" answers!");
answers = Collections.synchronizedList(new ArrayList(n));
answers = Collections.synchronizedList(
new ArrayList<DNSRecord>(n));
for (int i = 0; i < n; i++)
{
String domain = readName();
@ -120,13 +118,13 @@ final class DNSIncoming
break;
case DNSConstants.TYPE_SRV:
//System.out.println("JMDNS: One is a SRV field!!");
rec = new DNSRecord.Service( domain,
type,
clazz,
rec = new DNSRecord.Service( domain,
type,
clazz,
ttl,
readUnsignedShort(),
readUnsignedShort(),
readUnsignedShort(),
readUnsignedShort(),
readUnsignedShort(),
readUnsignedShort(),
readName());
break;
case DNSConstants.TYPE_HINFO:
@ -157,8 +155,8 @@ final class DNSIncoming
}
else
{
if (answers.size() < numAnswers +
numAuthorities +
if (answers.size() < numAnswers +
numAuthorities +
numAdditionals)
{
numAdditionals--;
@ -172,7 +170,7 @@ final class DNSIncoming
}
catch (IOException e)
{
logger.log(Level.WARNING,
logger.log(Level.WARNING,
"DNSIncoming() dump " + print(true) + "\n exception ", e);
throw e;
}
@ -183,7 +181,7 @@ final class DNSIncoming
*/
boolean isQuery()
{
return (flags & DNSConstants.FLAGS_QR_MASK) ==
return (flags & DNSConstants.FLAGS_QR_MASK) ==
DNSConstants.FLAGS_QR_QUERY;
}
@ -200,7 +198,7 @@ boolean isTruncated()
*/
boolean isResponse()
{
return (flags & DNSConstants.FLAGS_QR_MASK) ==
return (flags & DNSConstants.FLAGS_QR_MASK) ==
DNSConstants.FLAGS_QR_RESPONSE;
}
@ -254,8 +252,8 @@ private void readUTF(StringBuffer buf, int off, int len) throws IOException
break;
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
ch = ((ch & 0x0f) << 12) |
((get(off++) & 0x3F) << 6) |
ch = ((ch & 0x0f) << 12) |
((get(off++) & 0x3F) << 6) |
(get(off++) & 0x3F);
break;
default:
@ -319,12 +317,15 @@ String print(boolean dump)
{
StringBuffer buf = new StringBuffer();
buf.append(toString() + "\n");
for (Iterator iterator = questions.iterator(); iterator.hasNext();)
for (Iterator<DNSEntry> iterator = questions.iterator();
iterator.hasNext();)
{
buf.append(" ques:" + iterator.next() + "\n");
}
int count = 0;
for (Iterator iterator = answers.iterator(); iterator.hasNext(); count++)
for (Iterator<DNSRecord> iterator = answers.iterator();
iterator.hasNext();
count++)
{
if (count < numAnswers)
{
@ -458,30 +459,31 @@ void append(DNSIncoming that)
{
if (that.numQuestions > 0) {
if (Collections.EMPTY_LIST.equals(this.questions))
this.questions =
this.questions =
Collections.synchronizedList(
new ArrayList(that.numQuestions));
new ArrayList<DNSEntry>(that.numQuestions));
this.questions.addAll(that.questions);
this.numQuestions += that.numQuestions;
}
if (Collections.EMPTY_LIST.equals(answers))
{
answers = Collections.synchronizedList(new ArrayList());
answers = Collections.synchronizedList(
new ArrayList<DNSRecord>());
}
if (that.numAnswers > 0)
{
this.answers.addAll(this.numAnswers,
this.answers.addAll(this.numAnswers,
that.answers.subList(0, that.numAnswers));
this.numAnswers += that.numAnswers;
}
if (that.numAuthorities > 0)
{
this.answers.addAll(this.numAnswers + this.numAuthorities,
this.answers.addAll(this.numAnswers + this.numAuthorities,
that.answers.subList(
that.numAnswers,
that.numAnswers,
that.numAnswers + that.numAuthorities));
this.numAuthorities += that.numAuthorities;
}
@ -489,7 +491,7 @@ void append(DNSIncoming that)
{
this.answers.addAll(
that.answers.subList(
that.numAnswers + that.numAuthorities,
that.numAnswers + that.numAuthorities,
that.numAnswers + that.numAuthorities + that.numAdditionals));
this.numAdditionals += that.numAdditionals;
}

@ -13,7 +13,7 @@
* @version 1.0 May 23, 2004 Created.
*/
public class DNSState
implements Comparable
implements Comparable<DNSState>
{
private static Logger logger =
Logger.getLogger(DNSState.class.toString());
@ -33,7 +33,8 @@ public class DNSState
* The sequence is consistent with the ordinal of a state.
* This is used for advancing through states.
*/
private final static ArrayList sequence = new ArrayList();
private final static ArrayList<DNSState> sequence
= new ArrayList<DNSState>();
private DNSState(String name)
{
@ -116,8 +117,8 @@ public boolean isAnnounced()
* PROBING_1 &lt; PROBING_2 &lt; PROBING_3 &lt; ANNOUNCING_1 &lt;
* ANNOUNCING_2 &lt; RESPONDING &lt; ANNOUNCED &lt; CANCELED.
*/
public int compareTo(Object o)
public int compareTo(DNSState state)
{
return ordinal - ((DNSState) o).ordinal;
return ordinal - state.ordinal;
}
}

@ -49,13 +49,13 @@ public class JmDNS
* Must by a synchronized collection, because it is updated from
* concurrent threads.
*/
private List listeners;
private List<DNSListener> listeners;
/**
* Holds instances of ServiceListener's.
* Keys are Strings holding a fully qualified service type.
* Values are LinkedList's of ServiceListener's.
*/
private Map serviceListeners;
private Map<String, List<ServiceListener>> serviceListeners;
/**
* Holds instances of ServiceTypeListener's.
*/
@ -554,10 +554,10 @@ public void addServiceListener(String type, ServiceListener listener)
{
String lotype = type.toLowerCase();
removeServiceListener(lotype, listener);
List list = null;
List<ServiceListener> list = null;
synchronized (this)
{
list = (List) serviceListeners.get(lotype);
list = serviceListeners.get(lotype);
if (list == null)
{
list = Collections.synchronizedList(new LinkedList());
@ -599,7 +599,7 @@ public void addServiceListener(String type, ServiceListener listener)
public void removeServiceListener(String type, ServiceListener listener)
{
type = type.toLowerCase();
List list = (List) serviceListeners.get(type);
List<ServiceListener> list = serviceListeners.get(type);
if (list != null)
{
synchronized (this)
@ -762,49 +762,6 @@ public void registerServiceType(String type)
}
}
/**
* Generate a possibly unique name for a host using the information we
* have in the cache.
*
* @return returns true, if the name of the host had to be changed.
*/
private boolean makeHostNameUnique(DNSRecord.Address host)
{
String originalName = host.getName();
long now = System.currentTimeMillis();
boolean collision;
do
{
collision = false;
// Check for collision in cache
for (DNSCache.CacheNode j = cache.find(
host.getName().toLowerCase());
j != null;
j = j.next())
{
DNSRecord a = (DNSRecord) j.getValue();
if (false)
{
host.name = incrementName(host.getName());
collision = true;
break;
}
}
}
while (collision);
if (originalName.equals(host.getName()))
{
return false;
}
else
{
return true;
}
}
/**
* Generate a possibly unique name for a service using the information we
* have in the cache.
@ -936,15 +893,16 @@ void updateRecord(long now, DNSRecord rec)
{
// We do not want to block the entire DNS
// while we are updating the record for each listener (service info)
List listenerList = null;
List<DNSListener> listenerList = null;
synchronized (this)
{
listenerList = new ArrayList(listeners);
listenerList = new ArrayList<DNSListener>(listeners);
}
//System.out.println("OUT OF MUTEX!!!!!");
for (Iterator iterator = listenerList.iterator(); iterator.hasNext();)
for (Iterator<DNSListener> iterator = listenerList.iterator();
iterator.hasNext();)
{
DNSListener listener = (DNSListener) iterator.next();
listener.updateRecord(this, now, rec);
@ -1329,12 +1287,13 @@ public void run()
// -------------------------------------
// To prevent race conditions, we defensively copy all cache
// entries into a list.
List list = new ArrayList();
List<DNSEntry> list = new ArrayList<DNSEntry>();
synchronized (cache)
{
for (Iterator i = cache.iterator(); i.hasNext();)
for (Iterator<DNSCache.CacheNode> i = cache.iterator();
i.hasNext();)
{
for (DNSCache.CacheNode n = (DNSCache.CacheNode) i.next();
for (DNSCache.CacheNode n = i.next();
n != null;
n = n.next())
{
@ -1344,9 +1303,9 @@ public void run()
}
// Now, we remove them.
long now = System.currentTimeMillis();
for (Iterator i = list.iterator(); i.hasNext();)
for (Iterator<DNSEntry> i = list.iterator(); i.hasNext();)
{
DNSRecord c = (DNSRecord) i.next();
DNSRecord c = (DNSRecord)i.next();
if (c.isExpired(now))
{
updateRecord(now, c);
@ -1439,9 +1398,10 @@ public boolean cancel()
// Remove associations from services to this
synchronized (JmDNS.this)
{
for (Iterator i = services.values().iterator(); i.hasNext();)
for (Iterator<ServiceInfo> i = services.values().iterator();
i.hasNext();)
{
ServiceInfo info = (ServiceInfo) i.next();
ServiceInfo info = i.next();
if (info.task == this)
{
info.task = null;
@ -1614,9 +1574,10 @@ public boolean cancel()
// Remove associations from services to this
synchronized (JmDNS.this)
{
for (Iterator i = services.values().iterator(); i.hasNext();)
for (Iterator<ServiceInfo> i = services.values().iterator();
i.hasNext();)
{
ServiceInfo info = (ServiceInfo) i.next();
ServiceInfo info = i.next();
if (info.task == this)
{
info.task = null;
@ -1784,9 +1745,10 @@ public boolean cancel()
// Remove associations from services to this
synchronized (JmDNS.this)
{
for (Iterator i = services.values().iterator(); i.hasNext();)
for (Iterator<ServiceInfo> i = services.values().iterator();
i.hasNext();)
{
ServiceInfo info = (ServiceInfo) i.next();
ServiceInfo info = i.next();
if (info.task == this)
{
info.task = null;
@ -1977,21 +1939,19 @@ public void run()
// We use these sets to prevent duplicate records
// FIXME - This should be moved into DNSOutgoing
HashSet questions = new HashSet();
HashSet answers = new HashSet();
HashSet<DNSQuestion> questions = new HashSet<DNSQuestion>();
HashSet<DNSRecord> answers = new HashSet<DNSRecord>();
if (state == DNSState.ANNOUNCED)
{
try
{
long now = System.currentTimeMillis();
long expirationTime = now + 1; //=now+DNSConstants.KNOWN_ANSWER_TTL;
boolean isUnicast = (port != DNSConstants.MDNS_PORT);
// Answer questions
for (Iterator iterator = in.questions.iterator();
for (Iterator<DNSEntry> iterator = in.questions.iterator();
iterator.hasNext();)
{
DNSEntry entry = (DNSEntry) iterator.next();
@ -2120,7 +2080,7 @@ public void run()
}
if (q.name.equalsIgnoreCase("_services._mdns._udp.local."))
{
for (Iterator serviceTypeIterator = serviceTypes.values().iterator();
for (Iterator<String> serviceTypeIterator = serviceTypes.values().iterator();
serviceTypeIterator.hasNext();)
{
answers.add(
@ -2214,18 +2174,20 @@ public void run()
if (isUnicast)
{
out = new DNSOutgoing(
DNSConstants.FLAGS_QR_RESPONSE | DNSConstants.FLAGS_AA,
DNSConstants.FLAGS_QR_RESPONSE
| DNSConstants.FLAGS_AA,
false);
}
for (Iterator i = questions.iterator(); i.hasNext();)
for (Iterator<DNSQuestion> i = questions.iterator();
i.hasNext();)
{
out.addQuestion((DNSQuestion) i.next());
}
for (Iterator i = answers.iterator(); i.hasNext();)
for (Iterator<DNSRecord> i = answers.iterator();
i.hasNext();)
{
out = addAnswer(in, addr, port, out,
(DNSRecord) i.next());
out = addAnswer(in, addr, port, out, i.next());
}
send(out);
}

@ -28,6 +28,11 @@ public class FirstWizardPage
implements WizardPage,
DocumentListener
{
/**
* An Eclipse generated UID.
*/
private static final long serialVersionUID = -4099426006855229937L;
public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
private JPanel labelsPanel = new TransparentPanel();
@ -268,11 +273,12 @@ private boolean isExistingAccount(String userID)
ProtocolProviderFactory factory
= RssAccRegWizzActivator.getRssProtocolProviderFactory();
ArrayList registeredAccounts = factory.getRegisteredAccounts();
ArrayList<AccountID> registeredAccounts
= factory.getRegisteredAccounts();
for (int i = 0; i < registeredAccounts.size(); i++)
{
AccountID accountID = (AccountID) registeredAccounts.get(i);
AccountID accountID = registeredAccounts.get(i);
if (userID.equalsIgnoreCase(accountID.getUserID()))
{

@ -223,15 +223,15 @@ private void readBasicUserInfo(ByteBlock block, int requestID)
// infoData.add(new ServerStoredDetails.NicknameDetail(bscInfo[0]));
// infoData.add(new ServerStoredDetails.FirstNameDetail(bscInfo[1]));
if(bscInfo[2] != null)
infoData.put(LAST_NAME, bscInfo[2]);
if(bscInfo[2] != null)
infoData.put(LAST_NAME, bscInfo[2]);
// infoData.add(new ServerStoredDetails.EmailAddressDetail(bscInfo[3]));
// infoData.add(new ServerStoredDetails.CityDetail(bscInfo[4]));
// infoData.add(new ServerStoredDetails.ProvinceDetail(bscInfo[5]));
if(bscInfo[6] != null)
infoData.put(PHONE_NUMBER, bscInfo[6]);
infoData.put(PHONE_NUMBER, bscInfo[6]);
// infoData.add(new ServerStoredDetails.FaxDetail(bscInfo[7]));
// infoData.add(new ServerStoredDetails.AddressDetail(bscInfo[8]));
@ -290,7 +290,7 @@ private void readMoreUserInfo(ByteBlock block, int requestID)
// infoData.add(new ServerStoredDetails.BirthDateDetail(birthDate));
// }
//
ArrayList langs = new ArrayList();
ArrayList<Integer> langs = new ArrayList<Integer>();
short speakingLanguage1 = getUByte(block, offset);
offset += 1;
if(speakingLanguage1 != 0 && speakingLanguage1 != 255)
@ -762,7 +762,7 @@ protected static SnacCommand getFullInfoRequestCommand(String senderUIN, String
private static class CommandFactory
implements SnacCmdFactory
{
static final List SUPPORTED_TYPES =
static final List<CmdType> SUPPORTED_TYPES =
DefensiveTools.asUnmodifiableList(new CmdType[]
{new CmdType(21, 3)});
@ -773,7 +773,7 @@ public SnacCommand genSnacCommand(SnacPacket packet)
return new FullUserInfoCmd(packet);
}
public List getSupportedTypes()
public List<CmdType> getSupportedTypes()
{
return SUPPORTED_TYPES;
}

Loading…
Cancel
Save