From cd0ff37fdb8dab8da9691f1b6a49c97750cfd6c8 Mon Sep 17 00:00:00 2001 From: dswitkin Date: Wed, 12 Nov 2008 16:21:19 +0000 Subject: [PATCH] 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 --- .../client/result/AbstractDoCoMoResultParser.java | 4 ---- .../client/result/AddressBookAUResultParser.java | 11 ++++++++--- .../com/google/zxing/client/result/ResultParser.java | 4 ++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/core/src/com/google/zxing/client/result/AbstractDoCoMoResultParser.java b/core/src/com/google/zxing/client/result/AbstractDoCoMoResultParser.java index 1c8417557..2318924cf 100644 --- a/core/src/com/google/zxing/client/result/AbstractDoCoMoResultParser.java +++ b/core/src/com/google/zxing/client/result/AbstractDoCoMoResultParser.java @@ -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 }; - } - } diff --git a/core/src/com/google/zxing/client/result/AddressBookAUResultParser.java b/core/src/com/google/zxing/client/result/AddressBookAUResultParser.java index 9edfc2b34..51160a188 100644 --- a/core/src/com/google/zxing/client/result/AddressBookAUResultParser.java +++ b/core/src/com/google/zxing/client/result/AddressBookAUResultParser.java @@ -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, diff --git a/core/src/com/google/zxing/client/result/ResultParser.java b/core/src/com/google/zxing/client/result/ResultParser.java index a3d6fc274..414eb3c8e 100644 --- a/core/src/com/google/zxing/client/result/ResultParser.java +++ b/core/src/com/google/zxing/client/result/ResultParser.java @@ -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) '\\');