Made a small change to the KDDI AU parsing code to handle pronunciation (aka Furigana...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Wed, 12 Nov 2008 16:21:19 +0000 (16:21 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Wed, 12 Nov 2008 16:21:19 +0000 (16:21 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@692 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/client/result/AbstractDoCoMoResultParser.java
core/src/com/google/zxing/client/result/AddressBookAUResultParser.java
core/src/com/google/zxing/client/result/ResultParser.java

index 1c84175..2318924 100644 (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 };
-  }
-
 }
index 9edfc2b..51160a1 100644 (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,
index a3d6fc2..414eb3c 100644 (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) '\\');