BluetoothPbapCardpublic class BluetoothPbapCard extends Object Entry representation of folder listing |
Fields Summary |
---|
public final String | handle | public final String | N | public final String | lastName | public final String | firstName | public final String | middleName | public final String | prefix | public final String | suffix |
Constructors Summary |
---|
public BluetoothPbapCard(String handle, String name)
this.handle = handle;
N = name;
/*
* format is as for vCard N field, so we have up to 5 tokens: LastName;
* FirstName; MiddleName; Prefix; Suffix
*/
String[] parsedName = name.split(";", 5);
lastName = parsedName.length < 1 ? null : parsedName[0];
firstName = parsedName.length < 2 ? null : parsedName[1];
middleName = parsedName.length < 3 ? null : parsedName[2];
prefix = parsedName.length < 4 ? null : parsedName[3];
suffix = parsedName.length < 5 ? null : parsedName[4];
|
Methods Summary |
---|
public static java.lang.String | jsonifyVcardEntry(com.android.vcard.VCardEntry vcard)
JSONObject json = new JSONObject();
try {
NameData name = vcard.getNameData();
json.put("formatted", name.getFormatted());
json.put("family", name.getFamily());
json.put("given", name.getGiven());
json.put("middle", name.getMiddle());
json.put("prefix", name.getPrefix());
json.put("suffix", name.getSuffix());
} catch (JSONException e) {
// do nothing
}
try {
JSONArray jsonPhones = new JSONArray();
List<PhoneData> phones = vcard.getPhoneList();
if (phones != null) {
for (PhoneData phone : phones) {
JSONObject jsonPhone = new JSONObject();
jsonPhone.put("type", phone.getType());
jsonPhone.put("number", phone.getNumber());
jsonPhone.put("label", phone.getLabel());
jsonPhone.put("is_primary", phone.isPrimary());
jsonPhones.put(jsonPhone);
}
json.put("phones", jsonPhones);
}
} catch (JSONException e) {
// do nothing
}
try {
JSONArray jsonEmails = new JSONArray();
List<EmailData> emails = vcard.getEmailList();
if (emails != null) {
for (EmailData email : emails) {
JSONObject jsonEmail = new JSONObject();
jsonEmail.put("type", email.getType());
jsonEmail.put("address", email.getAddress());
jsonEmail.put("label", email.getLabel());
jsonEmail.put("is_primary", email.isPrimary());
jsonEmails.put(jsonEmail);
}
json.put("emails", jsonEmails);
}
} catch (JSONException e) {
// do nothing
}
return json.toString();
| public java.lang.String | toString()
JSONObject json = new JSONObject();
try {
json.put("handle", handle);
json.put("N", N);
json.put("lastName", lastName);
json.put("firstName", firstName);
json.put("middleName", middleName);
json.put("prefix", prefix);
json.put("suffix", suffix);
} catch (JSONException e) {
// do nothing
}
return json.toString();
|
|