Small style stuff
[zxing.git] / core / src / com / google / zxing / datamatrix / decoder / Decoder.java
index 5ec86d2..47ecac9 100644 (file)
@@ -16,7 +16,8 @@
 \r
 package com.google.zxing.datamatrix.decoder;\r
 \r
-import com.google.zxing.ReaderException;\r
+import com.google.zxing.ChecksumException;\r
+import com.google.zxing.FormatException;\r
 import com.google.zxing.common.BitMatrix;\r
 import com.google.zxing.common.DecoderResult;\r
 import com.google.zxing.common.reedsolomon.GF256;\r
@@ -43,15 +44,16 @@ public final class Decoder {
    *\r
    * @param image booleans representing white/black Data Matrix Code modules\r
    * @return text and bytes encoded within the Data Matrix Code\r
-   * @throws ReaderException if the Data Matrix Code cannot be decoded\r
+   * @throws FormatException if the Data Matrix Code cannot be decoded\r
+   * @throws ChecksumException if error correction fails\r
    */\r
-  public DecoderResult decode(boolean[][] image) throws ReaderException {\r
+  public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException {\r
     int dimension = image.length;\r
     BitMatrix bits = new BitMatrix(dimension);\r
     for (int i = 0; i < dimension; i++) {\r
       for (int j = 0; j < dimension; j++) {\r
         if (image[i][j]) {\r
-          bits.set(i, j);\r
+          bits.set(j, i);\r
         }\r
       }\r
     }\r
@@ -64,13 +66,14 @@ public final class Decoder {
    *\r
    * @param bits booleans representing white/black Data Matrix Code modules\r
    * @return text and bytes encoded within the Data Matrix Code\r
-   * @throws ReaderException if the Data Matrix Code cannot be decoded\r
+   * @throws FormatException if the Data Matrix Code cannot be decoded\r
+   * @throws ChecksumException if error correction fails\r
    */\r
-  public DecoderResult decode(BitMatrix bits) throws ReaderException {\r
+  public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException {\r
 \r
     // Construct a parser and read version, error-correction level\r
     BitMatrixParser parser = new BitMatrixParser(bits);\r
-    Version version = parser.readVersion(bits);\r
+    Version version = parser.getVersion();\r
 \r
     // Read codewords\r
     byte[] codewords = parser.readCodewords();\r
@@ -106,9 +109,9 @@ public final class Decoder {
    *\r
    * @param codewordBytes data and error correction codewords\r
    * @param numDataCodewords number of codewords that are data bytes\r
-   * @throws ReaderException if error correction fails\r
+   * @throws ChecksumException if error correction fails\r
    */\r
-  private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ReaderException {\r
+  private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {\r
     int numCodewords = codewordBytes.length;\r
     // First read into an array of ints\r
     int[] codewordsInts = new int[numCodewords];\r
@@ -119,7 +122,7 @@ public final class Decoder {
     try {\r
       rsDecoder.decode(codewordsInts, numECCodewords);\r
     } catch (ReedSolomonException rse) {\r
-      throw new ReaderException(rse.toString());\r
+      throw ChecksumException.getChecksumInstance();\r
     }\r
     // Copy back into array of bytes -- only need to worry about the bytes that were data\r
     // We don't care about errors in the error-correction codewords\r