Commit 1213aab0 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Minor refactoring work.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@747 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7c3dcdc2
......@@ -176,9 +176,7 @@ public class PresenceUpdateHandler extends BasicModule implements ChannelHandler
if (!"".equals(session.getAddress().getNode())) {
String username = session.getAddress().getNode();
Roster roster = rosterManager.getRoster(username);
Iterator items = roster.getRosterItems();
while (items.hasNext()) {
RosterItem item = (RosterItem)items.next();
for (RosterItem item : roster.getRosterItems()) {
if (item.getRecvStatus() == RosterItem.RECV_SUBSCRIBE) {
session.getConnection().deliver(createSubscribePresence(item.getJid(), true));
}
......
......@@ -77,12 +77,12 @@ public class Roster implements Cacheable {
}
/**
* Returns an iterator of users in this roster.
* Returns a collection of users in this roster.
*
* @return an iterator of users in this roster.
* @return a collection of users in this roster.
*/
public Iterator<RosterItem> getRosterItems() {
return Collections.unmodifiableMap(rosterItems).values().iterator();
public Collection<RosterItem> getRosterItems() {
return Collections.unmodifiableCollection(rosterItems.values());
}
/**
......@@ -257,9 +257,7 @@ public class Roster implements Cacheable {
*/
public org.xmpp.packet.Roster getReset() {
org.xmpp.packet.Roster roster = new org.xmpp.packet.Roster();
Iterator items = getRosterItems();
while (items.hasNext()) {
RosterItem item = (RosterItem)items.next();
for (RosterItem item : rosterItems.values()) {
if (item.getSubStatus() != RosterItem.SUB_NONE || item.getAskStatus() != RosterItem.ASK_NONE) {
roster.addItem(item.getJid(), item.getNickname(),
getAskStatus(item.getAskStatus()),
......@@ -291,9 +289,7 @@ public class Roster implements Cacheable {
if (routingTable == null) {
return;
}
Iterator items = getRosterItems();
while (items.hasNext()) {
RosterItem item = (RosterItem)items.next();
for (RosterItem item : rosterItems.values()) {
if (item.getSubStatus() == RosterItem.SUB_BOTH
|| item.getSubStatus() == RosterItem.SUB_FROM) {
JID searchNode = new JID(item.getJid().getNode(), item.getJid().getDomain(), null);
......@@ -337,10 +333,6 @@ public class Roster implements Cacheable {
size += CacheSizes.sizeOfObject(); // overhead of object
size += CacheSizes.sizeOfCollection(rosterItems.values()); // roster item cache
size += CacheSizes.sizeOfString(username); // username
Iterator<RosterItem> itemIter = getRosterItems();
while (itemIter.hasNext()) {
size += itemIter.next().getCachedSize();
}
return size;
}
}
\ No newline at end of file
......@@ -81,9 +81,8 @@ public class RosterManager extends BasicModule {
roster = new Roster(username);
}
// Remove each roster item from the user's roster
Iterator<RosterItem> items = roster.getRosterItems();
while (items.hasNext()) {
roster.deleteRosterItem(items.next().getJid());
for (RosterItem item : roster.getRosterItems()) {
roster.deleteRosterItem(item.getJid());
}
// Remove the cached roster from memory
CacheManager.getCache("username2roster").remove(username);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment