Added more javadoc
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 6 Nov 2007 18:56:30 +0000 (18:56 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 6 Nov 2007 18:56:30 +0000 (18:56 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@9 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/common/BitArray.java
core/src/com/google/zxing/common/BitMatrix.java
core/src/com/google/zxing/common/Collections.java
core/src/com/google/zxing/common/reedsolomon/GF256.java
core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java

index 398be9e..d4e2f19 100644 (file)
@@ -34,6 +34,7 @@ public final class BitArray {
   }\r
 \r
   /**\r
+   * @param i bit to get\r
    * @return true iff bit i is set\r
    */\r
   public boolean get(int i) {\r
@@ -42,17 +43,26 @@ public final class BitArray {
 \r
   /**\r
    * Sets bit i.\r
+   *\r
+   * @param i bit to set\r
    */\r
   public void set(int i) {\r
     bits[i >> 5] |= 1 << (i & 0x1F);\r
   }\r
 \r
+  /**\r
+   * Sets a block of 32 bits, starting at bit i.\r
+   *\r
+   * @param i first bit to set\r
+   * @param newBits the new value of the next 32 bits. Note again that the least-significant bit\r
+   *  correponds to bit i, the next-least-significant to i+1, and so on.\r
+   */\r
   public void setBulk(int i, int newBits) {\r
     bits[i >> 5] = newBits;\r
   }\r
 \r
   /**\r
-   * Clears all bits.\r
+   * Clears all bits (sets to false).\r
    */\r
   public void clear() {\r
     int max = bits.length;\r
index 435708f..1181669 100755 (executable)
@@ -50,16 +50,35 @@ public final class BitMatrix {
     bits = new int[arraySize];\r
   }\r
 \r
+  /**\r
+   * @param i row offset\r
+   * @param j column offset\r
+   * @return value of given bit in matrix\r
+   */\r
   public boolean get(int i, int j) {\r
     int offset = i + dimension * j;\r
     return ((bits[offset >> 5] >>> (offset & 0x1F)) & 0x01) != 0;\r
   }\r
 \r
+  /**\r
+   * <p>Sets the given bit to true.</p>\r
+   *\r
+   * @param i row offset\r
+   * @param j column offset\r
+   */\r
   public void set(int i, int j) {\r
     int offset = i + dimension * j;\r
     bits[offset >> 5] |= 1 << (offset & 0x1F);\r
   }\r
 \r
+  /**\r
+   * <p>Sets a square region of the bit matrix to true.</p>\r
+   *\r
+   * @param topI row offset of region's top-left corner (inclusive)\r
+   * @param leftJ column offset of region's top-left corner (inclusive)\r
+   * @param height height of region\r
+   * @param width width of region\r
+   */\r
   public void setRegion(int topI, int leftJ, int height, int width) {\r
     if (topI < 0 || leftJ < 0) {\r
       throw new IllegalArgumentException("topI and leftJ must be nonnegative");\r
@@ -82,25 +101,30 @@ public final class BitMatrix {
     }\r
   }\r
 \r
+  /**\r
+   * @return row/column dimension of this matrix\r
+   */\r
   public int getDimension() {\r
     return dimension;\r
   }\r
 \r
+  /**\r
+   * @return array of ints holding internal representation of this matrix's bits\r
+   */\r
   public int[] getBits() {\r
     return bits;\r
   }\r
 \r
   /*\r
   public BufferedImage toBufferedImage() {\r
-               BufferedImage image =\r
-                 new BufferedImage(dimension, dimension, BufferedImage.TYPE_BYTE_BINARY);\r
-               for (int j = 0; j < dimension; j++) {\r
-                       for (int i = 0; i < dimension; i++) {\r
-                               image.setRGB(j, i, get(i, j) ? 0x00000000 : 0x00FFFFFF);\r
-                       }\r
-               }\r
-               return image;\r
-       }\r
-        */\r
+    BufferedImage image = new BufferedImage(dimension, dimension, BufferedImage.TYPE_BYTE_BINARY);\r
+    for (int j = 0; j < dimension; j++) {\r
+      for (int i = 0; i < dimension; i++) {\r
+        image.setRGB(j, i, get(i, j) ? 0x00000000 : 0x00FFFFFF);\r
+      }\r
+    }\r
+    return image;\r
+  }\r
+   */\r
 \r
 }\r
index 4518b60..fc927f5 100644 (file)
@@ -30,8 +30,8 @@ public final class Collections {
    * Sorts its argument (destructively) using insert sort; in the context of this package
    * insertion sort is simple and efficient given its relatively small inputs.
    * 
-   * @param vector
-   * @param comparator
+   * @param vector vector to sort
+   * @param comparator comparator to define sort ordering
    */
   public static void insertionSort(Vector vector, Comparator comparator) {
     int max = vector.size();
index 6bf44c2..fec0312 100644 (file)
@@ -51,16 +51,24 @@ final class GF256 {
   }
 
   /**
-   * Addition and subtraction are the same in GF(256).
+   * Implements both addition and subtraction -- they are the same in GF(256).
+   * 
+   * @return sum/difference of a and b
    */
   static int addOrSubtract(int a, int b) {
     return a ^ b;
   }
 
+  /**
+   * @return 2 to the power of a in GF(256)
+   */
   static int exp(int a) {
     return exp[a];
   }
 
+  /**
+   * @return base 2 log of a in GF(256)
+   */
   static int log(int a) {
     if (a == 0) {
       throw new IllegalArgumentException();
@@ -78,6 +86,12 @@ final class GF256 {
     return exp[255 - log[a]];
   }
 
+  /**
+   *
+   * @param a
+   * @param b
+   * @return product of a and b in GF(256)
+   */
   static int multiply(int a, int b) {
     if (a == 0 || b == 0) {
       return 0;
index 6986b1f..ee94fc2 100644 (file)
@@ -37,12 +37,22 @@ import java.util.Vector;
  * port of his C++ Reed-Solomon implementation.</p>
  *
  * @author srowen@google.com (Sean Owen)
+ * @author William Rucklidge
  */
 public final class ReedSolomonDecoder {
   
   private ReedSolomonDecoder() {
   }
 
+  /**
+   * <p>Decodes given set of received codewords, which include both data and error-correction
+   * codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place,
+   * in the input.</p>
+   *
+   * @param received data and error-correction codewords
+   * @param twoS number of error-correction codewords available
+   * @throws ReedSolomonException if decoding fails for any reaosn
+   */
   public static void decode(int[] received, int twoS) throws ReedSolomonException {
     GF256Poly poly = new GF256Poly(received);
     int[] syndromeCoefficients = new int[twoS];