package com.google.zxing.qrcode.decoder;\r
\r
/**\r
- * This provides an easy abstraction to read bits at a time from a sequence of bytes, where the\r
- * number of bits read is not often a multiple of 8.\r
+ * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the\r
+ * number of bits read is not often a multiple of 8.</p>\r
+ *\r
+ * <p>This class is not thread-safe.</p>\r
*\r
* @author srowen@google.com (Sean Owen)\r
*/\r
private int byteOffset;\r
private int bitOffset;\r
\r
+ /**\r
+ * @param bytes bytes from which this will read bits. Bits will be read from the first byte first.\r
+ * Bits are read within a byte from most-significant to least-significant bit.\r
+ */\r
BitSource(byte[] bytes) {\r
this.bytes = bytes;\r
}\r
\r
/**\r
+ * @param numBits number of bits to read\r
+ * @return int representing the bits read. The bits will appear as the least-significant\r
+ * bits of the int\r
* @throws IllegalArgumentException if numBits isn't in [1,32]\r
*/\r
int readBits(int numBits) {\r
return result;\r
}\r
\r
+ /**\r
+ * @return number of bits that can be read successfully\r
+ */\r
int available() {\r
return 8 * (bytes.length - byteOffset) - bitOffset;\r
}\r