Small style stuff
[zxing.git] / core / src / com / google / zxing / datamatrix / decoder / Version.java
index dc6469b..5f97854 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright 2007 Google Inc.\r
+ * Copyright 2007 ZXing authors\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -16,8 +16,7 @@
 \r
 package com.google.zxing.datamatrix.decoder;\r
 \r
-import com.google.zxing.ReaderException;\r
-import com.google.zxing.common.BitMatrix;\r
+import com.google.zxing.FormatException;\r
 \r
 /**\r
  * The Version object encapsulates attributes about a particular\r
@@ -52,11 +51,11 @@ public final class Version {
     \r
     // Calculate the total number of codewords\r
     int total = 0;\r
-    int ecCodewords = ecBlocks.ecCodewords;\r
-    ECB[] ecbArray = ecBlocks.ecBlocks;\r
+    int ecCodewords = ecBlocks.getECCodewords();\r
+    ECB[] ecbArray = ecBlocks.getECBlocks();\r
     for (int i = 0; i < ecbArray.length; i++) {\r
       ECB ecBlock = ecbArray[i];\r
-      total += ecBlock.count * (ecBlock.dataCodewords + ecCodewords);\r
+      total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords);\r
     }\r
     this.totalCodewords = total;\r
   }\r
@@ -93,13 +92,13 @@ public final class Version {
    * <p>Deduces version information from Data Matrix dimensions.</p>\r
    *\r
    * @param numRows Number of rows in modules\r
-   * @param numRows Number of columns in modules\r
+   * @param numColumns Number of columns in modules\r
    * @return {@link Version} for a Data Matrix Code of those dimensions\r
-   * @throws ReaderException if dimensions do correspond to a valid Data Matrix size\r
+   * @throws FormatException if dimensions do correspond to a valid Data Matrix size\r
    */\r
-  public static Version getVersionForDimensions(int numRows, int numColumns) throws ReaderException {\r
+  public static Version getVersionForDimensions(int numRows, int numColumns) throws FormatException {\r
     if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) {\r
-      throw new ReaderException("Dimension must be 0 mod 2");\r
+      throw FormatException.getFormatInstance();\r
     }\r
     \r
     // TODO(bbrown): This is doing a linear search through the array of versions.\r
@@ -108,14 +107,12 @@ public final class Version {
     int numVersions = VERSIONS.length;\r
     for (int i = 0; i < numVersions; ++i){\r
       Version version = VERSIONS[i];\r
-      if (version.symbolSizeRows == numRows) {\r
-        if (version.symbolSizeColumns == numColumns) {\r
-          return version;\r
-        }\r
+      if (version.symbolSizeRows == numRows && version.symbolSizeColumns == numColumns) {\r
+        return version;\r
       }\r
     }\r
     \r
-    throw new ReaderException("Dimensions do not correspond to a valid Data Matrix Version.");\r
+    throw FormatException.getFormatInstance();\r
   }\r
 \r
   /**\r
@@ -125,8 +122,8 @@ public final class Version {
    * will be the same across all blocks within one version.</p>\r
    */\r
   static final class ECBlocks {\r
-    private int ecCodewords;\r
-    private ECB[] ecBlocks;\r
+    private final int ecCodewords;\r
+    private final ECB[] ecBlocks;\r
 \r
     private ECBlocks(int ecCodewords, ECB ecBlocks) {\r
       this.ecCodewords = ecCodewords;\r
@@ -153,8 +150,8 @@ public final class Version {
    * parameters is used consecutively in the Data Matrix code version's format.</p>\r
    */\r
   static final class ECB {\r
-    private int count;\r
-    private int dataCodewords;\r
+    private final int count;\r
+    private final int dataCodewords;\r
 \r
     private ECB(int count, int dataCodewords) {\r
       this.count = count;\r
@@ -235,7 +232,7 @@ public final class Version {
             new ECBlocks(14, new ECB(1, 16))),\r
         new Version(28, 12, 36, 10, 16,\r
             new ECBlocks(18, new ECB(1, 22))),\r
-        new Version(29, 16, 36, 10, 16,\r
+        new Version(29, 16, 36, 14, 16,\r
             new ECBlocks(24, new ECB(1, 32))),\r
         new Version(30, 16, 48, 14, 22,\r
             new ECBlocks(28, new ECB(1, 49)))\r