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()]); }
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()]); }
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()); } }