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 
StructuredNameDataItem()29   public StructuredNameDataItem() {
30     super(new ContentValues());
31     getContentValues().put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
32   }
33 
StructuredNameDataItem(ContentValues values)34   /* package */ StructuredNameDataItem(ContentValues values) {
35     super(values);
36   }
37 
getDisplayName()38   public String getDisplayName() {
39     return getContentValues().getAsString(StructuredName.DISPLAY_NAME);
40   }
41 
setDisplayName(String name)42   public void setDisplayName(String name) {
43     getContentValues().put(StructuredName.DISPLAY_NAME, name);
44   }
45 
getGivenName()46   public String getGivenName() {
47     return getContentValues().getAsString(StructuredName.GIVEN_NAME);
48   }
49 
getFamilyName()50   public String getFamilyName() {
51     return getContentValues().getAsString(StructuredName.FAMILY_NAME);
52   }
53 
getPrefix()54   public String getPrefix() {
55     return getContentValues().getAsString(StructuredName.PREFIX);
56   }
57 
getMiddleName()58   public String getMiddleName() {
59     return getContentValues().getAsString(StructuredName.MIDDLE_NAME);
60   }
61 
getSuffix()62   public String getSuffix() {
63     return getContentValues().getAsString(StructuredName.SUFFIX);
64   }
65 
getPhoneticGivenName()66   public String getPhoneticGivenName() {
67     return getContentValues().getAsString(StructuredName.PHONETIC_GIVEN_NAME);
68   }
69 
setPhoneticGivenName(String name)70   public void setPhoneticGivenName(String name) {
71     getContentValues().put(StructuredName.PHONETIC_GIVEN_NAME, name);
72   }
73 
getPhoneticMiddleName()74   public String getPhoneticMiddleName() {
75     return getContentValues().getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
76   }
77 
setPhoneticMiddleName(String name)78   public void setPhoneticMiddleName(String name) {
79     getContentValues().put(StructuredName.PHONETIC_MIDDLE_NAME, name);
80   }
81 
getPhoneticFamilyName()82   public String getPhoneticFamilyName() {
83     return getContentValues().getAsString(StructuredName.PHONETIC_FAMILY_NAME);
84   }
85 
setPhoneticFamilyName(String name)86   public void setPhoneticFamilyName(String name) {
87     getContentValues().put(StructuredName.PHONETIC_FAMILY_NAME, name);
88   }
89 
getFullNameStyle()90   public String getFullNameStyle() {
91     return getContentValues().getAsString(StructuredName.FULL_NAME_STYLE);
92   }
93 
isSuperPrimary()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