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 HistoryWriter writer;
private SortedMap historyDocuments = new TreeMap(); private SortedMap<String, Object> historyDocuments
= new TreeMap<String, Object>();
protected HistoryImpl(HistoryID id, File directory, protected HistoryImpl(HistoryID id, File directory,
HistoryRecordStructure historyRecordStructure, 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(); return this.historyDocuments.keySet().iterator();
} }

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

@ -39,13 +39,14 @@ public class ChatRoomMsnImpl
/** /**
* List of unresolved member names. * 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 * List of the users that are banned. Note: Not possible inside the MSN
* protocol, the list is always empty. * protocol, the list is always empty.
*/ */
private Hashtable banList = new Hashtable(); private Hashtable<String, ChatRoomMemberMsnImpl> banList
= new Hashtable<String, ChatRoomMemberMsnImpl>();
/** /**
* The chat rooms name. * The chat rooms name.
@ -63,13 +64,6 @@ public class ChatRoomMsnImpl
*/ */
private String chatSubject = null; 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 * 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 * 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 * Listeners that will be notified of changes in member status in the room
* such as member joined, left or being kicked or dropped. * 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 * Listeners that will be notified of changes in member role in the room
* such as member being granted admin permissions, or revoked admin * such as member being granted admin permissions, or revoked admin
* permissions. * 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 * Listeners that will be notified of changes in local user role in the room
* such as member being granted administrator permissions, or revoked * such as member being granted administrator permissions, or revoked
* administrator permissions. * 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 * Listeners that will be notified every time a new message is received on
* this chat room. * 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 * Listeners that will be notified every time a chat room property has been
* changed. * 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 * Listeners that will be notified every time a chat room member property
* has been changed. * 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. * A Message buffer, will keep all messages until the msn chatroom is ready.
*/ */
public Vector<EventObject> messageBuffer = new Vector<EventObject>(); 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 * Creates an instance of <tt>ChatRoomMsnImpl</tt>, by specifying the name
* of the chat room and the protocol provider. * of the chat room and the protocol provider.
@ -438,9 +432,9 @@ public Message createMessage(String messageText)
/** /**
* Returns the list of banned users. * 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 * @return a <tt>List</tt> of <tt>Contact</tt> corresponding to all room
* members. * 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; switchboard = null;
} }
Iterator membersIter = members.values().iterator(); Iterator<ChatRoomMemberMsnImpl> membersIter
= members.values().iterator();
while (membersIter.hasNext()) while (membersIter.hasNext())
{ {
@ -806,10 +801,11 @@ public ChatRoomMemberMsnImpl getChatRoomMember(String id)
*/ */
public void fireMessageEvent(EventObject evt) public void fireMessageEvent(EventObject evt)
{ {
Iterator listeners = null; Iterator<ChatRoomMessageListener> listeners = null;
synchronized (messageListeners) synchronized (messageListeners)
{ {
listeners = new ArrayList(messageListeners).iterator(); listeners = new ArrayList<ChatRoomMessageListener>(
messageListeners).iterator();
} }
if (!listeners.hasNext()) if (!listeners.hasNext())
@ -896,10 +892,11 @@ private void fireMemberPresenceEvent( ChatRoomMember member,
logger.trace("Will dispatch the following ChatRoom event: " + evt); logger.trace("Will dispatch the following ChatRoom event: " + evt);
Iterator listeners = null; Iterator<ChatRoomMemberPresenceListener> listeners = null;
synchronized (memberListeners) synchronized (memberListeners)
{ {
listeners = new ArrayList(memberListeners).iterator(); listeners = new ArrayList<ChatRoomMemberPresenceListener>(
memberListeners).iterator();
} }
while (listeners.hasNext()) 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 * Listeners that will be notified of changes in member status in the room
* such as member joined, left or being kicked or dropped. * 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 * Listeners that will be notified of changes in member role in the room
* such as member being granted admin permissions, or revoked admin * such as member being granted admin permissions, or revoked admin
* permissions. * 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 * Listeners that will be notified of changes in local user role in the room
* such as member being granted admin permissions, or revoked admin * such as member being granted admin permissions, or revoked admin
* permissions. * 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 * Listeners that will be notified every time a new message is received on
* this chat room. * 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 * Listeners that will be notified every time a chat room property has been
* changed. * 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 * Listeners that will be notified every time a chat room member property
* has been changed. * has been changed.
*/ */
private Vector memberPropChangeListeners = new Vector(); private Vector<ChatRoomMemberPropertyChangeListener>
memberPropChangeListeners
= new Vector<ChatRoomMemberPropertyChangeListener>();
/** /**
* The protocol provider that created us * The protocol provider that created us
@ -77,12 +84,14 @@ public class ChatRoomYahooImpl implements ChatRoom
/** /**
* The list of members of this chat room. * 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. * 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. * The nickname of this chat room local user participant.
@ -305,12 +314,12 @@ public List getMembers()
public void updateMemberList() public void updateMemberList()
{ {
Vector memberList = yahooConference.getMembers(); Vector<YahooUser> memberList = yahooConference.getMembers();
Iterator it = memberList.iterator(); Iterator<YahooUser> it = memberList.iterator();
while (it.hasNext()) while (it.hasNext())
{ {
YahooUser user = (YahooUser) it.next(); YahooUser user = it.next();
ChatRoomMemberYahooImpl member = new ChatRoomMemberYahooImpl(this, ChatRoomMemberYahooImpl member = new ChatRoomMemberYahooImpl(this,
user.getId(), user.getId(), ChatRoomMemberRole.MEMBER); 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 * 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); provider.getYahooSession().leaveConference(yahooConference);
Iterator membersSet = members.entrySet().iterator(); Iterator< Map.Entry<String, ChatRoomMemberYahooImpl>> membersSet
= members.entrySet().iterator();
while (membersSet.hasNext()) 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(); ChatRoomMember member = (ChatRoomMember) memberEntry.getValue();
@ -773,7 +785,7 @@ public void setUserNickname(String nickname)
*/ */
public ChatRoomMemberYahooImpl getChatRoomMember(String userAddress) public ChatRoomMemberYahooImpl getChatRoomMember(String userAddress)
{ {
Iterator it = members.values().iterator(); Iterator<ChatRoomMemberYahooImpl> it = members.values().iterator();
while (it.hasNext()) while (it.hasNext())
{ {
@ -797,10 +809,11 @@ public ChatRoomMemberYahooImpl getChatRoomMember(String userAddress)
*/ */
public void fireMessageEvent(EventObject evt) public void fireMessageEvent(EventObject evt)
{ {
Iterator listeners = null; Iterator<ChatRoomMessageListener> listeners = null;
synchronized (messageListeners) synchronized (messageListeners)
{ {
listeners = new ArrayList(messageListeners).iterator(); listeners = new ArrayList<ChatRoomMessageListener>(
messageListeners).iterator();
} }
while (listeners.hasNext()) while (listeners.hasNext())
@ -842,10 +855,11 @@ public void fireMemberPresenceEvent(ChatRoomMember member, String eventID,
logger.trace("Will dispatch the following ChatRoom event: " + evt); logger.trace("Will dispatch the following ChatRoom event: " + evt);
Iterator listeners = null; Iterator<ChatRoomMemberPresenceListener> listeners = null;
synchronized (memberListeners) synchronized (memberListeners)
{ {
listeners = new ArrayList(memberListeners).iterator(); listeners = new ArrayList<ChatRoomMemberPresenceListener>(
memberListeners).iterator();
} }
while (listeners.hasNext()) while (listeners.hasNext())

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

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

@ -13,7 +13,7 @@
* @version 1.0 May 23, 2004 Created. * @version 1.0 May 23, 2004 Created.
*/ */
public class DNSState public class DNSState
implements Comparable implements Comparable<DNSState>
{ {
private static Logger logger = private static Logger logger =
Logger.getLogger(DNSState.class.toString()); Logger.getLogger(DNSState.class.toString());
@ -33,7 +33,8 @@ public class DNSState
* The sequence is consistent with the ordinal of a state. * The sequence is consistent with the ordinal of a state.
* This is used for advancing through states. * 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) private DNSState(String name)
{ {
@ -116,8 +117,8 @@ public boolean isAnnounced()
* PROBING_1 &lt; PROBING_2 &lt; PROBING_3 &lt; ANNOUNCING_1 &lt; * PROBING_1 &lt; PROBING_2 &lt; PROBING_3 &lt; ANNOUNCING_1 &lt;
* ANNOUNCING_2 &lt; RESPONDING &lt; ANNOUNCED &lt; CANCELED. * 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 * Must by a synchronized collection, because it is updated from
* concurrent threads. * concurrent threads.
*/ */
private List listeners; private List<DNSListener> listeners;
/** /**
* Holds instances of ServiceListener's. * Holds instances of ServiceListener's.
* Keys are Strings holding a fully qualified service type. * Keys are Strings holding a fully qualified service type.
* Values are LinkedList's of ServiceListener's. * Values are LinkedList's of ServiceListener's.
*/ */
private Map serviceListeners; private Map<String, List<ServiceListener>> serviceListeners;
/** /**
* Holds instances of ServiceTypeListener's. * Holds instances of ServiceTypeListener's.
*/ */
@ -554,10 +554,10 @@ public void addServiceListener(String type, ServiceListener listener)
{ {
String lotype = type.toLowerCase(); String lotype = type.toLowerCase();
removeServiceListener(lotype, listener); removeServiceListener(lotype, listener);
List list = null; List<ServiceListener> list = null;
synchronized (this) synchronized (this)
{ {
list = (List) serviceListeners.get(lotype); list = serviceListeners.get(lotype);
if (list == null) if (list == null)
{ {
list = Collections.synchronizedList(new LinkedList()); list = Collections.synchronizedList(new LinkedList());
@ -599,7 +599,7 @@ public void addServiceListener(String type, ServiceListener listener)
public void removeServiceListener(String type, ServiceListener listener) public void removeServiceListener(String type, ServiceListener listener)
{ {
type = type.toLowerCase(); type = type.toLowerCase();
List list = (List) serviceListeners.get(type); List<ServiceListener> list = serviceListeners.get(type);
if (list != null) if (list != null)
{ {
synchronized (this) 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 * Generate a possibly unique name for a service using the information we
* have in the cache. * have in the cache.
@ -936,15 +893,16 @@ void updateRecord(long now, DNSRecord rec)
{ {
// We do not want to block the entire DNS // We do not want to block the entire DNS
// while we are updating the record for each listener (service info) // while we are updating the record for each listener (service info)
List listenerList = null; List<DNSListener> listenerList = null;
synchronized (this) synchronized (this)
{ {
listenerList = new ArrayList(listeners); listenerList = new ArrayList<DNSListener>(listeners);
} }
//System.out.println("OUT OF MUTEX!!!!!"); //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(); DNSListener listener = (DNSListener) iterator.next();
listener.updateRecord(this, now, rec); listener.updateRecord(this, now, rec);
@ -1329,12 +1287,13 @@ public void run()
// ------------------------------------- // -------------------------------------
// To prevent race conditions, we defensively copy all cache // To prevent race conditions, we defensively copy all cache
// entries into a list. // entries into a list.
List list = new ArrayList(); List<DNSEntry> list = new ArrayList<DNSEntry>();
synchronized (cache) 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 != null;
n = n.next()) n = n.next())
{ {
@ -1344,9 +1303,9 @@ public void run()
} }
// Now, we remove them. // Now, we remove them.
long now = System.currentTimeMillis(); 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)) if (c.isExpired(now))
{ {
updateRecord(now, c); updateRecord(now, c);
@ -1439,9 +1398,10 @@ public boolean cancel()
// Remove associations from services to this // Remove associations from services to this
synchronized (JmDNS.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) if (info.task == this)
{ {
info.task = null; info.task = null;
@ -1614,9 +1574,10 @@ public boolean cancel()
// Remove associations from services to this // Remove associations from services to this
synchronized (JmDNS.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) if (info.task == this)
{ {
info.task = null; info.task = null;
@ -1784,9 +1745,10 @@ public boolean cancel()
// Remove associations from services to this // Remove associations from services to this
synchronized (JmDNS.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) if (info.task == this)
{ {
info.task = null; info.task = null;
@ -1977,21 +1939,19 @@ public void run()
// We use these sets to prevent duplicate records // We use these sets to prevent duplicate records
// FIXME - This should be moved into DNSOutgoing // FIXME - This should be moved into DNSOutgoing
HashSet questions = new HashSet(); HashSet<DNSQuestion> questions = new HashSet<DNSQuestion>();
HashSet answers = new HashSet(); HashSet<DNSRecord> answers = new HashSet<DNSRecord>();
if (state == DNSState.ANNOUNCED) if (state == DNSState.ANNOUNCED)
{ {
try try
{ {
long now = System.currentTimeMillis();
long expirationTime = now + 1; //=now+DNSConstants.KNOWN_ANSWER_TTL;
boolean isUnicast = (port != DNSConstants.MDNS_PORT); boolean isUnicast = (port != DNSConstants.MDNS_PORT);
// Answer questions // Answer questions
for (Iterator iterator = in.questions.iterator(); for (Iterator<DNSEntry> iterator = in.questions.iterator();
iterator.hasNext();) iterator.hasNext();)
{ {
DNSEntry entry = (DNSEntry) iterator.next(); DNSEntry entry = (DNSEntry) iterator.next();
@ -2120,7 +2080,7 @@ public void run()
} }
if (q.name.equalsIgnoreCase("_services._mdns._udp.local.")) if (q.name.equalsIgnoreCase("_services._mdns._udp.local."))
{ {
for (Iterator serviceTypeIterator = serviceTypes.values().iterator(); for (Iterator<String> serviceTypeIterator = serviceTypes.values().iterator();
serviceTypeIterator.hasNext();) serviceTypeIterator.hasNext();)
{ {
answers.add( answers.add(
@ -2214,18 +2174,20 @@ public void run()
if (isUnicast) if (isUnicast)
{ {
out = new DNSOutgoing( out = new DNSOutgoing(
DNSConstants.FLAGS_QR_RESPONSE | DNSConstants.FLAGS_AA, DNSConstants.FLAGS_QR_RESPONSE
| DNSConstants.FLAGS_AA,
false); false);
} }
for (Iterator i = questions.iterator(); i.hasNext();) for (Iterator<DNSQuestion> i = questions.iterator();
i.hasNext();)
{ {
out.addQuestion((DNSQuestion) i.next()); 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, out = addAnswer(in, addr, port, out, i.next());
(DNSRecord) i.next());
} }
send(out); send(out);
} }

@ -28,6 +28,11 @@ public class FirstWizardPage
implements WizardPage, implements WizardPage,
DocumentListener DocumentListener
{ {
/**
* An Eclipse generated UID.
*/
private static final long serialVersionUID = -4099426006855229937L;
public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier"; public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
private JPanel labelsPanel = new TransparentPanel(); private JPanel labelsPanel = new TransparentPanel();
@ -268,11 +273,12 @@ private boolean isExistingAccount(String userID)
ProtocolProviderFactory factory ProtocolProviderFactory factory
= RssAccRegWizzActivator.getRssProtocolProviderFactory(); = RssAccRegWizzActivator.getRssProtocolProviderFactory();
ArrayList registeredAccounts = factory.getRegisteredAccounts(); ArrayList<AccountID> registeredAccounts
= factory.getRegisteredAccounts();
for (int i = 0; i < registeredAccounts.size(); i++) for (int i = 0; i < registeredAccounts.size(); i++)
{ {
AccountID accountID = (AccountID) registeredAccounts.get(i); AccountID accountID = registeredAccounts.get(i);
if (userID.equalsIgnoreCase(accountID.getUserID())) 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.NicknameDetail(bscInfo[0]));
// infoData.add(new ServerStoredDetails.FirstNameDetail(bscInfo[1])); // infoData.add(new ServerStoredDetails.FirstNameDetail(bscInfo[1]));
if(bscInfo[2] != null) if(bscInfo[2] != null)
infoData.put(LAST_NAME, bscInfo[2]); infoData.put(LAST_NAME, bscInfo[2]);
// infoData.add(new ServerStoredDetails.EmailAddressDetail(bscInfo[3])); // infoData.add(new ServerStoredDetails.EmailAddressDetail(bscInfo[3]));
// infoData.add(new ServerStoredDetails.CityDetail(bscInfo[4])); // infoData.add(new ServerStoredDetails.CityDetail(bscInfo[4]));
// infoData.add(new ServerStoredDetails.ProvinceDetail(bscInfo[5])); // infoData.add(new ServerStoredDetails.ProvinceDetail(bscInfo[5]));
if(bscInfo[6] != null) 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.FaxDetail(bscInfo[7]));
// infoData.add(new ServerStoredDetails.AddressDetail(bscInfo[8])); // infoData.add(new ServerStoredDetails.AddressDetail(bscInfo[8]));
@ -290,7 +290,7 @@ private void readMoreUserInfo(ByteBlock block, int requestID)
// infoData.add(new ServerStoredDetails.BirthDateDetail(birthDate)); // infoData.add(new ServerStoredDetails.BirthDateDetail(birthDate));
// } // }
// //
ArrayList langs = new ArrayList(); ArrayList<Integer> langs = new ArrayList<Integer>();
short speakingLanguage1 = getUByte(block, offset); short speakingLanguage1 = getUByte(block, offset);
offset += 1; offset += 1;
if(speakingLanguage1 != 0 && speakingLanguage1 != 255) if(speakingLanguage1 != 0 && speakingLanguage1 != 255)
@ -762,7 +762,7 @@ protected static SnacCommand getFullInfoRequestCommand(String senderUIN, String
private static class CommandFactory private static class CommandFactory
implements SnacCmdFactory implements SnacCmdFactory
{ {
static final List SUPPORTED_TYPES = static final List<CmdType> SUPPORTED_TYPES =
DefensiveTools.asUnmodifiableList(new CmdType[] DefensiveTools.asUnmodifiableList(new CmdType[]
{new CmdType(21, 3)}); {new CmdType(21, 3)});
@ -773,7 +773,7 @@ public SnacCommand genSnacCommand(SnacPacket packet)
return new FullUserInfoCmd(packet); return new FullUserInfoCmd(packet);
} }
public List getSupportedTypes() public List<CmdType> getSupportedTypes()
{ {
return SUPPORTED_TYPES; return SUPPORTED_TYPES;
} }

Loading…
Cancel
Save