diff --git a/core/src/com/google/zxing/common/BitArray.java b/core/src/com/google/zxing/common/BitArray.java index 398be9e15..d4e2f1903 100644 --- a/core/src/com/google/zxing/common/BitArray.java +++ b/core/src/com/google/zxing/common/BitArray.java @@ -34,6 +34,7 @@ public final class BitArray { } /** + * @param i bit to get * @return true iff bit i is set */ public boolean get(int i) { @@ -42,17 +43,26 @@ public final class BitArray { /** * Sets bit i. + * + * @param i bit to set */ public void set(int i) { bits[i >> 5] |= 1 << (i & 0x1F); } + /** + * Sets a block of 32 bits, starting at bit i. + * + * @param i first bit to set + * @param newBits the new value of the next 32 bits. Note again that the least-significant bit + * correponds to bit i, the next-least-significant to i+1, and so on. + */ public void setBulk(int i, int newBits) { bits[i >> 5] = newBits; } /** - * Clears all bits. + * Clears all bits (sets to false). */ public void clear() { int max = bits.length; diff --git a/core/src/com/google/zxing/common/BitMatrix.java b/core/src/com/google/zxing/common/BitMatrix.java index 435708f89..118166960 100755 --- a/core/src/com/google/zxing/common/BitMatrix.java +++ b/core/src/com/google/zxing/common/BitMatrix.java @@ -50,16 +50,35 @@ public final class BitMatrix { bits = new int[arraySize]; } + /** + * @param i row offset + * @param j column offset + * @return value of given bit in matrix + */ public boolean get(int i, int j) { int offset = i + dimension * j; return ((bits[offset >> 5] >>> (offset & 0x1F)) & 0x01) != 0; } + /** + *

Sets the given bit to true.

+ * + * @param i row offset + * @param j column offset + */ public void set(int i, int j) { int offset = i + dimension * j; bits[offset >> 5] |= 1 << (offset & 0x1F); } + /** + *

Sets a square region of the bit matrix to true.

+ * + * @param topI row offset of region's top-left corner (inclusive) + * @param leftJ column offset of region's top-left corner (inclusive) + * @param height height of region + * @param width width of region + */ public void setRegion(int topI, int leftJ, int height, int width) { if (topI < 0 || leftJ < 0) { throw new IllegalArgumentException("topI and leftJ must be nonnegative"); @@ -82,25 +101,30 @@ public final class BitMatrix { } } + /** + * @return row/column dimension of this matrix + */ public int getDimension() { return dimension; } + /** + * @return array of ints holding internal representation of this matrix's bits + */ public int[] getBits() { return bits; } /* public BufferedImage toBufferedImage() { - BufferedImage image = - new BufferedImage(dimension, dimension, BufferedImage.TYPE_BYTE_BINARY); - for (int j = 0; j < dimension; j++) { - for (int i = 0; i < dimension; i++) { - image.setRGB(j, i, get(i, j) ? 0x00000000 : 0x00FFFFFF); - } - } - return image; - } - */ + BufferedImage image = new BufferedImage(dimension, dimension, BufferedImage.TYPE_BYTE_BINARY); + for (int j = 0; j < dimension; j++) { + for (int i = 0; i < dimension; i++) { + image.setRGB(j, i, get(i, j) ? 0x00000000 : 0x00FFFFFF); + } + } + return image; + } + */ } diff --git a/core/src/com/google/zxing/common/Collections.java b/core/src/com/google/zxing/common/Collections.java index 4518b609d..fc927f576 100644 --- a/core/src/com/google/zxing/common/Collections.java +++ b/core/src/com/google/zxing/common/Collections.java @@ -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(); diff --git a/core/src/com/google/zxing/common/reedsolomon/GF256.java b/core/src/com/google/zxing/common/reedsolomon/GF256.java index 6bf44c2f0..fec0312c7 100644 --- a/core/src/com/google/zxing/common/reedsolomon/GF256.java +++ b/core/src/com/google/zxing/common/reedsolomon/GF256.java @@ -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; diff --git a/core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java b/core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java index 6986b1f25..ee94fc258 100644 --- a/core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java +++ b/core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java @@ -37,12 +37,22 @@ import java.util.Vector; * port of his C++ Reed-Solomon implementation.

* * @author srowen@google.com (Sean Owen) + * @author William Rucklidge */ public final class ReedSolomonDecoder { private ReedSolomonDecoder() { } + /** + *

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.

+ * + * @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];