You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2014/11/01 12:31:57 UTC
svn commit: r1635927 -
/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/BitInputStream.java
Author: bodewig
Date: Sat Nov 1 11:31:56 2014
New Revision: 1635927
URL: http://svn.apache.org/r1635927
Log:
add some javadocs, check argument to readBits
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/BitInputStream.java
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/BitInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/BitInputStream.java?rev=1635927&r1=1635926&r2=1635927&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/BitInputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/BitInputStream.java Sat Nov 1 11:31:56 2014
@@ -49,12 +49,26 @@ public class BitInputStream implements C
in.close();
}
+ /**
+ * Clears the cache of bits that have been read from the
+ * underlying stream but not yet provided via {@link #readBits}.
+ */
public void clearBitCache() {
bitsCached = 0;
bitsCachedSize = 0;
}
+ /**
+ * Returns at most 32 bits read from the underlying stream.
+ *
+ * @param count the number of bits to read, must be a positive
+ * number not bigger than 32.
+ * @return the bits concatenated as an integer using the stream's byte order.
+ */
public int readBits(final int count) throws IOException {
+ if (count < 0 || count > 32) {
+ throw new IllegalArgumentException("count must be between 0 and 32");
+ }
while (bitsCachedSize < count) {
final int nextByte = in.read();
if (nextByte < 0) {