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").
This class is immutable.
| 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,
Boolean approved,
Contact.Subscription subscription,
Collection<String> groups)
Creates a new contact associated with the given JID, name and groups.
|
Contact(Jid jid,
String name,
Collection<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.
|
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, Collection<String> groups)
jid - The JID.name - The name.groups - The groups for this contact.public Contact(Jid jid, String name, Boolean isPending, Boolean approved, Contact.Subscription subscription, Collection<String> groups)
jid - The JID.name - The name.isPending - Indicates, whether the contact's subscription approval is pending.approved - Indicates, whether the contact is pre-approved.subscription - The subscription.groups - The groups for this contact.public final Jid getJid()
public final String getName()
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.
public final Contact.Subscription getSubscription()
public final List<String> getGroups()
public final 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 final 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 final int compareTo(Contact o)
compareTo in interface Comparable<Contact>o - The other contact.Copyright © 2014–2015 XMPP.rocks. All rights reserved.