1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 14:22:05 +01:00

Improvements in entry creation and management.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1854 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-03-23 23:03:19 +00:00 committed by mtucker
parent 25e4481984
commit dd4c10ac9d
2 changed files with 44 additions and 2 deletions

View file

@ -104,6 +104,17 @@ public class Roster {
} }
} }
/**
* Cretaes a new roster entry.
*
* @param user
* @param name
* @return
*/
public RosterEntry createEntry(String user, String name) {
return new RosterEntry(user, name, connection);
}
/** /**
* Returns the roster group with the specified name, or <tt>null</tt> if the * Returns the roster group with the specified name, or <tt>null</tt> if the
* group doesn't exist. * group doesn't exist.
@ -117,6 +128,17 @@ public class Roster {
} }
} }
/**
* Returns the number of the groups in the roster.
*
* @return the number of groups in the roster.
*/
public int getGroupCount() {
synchronized (groups) {
return groups.size();
}
}
/** /**
* Returns an iterator the for all the roster groups. * Returns an iterator the for all the roster groups.
* *

View file

@ -108,18 +108,38 @@ public class RosterGroup {
} }
} }
/**
* Returns the number of entries in the group.
*
* @return the number of entries in the group.
*/
public int getEntryCount() { public int getEntryCount() {
synchronized (entries) { synchronized (entries) {
return entries.size(); return entries.size();
} }
} }
/**
* Returns an iterator for the entries in the group.
*
* @return an iterator for the entries in the group.
*/
public Iterator getEntries() { public Iterator getEntries() {
return Collections.unmodifiableList(entries).iterator(); synchronized (entries) {
return Collections.unmodifiableList(new ArrayList(entries)).iterator();
}
} }
/**
* Returns true if an entry is part of the group.
*
* @param entry
* @return
*/
public boolean contains(RosterEntry entry) { public boolean contains(RosterEntry entry) {
return entries.contains(entry); synchronized (entries) {
return entries.contains(entry);
}
} }
public void addEntry(RosterEntry entry) { public void addEntry(RosterEntry entry) {