Entityset (entitydeltalist) of the contact data model)

Source: Internet
Author: User

Com. android. contacts. model. entityset has been renamed to com in Android 4.0. android. contacts. model. entitydeltalist. public class entityset extends arraylist <entitydelta> implements parcelableentityset extends from arraylist <entitydelta> and implements the parcelable interface. Description of the data model of entityset: An arraylist that stores entitydelta. Note: An entitydelta corresponds to a rawcontact constructor: Private entityset (). Note 1: The constructor of entityset is private and can only be constructed externally through its static methods fromsingle and fromquery. NOTE 2: For more information about entitydelta, refer 《 Entitydelta of contact data modelThe main member variable private Boolean msplitrawcontacts indicates whether to insert rawcontact of the set to other rawcontact of the set. The default value is aggregationexceptions. type_keep_separate. The main static function is public static entityset fromsingle (entitydelta delta). Create an entityset, add entitydelta Delta to it, and return the entityset. Public static entityset fromquery (contentresolver resolver, string selection, string []
Selectionargs, string sortorder) first creates an entityset, and then extracts rawcontactsentity from the Database Based on the condition. content_uri: Query and return the rawcontacts data cursor, and then use rawcontacts. newentityiterator converts cursor to entityiterator (entity iterator), then traverses entityiterator and uses entitydelta. the frombefore method converts each entity to entitydelta, and adds entitydelta to entityset. Finally, after the traversal is complete, the entityset is returned. Public static entityset mergeafter (entityset local, entityset remote) uses entityset remote to perform mergeafter on entityset local (perform entitydelta on entityset local and entityset which have the same ID as the primary table in entityset remote. mergeafter operation and return results. Finally, a new entityset local is returned. Note 1: If entityset local is null, an empty entitydelta is created for processing. Note 2: The mergeafter operation is for entityset local, so it will be changed. Note 3: For more information about the entitydelta. mergeafter operation, see 《 Entitydelta of contact data modelPublic static final parcelable. creator <entitydelta> creator note: this variable exists due to parcelable. The main member function is public arraylist <contentprovideroperation> builddiff (), which converts all entitydelta to contentprovideroperation and puts it to arraylist <contentprovideroperation>. First, traverse all entitydelta and call their buildassert to generate assertquery-like contentprovideroperation and put it into arraylist <contentprovideroperation>. Traverse all entitydelta and use their builddiff to generate the corresponding contentprovideroperation and put it into the arraylist <contentprovideroperation>. If msplitrawcontacts is false and is an insert operation, aggregationexceptions. conflict is also required. Then, after the traversal is complete, msplitrawcontacts is true, and aggregationexceptions. type_keep_separate is also required so that all raw_contacts of entityset are on different aggregation. Note: Here aggregationexceptions. type_keep_together requires that, if there is an update entitydelta, select the entitydelta of the first update, and then all the insert entitydelta will perform aggregationexceptions. type_keep_together operations with it. If there is no update entitydelta, The aggregationexceptions. type_keep_together operation will be performed for both the entitydelta except the first insert and the first entitydelta of insert. Protected builder beginkeeptogether () generates a builder of the aggregationexceptions. type_keep_together type. Private void buildsplitcontactdiff (final arraylist <contentprovideroperation> diff, int [] backrefs) creates aggregationexceptions for raw_contact corresponding to all entitydelta on the entityset. the contentprovideroperation of the type_keep_separate operation is added to the arraylist <contentprovideroperation> diff. Note 1: because some entitydelta operations are insert operations, int [] backrefs is required, which stores the insert operation's backreference address (in the order of arraylist <contentprovideroperation>). Note 2: this function calls buildsplitcontactdiff (arraylist <contentprovideroperation> diff, int index1, int index2, int [] backrefs) to implement the main functions. Private void Merge (arraylist <contentprovideroperation> diff, int index1, int index2, int [] backrefs) creates aggregationexceptions for raw_contact corresponding to entityset at int index1 and INT index2. the contentprovideroperation of the type_keep_separate operation is added to the arraylist <contentprovideroperation> diff. Note 1: Because entitydelta operations at int index1 and INT index2 may be performed, int [] backrefs is required, the backreference address containing the insert operation (in the order of arraylist <contentprovideroperation>) Public long findrawcontactid () needs to find the first rawcontacts. _ id entitydelta and return its rawcontacts. _ id. Public long getrawcontactid (INT index) needs to find the entitydelta at the index position. If it is isvisible (), return its rawcontacts. _ id; otherwise, return null. Public entitydelta Delta (long rawcontactid) returns the location of the entitydelta public int delta (long rawcontactid) of rawcontactid whose ID is long rawcontactid on the entityset. Public valuesdelta getsuperprimaryentry (final string mimetype) searches for the valuesdelta whose mime is mimetype in the collection. If there is issuperprimary () valuesdelta, it is directly returned; otherwise, the first isprimary () is returned () valuesdelta. If no isprimary () valuesdelta exists, the first valuesdelta is returned. Public int describecontents () returns 0. // nothing special about this parcel Note: This method is from parcelable. Public void writetoparcel (parcel DEST, int flags) writes entitydelta data to parcel. Note: This method is from parcelable. Public void readfromparcel (parcel source) reads entitydelta data from parcel source.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.