Class RosterItem
- java.lang.Object
-
- org.jivesoftware.openfire.roster.RosterItem
-
- All Implemented Interfaces:
Externalizable,Serializable,Cacheable
public class RosterItem extends Object implements Cacheable, Externalizable
Represents a single roster item for a User's Roster.
The server doesn't need to know anything about roster groups so they are not stored with easy retrieval or manipulation in mind. The important data elements of a roster item (beyond the jid adddress of the roster entry) includes:
- nick - A nickname for the user when used in this roster
- sub - A subscription type: to, from, none, both
- ask - An optional subscription ask status: subscribe, unsubscribe
- groups - A list of groups to organize roster entries under (e.g. friends, co-workers, etc)
- Author:
- Gaston Dombiak
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRosterItem.AskTypestatic classRosterItem.RecvTypestatic classRosterItem.SubType
-
Field Summary
Fields Modifier and Type Field Description static RosterItem.AskTypeASK_NONEThe roster item has no pending subscription requests.static RosterItem.AskTypeASK_SUBSCRIBEThe roster item has been asked for permission to subscribe to their presence but no response has been received.static RosterItem.AskTypeASK_UNSUBSCRIBEThe roster owner has asked to the roster item to unsubscribe from it's presence but has not received confirmation.protected RosterItem.AskTypeaskStatusprotected List<String>groupsprotected Set<String>invisibleSharedGroupsprotected org.xmpp.packet.JIDjidprotected Stringnicknamestatic RosterItem.RecvTypeRECV_NONEThere are no subscriptions that have been received but not presented to the user.static RosterItem.RecvTypeRECV_SUBSCRIBEThe server has received a subscribe request, but has not forwarded it to the user.static RosterItem.RecvTypeRECV_UNSUBSCRIBEThe server has received an unsubscribe request, but has not forwarded it to the user.protected RosterItem.RecvTyperecvStatusprotected Set<String>sharedGroupsstatic RosterItem.SubTypeSUB_BOTHThe roster item and owner have a mutual subscription.static RosterItem.SubTypeSUB_FROMThe roster item has a subscription to the roster owner's presence.static RosterItem.SubTypeSUB_NONENo subscription is established.static RosterItem.SubTypeSUB_REMOVEIndicates the roster item should be removed.static RosterItem.SubTypeSUB_TOThe roster owner has a subscription to the roster item's presence.protected RosterItem.SubTypesubStatus
-
Constructor Summary
Constructors Constructor Description RosterItem()Constructor added for Externalizable.RosterItem(long id, org.xmpp.packet.JID jid, RosterItem.SubType subStatus, RosterItem.AskType askStatus, RosterItem.RecvType recvStatus, String nickname, List<String> groups)RosterItem(org.xmpp.packet.JID jid, RosterItem.SubType subStatus, RosterItem.AskType askStatus, RosterItem.RecvType recvStatus, String nickname, List<String> groups)RosterItem(org.xmpp.packet.Roster.Item item)Create a roster item from the data in another one.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInvisibleSharedGroup(Group sharedGroup)Adds a new group to the list shared groups that won't be sent to the user.voidaddSharedGroup(Group sharedGroup)Adds a new group to the shared groups list.RosterItem.AskTypegetAskStatus()Obtain the current ask status of the item.static RosterItem.AskTypegetAskStatus(org.xmpp.packet.Roster.Item item)intgetCachedSize()Returns the approximate size of the Object in bytes.List<String>getGroups()Returns the groups for the item.longgetID()Returns the roster ID associated with this particular roster item.Collection<Group>getInvisibleSharedGroups()Returns the invisible shared groups for the item.org.xmpp.packet.JIDgetJid()Obtain the address of the item.StringgetNickname()Obtain the current nickname for the item.RosterItem.RecvTypegetRecvStatus()Obtain the current recv status of the item.Collection<Group>getSharedGroups()Returns the shared groups for the item.RosterItem.SubTypegetSubStatus()Obtain the current subscription status of the item.static RosterItem.SubTypegetSubType(org.xmpp.packet.Roster.Item item)booleanisOnlyShared()Returns true if this item belongs ONLY to shared groups.booleanisShared()Returns true if this item belongs to a shared group.voidreadExternal(ObjectInput in)voidremoveSharedGroup(Group sharedGroup)Removes a group from the shared groups list.voidsetAsCopyOf(org.xmpp.packet.Roster.Item item)Update the cached item as a copy of the given item.voidsetAskStatus(RosterItem.AskType askStatus)Set the current ask status of the item.voidsetGroups(List<String> groups)Set the current groups for the item.voidsetID(long rosterID)Sets the roster ID associated with this particular roster item.voidsetNickname(String nickname)Set the current nickname for the item.voidsetRecvStatus(RosterItem.RecvType recvStatus)Set the current recv status of the item.voidsetSubStatus(RosterItem.SubType subStatus)Set the current subscription status of the item.voidwriteExternal(ObjectOutput out)
-
-
-
Field Detail
-
SUB_REMOVE
public static final RosterItem.SubType SUB_REMOVE
Indicates the roster item should be removed.
-
SUB_NONE
public static final RosterItem.SubType SUB_NONE
No subscription is established.
-
SUB_TO
public static final RosterItem.SubType SUB_TO
The roster owner has a subscription to the roster item's presence.
-
SUB_FROM
public static final RosterItem.SubType SUB_FROM
The roster item has a subscription to the roster owner's presence.
-
SUB_BOTH
public static final RosterItem.SubType SUB_BOTH
The roster item and owner have a mutual subscription.
-
ASK_NONE
public static final RosterItem.AskType ASK_NONE
The roster item has no pending subscription requests.
-
ASK_SUBSCRIBE
public static final RosterItem.AskType ASK_SUBSCRIBE
The roster item has been asked for permission to subscribe to their presence but no response has been received.
-
ASK_UNSUBSCRIBE
public static final RosterItem.AskType ASK_UNSUBSCRIBE
The roster owner has asked to the roster item to unsubscribe from it's presence but has not received confirmation.
-
RECV_NONE
public static final RosterItem.RecvType RECV_NONE
There are no subscriptions that have been received but not presented to the user.
-
RECV_SUBSCRIBE
public static final RosterItem.RecvType RECV_SUBSCRIBE
The server has received a subscribe request, but has not forwarded it to the user.
-
RECV_UNSUBSCRIBE
public static final RosterItem.RecvType RECV_UNSUBSCRIBE
The server has received an unsubscribe request, but has not forwarded it to the user.
-
recvStatus
protected RosterItem.RecvType recvStatus
-
jid
protected org.xmpp.packet.JID jid
-
nickname
protected String nickname
-
subStatus
protected RosterItem.SubType subStatus
-
askStatus
protected RosterItem.AskType askStatus
-
-
Constructor Detail
-
RosterItem
public RosterItem()
Constructor added for Externalizable. Do not use this constructor.
-
RosterItem
public RosterItem(long id, org.xmpp.packet.JID jid, RosterItem.SubType subStatus, RosterItem.AskType askStatus, RosterItem.RecvType recvStatus, String nickname, List<String> groups)
-
RosterItem
public RosterItem(org.xmpp.packet.JID jid, RosterItem.SubType subStatus, RosterItem.AskType askStatus, RosterItem.RecvType recvStatus, String nickname, List<String> groups)
-
RosterItem
public RosterItem(org.xmpp.packet.Roster.Item item)
Create a roster item from the data in another one.- Parameters:
item- Item that contains the info of the roster item.
-
-
Method Detail
-
getAskStatus
public static RosterItem.AskType getAskStatus(org.xmpp.packet.Roster.Item item)
-
getSubType
public static RosterItem.SubType getSubType(org.xmpp.packet.Roster.Item item)
-
getSubStatus
public RosterItem.SubType getSubStatus()
Obtain the current subscription status of the item.
- Returns:
- The subscription status of the item
-
setSubStatus
public void setSubStatus(RosterItem.SubType subStatus)
Set the current subscription status of the item.
- Parameters:
subStatus- The subscription status of the item
-
getAskStatus
public RosterItem.AskType getAskStatus()
Obtain the current ask status of the item.
- Returns:
- The ask status of the item
-
setAskStatus
public void setAskStatus(RosterItem.AskType askStatus)
Set the current ask status of the item.
- Parameters:
askStatus- The ask status of the item
-
getRecvStatus
public RosterItem.RecvType getRecvStatus()
Obtain the current recv status of the item.
- Returns:
- The recv status of the item
-
setRecvStatus
public void setRecvStatus(RosterItem.RecvType recvStatus)
Set the current recv status of the item.
- Parameters:
recvStatus- The recv status of the item
-
getJid
public org.xmpp.packet.JID getJid()
Obtain the address of the item.
- Returns:
- The address of the item
-
getNickname
public String getNickname()
Obtain the current nickname for the item.
- Returns:
- The subscription status of the item
-
setNickname
public void setNickname(String nickname)
Set the current nickname for the item.
- Parameters:
nickname- The subscription status of the item
-
getGroups
public List<String> getGroups()
Returns the groups for the item. Shared groups won't be included in the answer.- Returns:
- The groups for the item.
-
setGroups
public void setGroups(List<String> groups) throws SharedGroupException
Set the current groups for the item.- Parameters:
groups- The new lists of groups the item belongs to.- Throws:
SharedGroupException- if trying to remove shared group.
-
getSharedGroups
public Collection<Group> getSharedGroups()
Returns the shared groups for the item.- Returns:
- The shared groups this item belongs to.
-
getInvisibleSharedGroups
public Collection<Group> getInvisibleSharedGroups()
Returns the invisible shared groups for the item. These groups are for internal use and help track the reason why a roster item has a presence subscription of type FROM when using shared groups.- Returns:
- The shared groups this item belongs to.
-
addSharedGroup
public void addSharedGroup(Group sharedGroup)
Adds a new group to the shared groups list.- Parameters:
sharedGroup- The shared group to add to the list of shared groups.
-
addInvisibleSharedGroup
public void addInvisibleSharedGroup(Group sharedGroup)
Adds a new group to the list shared groups that won't be sent to the user. These groups are for internal use and help track the reason why a roster item has a presence subscription of type FROM when using shared groups.- Parameters:
sharedGroup- The shared group to add to the list of shared groups.
-
removeSharedGroup
public void removeSharedGroup(Group sharedGroup)
Removes a group from the shared groups list.- Parameters:
sharedGroup- The shared group to remove from the list of shared groups.
-
isShared
public boolean isShared()
Returns true if this item belongs to a shared group. Return true even if the item belongs to a personal group and a shared group.- Returns:
- true if this item belongs to a shared group.
-
isOnlyShared
public boolean isOnlyShared()
Returns true if this item belongs ONLY to shared groups. This means that the the item is considered to be "only shared" if it doesn't belong to a personal group but only to shared groups.- Returns:
- true if this item belongs ONLY to shared groups.
-
getID
public long getID()
Returns the roster ID associated with this particular roster item. A value of zero means that the roster item is not being persisted in the backend store.Databases can use the roster ID as the key in locating roster items.
- Returns:
- The roster ID
-
setID
public void setID(long rosterID)
Sets the roster ID associated with this particular roster item. A value of zero means that the roster item is not being persisted in the backend store.Databases can use the roster ID as the key in locating roster items.
- Parameters:
rosterID- The roster ID.
-
setAsCopyOf
public void setAsCopyOf(org.xmpp.packet.Roster.Item item) throws SharedGroupExceptionUpdate the cached item as a copy of the given item.
A convenience for getting the item and setting each attribute.
- Parameters:
item- The item who's settings will be copied into the cached copy- Throws:
SharedGroupException- if trying to remove shared group.
-
getCachedSize
public int getCachedSize() throws CannotCalculateSizeExceptionDescription copied from interface:CacheableReturns the approximate size of the Object in bytes. The size should be considered to be a best estimate of how much memory the Object occupies and may be based on empirical trials or dynamic calculations.- Specified by:
getCachedSizein interfaceCacheable- Returns:
- the size of the Object in bytes.
- Throws:
CannotCalculateSizeException- if the size cannot be calculated
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
-