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 class
RosterItem.AskType
static class
RosterItem.RecvType
static class
RosterItem.SubType
-
Field Summary
Fields Modifier and Type Field Description static RosterItem.AskType
ASK_NONE
The roster item has no pending subscription requests.static RosterItem.AskType
ASK_SUBSCRIBE
The roster item has been asked for permission to subscribe to their presence but no response has been received.static RosterItem.AskType
ASK_UNSUBSCRIBE
The roster owner has asked to the roster item to unsubscribe from it's presence but has not received confirmation.protected RosterItem.AskType
askStatus
protected List<String>
groups
protected Set<String>
invisibleSharedGroups
protected org.xmpp.packet.JID
jid
protected String
nickname
static RosterItem.RecvType
RECV_NONE
There are no subscriptions that have been received but not presented to the user.static RosterItem.RecvType
RECV_SUBSCRIBE
The server has received a subscribe request, but has not forwarded it to the user.static RosterItem.RecvType
RECV_UNSUBSCRIBE
The server has received an unsubscribe request, but has not forwarded it to the user.protected RosterItem.RecvType
recvStatus
protected Set<String>
sharedGroups
static RosterItem.SubType
SUB_BOTH
The roster item and owner have a mutual subscription.static RosterItem.SubType
SUB_FROM
The roster item has a subscription to the roster owner's presence.static RosterItem.SubType
SUB_NONE
No subscription is established.static RosterItem.SubType
SUB_REMOVE
Indicates the roster item should be removed.static RosterItem.SubType
SUB_TO
The roster owner has a subscription to the roster item's presence.protected org.xmpp.packet.Presence
subscribeStanza
protected RosterItem.SubType
subStatus
-
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 void
addInvisibleSharedGroup(Group sharedGroup)
Adds a new group to the list shared groups that won't be sent to the user.void
addSharedGroup(Group sharedGroup)
Adds a new group to the shared groups list.RosterItem.AskType
getAskStatus()
Obtain the current ask status of the item.static RosterItem.AskType
getAskStatus(org.xmpp.packet.Roster.Item item)
int
getCachedSize()
Returns the approximate size of the Object in bytes.List<String>
getGroups()
Returns the groups for the item.long
getID()
Returns the roster ID associated with this particular roster item.Collection<Group>
getInvisibleSharedGroups()
Returns the invisible shared groups for the item.org.xmpp.packet.JID
getJid()
Obtain the address of the item.String
getNickname()
Obtain the current nickname for the item.RosterItem.RecvType
getRecvStatus()
Obtain the current recv status of the item.Collection<Group>
getSharedGroups()
Returns the shared groups for the item.org.xmpp.packet.Presence
getStoredSubscribeStanza()
org.xmpp.packet.Presence
getSubscribeStanza()
RosterItem.SubType
getSubStatus()
Obtain the current subscription status of the item.static RosterItem.SubType
getSubType(org.xmpp.packet.Roster.Item item)
boolean
isOnlyShared()
Returns true if this item belongs ONLY to shared groups.boolean
isShared()
Returns true if this item belongs to a shared group.void
readExternal(ObjectInput in)
void
removeSharedGroup(Group sharedGroup)
Removes a group from the shared groups list.void
setAsCopyOf(org.xmpp.packet.Roster.Item item)
Update the cached item as a copy of the given item.void
setAskStatus(RosterItem.AskType askStatus)
Set the current ask status of the item.void
setGroups(List<String> groups)
Set the current groups for the item.void
setID(long rosterID)
Sets the roster ID associated with this particular roster item.void
setNickname(String nickname)
Set the current nickname for the item.void
setRecvStatus(RosterItem.RecvType recvStatus)
Set the current recv status of the item.void
setStoredSubscribeStanza(org.xmpp.packet.Presence subscribeStanza)
void
setSubStatus(RosterItem.SubType subStatus)
Set the current subscription status of the item.void
writeExternal(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
-
subscribeStanza
protected org.xmpp.packet.Presence subscribeStanza
-
-
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 SharedGroupException
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
public int getCachedSize() throws CannotCalculateSizeException
Description copied from interface:Cacheable
Returns 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:
getCachedSize
in 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:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
getSubscribeStanza
public org.xmpp.packet.Presence getSubscribeStanza() throws IllegalStateException
- Throws:
IllegalStateException
-
getStoredSubscribeStanza
public org.xmpp.packet.Presence getStoredSubscribeStanza()
-
setStoredSubscribeStanza
public void setStoredSubscribeStanza(org.xmpp.packet.Presence subscribeStanza)
-
-