Package org.jivesoftware.smack.roster
Class RosterGroup
- java.lang.Object
-
- org.jivesoftware.smack.Manager
-
- org.jivesoftware.smack.roster.RosterGroup
-
public class RosterGroup extends Manager
A group of roster entries.- See Also:
Roster.getGroup(String)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntry(RosterEntry entry)
Adds a roster entry to this group.boolean
contains(RosterEntry entry)
Returns true if the specified entry is part of this group.boolean
contains(Jid user)
Returns true if the specified XMPP address is an entry in this group.List<RosterEntry>
getEntries()
Returns an copied list of all entries in the group.RosterEntry
getEntry(Jid user)
Returns the roster entry associated with the given XMPP address ornull
if the user is not an entry in the group.int
getEntryCount()
Returns the number of entries in the group.String
getName()
Returns the name of the group.void
removeEntry(RosterEntry entry)
Removes a roster entry from this group.void
setName(String name)
Sets the name of the group.-
Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
-
-
-
Method Detail
-
setName
public void setName(String name) throws SmackException.NotConnectedException, SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException
Sets the name of the group. Changing the group's name is like moving all the group entries of the group to a new group specified by the new name. Since this group won't have entries it will be removed from the roster. This means that all the references to this object will be invalid and will need to be updated to the new group specified by the new name.- Parameters:
name
- the name of the group.- Throws:
SmackException.NotConnectedException
- if the XMPP connection is not connected.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.InterruptedException
- if the calling thread was interrupted.
-
getEntryCount
public int getEntryCount()
Returns the number of entries in the group.- Returns:
- the number of entries in the group.
-
getEntries
public List<RosterEntry> getEntries()
Returns an copied list of all entries in the group.- Returns:
- all entries in the group.
-
getEntry
public RosterEntry getEntry(Jid user)
Returns the roster entry associated with the given XMPP address ornull
if the user is not an entry in the group.- Parameters:
user
- the XMPP address of the user (eg "jsmith@example.com").- Returns:
- the roster entry or
null
if it does not exist in the group.
-
contains
public boolean contains(RosterEntry entry)
Returns true if the specified entry is part of this group.- Parameters:
entry
- a roster entry.- Returns:
- true if the entry is part of this group.
-
contains
public boolean contains(Jid user)
Returns true if the specified XMPP address is an entry in this group.- Parameters:
user
- the XMPP address of the user.- Returns:
- true if the XMPP address is an entry in this group.
-
addEntry
public void addEntry(RosterEntry entry) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Adds a roster entry to this group. If the entry was unfiled then it will be removed from the unfiled list and will be added to this group. Note that this is a synchronous call -- Smack must wait for the server to receive the updated roster.- Parameters:
entry
- a roster entry.- Throws:
XMPPException.XMPPErrorException
- if an error occurred while trying to add the entry to the group.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
removeEntry
public void removeEntry(RosterEntry entry) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Removes a roster entry from this group. If the entry does not belong to any other group then it will be considered as unfiled, therefore it will be added to the list of unfiled entries. Note that this is a synchronous call -- Smack must wait for the server to receive the updated roster.- Parameters:
entry
- a roster entry.- Throws:
XMPPException.XMPPErrorException
- if an error occurred while trying to remove the entry from the group.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
-