AddressBookDoCoMoResultParser.java (zxing-zxing-3.4.0) | : | AddressBookDoCoMoResultParser.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
* @author Sean Owen | * @author Sean Owen | |||
*/ | */ | |||
public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultPar ser { | public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultPar ser { | |||
@Override | @Override | |||
public AddressBookParsedResult parse(Result result) { | public AddressBookParsedResult parse(Result result) { | |||
String rawText = getMassagedText(result); | String rawText = getMassagedText(result); | |||
if (!rawText.startsWith("MECARD:")) { | if (!rawText.startsWith("MECARD:")) { | |||
return null; | return null; | |||
} | } | |||
String[] rawName = matchDoCoMoPrefixedField("N:", rawText, true); | String[] rawName = matchDoCoMoPrefixedField("N:", rawText); | |||
if (rawName == null) { | if (rawName == null) { | |||
return null; | return null; | |||
} | } | |||
String name = parseName(rawName[0]); | String name = parseName(rawName[0]); | |||
String pronunciation = matchSingleDoCoMoPrefixedField("SOUND:", rawText, tru e); | String pronunciation = matchSingleDoCoMoPrefixedField("SOUND:", rawText, tru e); | |||
String[] phoneNumbers = matchDoCoMoPrefixedField("TEL:", rawText, true); | String[] phoneNumbers = matchDoCoMoPrefixedField("TEL:", rawText); | |||
String[] emails = matchDoCoMoPrefixedField("EMAIL:", rawText, true); | String[] emails = matchDoCoMoPrefixedField("EMAIL:", rawText); | |||
String note = matchSingleDoCoMoPrefixedField("NOTE:", rawText, false); | String note = matchSingleDoCoMoPrefixedField("NOTE:", rawText, false); | |||
String[] addresses = matchDoCoMoPrefixedField("ADR:", rawText, true); | String[] addresses = matchDoCoMoPrefixedField("ADR:", rawText); | |||
String birthday = matchSingleDoCoMoPrefixedField("BDAY:", rawText, true); | String birthday = matchSingleDoCoMoPrefixedField("BDAY:", rawText, true); | |||
if (!isStringOfDigits(birthday, 8)) { | if (!isStringOfDigits(birthday, 8)) { | |||
// No reason to throw out the whole card because the birthday is formatted wrong. | // No reason to throw out the whole card because the birthday is formatted wrong. | |||
birthday = null; | birthday = null; | |||
} | } | |||
String[] urls = matchDoCoMoPrefixedField("URL:", rawText, true); | String[] urls = matchDoCoMoPrefixedField("URL:", rawText); | |||
// Although ORG may not be strictly legal in MECARD, it does exist in VCARD and we might as well | // Although ORG may not be strictly legal in MECARD, it does exist in VCARD and we might as well | |||
// honor it when found in the wild. | // honor it when found in the wild. | |||
String org = matchSingleDoCoMoPrefixedField("ORG:", rawText, true); | String org = matchSingleDoCoMoPrefixedField("ORG:", rawText, true); | |||
return new AddressBookParsedResult(maybeWrap(name), | return new AddressBookParsedResult(maybeWrap(name), | |||
null, | null, | |||
pronunciation, | pronunciation, | |||
phoneNumbers, | phoneNumbers, | |||
null, | null, | |||
End of changes. 4 change blocks. | ||||
5 lines changed or deleted | 5 lines changed or added |