Package net.sf.jazzlib
Class PendingBuffer
java.lang.Object
net.sf.jazzlib.PendingBuffer
- Direct Known Subclasses:
DeflaterPending
This class is general purpose class for writing data to a buffer.
It allows you to write bits as well as bytes
Based on DeflaterPending.java
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidfinal intflush(byte[] output, int offset, int length) Flushes the pending buffer into the given output array.final intfinal booleanfinal voidreset()final byte[]Flushes the pending buffer and returns that data in a new arrayfinal voidwriteBits(int b, int count) final voidwriteBlock(byte[] block, int offset, int len) final voidwriteByte(int b) final voidwriteInt(int s) final voidwriteShort(int s) final voidwriteShortMSB(int s)
-
Field Details
-
buf
protected byte[] buf -
start
int start -
end
int end -
bits
int bits -
bitCount
int bitCount
-
-
Constructor Details
-
PendingBuffer
public PendingBuffer() -
PendingBuffer
public PendingBuffer(int bufsize)
-
-
Method Details
-
reset
public final void reset() -
writeByte
public final void writeByte(int b) -
writeShort
public final void writeShort(int s) -
writeInt
public final void writeInt(int s) -
writeBlock
public final void writeBlock(byte[] block, int offset, int len) -
getBitCount
public final int getBitCount() -
alignToByte
public final void alignToByte() -
writeBits
public final void writeBits(int b, int count) -
writeShortMSB
public final void writeShortMSB(int s) -
isFlushed
public final boolean isFlushed() -
flush
public final int flush(byte[] output, int offset, int length) Flushes the pending buffer into the given output array. If the output array is to small, only a partial flush is done.- Parameters:
output- the output array;offset- the offset into output array;length- the maximum number of bytes to store;- Throws:
IndexOutOfBoundsException- if offset or length are invalid.
-
toByteArray
public final byte[] toByteArray()Flushes the pending buffer and returns that data in a new array- Parameters:
output- the output stream
-