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;
21 import android.provider.ContactsContract.CommonDataKinds.StructuredName;
22 import android.provider.ContactsContract.Contacts.Data;
23 
24 /**
25  * Represents a structured name data item, wrapping the columns in
26  * {@link ContactsContract.CommonDataKinds.StructuredName}.
27  */
28 public class StructuredNameDataItem extends DataItem {
29 
StructuredNameDataItem()30     public StructuredNameDataItem() {
31         super(new ContentValues());
32         getContentValues().put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
33     }
34 
StructuredNameDataItem(ContentValues values)35     /* package */ StructuredNameDataItem(ContentValues values) {
36         super(values);
37     }
38 
getDisplayName()39     public String getDisplayName() {
40         return getContentValues().getAsString(StructuredName.DISPLAY_NAME);
41     }
42 
setDisplayName(String name)43     public void setDisplayName(String name) {
44         getContentValues().put(StructuredName.DISPLAY_NAME, name);
45     }
46 
getGivenName()47     public String getGivenName() {
48         return getContentValues().getAsString(StructuredName.GIVEN_NAME);
49     }
50 
getFamilyName()51     public String getFamilyName() {
52         return getContentValues().getAsString(StructuredName.FAMILY_NAME);
53     }
54 
getPrefix()55     public String getPrefix() {
56         return getContentValues().getAsString(StructuredName.PREFIX);
57     }
58 
getMiddleName()59     public String getMiddleName() {
60         return getContentValues().getAsString(StructuredName.MIDDLE_NAME);
61     }
62 
getSuffix()63     public String getSuffix() {
64         return getContentValues().getAsString(StructuredName.SUFFIX);
65     }
66 
getPhoneticGivenName()67     public String getPhoneticGivenName() {
68         return getContentValues().getAsString(StructuredName.PHONETIC_GIVEN_NAME);
69     }
70 
getPhoneticMiddleName()71     public String getPhoneticMiddleName() {
72         return getContentValues().getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
73     }
74 
getPhoneticFamilyName()75     public String getPhoneticFamilyName() {
76         return getContentValues().getAsString(StructuredName.PHONETIC_FAMILY_NAME);
77     }
78 
getFullNameStyle()79     public String getFullNameStyle() {
80         return getContentValues().getAsString(StructuredName.FULL_NAME_STYLE);
81     }
82 
setPhoneticFamilyName(String name)83     public void setPhoneticFamilyName(String name) {
84         getContentValues().put(StructuredName.PHONETIC_FAMILY_NAME, name);
85     }
86 
setPhoneticMiddleName(String name)87     public void setPhoneticMiddleName(String name) {
88         getContentValues().put(StructuredName.PHONETIC_MIDDLE_NAME, name);
89     }
90 
setPhoneticGivenName(String name)91     public void setPhoneticGivenName(String name) {
92         getContentValues().put(StructuredName.PHONETIC_GIVEN_NAME, name);
93     }
94 
isSuperPrimary()95     public boolean isSuperPrimary() {
96         final ContentValues contentValues = getContentValues();
97         return contentValues == null || !contentValues.containsKey(StructuredName.IS_SUPER_PRIMARY)
98                 ? false : contentValues.getAsBoolean(StructuredName.IS_SUPER_PRIMARY);
99     }
100 }
101