@Override protected int[] decodeEnd(BitArray row, int endStart) throws NotFoundException { return findGuardPattern(row, endStart, true, MIDDLE_END_PATTERN); }
@Override protected int decodeMiddle(BitArray row, int[] startRange, StringBuilder result) throws NotFoundException { int[] counters = decodeMiddleCounters; counters[0] = 0; counters[1] = 0; counters[2] = 0; counters[3] = 0; int end = row.getSize(); int rowOffset = startRange[1]; int lgPatternFound = 0; for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); result.append((char) ('0' + bestMatch % 10)); for (int counter : counters) { rowOffset += counter; } if (bestMatch >= 10) { lgPatternFound |= 1 << (5 - x); } } determineNumSysAndCheckDigit(result, lgPatternFound); return rowOffset; }
@Override protected boolean checkChecksum(String s) throws FormatException { return super.checkChecksum(convertUPCEtoUPCA(s)); }
public MultiFormatUPCEANReader(Map<DecodeHintType,?> hints) { @SuppressWarnings("unchecked") Collection<BarcodeFormat> possibleFormats = hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS); Collection<UPCEANReader> readers = new ArrayList<>(); if (possibleFormats != null) { if (possibleFormats.contains(BarcodeFormat.EAN_13)) { readers.add(new EAN13Reader()); } else if (possibleFormats.contains(BarcodeFormat.UPC_A)) { readers.add(new UPCAReader()); } if (possibleFormats.contains(BarcodeFormat.EAN_8)) { readers.add(new EAN8Reader()); } if (possibleFormats.contains(BarcodeFormat.UPC_E)) { readers.add(new UPCEReader()); } } if (readers.isEmpty()) { readers.add(new EAN13Reader()); // UPC-A is covered by EAN-13 readers.add(new EAN8Reader()); readers.add(new UPCEReader()); } this.readers = readers.toArray(new UPCEANReader[readers.size()]); }
@Override protected int decodeMiddle(BitArray row, int[] startRange, StringBuilder result) throws NotFoundException { int[] counters = decodeMiddleCounters; counters[0] = 0; counters[1] = 0; counters[2] = 0; counters[3] = 0; int end = row.getSize(); int rowOffset = startRange[1]; int lgPatternFound = 0; for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); result.append((char) ('0' + bestMatch % 10)); for (int counter : counters) { rowOffset += counter; } if (bestMatch >= 10) { lgPatternFound |= 1 << (5 - x); } } determineNumSysAndCheckDigit(result, lgPatternFound); return rowOffset; }
@Override protected boolean checkChecksum(String s) throws FormatException { return super.checkChecksum(convertUPCEtoUPCA(s)); }
public MultiFormatUPCEANReader(Map<DecodeHintType,?> hints) { @SuppressWarnings("unchecked") Collection<BarcodeFormat> possibleFormats = hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS); Collection<UPCEANReader> readers = new ArrayList<>(); if (possibleFormats != null) { if (possibleFormats.contains(BarcodeFormat.EAN_13)) { readers.add(new EAN13Reader()); } else if (possibleFormats.contains(BarcodeFormat.UPC_A)) { readers.add(new UPCAReader()); } if (possibleFormats.contains(BarcodeFormat.EAN_8)) { readers.add(new EAN8Reader()); } if (possibleFormats.contains(BarcodeFormat.UPC_E)) { readers.add(new UPCEReader()); } } if (readers.isEmpty()) { readers.add(new EAN13Reader()); // UPC-A is covered by EAN-13 readers.add(new EAN8Reader()); readers.add(new UPCEReader()); } this.readers = readers.toArray(new UPCEANReader[readers.size()]); }
protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer result) throws NotFoundException { int[] counters = decodeMiddleCounters; counters[0] = 0; counters[1] = 0; counters[2] = 0; counters[3] = 0; int end = row.getSize(); int rowOffset = startRange[1]; int lgPatternFound = 0; for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); result.append((char) ('0' + bestMatch % 10)); for (int i = 0; i < counters.length; i++) { rowOffset += counters[i]; } if (bestMatch >= 10) { lgPatternFound |= 1 << (5 - x); } } determineNumSysAndCheckDigit(result, lgPatternFound); return rowOffset; }
protected boolean checkChecksum(String s) throws FormatException, ChecksumException { return super.checkChecksum(convertUPCEtoUPCA(s)); }
@Override protected int[] decodeEnd(BitArray row, int endStart) throws NotFoundException { return findGuardPattern(row, endStart, true, MIDDLE_END_PATTERN); }
public MultiFormatUPCEANReader(Hashtable hints) { Vector possibleFormats = hints == null ? null : (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS); readers = new Vector(); if (possibleFormats != null) { if (possibleFormats.contains(BarcodeFormat.EAN_13)) { readers.addElement(new EAN13Reader()); } else if (possibleFormats.contains(BarcodeFormat.UPC_A)) { readers.addElement(new UPCAReader()); } if (possibleFormats.contains(BarcodeFormat.EAN_8)) { readers.addElement(new EAN8Reader()); } if (possibleFormats.contains(BarcodeFormat.UPC_E)) { readers.addElement(new UPCEReader()); } } if (readers.isEmpty()) { readers.addElement(new EAN13Reader()); // UPC-A is covered by EAN-13 readers.addElement(new EAN8Reader()); readers.addElement(new UPCEReader()); } }
public static ProductParsedResult parse(Result result) { BarcodeFormat format = result.getBarcodeFormat(); if (!(BarcodeFormat.UPC_A.equals(format) || BarcodeFormat.UPC_E.equals(format) || BarcodeFormat.EAN_8.equals(format) || BarcodeFormat.EAN_13.equals(format))) { return null; } // Really neither of these should happen: String rawText = result.getText(); if (rawText == null) { return null; } int length = rawText.length(); for (int x = 0; x < length; x++) { char c = rawText.charAt(x); if (c < '0' || c > '9') { return null; } } // Not actually checking the checksum again here String normalizedProductID; // Expand UPC-E for purposes of searching if (BarcodeFormat.UPC_E.equals(format)) { normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText); } else { normalizedProductID = rawText; } return new ProductParsedResult(rawText, normalizedProductID); }
protected int[] decodeEnd(BitArray row, int endStart) throws NotFoundException { return findGuardPattern(row, endStart, true, MIDDLE_END_PATTERN); }
check = UPCEANReader.getStandardUPCEANChecksum(UPCEReader.convertUPCEtoUPCA(contents)); } catch (FormatException fe) { throw new IllegalArgumentException(fe);
check = UPCEANReader.getStandardUPCEANChecksum(UPCEReader.convertUPCEtoUPCA(contents)); } catch (FormatException fe) { throw new IllegalArgumentException(fe);