Class BitStreamReader
- java.lang.Object
-
- com.sedmelluq.discord.lavaplayer.tools.io.BitStreamReader
-
- Direct Known Subclasses:
BitBufferReader
public class BitStreamReader extends java.lang.ObjectHelper for reading a specific number of bits at a time from a stream.
-
-
Constructor Summary
Constructors Constructor Description BitStreamReader(java.io.InputStream stream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intasInteger(int bitsNeeded)Get the specified number of bits as an integer valuelongasLong(int bitsNeeded)Get the specified number of bits as a long valueintasSignedInteger(int bitsNeeded)Get the specific number of bits as a signed integer value (highest order bit is sign)longasSignedLong(int bitsNeeded)Get the specific number of bits as a signed long value (highest order bit is sign)intreadAllZeroes()Reads bits from the stream until a set bit is reached.protected intreadByte()intreadRemainingBits()Reads the number of bits it requires to make the reader align on a byte.
-
-
-
Method Detail
-
asLong
public long asLong(int bitsNeeded) throws java.io.IOExceptionGet the specified number of bits as a long value- Parameters:
bitsNeeded- Number of bits to retrieve- Returns:
- The value of those bits as a long
- Throws:
java.io.IOException- On read error
-
asSignedLong
public long asSignedLong(int bitsNeeded) throws java.io.IOExceptionGet the specific number of bits as a signed long value (highest order bit is sign)- Parameters:
bitsNeeded- Number of bits needed- Returns:
- The signed value
- Throws:
java.io.IOException- On read error
-
asInteger
public int asInteger(int bitsNeeded) throws java.io.IOExceptionGet the specified number of bits as an integer value- Parameters:
bitsNeeded- Number of bits to retrieve- Returns:
- The value of those bits as an integer
- Throws:
java.io.IOException- On read error
-
asSignedInteger
public int asSignedInteger(int bitsNeeded) throws java.io.IOExceptionGet the specific number of bits as a signed integer value (highest order bit is sign)- Parameters:
bitsNeeded- Number of bits needed- Returns:
- The signed value
- Throws:
java.io.IOException- On read error
-
readAllZeroes
public int readAllZeroes() throws java.io.IOExceptionReads bits from the stream until a set bit is reached.- Returns:
- The number of zeroes read
- Throws:
java.io.IOException- On read error
-
readRemainingBits
public int readRemainingBits()
Reads the number of bits it requires to make the reader align on a byte.- Returns:
- The read bits as an unsigned value
-
readByte
protected int readByte() throws java.io.IOException- Throws:
java.io.IOException
-
-