|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGiciStream.BitStream
public class BitStream
This class is a bit buffer, useful to store a bit stream.
ATTENTION: this class should be optimized like ByteStream. Now it has a very poor performance!!!
Field Summary | |
---|---|
(package private) long |
actualPosition
Actual position in the bitstream (useful to scan bytestream from begin to end).. |
(package private) byte[] |
bitBuffer
Byte array used to store bits. |
(package private) int |
buffAllocation
Number of bytes used in each step of buffer allocation (when the buffer is full, another one es reserved with buffAllocation bytes more and the contents are copied). |
(package private) long |
numBits
Number of bits saved in bitBuffer. |
Constructor Summary | |
---|---|
BitStream()
Class constructor (performs needed initializations). |
|
BitStream(byte[] bitBuffer)
Class constructor that initilizaes the BitStream with a bitBuffer. |
|
BitStream(int initialSizeBuffer)
Class constructor with a specified amount of bits to allocate initially in the buffer. |
Method Summary | |
---|---|
void |
addBit(boolean bit)
Inserts a bit in the bitstream. |
void |
addBit(int bit)
Inserts a bit in the bitstream. |
void |
addBits(int bits,
int length)
Inserts the bits of an int to the bitstream starting at length MSB position of the int passed. |
void |
addBitStream(BitStream bs)
Inserts a BitStream in the current object. |
void |
addByte(int byt)
Inserts the bits of a byte into the bitstream. |
void |
deleteBeginBit()
Deletes a bit of the bitstream (starting at the begining of bitstream). |
void |
deleteBeginBits(long num)
Deletes a number of bits of the bitstream (starting at the begining of bitstream). |
void |
deleteEndBit()
Deletes a bit of the bitstream (starting at the end of bitstream). |
void |
deleteEndBits(long num)
Deletes a number of bits of the bitstream (starting at the end of bitstream). |
long |
getActualPosition()
Return the position of the bit which is pointed by the bitstream |
boolean |
getBit()
Return the actual bit and increments actual bit plus 1. |
boolean |
getBit(long numBit)
Return the bit value indicated. |
int |
getBits(int length)
Return length bits like an integer. |
byte[] |
getBitStream()
Return the bit stream in an array of bytes (the length of array byte returned is equal or greater than the real bytes used in bitStream -it can be known using getNumBits function-). |
byte |
getByte(int numByte)
Return the byte indicated. |
long |
getNumBits()
Return the number of bits in the bit stream. |
long |
getNumBytes()
Return the number of bytes in the bit stream. |
void |
reset()
Reset the bit stream |
void |
rewindBits(long numBits)
Rewind the index in the bit stream |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
byte[] bitBuffer
All values allowed.
long numBits
Negative values are not allowed for this field.
long actualPosition
Only positive values allowed.
int buffAllocation
Negative values are not allowed for this field.
Constructor Detail |
---|
public BitStream()
public BitStream(int initialSizeBuffer)
initialSizeBuffer
- number of bits that initially the buffer will containpublic BitStream(byte[] bitBuffer)
bitBuffer
- a byte array from which the BitStream initializes his bitBufferMethod Detail |
---|
public void addBit(boolean bit)
bit
- a boolean that indicates the bit (1=true, 0=false) to insertpublic void addBit(int bit)
bit
- a integer that indicates the bit (1=true, 0=false) to insertpublic void addByte(int byt)
byt
- the byte to be insertedpublic void addBits(int bits, int length)
bits
- a integer that contains the sequence of values to be insertedlength
- a integer that indicates the number of bits to take into accountpublic void addBitStream(BitStream bs)
bs
- BitStream object to append.public void deleteEndBit()
public void deleteEndBits(long num)
num
- the number of bits to deletepublic void deleteBeginBit() throws WarningException
WarningException
- because it uses addBit functionspublic void deleteBeginBits(long num) throws WarningException
num
- the number of bits to delete
WarningException
- because it uses addBit functionspublic boolean getBit(long numBit) throws WarningException
numBit
- the number of bit in bitstream (starting at 0)
WarningException
- when numBit is greater than the buffer lengthpublic boolean getBit() throws WarningException
WarningException
- when max buffer length is reachedpublic int getBits(int length) throws WarningException
length
- indicated the number of bits that must be given
WarningException
- when max buffer length is reachedpublic byte[] getBitStream()
public long getNumBits()
public byte getByte(int numByte) throws WarningException
numByte
- the number of byte in bytestream (starting at 0)
WarningException
- when numByte is greater than the buffer lengthpublic long getNumBytes()
public long getActualPosition()
public void reset()
public void rewindBits(long numBits) throws WarningException
numBits
- indicates the number of bits to be rewinded
WarningException
- when the number of bits to be rewinded is greater than the available.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |