"Split" ReaderException into subclasses to enable more useful error reporting
[zxing.git] / core / src / com / google / zxing / qrcode / decoder / BitMatrixParser.java
index fd8071c..c6f79b3 100644 (file)
@@ -16,7 +16,7 @@
 \r
 package com.google.zxing.qrcode.decoder;\r
 \r
-import com.google.zxing.ReaderException;\r
+import com.google.zxing.FormatException;\r
 import com.google.zxing.common.BitMatrix;\r
 \r
 /**\r
@@ -30,12 +30,12 @@ final class BitMatrixParser {
 \r
   /**\r
    * @param bitMatrix {@link BitMatrix} to parse\r
-   * @throws ReaderException if dimension is not >= 21 and 1 mod 4\r
+   * @throws FormatException if dimension is not >= 21 and 1 mod 4\r
    */\r
-  BitMatrixParser(BitMatrix bitMatrix) throws ReaderException {\r
+  BitMatrixParser(BitMatrix bitMatrix) throws FormatException {\r
     int dimension = bitMatrix.getDimension();\r
     if (dimension < 21 || (dimension & 0x03) != 1) {\r
-      throw ReaderException.getInstance();\r
+      throw FormatException.getFormatInstance();\r
     }\r
     this.bitMatrix = bitMatrix;\r
   }\r
@@ -44,10 +44,10 @@ final class BitMatrixParser {
    * <p>Reads format information from one of its two locations within the QR Code.</p>\r
    *\r
    * @return {@link FormatInformation} encapsulating the QR Code's format info\r
-   * @throws ReaderException if both format information locations cannot be parsed as\r
+   * @throws FormatException if both format information locations cannot be parsed as\r
    * the valid encoding of format information\r
    */\r
-  FormatInformation readFormatInformation() throws ReaderException {\r
+  FormatInformation readFormatInformation() throws FormatException {\r
 \r
     if (parsedFormatInfo != null) {\r
       return parsedFormatInfo;\r
@@ -87,17 +87,17 @@ final class BitMatrixParser {
     if (parsedFormatInfo != null) {\r
       return parsedFormatInfo;\r
     }\r
-    throw ReaderException.getInstance();\r
+    throw FormatException.getFormatInstance();\r
   }\r
 \r
   /**\r
    * <p>Reads version information from one of its two locations within the QR Code.</p>\r
    *\r
    * @return {@link Version} encapsulating the QR Code's version\r
-   * @throws ReaderException if both version information locations cannot be parsed as\r
+   * @throws FormatException if both version information locations cannot be parsed as\r
    * the valid encoding of version information\r
    */\r
-  Version readVersion() throws ReaderException {\r
+  Version readVersion() throws FormatException {\r
 \r
     if (parsedVersion != null) {\r
       return parsedVersion;\r
@@ -136,7 +136,7 @@ final class BitMatrixParser {
     if (parsedVersion != null && parsedVersion.getDimensionForVersion() == dimension) {\r
       return parsedVersion;\r
     }\r
-    throw ReaderException.getInstance();\r
+    throw FormatException.getFormatInstance();\r
   }\r
 \r
   private int copyBit(int i, int j, int versionBits) {\r
@@ -149,9 +149,9 @@ final class BitMatrixParser {
    * QR Code.</p>\r
    *\r
    * @return bytes encoded within the QR Code\r
-   * @throws ReaderException if the exact number of bytes expected is not read\r
+   * @throws FormatException if the exact number of bytes expected is not read\r
    */\r
-  byte[] readCodewords() throws ReaderException {\r
+  byte[] readCodewords() throws FormatException {\r
 \r
     FormatInformation formatInfo = readFormatInformation();\r
     Version version = readVersion();\r
@@ -200,7 +200,7 @@ final class BitMatrixParser {
       readingUp ^= true; // readingUp = !readingUp; // switch directions\r
     }\r
     if (resultOffset != version.getTotalCodewords()) {\r
-      throw ReaderException.getInstance();\r
+      throw FormatException.getFormatInstance();\r
     }\r
     return result;\r
   }\r