Issue #217: copy result metadata (like EAN extension) even when return EAN-13 as UPC-A

This commit is contained in:
Sean Owen 2018-05-17 12:10:41 -05:00
parent c99e635482
commit 2c2c395afa

View file

@ -77,7 +77,11 @@ public final class UPCAReader extends UPCEANReader {
private static Result maybeReturnResult(Result result) throws FormatException { private static Result maybeReturnResult(Result result) throws FormatException {
String text = result.getText(); String text = result.getText();
if (text.charAt(0) == '0') { if (text.charAt(0) == '0') {
return new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A); Result upcaResult = new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
if (result.getResultMetadata() != null) {
upcaResult.putAllMetadata(result.getResultMetadata());
}
return upcaResult;
} else { } else {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }