Draft of 'thinking' visualization for barcode scanning. Works for 1D and QR codes.
[zxing.git] / core / src / com / google / zxing / oned / MultiFormatUPCEANReader.java
index 26977b0..295df32 100644 (file)
@@ -27,16 +27,18 @@ import java.util.Vector;
 
 /**
  * <p>A reader that can read all available UPC/EAN formats. If a caller wants to try to
- * read all such formats, it is most efficent to use this implementation rather than invoke
+ * read all such formats, it is most efficient to use this implementation rather than invoke
  * individual readers.</p>
  *
- * @author srowen@google.com (Sean Owen)
+ * @author Sean Owen
  */
 public final class MultiFormatUPCEANReader extends AbstractOneDReader {
 
-  public Result decodeRow(int rowNumber, BitArray row, Hashtable hints) throws ReaderException {
+  private final Vector readers;
+
+  public MultiFormatUPCEANReader(Hashtable hints) {
     Vector possibleFormats = hints == null ? null : (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS);
-    Vector readers = new Vector();
+    readers = new Vector();
     if (possibleFormats != null) {
       if (possibleFormats.contains(BarcodeFormat.EAN_13)) {
         readers.addElement(new EAN13Reader());
@@ -56,14 +58,17 @@ public final class MultiFormatUPCEANReader extends AbstractOneDReader {
       readers.addElement(new EAN8Reader());
       readers.addElement(new UPCEReader());
     }
+  }
 
+  public Result decodeRow(int rowNumber, BitArray row, Hashtable hints) throws ReaderException {
     // Compute this location once and reuse it on multiple implementations
     int[] startGuardPattern = AbstractUPCEANReader.findStartGuardPattern(row);
-    for (int i = 0; i < readers.size(); i++) {
+    int size = readers.size();
+    for (int i = 0; i < size; i++) {
       UPCEANReader reader = (UPCEANReader) readers.elementAt(i);
       Result result;
       try {
-        result = reader.decodeRow(rowNumber, row, startGuardPattern);
+        result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
       } catch (ReaderException re) {
         continue;
       }
@@ -83,7 +88,7 @@ public final class MultiFormatUPCEANReader extends AbstractOneDReader {
       return result;
     }
 
-    throw new ReaderException("No barcode was detected in this image.");
+    throw ReaderException.getInstance();
   }
 
-}
\ No newline at end of file
+}