import com.google.zxing.DecodeHintType;
import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException;
+import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.ResultPoint;
import com.google.zxing.ResultPointCallback;
}
private final StringBuffer decodeRowStringBuffer;
+ private final UPCEANExtensionSupport extensionReader;
protected UPCEANReader() {
decodeRowStringBuffer = new StringBuffer(20);
+ extensionReader = new UPCEANExtensionSupport();
}
static int[] findStartGuardPattern(BitArray row) throws NotFoundException {
float left = (float) (startGuardRange[1] + startGuardRange[0]) / 2.0f;
float right = (float) (endRange[1] + endRange[0]) / 2.0f;
- return new Result(resultString,
+ Result decodeResult = new Result(resultString,
null, // no natural byte representation for these barcodes
new ResultPoint[]{
new ResultPoint(left, (float) rowNumber),
new ResultPoint(right, (float) rowNumber)},
getBarcodeFormat());
+
+ try {
+ Result extensionResult = extensionReader.decodeRow(row, endRange[1]);
+ decodeResult.putAllMetadata(extensionResult.getResultMetadata());
+ } catch (ReaderException re) {
+ // continue
+ }
+ return decodeResult;
}
/**
* @param s string of digits to check
* @return true iff string of digits passes the UPC/EAN checksum algorithm
* @throws FormatException if the string does not contain only digits
- * @throws ChecksumException if checksum mismatches
*/
- private static boolean checkStandardUPCEANChecksum(String s) throws ChecksumException, FormatException {
+ private static boolean checkStandardUPCEANChecksum(String s) throws FormatException {
int length = s.length();
if (length == 0) {
return false;
for (int i = length - 1; i >= 0; i -= 2) {
int digit = (int) s.charAt(i) - (int) '0';
if (digit < 0 || digit > 9) {
- throw ChecksumException.getChecksumInstance();
+ throw FormatException.getFormatInstance();
}
sum += digit;
}