public static AddressBookParsedResult parse(Result result) { String rawText = result.getText(); // MEMORY is mandatory; seems like a decent indicator, as does end-of-record separator CR/LF if (rawText == null || rawText.indexOf("MEMORY") < 0 || rawText.indexOf("\r\n") < 0) { return null; } // NAME1 and NAME2 have specific uses, namely written name and pronunciation, respectively. // Therefore we treat them specially instead of as an array of names. String name = matchSinglePrefixedField("NAME1:", rawText, '\r', true); String pronunciation = matchSinglePrefixedField("NAME2:", rawText, '\r', true); String[] phoneNumbers = matchMultipleValuePrefix("TEL", 3, rawText, true); String[] emails = matchMultipleValuePrefix("MAIL", 3, rawText, true); String note = matchSinglePrefixedField("MEMORY:", rawText, '\r', false); String address = matchSinglePrefixedField("ADD:", rawText, '\r', true); String[] addresses = address == null ? null : new String[] {address}; return new AddressBookParsedResult(maybeWrap(name), pronunciation, phoneNumbers, emails, note, addresses, null, null, null, null); }
public static AddressBookParsedResult parse(Result result) { String rawText = result.getText(); if (rawText == null || !rawText.startsWith("BIZCARD:")) { return null; } String firstName = matchSingleDoCoMoPrefixedField("N:", rawText, true); String lastName = matchSingleDoCoMoPrefixedField("X:", rawText, true); String fullName = buildName(firstName, lastName); String title = matchSingleDoCoMoPrefixedField("T:", rawText, true); String org = matchSingleDoCoMoPrefixedField("C:", rawText, true); String[] addresses = matchDoCoMoPrefixedField("A:", rawText, true); String phoneNumber1 = matchSingleDoCoMoPrefixedField("B:", rawText, true); String phoneNumber2 = matchSingleDoCoMoPrefixedField("M:", rawText, true); String phoneNumber3 = matchSingleDoCoMoPrefixedField("F:", rawText, true); String email = matchSingleDoCoMoPrefixedField("E:", rawText, true); return new AddressBookParsedResult(maybeWrap(fullName), null, buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3), maybeWrap(email), null, addresses, org, null, title, null); }
return new AddressBookParsedResult(maybeWrap(name), pronunciation, phoneNumbers,
return new AddressBookParsedResult(names, null, phoneNumbers, emails, note, addresses, org, birthday, title, url);