diff --git a/source/org/jivesoftware/smack/Roster.java b/source/org/jivesoftware/smack/Roster.java index 2e3149c06..93cc4ecf7 100644 --- a/source/org/jivesoftware/smack/Roster.java +++ b/source/org/jivesoftware/smack/Roster.java @@ -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 null if the * 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. * diff --git a/source/org/jivesoftware/smack/RosterGroup.java b/source/org/jivesoftware/smack/RosterGroup.java index f2990fa94..4be53f0ac 100644 --- a/source/org/jivesoftware/smack/RosterGroup.java +++ b/source/org/jivesoftware/smack/RosterGroup.java @@ -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() { synchronized (entries) { return entries.size(); } } + /** + * Returns an iterator for the entries in the group. + * + * @return an iterator for the entries in the group. + */ 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) { - return entries.contains(entry); + synchronized (entries) { + return entries.contains(entry); + } } public void addEntry(RosterEntry entry) {