com.vodafone360.people.datatypes
Class Contact

java.lang.Object
  extended by com.vodafone360.people.datatypes.BaseDataType
      extended by com.vodafone360.people.datatypes.Contact
All Implemented Interfaces:
Persistable

public class Contact
extends BaseDataType
implements Persistable

BaseDataType encapsulating a Contact retrieved from, or sent to, Now+ server.

Represents a contact in the people client database with all the associated information. Information stored in a contact is fetched from multiple sub-tables. For example a contact is made up of multiple details which are fetched from the contact details table.

The lighter weight ContactSummary object should be used if only the contact name and essential details are needed.


Nested Class Summary
private static class Contact.MemberData
          Member data definitions used when reading and writing Contact from/to Parcels.
private static class Contact.Tags
          Tags for fields associated with Contact items.
 
Nested classes/interfaces inherited from interface com.vodafone360.people.database.persistenceHelper.Persistable
Persistable.Column, Persistable.Entity, Persistable.Id, Persistable.Table
 
Field Summary
 java.lang.String aboutMe
          Contains the about me string provided by the server
 java.lang.Long contactID
          The server ID (or null if the contact has not yet been synchronised)
 java.lang.Boolean deleted
          Contains true if the contact has been deleted on the server
 java.util.List<ContactDetail> details
          A list of contact details (this contains the main information stored in the contact such as name, phone number, email, etc.)
 java.lang.Boolean friendOfMine
          Contains true if the contacts is marked as a friend
 java.lang.Integer gender
          The gender of the contact received from the server
 java.util.List<java.lang.Long> groupList
          A list groups (server IDs) which the contact is a member of
 java.lang.Long localContactID
          Primary key in the database
 java.lang.Integer nativeContactId
          Internal value which is used to store the primary key of the contact stored in the native Android addressbook.
 java.lang.String profilePath
          The path of the contact thumbnail/avatar on the server
 java.util.List<java.lang.String> sources
          A list of sources which has been fetched from the sources sub-table
 java.lang.Boolean synctophone
          Set to true if this contact should be synchronised with the native address book.
 java.lang.Long updated
          The timestamp when the contact was last updated on the server
 java.lang.Long userID
          The user ID if the contact has been sychronised with the server and the contact is associated with a user
 
Constructor Summary
Contact()
           
 
Method Summary
 void copy(UserProfile source)
          Copy parameters from UserProfile object.
static Contact createFromHashtable(java.util.Hashtable<java.lang.String,java.lang.Object> hash)
          Create Contact item from Hashtable generated by Hessian-decoder
 java.util.Hashtable<java.lang.String,java.lang.Object> createHashtable()
          Create Hashtable representing Contact parameters.
 int describeContents()
          
private  Contact.Tags findTag(java.lang.String tag)
          Find Tags item for specified String
 ContactDetail getContactDetail(ContactDetail.DetailKeys detailKey)
          Fetches the preffered ContactDetail for this Contact for example the preffered phone number or email address If no such is found, an unpreffered contact will be taken
 java.lang.String getDetailString()
           
private  ContactDetail getPrefferedContactDetail(ContactDetail.DetailKeys detailKey)
          Fetches the preffered ContactDetail for this Contact and a DetailKey for example the preffered phone number or email address
 java.lang.String name()
          Return name of the current Data-type.
 void readFromParcel(Parcel in)
          Read Contact from Parcel.
private  void setValue(Contact.Tags tag, java.lang.Object value)
          Sets the value of the member data item associated with the specified tag.
 java.lang.String toString()
          
 void writeToParcel(Parcel dest, int flags)
           Note: only called from tests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

localContactID

public java.lang.Long localContactID
Primary key in the database


aboutMe

public java.lang.String aboutMe
Contains the about me string provided by the server


contactID

public java.lang.Long contactID
The server ID (or null if the contact has not yet been synchronised)


userID

public java.lang.Long userID
The user ID if the contact has been sychronised with the server and the contact is associated with a user


sources

public java.util.List<java.lang.String> sources
A list of sources which has been fetched from the sources sub-table


updated

public java.lang.Long updated
The timestamp when the contact was last updated on the server


profilePath

public java.lang.String profilePath
The path of the contact thumbnail/avatar on the server


gender

public java.lang.Integer gender
The gender of the contact received from the server


friendOfMine

public java.lang.Boolean friendOfMine
Contains true if the contacts is marked as a friend


deleted

public java.lang.Boolean deleted
Contains true if the contact has been deleted on the server


nativeContactId

public java.lang.Integer nativeContactId
Internal value which is used to store the primary key of the contact stored in the native Android addressbook.


details

public final java.util.List<ContactDetail> details
A list of contact details (this contains the main information stored in the contact such as name, phone number, email, etc.)


groupList

public java.util.List<java.lang.Long> groupList
A list groups (server IDs) which the contact is a member of


synctophone

public java.lang.Boolean synctophone
Set to true if this contact should be synchronised with the native address book.

Also determines which contacts are shown in the phonebook group in the UI.

Constructor Detail

Contact

public Contact()
Method Detail

findTag

private Contact.Tags findTag(java.lang.String tag)
Find Tags item for specified String

Parameters:
tag - String value to find Tags item for
Returns:
Tags item for specified String, null otherwise

name

public java.lang.String name()
Return name of the current Data-type.

Specified by:
name in class BaseDataType
Returns:
String containing name of the data-type.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

createHashtable

public java.util.Hashtable<java.lang.String,java.lang.Object> createHashtable()
Create Hashtable representing Contact parameters. This is used to create Hessian encoded payload for Contacts upload.

Returns:
Hashtable containing contact parameters.

createFromHashtable

public static Contact createFromHashtable(java.util.Hashtable<java.lang.String,java.lang.Object> hash)
Create Contact item from Hashtable generated by Hessian-decoder

Parameters:
hash - Hashtable containing Contact parameters
Returns:
Contact item created from hashtable or null if hash was corrupted

setValue

private void setValue(Contact.Tags tag,
                      java.lang.Object value)
Sets the value of the member data item associated with the specified tag.

Parameters:
tag - Current tag
val - Value associated with the tag

copy

public void copy(UserProfile source)
Copy parameters from UserProfile object.

Parameters:
source - UserProfile object to populate Contact with.

readFromParcel

public void readFromParcel(Parcel in)
Read Contact from Parcel. Note: only called from tests.

Parameters:
in - Parcel containing Contact item.

describeContents

public int describeContents()


writeToParcel

public void writeToParcel(Parcel dest,
                          int flags)
Note: only called from tests.


getContactDetail

public ContactDetail getContactDetail(ContactDetail.DetailKeys detailKey)
Fetches the preffered ContactDetail for this Contact for example the preffered phone number or email address If no such is found, an unpreffered contact will be taken

Parameters:
detailKey - The type of the Detail (PHONE, EMAIL_ADDRESS)
Returns:
preffered ContactDetail, any ContactDetail if no preferred is found or null if no detail at all is found

getPrefferedContactDetail

private ContactDetail getPrefferedContactDetail(ContactDetail.DetailKeys detailKey)
Fetches the preffered ContactDetail for this Contact and a DetailKey for example the preffered phone number or email address

Parameters:
detailKey - The type of the Detail (PHONE, EMAIL_ADDRESS)
Returns:
preffered ContactDetail or null if no such is found

getDetailString

public java.lang.String getDetailString()


JavaDoc