Issue 537, don't return UPC-A for EAN-13 starting with 0 when UPC-A isn't allowed
[zxing.git] / core / src / com / google / zxing / oned / EAN13Reader.java
index 203ccdb..9c90e83 100644 (file)
@@ -16,8 +16,8 @@
 
 package com.google.zxing.oned;
 
-import com.google.zxing.ReaderException;
 import com.google.zxing.BarcodeFormat;
+import com.google.zxing.NotFoundException;
 import com.google.zxing.common.BitArray;
 
 /**
@@ -27,7 +27,7 @@ import com.google.zxing.common.BitArray;
  * @author Sean Owen
  * @author alasdair@google.com (Alasdair Mackintosh)
  */
-public final class EAN13Reader extends AbstractUPCEANReader {
+public final class EAN13Reader extends UPCEANReader {
 
   // For an EAN-13 barcode, the first digit is represented by the parities used
   // to encode the next six digits, according to the table below. For example,
@@ -58,7 +58,7 @@ public final class EAN13Reader extends AbstractUPCEANReader {
   // in binary:
   //                0    1    1   0   0    1   == 0x19
   //
-  public static final int[] FIRST_DIGIT_ENCODINGS = {
+  static final int[] FIRST_DIGIT_ENCODINGS = {
       0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A
   };
 
@@ -68,7 +68,8 @@ public final class EAN13Reader extends AbstractUPCEANReader {
     decodeMiddleCounters = new int[4];
   }
 
-  protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer resultString) throws ReaderException {
+  protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer resultString)
+      throws NotFoundException {
     int[] counters = decodeMiddleCounters;
     counters[0] = 0;
     counters[1] = 0;
@@ -111,22 +112,24 @@ public final class EAN13Reader extends AbstractUPCEANReader {
   }
 
   /**
-   * Based on pattern of odd-even ('L' and 'G') patterns used to encoded the explicitly-encoded digits
-   * in a barcode, determines the implicitly encoded first digit and adds it to the result string.
+   * Based on pattern of odd-even ('L' and 'G') patterns used to encoded the explicitly-encoded
+   * digits in a barcode, determines the implicitly encoded first digit and adds it to the
+   * result string.
    *
    * @param resultString string to insert decoded first digit into
    * @param lgPatternFound int whose bits indicates the pattern of odd/even L/G patterns used to
-   * encode digits
-   * @throws ReaderException if first digit cannot be determined
+   *  encode digits
+   * @throws NotFoundException if first digit cannot be determined
    */
-  private static void determineFirstDigit(StringBuffer resultString, int lgPatternFound) throws ReaderException {
+  private static void determineFirstDigit(StringBuffer resultString, int lgPatternFound)
+      throws NotFoundException {
     for (int d = 0; d < 10; d++) {
       if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) {
         resultString.insert(0, (char) ('0' + d));
         return;
       }
     }
-    throw ReaderException.getInstance();
+    throw NotFoundException.getNotFoundInstance();
   }
 
-}
\ No newline at end of file
+}