public final class Contact extends Object implements Comparable<Contact>
The
<query/>element inside a roster set contains one<item/>child, and a roster result typically contains multiple<item/>children. Each<item/>element describes a unique "roster item" (sometimes also called a "contact").
| Modifier and Type | Class and Description |
|---|---|
static class |
Contact.Subscription
The implementation of the 'subscription' attribute.
|
| Constructor and Description |
|---|
Contact(Jid jid)
Creates a new contact associated with the given JID.
|
Contact(Jid jid,
String name)
Creates a new contact associated with the given JID and name.
|
Contact(Jid jid,
String name,
boolean isPending,
Contact.Subscription subscription,
String... groups)
Creates a new contact associated with the given JID, name and groups.
|
Contact(Jid jid,
String name,
List<String> groups)
Creates a new contact associated with the given JID, name and groups.
|
Contact(Jid jid,
String name,
String... groups)
Creates a new contact associated with the given JID, name and groups.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Contact o)
Compares two contacts with each other by first comparing their names, then their subscription states and eventually their pending states.
|
boolean |
equals(Object o) |
List<String> |
getGroups()
Gets the groups of the contact.
|
Jid |
getJid()
Gets the JID of the contact.
|
String |
getName()
Gets the name of the contact.
|
Contact.Subscription |
getSubscription()
Gets the subscription attribute.
|
int |
hashCode() |
boolean |
isApproved()
Gets the subscription pre-approval status.
|
boolean |
isPending()
Gets the pending state of the contact.
|
void |
setName(String name)
Sets the name of the contact.
|
void |
setSubscription(Contact.Subscription subscription)
Sets the subscription state of the contact.
|
String |
toString() |
public Contact(Jid jid)
jid - The JID.public Contact(Jid jid, String name)
jid - The JID.name - The name.public Contact(Jid jid, String name, String... groups)
jid - The JID.name - The name.groups - The groups for this contact.public Contact(Jid jid, String name, List<String> groups)
jid - The JID.name - The name.groups - The groups for this contact.public Contact(Jid jid, String name, boolean isPending, Contact.Subscription subscription, String... groups)
jid - The JID.name - The name.isPending - Indicates, whether the contact's subscription approval is pending.subscription - The subscription.groups - The groups for this contact.public Jid getJid()
public String getName()
setName(String)public void setName(String name)
The 'name' attribute of the
<item/>element specifies the "handle" to be associated with the JID, as determined by the user (not the contact). Although the value of the 'name' attribute MAY have meaning to a human user, it is opaque to the server. However, the 'name' attribute MAY be used by the server for matching purposes within the context of various XMPP extensions (one possible comparison method is that described for XMPP resourceparts in [XMPP-ADDR]).It is OPTIONAL for a client to include the 'name' attribute when adding or updating a roster item.
name - The name.public Contact.Subscription getSubscription()
public void setSubscription(Contact.Subscription subscription)
Contact.Subscription.REMOVE as other states are managed via presence stanzas.subscription - The subscription.public boolean isPending()
The 'ask' attribute of the
<item/>element with a value of "subscribe" is used to signal various subscription sub-states that include a "Pending Out" aspect as described under Section 3.1.2.A server SHOULD include the 'ask' attribute to inform the client of "Pending Out" sub-states. A client MUST NOT include the 'ask' attribute in the roster sets it sends to the server, but instead MUST use presence stanzas of type "subscribe" and "unsubscribe" to manage such sub-states as described under Section 3.1.2.
public boolean isApproved()
The boolean 'approved' attribute with a value of "true" is used to signal subscription pre-approval as described under Section 3.4
public int compareTo(Contact o)
compareTo in interface Comparable<Contact>o - The other contact.Copyright © 2014 XMPP.rocks. All rights reserved.