Only parse UPC result out of a UPC format code, to avoid "false positives" from other...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 17 Mar 2008 20:16:20 +0000 (20:16 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 17 Mar 2008 20:16:20 +0000 (20:16 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@291 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/client/result/UPCParsedResult.java

index bb112ad..1287eaa 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.google.zxing.client.result;
 
+import com.google.zxing.BarcodeFormat;
 import com.google.zxing.Result;
 
 /**
@@ -31,6 +32,10 @@ public final class UPCParsedResult extends ParsedReaderResult {
   }
 
   public static UPCParsedResult parse(Result result) {
+    BarcodeFormat format = result.getBarcodeFormat();
+    if (!BarcodeFormat.UPC_A.equals(format) && !BarcodeFormat.UPC_E.equals(format)) {
+      return null;
+    }
     String rawText = result.getText();
     int length = rawText.length();
     if (length != 12 && length != 13) {