|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiz.c24.io.api.presentation.stream.ByteAlignedBitDataWriter
biz.c24.io.api.presentation.stream.BitDataWriter
public class BitDataWriter
Bit aligned data stream writer.
Provides the byte stream processing as bit sequence.
Field Summary |
---|
Fields inherited from class biz.c24.io.api.presentation.stream.ByteAlignedBitDataWriter |
---|
stream |
Constructor Summary | |
---|---|
BitDataWriter(OutputStream out)
Constructs the bit sequence stream with underlied input stream. |
Method Summary | |
---|---|
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out. |
void |
write(byte[] data,
int length)
Write byte array into output stream. |
protected void |
write(byte data,
int length,
int shiftLeft,
int shiftRight)
|
void |
writeByte(byte data,
int length)
Writes one byte into an output stream. |
void |
writeInteger(int data,
int length)
Writes fourth bytes into an output stream. |
void |
writeLong(long data,
int length)
Writes eights bytes into an output stream. |
protected void |
writePrimitives(long data,
int length)
Write data into output stream. |
void |
writeShort(short data,
int length)
Writes two bytes into an output stream. |
Methods inherited from class biz.c24.io.api.presentation.stream.ByteAlignedBitDataWriter |
---|
acquireLength, checkLength, close |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BitDataWriter(OutputStream out)
out
- The underlied output stream.Method Detail |
---|
public void writeByte(byte data, int length) throws IOException
write..()
method with same length specified.
writeByte
in class ByteAlignedBitDataWriter
data
- the data.length
- the number of bits to write (allowed values 1..8).
IllegalArgumentException
- if specified length is
below or equals to 0 or greater than 8.
IOException
- if an I/O error occurs.write(byte[], int)
public void writeShort(short data, int length) throws IOException
write..()
method with same length specified.
writeShort
in class ByteAlignedBitDataWriter
data
- the data.length
- the number of bits to write (allowed values 1..16).
IllegalArgumentException
- if specified length is
below or equals to 0 or greater than 16.
IOException
- if an I/O error occurs.writeByte(byte, int)
,
write(byte[], int)
public void writeInteger(int data, int length) throws IOException
write..()
method with same length specified.
writeInteger
in class ByteAlignedBitDataWriter
data
- the data.length
- the number of bits to write (allowed values 1..32).
IllegalArgumentException
- if specified length is
below or equals to 0 or greater than 32.
IOException
- if an I/O error occurs.writeByte(byte, int)
,
writeShort(short, int)
,
write(byte[], int)
public void writeLong(long data, int length) throws IOException
write..()
method with same length specified.
writeLong
in class ByteAlignedBitDataWriter
data
- the data.length
- the number of bits to write (allowed values 1..64).
IllegalArgumentException
- if specified length is
below or equals to 0 or greater than 64.
IOException
- if an I/O error occurs.writeShort(short, int)
,
writeInteger(int, int)
,
write(byte[], int)
public void write(byte[] data, int length) throws IOException
[0]
is the first byte written and data[length - 1]
is
the last byte written by this operation.
This method calls the special write
method on each of the bytes to be written out. Subclasses are encouraged
to override the method
to provide an
other byte ordering implementation.
The null value is restricted as data value. The allowed values of length is any positive number above the 0.
write
in class ByteAlignedBitDataWriter
data
- the data to be written.length
- the number of bits to write.
NullPointerException
- if specified data is
null.
IllegalArgumentException
- if specified length is
below or equals to 0.
IOException
- if an I/O error occurs. In particular, an
IOException
is thrown if the output
stream is closed.public void flush() throws IOException
flush
is that calling
it is an indication that, if any bytes previously written have been
buffered by the implementation of the output stream, such bytes should
immediately be written to their intended destination.
The flush
method of OutputStream
does nothing.
flush
in class ByteAlignedBitDataWriter
IOException
- if an I/O error occurs.protected void writePrimitives(long data, int length) throws IOException
short
, int
and long
. Subclasses of this may override it to provide
the other byte ordering.
The general contract for this method is that the bytes in the
data are written to the output stream in network order (the
standard Java byte ordering) when highest byte is the first byte written
and lowest is the last byte written by this operation.
writePrimitives
in class ByteAlignedBitDataWriter
data
- the data to be written.length
- the number of bits that should be written.
IOException
- if an I/O error occurs.protected final void write(byte data, int length, int shiftLeft, int shiftRight) throws IOException
data
- length
- shiftLeft
- shiftRight
-
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |