mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +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:
parent
25e4481984
commit
dd4c10ac9d
2 changed files with 44 additions and 2 deletions
|
@ -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.
|
||||||
*
|
*
|
||||||
|
|
|
@ -108,19 +108,39 @@ 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) {
|
||||||
|
synchronized (entries) {
|
||||||
return entries.contains(entry);
|
return entries.contains(entry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addEntry(RosterEntry entry) {
|
public void addEntry(RosterEntry entry) {
|
||||||
// Only add the entry if it isn't already in the list.
|
// Only add the entry if it isn't already in the list.
|
||||||
|
|
Loading…
Reference in a new issue