Made a small change to the KDDI AU parsing code to handle pronunciation (aka Furigana) specifically.

git-svn-id: https://zxing.googlecode.com/svn/trunk@692 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin 2008-11-12 16:21:19 +00:00
parent bbbef0d716
commit cd0ff37fdb
3 changed files with 12 additions and 7 deletions

View file

@ -36,8 +36,4 @@ abstract class AbstractDoCoMoResultParser extends ResultParser {
return matchSinglePrefixedField(prefix, rawText, ';', trim);
}
static String[] maybeWrap(String value) {
return value == null ? null : new String[] { value };
}
}

View file

@ -36,13 +36,18 @@ final class AddressBookAUResultParser extends ResultParser {
if (rawText == null || rawText.indexOf("MEMORY") < 0 || rawText.indexOf("\r\n") < 0) {
return null;
}
String[] names = matchMultipleValuePrefix("NAME", 2, rawText, true);
// 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);
return new AddressBookParsedResult(names, null, phoneNumbers, emails, note, address, null, null,
null, null);
return new AddressBookParsedResult(maybeWrap(name), pronunciation, phoneNumbers, emails, note,
address, null, null, null, null);
}
private static String[] matchMultipleValuePrefix(String prefix, int max, String rawText,

View file

@ -90,6 +90,10 @@ public abstract class ResultParser {
}
}
protected static String[] maybeWrap(String value) {
return value == null ? null : new String[] { value };
}
protected static String unescapeBackslash(String escaped) {
if (escaped != null) {
int backslash = escaped.indexOf((int) '\\');