public class RosterExchange extends Object implements PacketExtension
The 'jabber:x:roster' namespace (which is not to be confused with the 'jabber:iq:roster' namespace) is used to send roster items from one client to another. A roster item is sent by adding to the <message/> element an <x/> child scoped by the 'jabber:x:roster' namespace. This <x/> element may contain one or more <item/> children (one for each roster item to be sent).
Each <item/> element may possess the following attributes:
<jid/> -- The id of the contact being sent. This attribute is required.
<name/> -- A natural-language nickname for the contact. This attribute is optional.
Each <item/> element may also contain one or more <group/> children specifying the natural-language name of a user-specified group, for the purpose of categorizing this contact into one or more roster groups.
Constructor and Description |
---|
RosterExchange()
Creates a new empty roster exchange package.
|
RosterExchange(Roster roster)
Creates a new roster exchange package with the entries specified in roster.
|
Modifier and Type | Method and Description |
---|---|
void |
addRosterEntry(RemoteRosterEntry remoteRosterEntry)
Adds a remote roster entry to the packet.
|
void |
addRosterEntry(RosterEntry rosterEntry)
Adds a roster entry to the packet.
|
String |
getElementName()
Returns the XML element name of the extension sub-packet root element.
|
int |
getEntryCount()
Returns a count of the entries in the roster exchange.
|
String |
getNamespace()
Returns the XML namespace of the extension sub-packet root element.
|
Iterator<RemoteRosterEntry> |
getRosterEntries()
Returns an Iterator for the roster entries in the packet.
|
String |
toXML()
Returns the XML representation of a Roster Item Exchange according the specification.
|
public RosterExchange()
public RosterExchange(Roster roster)
roster
- the roster to send to other XMPP entity.public void addRosterEntry(RosterEntry rosterEntry)
rosterEntry
- a roster entry to add.public void addRosterEntry(RemoteRosterEntry remoteRosterEntry)
remoteRosterEntry
- a remote roster entry to add.public String getElementName()
getElementName
in interface PacketExtension
public String getNamespace()
getNamespace
in interface PacketExtension
public Iterator<RemoteRosterEntry> getRosterEntries()
public int getEntryCount()
public String toXML()
<message id="MlIpV-4" to="gato1@gato.home" from="gato3@gato.home/Smack"> <subject>Any subject you want</subject> <body>This message contains roster items.</body> <x xmlns="jabber:x:roster"> <item jid="gato1@gato.home"/> <item jid="gato2@gato.home"/> </x> </message>
toXML
in interface PacketExtension