Class RosterItem
- All Implemented Interfaces:
Externalizable,Serializable,Cacheable
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RosterItem.AskTypeThe roster item has no pending subscription requests.static final RosterItem.AskTypeThe roster item has been asked for permission to subscribe to their presence but no response has been received.static final RosterItem.AskTypeThe roster owner has asked to the roster item to unsubscribe from it's presence but has not received confirmation.protected RosterItem.AskTypeprotected org.xmpp.packet.JIDprotected Stringstatic final RosterItem.RecvTypeThere are no subscriptions that have been received but not presented to the user.static final RosterItem.RecvTypeThe server has received a subscribe request, but has not forwarded it to the user.static final RosterItem.RecvTypeThe server has received an unsubscribe request, but has not forwarded it to the user.protected RosterItem.RecvTypestatic final RosterItem.SubTypeThe roster item and owner have a mutual subscription.static final RosterItem.SubTypeThe roster item has a subscription to the roster owner's presence.static final RosterItem.SubTypeNo subscription is established.static final RosterItem.SubTypeIndicates the roster item should be removed.static final RosterItem.SubTypeThe roster owner has a subscription to the roster item's presence.protected org.xmpp.packet.Presenceprotected RosterItem.SubType -
Constructor Summary
ConstructorsConstructorDescriptionConstructor 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
Modifier and TypeMethodDescriptionvoidaddInvisibleSharedGroup(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.Obtain the current ask status of the item.static RosterItem.AskTypegetAskStatus(org.xmpp.packet.Roster.Item item) intReturns the approximate size of the Object in bytes.Returns the groups for the item.longgetID()Returns the roster ID associated with this particular roster item.Returns the invisible shared groups for the item.org.xmpp.packet.JIDgetJid()Obtain the address of the item.Obtain the current nickname for the item.Obtain the current recv status of the item.Returns the shared groups for the item.org.xmpp.packet.Presenceorg.xmpp.packet.PresenceObtain the current subscription status of the item.static RosterItem.SubTypegetSubType(org.xmpp.packet.Roster.Item item) booleanReturns true if this item belongs ONLY to shared groups.booleanisShared()Returns true if this item belongs to a shared group.voidvoidremoveSharedGroup(Group sharedGroup) Removes a group from the shared groups list.intGenerates a hash code based on only those fields that are relevant for Roster Versioning (as defined in RFC 6121 section 2.6).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.voidSet 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.voidsetStoredSubscribeStanza(org.xmpp.packet.Presence subscribeStanza) voidsetSubStatus(RosterItem.SubType subStatus) Set the current subscription status of the item.void
-
Field Details
-
SUB_REMOVE
Indicates the roster item should be removed.
-
SUB_NONE
No subscription is established.
-
SUB_TO
The roster owner has a subscription to the roster item's presence.
-
SUB_FROM
The roster item has a subscription to the roster owner's presence.
-
SUB_BOTH
The roster item and owner have a mutual subscription.
-
ASK_NONE
The roster item has no pending subscription requests.
-
ASK_SUBSCRIBE
The roster item has been asked for permission to subscribe to their presence but no response has been received.
-
ASK_UNSUBSCRIBE
The roster owner has asked to the roster item to unsubscribe from it's presence but has not received confirmation.
-
RECV_NONE
There are no subscriptions that have been received but not presented to the user.
-
RECV_SUBSCRIBE
The server has received a subscribe request, but has not forwarded it to the user.
-
RECV_UNSUBSCRIBE
The server has received an unsubscribe request, but has not forwarded it to the user.
-
recvStatus
-
jid
protected org.xmpp.packet.JID jid -
nickname
-
groups
-
subStatus
-
askStatus
-
subscribeStanza
protected org.xmpp.packet.Presence subscribeStanza
-
-
Constructor Details
-
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 Details
-
getAskStatus
-
getSubType
-
getSubStatus
Obtain the current subscription status of the item.
- Returns:
- The subscription status of the item
-
setSubStatus
Set the current subscription status of the item.
- Parameters:
subStatus- The subscription status of the item
-
getAskStatus
Obtain the current ask status of the item.
- Returns:
- The ask status of the item
-
setAskStatus
Set the current ask status of the item.
- Parameters:
askStatus- The ask status of the item
-
getRecvStatus
Obtain the current recv status of the item.
- Returns:
- The recv status of the item
-
setRecvStatus
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
Obtain the current nickname for the item.
- Returns:
- The subscription status of the item
-
setNickname
Set the current nickname for the item.
- Parameters:
nickname- The subscription status of the item
-
getGroups
Returns the groups for the item. Shared groups won't be included in the answer.- Returns:
- The groups for the item.
-
setGroups
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.
-
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
Update 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
Description 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
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
getSubscribeStanza
- Throws:
IllegalStateException
-
getStoredSubscribeStanza
public org.xmpp.packet.Presence getStoredSubscribeStanza() -
setStoredSubscribeStanza
public void setStoredSubscribeStanza(org.xmpp.packet.Presence subscribeStanza) -
rosterVerHashCode
public int rosterVerHashCode()Generates a hash code based on only those fields that are relevant for Roster Versioning (as defined in RFC 6121 section 2.6).- Returns:
- A hash code
-