|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiz.c24.io.api.presentation.stream.DataReader
biz.c24.io.api.presentation.stream.ByteAlignedBitDataReader
public class ByteAlignedBitDataReader
Byte aligned data stream reader.
Provides the byte processing during its deserialization.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class biz.c24.io.api.presentation.stream.DataReader |
---|
DataReader.Locator |
Field Summary | |
---|---|
protected byte[] |
buffer
The internal buffer array where the data is stored. |
protected InputStream |
stream
Underlied byte stream. |
Fields inherited from class biz.c24.io.api.presentation.stream.DataReader |
---|
count, eof, locator, pos |
Constructor Summary | |
---|---|
ByteAlignedBitDataReader(InputStream in)
Constructor with underlied byte input stream. |
Method Summary | |
---|---|
int |
available()
Returns the number of bits that can be read from this input stream. |
int |
availableBytes()
Returns the number of bytes that can be read from this input stream. |
protected void |
checkLength(int limit,
int actual)
|
protected int |
checkTheSign(long result,
int length)
|
void |
close()
Closes this input stream and releases any system resources associated with it. |
protected void |
compact(int from,
int requested)
Compacts the data in the internal buffer. |
protected int |
fill(int requested)
Fills the buffer with more data, taking into account shuffling and other tricks for dealing with marks. |
protected DataReader.Locator |
instantiateLocator()
|
byte[] |
read(int length)
Reads bytes from this byte-input stream into the specified byte array, starting at the given offset. |
byte |
readByte(int length)
Reades one byte from an input stream. |
int |
readInteger(int length)
Reades four bytes from an input stream. |
long |
readLong(int length)
Reades eight bytes from an input stream. |
protected long |
readPrimitives(int length)
|
short |
readShort(int length)
Reades two bytes from an input stream. |
byte |
readUnsignedByte(int length)
Reades one byte from an input stream. |
int |
readUnsignedInteger(int length)
Reades four bytes from an input stream. |
long |
readUnsignedLong(int length)
Reades eight bytes from an input stream. |
short |
readUnsignedShort(int length)
Reades two bytes from an input stream. |
int |
skip(int n)
See the general contract of the skip method of DataReader . |
int |
startsFrom(String[] sign)
Check wether the byte stream equals to specified str bytes. |
protected void |
updateValue(byte[] result,
int idx,
byte value)
|
protected long |
updateValue(long result,
int idx,
byte value)
|
Methods inherited from class biz.c24.io.api.presentation.stream.DataReader |
---|
ensureOpen, eof, getDataStream, getLocator, getLookAhead, getLookBehind, mark, rollback, setLookAhead, setLookBehind, updateLocator |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected InputStream stream
protected byte[] buffer
Constructor Detail |
---|
public ByteAlignedBitDataReader(InputStream in)
in
- the underlying input stream.
IllegalArgumentException
- if underlying input stream is NULL.Method Detail |
---|
public void close() throws IOException
close
in class DataReader
IOException
- if an I/O error occurs.public int available()
available
in class DataReader
FilterInputStream.in
public int availableBytes()
public int startsFrom(String[] sign) throws IOException
sign
- The charachter sequence against that the equality is checked.
IOException
- If an I/O error occurs.public byte readByte(int length) throws IOException
read..()
method with same length specified.
length
- the number of bits to read (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.read(int)
public byte readUnsignedByte(int length) throws IOException
read..()
method with same length specified.
length
- the number of bits to read (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.read(int)
public short readShort(int length) throws IOException
read..()
method with same length specified.
length
- the number of bits to read (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.readByte(int)
,
read(int)
public short readUnsignedShort(int length) throws IOException
read..()
method with same length specified.
length
- the number of bits to read (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.readByte(int)
,
read(int)
public int readInteger(int length) throws IOException
read..()
method with same length specified.
length
- the number of bits to read (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.readShort(int)
,
readByte(int)
,
read(int)
public int readUnsignedInteger(int length) throws IOException
read..()
method with same length specified.
length
- the number of bits to read (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.readShort(int)
,
readByte(int)
,
read(int)
public long readLong(int length) throws IOException
read..()
method with same length specified.
length
- the number of bits to read (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.readShort(int)
,
readByte(int)
,
read(int)
public long readUnsignedLong(int length) throws IOException
read..()
method with same length specified.
length
- the number of bits to read (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.readShort(int)
,
readByte(int)
,
read(int)
protected long readPrimitives(int length) throws IOException
IOException
public byte[] read(int length) throws IOException
This method implements the general contract of the corresponding
method of the read
class. As an
additional convenience, it attempts to read as many bytes as possible by
repeatedly invoking the InputStream
read
method of the underlying
stream. This iterated read
continues until one of the
following conditions becomes true:
read
method of the underlying stream returns
-1
, indicating end-of-file, or
available
method of the underlying stream returns
zero, indicating that further input requests would block.
read
on the underlying stream returns
-1
to indicate end-of-file then this method returns
-1
. Otherwise this method returns the number of bytes
actually read.
Subclasses of this class are encouraged, but not required, to attempt to read as many bytes as possible in the same fashion.
length
- number of bits to read.
-1
if the end of the
stream has been reached.
IOException
- if an I/O error occurs.public int skip(int n) throws IOException
skip
method of DataReader
.
skip
in class DataReader
n
- the number of bytes to be skipped.
IOException
- if an I/O error occurs.protected DataReader.Locator instantiateLocator()
protected int fill(int requested) throws IOException
fill
in class DataReader
requested
- The requested length of data in bytes.
IOException
- If read the underlied input stream failed.protected void compact(int from, int requested) throws IOException
DataReader
limit
values.
compact
in class DataReader
from
- The pointer in buffer up to which data may be marked as invalidated.requested
- the number of bytes that should stay in buffer in any way.
IOException
- If unexpected I/O error happends.protected int checkTheSign(long result, int length)
protected void updateValue(byte[] result, int idx, byte value)
protected long updateValue(long result, int idx, byte value)
protected final void checkLength(int limit, int actual)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |