mirror of
https://github.com/zxing/zxing.git
synced 2025-02-21 02:55:27 -08:00
Only parse UPC result out of a UPC format code, to avoid "false positives" from other formats
git-svn-id: https://zxing.googlecode.com/svn/trunk@291 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
5ae6e5be71
commit
5248fb1a7e
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.google.zxing.client.result;
|
package com.google.zxing.client.result;
|
||||||
|
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.Result;
|
import com.google.zxing.Result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +32,10 @@ public final class UPCParsedResult extends ParsedReaderResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UPCParsedResult parse(Result result) {
|
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();
|
String rawText = result.getText();
|
||||||
int length = rawText.length();
|
int length = rawText.length();
|
||||||
if (length != 12 && length != 13) {
|
if (length != 12 && length != 13) {
|
||||||
|
|
Loading…
Reference in a new issue