public class MetaContactImpl extends DataObject implements MetaContact
MetaContact
interface.Constructor and Description |
---|
MetaContactImpl()
Creates new meta contact with a newly generated meta contact UID.
|
MetaContactImpl(java.lang.String metaUID,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> details)
Creates a new meta contact with the specified UID.
|
Modifier and Type | Method and Description |
---|---|
void |
addDetail(java.lang.String name,
java.lang.String value)
Adds a custom detail to this contact.
|
(package private) void |
addProtoContact(Contact contact)
Adds the specified protocol specific contact to the list of contacts
merged in this meta contact.
|
void |
cacheAvatar(Contact protoContact,
byte[] avatarBytes)
Stores avatar bytes in the given Contact.
|
void |
changeDetail(java.lang.String name,
java.lang.String oldValue,
java.lang.String newValue)
Change the detail.
|
int |
compareTo(MetaContact o)
Compares this meta contact with the specified object for order.
|
boolean |
containsContact(Contact protocolContact)
Returns true if the given protocolContact is contained
in this MetaContact, otherwise - returns false.
|
byte[] |
getAvatar()
Returns an avatar that can be used when presenting this
MetaContact in user interface.
|
byte[] |
getAvatar(boolean isLazy)
Returns the avatar of this contact, that can be used when including this
MetaContact in user interface.
|
Contact |
getContact(java.lang.String contactAddress,
ProtocolProviderService ownerProvider)
Returns a contact encapsulated by this meta contact, having the specified
contactAddress and coming from the indicated ownerProvider.
|
Contact |
getContact(java.lang.String contactAddress,
java.lang.String accountID)
Returns a contact encapsulated by this meta contact, having the specified
contactAddress and coming from a provider with a mathing
accountID.
|
int |
getContactCount()
Returns the number of protocol specific Contacts that this
MetaContact contains.
|
java.util.Iterator<Contact> |
getContacts()
Returns a java.util.Iterator over all protocol specific
Contacts encapsulated by this MetaContact.
|
java.util.Iterator<Contact> |
getContactsForContactGroup(ContactGroup parentProtoGroup)
Returns contacts, encapsulated by this MetaContact and belonging to
the specified protocol ContactGroup.
|
java.util.List<Contact> |
getContactsForOperationSet(java.lang.Class<? extends OperationSet> opSetClass)
Returns all protocol specific Contacts, encapsulated by this MetaContact
and supporting the given opSetClass.
|
java.util.Iterator<Contact> |
getContactsForProvider(ProtocolProviderService provider)
Returns a Contact, encapsulated by this MetaContact and coming from
the specified ProtocolProviderService.
|
Contact |
getDefaultContact()
Currently simply returns the most connected protocol contact.
|
Contact |
getDefaultContact(java.lang.Class<? extends OperationSet> operationSet)
Returns a default contact for a specific operation (call,
file transfer, IM ...)
|
java.util.List<java.lang.String> |
getDetails(java.lang.String name)
Gets all details with a given name.
|
java.lang.String |
getDisplayName()
Returns a characteristic display name that can be used when including
this MetaContact in user interface.
|
java.lang.String |
getMetaUID()
Returns a String identifier (the actual contents is left to
implementations) that uniquely represents this MetaContact in
the containing MetaContactList
|
(package private) MetaContactGroupImpl |
getParentGroup()
Returns the group that is currently holding this meta contact.
|
MetaContactGroup |
getParentMetaContactGroup()
Returns the MetaContactGroup currently containing this meta contact
|
(package private) boolean |
isDisplayNameUserDefined()
Determines if display name was changed for
this MetaContact in user interface.
|
(package private) int |
reevalContact()
Called by MetaContactListServiceImpl after a contact has changed its
status, so that ordering in the parent group is updated.
|
(package private) boolean |
removeContactsForGroup(ContactGroup protoGroup)
Removes all proto contacts that belong to the specified protocol group.
|
(package private) boolean |
removeContactsForProvider(ProtocolProviderService provider)
Removes all proto contacts that belong to the specified provider.
|
void |
removeDetail(java.lang.String name,
java.lang.String value)
Remove the given detail.
|
void |
removeDetails(java.lang.String name)
Remove all details with given name.
|
(package private) void |
removeProtoContact(Contact contact)
Removes the specified protocol specific contact from the contacts
encapsulated in this
MetaContact . |
(package private) void |
setDisplayName(java.lang.String displayName)
Sets a name that can be used when displaying this contact in user
interface components.
|
(package private) void |
setDisplayNameUserDefined(boolean value)
Changes that display name was changed for
this MetaContact in user interface.
|
(package private) void |
setParentGroup(MetaContactGroupImpl parentGroup)
Sets parentGroup as a parent of this meta contact.
|
java.lang.String |
toString()
Returns a string representation of this contact, containing most of its
representative details.
|
(package private) void |
unsetParentGroup(MetaContactGroupImpl parentGrp)
If parentGroup was the parent of this meta contact then it
sets it to null.
|
void |
updateCapabilities(Contact contact,
java.util.Map<java.lang.String,? extends OperationSet> opSets)
Updates the capabilities for the given contact.
|
getData, setData
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getData, setData
MetaContactImpl()
MetaContactImpl(java.lang.String metaUID, java.util.Map<java.lang.String,java.util.List<java.lang.String>> details)
metaUID
- the meta uid that this meta contact should have.details
- the already stored details for the contact.public int getContactCount()
getContactCount
in interface MetaContact
public java.util.Iterator<Contact> getContactsForProvider(ProtocolProviderService provider)
In order to prevent problems with concurrency, the Iterator returned by this method is not be over the actual list of contacts but over a copy of that list.
getContactsForProvider
in interface MetaContact
provider
- a reference to the ProtocolProviderService
that we'd like to get a Contact for.public java.util.List<Contact> getContactsForOperationSet(java.lang.Class<? extends OperationSet> opSetClass)
getContactsForOperationSet
in interface MetaContact
opSetClass
- the operation for which the default contact is neededpublic java.util.Iterator<Contact> getContactsForContactGroup(ContactGroup parentProtoGroup)
In order to prevent problems with concurrency, the Iterator returned by this method is not be over the actual list of contacts but over a copy of that list.
parentProtoGroup
- a reference to the ContactGroup
whose children we'd like removed..public Contact getContact(java.lang.String contactAddress, ProtocolProviderService ownerProvider)
getContact
in interface MetaContact
contactAddress
- the address of the contact who we're looking for.ownerProvider
- a reference to the ProtocolProviderService that
the contact we're looking for belongs to.public Contact getContact(java.lang.String contactAddress, java.lang.String accountID)
contactAddress
- the address of the contact who we're looking for.accountID
- the identifier of the provider that the contact we're
looking for must belong to.public boolean containsContact(Contact protocolContact)
containsContact
in interface MetaContact
protocolContact
- the Contact we're looking forpublic java.util.Iterator<Contact> getContacts()
In order to prevent problems with concurrency, the Iterator returned by this method is not over the actual list of contacts but over a copy of that list.
getContacts
in interface MetaContact
public Contact getDefaultContact()
getDefaultContact
in interface MetaContact
public Contact getDefaultContact(java.lang.Class<? extends OperationSet> operationSet)
getDefaultContact
in interface MetaContact
operationSet
- the operation for which the default contact is neededpublic java.lang.String getMetaUID()
getMetaUID
in interface MetaContact
public int compareTo(MetaContact o)
The result of this method is calculated the following way:
(contactsOnline - o.contactsOnline) * 1 000 000
+ getDisplayName().compareTo(o.getDisplayName()) * 100 000
+ getMetaUID().compareTo(o.getMetaUID())
Or in other words ordering of meta accounts would be first done by presence status, then display name, and finally (in order to avoid equalities) be the fairly random meta contact metaUID.
compareTo
in interface java.lang.Comparable<MetaContact>
o
- the MetaContact
to be compared.java.lang.ClassCastException
- if the specified object is not
a MetaContactListImplpublic java.lang.String toString()
toString
in interface MetaContact
toString
in class java.lang.Object
public java.lang.String getDisplayName()
getDisplayName
in interface MetaContact
boolean isDisplayNameUserDefined()
void setDisplayNameUserDefined(boolean value)
value
- control whether display name is user definedpublic byte[] getAvatar(boolean isLazy)
getAvatar
in interface MetaContact
isLazy
- Indicates if this method should return the locally stored
avatar or it should obtain the avatar right from the server.public byte[] getAvatar()
getAvatar
in interface MetaContact
void setDisplayName(java.lang.String displayName)
displayName
- a human readable String representing this
MetaContactvoid addProtoContact(Contact contact)
contact
- the protocol specific Contact to add.int reevalContact()
void removeProtoContact(Contact contact)
MetaContact
. The method also updates
the total status field accordingly. And updates its ordered position
in its parent group. If the display name of this MetaContact
was the one of the removed contact, we update it.contact
- the contact to removeboolean removeContactsForProvider(ProtocolProviderService provider)
provider
- the provider whose contacts we want removed.boolean removeContactsForGroup(ContactGroup protoGroup)
protoGroup
- the group whose children we want removed.void setParentGroup(MetaContactGroupImpl parentGroup)
parentGroup
- the MetaContactGroupImpl that is currently a
parent of this meta contact.java.lang.NullPointerException
- if parentGroup is null.void unsetParentGroup(MetaContactGroupImpl parentGrp)
parentGrp
- the MetaContactGroupImpl that we don't want
considered as a parent of this contact any more.MetaContactGroupImpl getParentGroup()
public MetaContactGroup getParentMetaContactGroup()
getParentMetaContactGroup
in interface MetaContact
public void addDetail(java.lang.String name, java.lang.String value)
addDetail
in interface MetaContact
name
- name of the detail.value
- the value of the detail.public void removeDetail(java.lang.String name, java.lang.String value)
removeDetail
in interface MetaContact
name
- of the detail to be removed.value
- value of the detail to be removed.public void removeDetails(java.lang.String name)
removeDetails
in interface MetaContact
name
- of the details to be removed.public void changeDetail(java.lang.String name, java.lang.String oldValue, java.lang.String newValue)
changeDetail
in interface MetaContact
name
- of the detail to be changed.oldValue
- the old value of the detail.newValue
- the new value of the detail.public java.util.List<java.lang.String> getDetails(java.lang.String name)
getDetails
in interface MetaContact
name
- the name of the details we are searching forpublic void cacheAvatar(Contact protoContact, byte[] avatarBytes)
protoContact
- The contact in which we store the avatar.avatarBytes
- The avatar image bytes.public void updateCapabilities(Contact contact, java.util.Map<java.lang.String,? extends OperationSet> opSets)
contact
- the Contact, which capabilities have changedopSets
- the new updated set of operation sets
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.