\r
package com.google.zxing.pdf417.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.NotFoundException;\r
import com.google.zxing.common.BitMatrix;\r
import com.google.zxing.common.DecoderResult;\r
//import com.google.zxing.pdf417.reedsolomon.ReedSolomonDecoder;\r
*\r
* @param image booleans representing white/black PDF417 modules\r
* @return text and bytes encoded within the PDF417 Code\r
- * @throws ReaderException if the PDF417 Code cannot be decoded\r
+ * @throws NotFoundException if the PDF417 Code cannot be decoded\r
*/\r
- public DecoderResult decode(boolean[][] image) throws ReaderException {\r
+ public DecoderResult decode(boolean[][] image) throws FormatException {\r
int dimension = image.length;\r
BitMatrix bits = new BitMatrix(dimension);\r
for (int i = 0; i < dimension; i++) {\r
*\r
* @param bits booleans representing white/black PDF417 Code modules\r
* @return text and bytes encoded within the PDF417 Code\r
- * @throws ReaderException if the PDF417 Code cannot be decoded\r
+ * @throws FormatException if the PDF417 Code cannot be decoded\r
*/\r
- public DecoderResult decode(BitMatrix bits) throws ReaderException {\r
+ public DecoderResult decode(BitMatrix bits) throws FormatException {\r
// Construct a parser to read the data codewords and error-correction level\r
BitMatrixParser parser = new BitMatrixParser(bits);\r
int[] codewords = parser.readCodewords();\r
if (codewords == null || codewords.length == 0) {\r
- throw ReaderException.getInstance();\r
+ throw FormatException.getFormatInstance();\r
}\r
\r
int ecLevel = parser.getECLevel();\r
*\r
* @param codewords\r
* @return an index to the first data codeword.\r
- * @throws ReaderException\r
+ * @throws FormatException\r
*/\r
- private static void verifyCodewordCount(int[] codewords, int numECCodewords) throws ReaderException {\r
+ private static void verifyCodewordCount(int[] codewords, int numECCodewords) throws FormatException {\r
if (codewords.length < 4) {\r
// Codeword array size should be at least 4 allowing for\r
// Count CW, At least one Data CW, Error Correction CW, Error Correction CW\r
- throw ReaderException.getInstance();\r
+ throw FormatException.getFormatInstance();\r
}\r
// The first codeword, the Symbol Length Descriptor, shall always encode the total number of data\r
// codewords in the symbol, including the Symbol Length Descriptor itself, data codewords and pad\r
// codewords, but excluding the number of error correction codewords.\r
int numberOfCodewords = codewords[0];\r
if (numberOfCodewords > codewords.length) {\r
- throw ReaderException.getInstance();\r
+ throw FormatException.getFormatInstance();\r
}\r
if (numberOfCodewords == 0) {\r
// Reset to the length of the array - 8 (Allow for at least level 3 Error Correction (8 Error Codewords)\r
if (numECCodewords < codewords.length) {\r
codewords[0] = codewords.length - numECCodewords;\r
} else {\r
- throw ReaderException.getInstance();\r
+ throw FormatException.getFormatInstance();\r
}\r
}\r
}\r
* correct the errors in-place using Reed-Solomon error correction.</p>\r
*\r
* @param codewords data and error correction codewords\r
- * @throws ReaderException if error correction fails\r
+ * @throws ChecksumException if error correction fails\r
*/\r
- private static int correctErrors(int[] codewords, int[] erasures, int numECCodewords) throws ReaderException {\r
+ private static int correctErrors(int[] codewords, int[] erasures, int numECCodewords) throws FormatException {\r
if ((erasures != null && erasures.length > numECCodewords / 2 + MAX_ERRORS) ||\r
(numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS)) {\r
// Too many errors or EC Codewords is corrupted\r
- throw ReaderException.getInstance();\r
+ throw FormatException.getFormatInstance();\r
}\r
// Try to correct the errors\r
+ // TODO enable error correction\r
int result = 0; // rsDecoder.correctErrors(codewords, numECCodewords);\r
if (erasures != null) {\r
int numErasures = erasures.length;\r
}\r
if (numErasures > MAX_ERRORS) {\r
// Still too many errors\r
- throw ReaderException.getInstance();\r
+ throw FormatException.getFormatInstance();\r
}\r
}\r
return result;\r