Fix small display problem when extension starts with 9
[zxing.git] / core / src / com / google / zxing / oned / MultiFormatOneDReader.java
index c22437b..fa3de5d 100644 (file)
 
 package com.google.zxing.oned;
 
+import com.google.zxing.BarcodeFormat;
 import com.google.zxing.DecodeHintType;
+import com.google.zxing.NotFoundException;
+import com.google.zxing.Reader;
 import com.google.zxing.ReaderException;
 import com.google.zxing.Result;
-import com.google.zxing.BarcodeFormat;
 import com.google.zxing.common.BitArray;
+import com.google.zxing.oned.rss.RSS14Reader;
+import com.google.zxing.oned.rss.expanded.RSSExpandedReader;
 
 import java.util.Hashtable;
 import java.util.Vector;
@@ -29,13 +33,15 @@ import java.util.Vector;
  * @author dswitkin@google.com (Daniel Switkin)
  * @author Sean Owen
  */
-public final class MultiFormatOneDReader extends AbstractOneDReader {
+public final class MultiFormatOneDReader extends OneDReader {
 
   private final Vector readers;
 
   public MultiFormatOneDReader(Hashtable hints) {
-    Vector possibleFormats = hints == null ? null : (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS);
-    boolean useCode39CheckDigit = hints != null && hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) != null;
+    Vector possibleFormats = hints == null ? null :
+        (Vector) hints.get(DecodeHintType.POSSIBLE_FORMATS);
+    boolean useCode39CheckDigit = hints != null &&
+        hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) != null;
     readers = new Vector();
     if (possibleFormats != null) {
       if (possibleFormats.contains(BarcodeFormat.EAN_13) ||
@@ -47,22 +53,38 @@ public final class MultiFormatOneDReader extends AbstractOneDReader {
       if (possibleFormats.contains(BarcodeFormat.CODE_39)) {
         readers.addElement(new Code39Reader(useCode39CheckDigit));
       }
+      if (possibleFormats.contains(BarcodeFormat.CODE_93)) {
+        readers.addElement(new Code93Reader());
+      }
       if (possibleFormats.contains(BarcodeFormat.CODE_128)) {
         readers.addElement(new Code128Reader());
       }
       if (possibleFormats.contains(BarcodeFormat.ITF)) {
          readers.addElement(new ITFReader());
       }
+      if (possibleFormats.contains(BarcodeFormat.CODABAR)) {
+         readers.addElement(new CodaBarReader());
+      }
+      if (possibleFormats.contains(BarcodeFormat.RSS14)) {
+         readers.addElement(new RSS14Reader());
+      }
+      if (possibleFormats.contains(BarcodeFormat.RSS_EXPANDED)){
+        readers.addElement(new RSSExpandedReader());
+      }
     }
     if (readers.isEmpty()) {
       readers.addElement(new MultiFormatUPCEANReader(hints));
       readers.addElement(new Code39Reader());
+      //readers.addElement(new CodaBarReader());
+      readers.addElement(new Code93Reader());      
       readers.addElement(new Code128Reader());
       readers.addElement(new ITFReader());
+      readers.addElement(new RSS14Reader());      
+      readers.addElement(new RSSExpandedReader());      
     }
   }
 
-  public Result decodeRow(int rowNumber, BitArray row, Hashtable hints) throws ReaderException {
+  public Result decodeRow(int rowNumber, BitArray row, Hashtable hints) throws NotFoundException {
     int size = readers.size();
     for (int i = 0; i < size; i++) {
       OneDReader reader = (OneDReader) readers.elementAt(i);
@@ -73,7 +95,15 @@ public final class MultiFormatOneDReader extends AbstractOneDReader {
       }
     }
 
-    throw ReaderException.getInstance();
+    throw NotFoundException.getNotFoundInstance();
+  }
+
+  public void reset() {
+    int size = readers.size();
+    for (int i = 0; i < size; i++) {
+      Reader reader = (Reader) readers.elementAt(i);
+      reader.reset();
+    }
   }
 
 }