Home | History | Annotate | Download | only in dataitem
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.contacts.common.model.dataitem;
     18 
     19 import android.content.ContentValues;
     20 import android.provider.ContactsContract.CommonDataKinds.StructuredName;
     21 import android.provider.ContactsContract.Contacts.Data;
     22 
     23 /**
     24  * Represents a structured name data item, wrapping the columns in {@link
     25  * ContactsContract.CommonDataKinds.StructuredName}.
     26  */
     27 public class StructuredNameDataItem extends DataItem {
     28 
     29   public StructuredNameDataItem() {
     30     super(new ContentValues());
     31     getContentValues().put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
     32   }
     33 
     34   /* package */ StructuredNameDataItem(ContentValues values) {
     35     super(values);
     36   }
     37 
     38   public String getDisplayName() {
     39     return getContentValues().getAsString(StructuredName.DISPLAY_NAME);
     40   }
     41 
     42   public void setDisplayName(String name) {
     43     getContentValues().put(StructuredName.DISPLAY_NAME, name);
     44   }
     45 
     46   public String getGivenName() {
     47     return getContentValues().getAsString(StructuredName.GIVEN_NAME);
     48   }
     49 
     50   public String getFamilyName() {
     51     return getContentValues().getAsString(StructuredName.FAMILY_NAME);
     52   }
     53 
     54   public String getPrefix() {
     55     return getContentValues().getAsString(StructuredName.PREFIX);
     56   }
     57 
     58   public String getMiddleName() {
     59     return getContentValues().getAsString(StructuredName.MIDDLE_NAME);
     60   }
     61 
     62   public String getSuffix() {
     63     return getContentValues().getAsString(StructuredName.SUFFIX);
     64   }
     65 
     66   public String getPhoneticGivenName() {
     67     return getContentValues().getAsString(StructuredName.PHONETIC_GIVEN_NAME);
     68   }
     69 
     70   public void setPhoneticGivenName(String name) {
     71     getContentValues().put(StructuredName.PHONETIC_GIVEN_NAME, name);
     72   }
     73 
     74   public String getPhoneticMiddleName() {
     75     return getContentValues().getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
     76   }
     77 
     78   public void setPhoneticMiddleName(String name) {
     79     getContentValues().put(StructuredName.PHONETIC_MIDDLE_NAME, name);
     80   }
     81 
     82   public String getPhoneticFamilyName() {
     83     return getContentValues().getAsString(StructuredName.PHONETIC_FAMILY_NAME);
     84   }
     85 
     86   public void setPhoneticFamilyName(String name) {
     87     getContentValues().put(StructuredName.PHONETIC_FAMILY_NAME, name);
     88   }
     89 
     90   public String getFullNameStyle() {
     91     return getContentValues().getAsString(StructuredName.FULL_NAME_STYLE);
     92   }
     93 
     94   public boolean isSuperPrimary() {
     95     final ContentValues contentValues = getContentValues();
     96     return contentValues == null || !contentValues.containsKey(StructuredName.IS_SUPER_PRIMARY)
     97         ? false
     98         : contentValues.getAsBoolean(StructuredName.IS_SUPER_PRIMARY);
     99   }
    100 }
    101