public class

ContactMatcher

extends Object
java.lang.Object
   ↳ com.android.providers.contacts.ContactMatcher

Class Overview

Logic for matching contacts' data and accumulating match scores.

Summary

Nested Classes
class ContactMatcher.MatchScore Captures the max score and match count for a specific contact. 
Constants
float APPROXIMATE_MATCH_THRESHOLD
float APPROXIMATE_MATCH_THRESHOLD_FOR_EMAIL
int MATCHING_ALGORITHM_APPROXIMATE
int MATCHING_ALGORITHM_CONSERVATIVE
int MATCHING_ALGORITHM_EXACT
int MAX_SCORE
long MULTIPLE_MATCHES
int SCORE_THRESHOLD_PRIMARY
int SCORE_THRESHOLD_SECONDARY
int SCORE_THRESHOLD_SUGGEST
Public Constructors
ContactMatcher()
Public Methods
void clear()
void keepIn(long contactId)
void keepOut(long contactId)
void matchName(long contactId, int candidateNameType, String candidateName, int nameType, String name, int algorithm)
Checks if there is a match and updates the overall score for the specified contact for a discovered match.
long pickBestMatch(int threshold, boolean allowMultipleMatches)
Returns the contactId with the best match score over the specified threshold or -1 if no such contact is found.
List<ContactMatcher.MatchScore> pickBestMatches(int threshold)
Returns matches in the order of descending score.
List<Long> prepareSecondaryMatchCandidates(int threshold)
Returns a list of IDs for contacts that are matched on secondary data elements (phone number, email address, nickname).
String toString()
void updateScoreWithEmailMatch(long contactId)
void updateScoreWithNicknameMatch(long contactId)
void updateScoreWithPhoneNumberMatch(long contactId)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final float APPROXIMATE_MATCH_THRESHOLD

Constant Value: 0.82

public static final float APPROXIMATE_MATCH_THRESHOLD_FOR_EMAIL

Constant Value: 0.95

public static final int MATCHING_ALGORITHM_APPROXIMATE

Constant Value: 2 (0x00000002)

public static final int MATCHING_ALGORITHM_CONSERVATIVE

Constant Value: 1 (0x00000001)

public static final int MATCHING_ALGORITHM_EXACT

Constant Value: 0 (0x00000000)

public static final int MAX_SCORE

Constant Value: 100 (0x00000064)

public static final long MULTIPLE_MATCHES

Constant Value: -2 (0xfffffffffffffffe)

public static final int SCORE_THRESHOLD_PRIMARY

Constant Value: 70 (0x00000046)

public static final int SCORE_THRESHOLD_SECONDARY

Constant Value: 50 (0x00000032)

public static final int SCORE_THRESHOLD_SUGGEST

Constant Value: 50 (0x00000032)

Public Constructors

public ContactMatcher ()

Public Methods

public void clear ()

public void keepIn (long contactId)

public void keepOut (long contactId)

public void matchName (long contactId, int candidateNameType, String candidateName, int nameType, String name, int algorithm)

Checks if there is a match and updates the overall score for the specified contact for a discovered match. The new score is determined by the prior score, by the type of name we were looking for, the type of name we found and, if the match is approximate, the distance between the candidate and actual name.

public long pickBestMatch (int threshold, boolean allowMultipleMatches)

Returns the contactId with the best match score over the specified threshold or -1 if no such contact is found.

public List<ContactMatcher.MatchScore> pickBestMatches (int threshold)

Returns matches in the order of descending score.

public List<Long> prepareSecondaryMatchCandidates (int threshold)

Returns a list of IDs for contacts that are matched on secondary data elements (phone number, email address, nickname). We still need to obtain the approximate primary score for those contacts to determine if any of them should be aggregated.

May return null.

public String toString ()

public void updateScoreWithEmailMatch (long contactId)

public void updateScoreWithNicknameMatch (long contactId)

public void updateScoreWithPhoneNumberMatch (long contactId)