public abstract class BlockInput extends java.lang.Object implements BasicInput
Modifier | Constructor and Description |
---|---|
protected |
BlockInput(int nblock)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract java.nio.ByteBuffer |
acquireBlock(int iblock)
Obtains a buffer corresponding to a named block of the stream.
|
void |
close()
Releases resources belonging to this object.
|
int |
getBlockCount()
Returns the number of mapped blocks used.
|
abstract long |
getBlockOffset(int iblock,
int offsetInBlock)
Returns the offset into this stream corresponding to a given
block index and offset into that block.
|
abstract int[] |
getBlockPos(long offset)
Returns the block location of a given byte offset.
|
long |
getOffset()
Returns the curent position in this stream
(optional operation).
|
boolean |
isRandom()
Indicates whether this object supports random access.
|
byte |
readByte()
Reads a byte from the stream.
|
void |
readBytes(byte[] bbuf)
Reads bytes into an array from the stream.
|
double |
readDouble()
Reads an 8-byte floating point value from the stream.
|
float |
readFloat()
Reads a 4-byte floating point value from the stream.
|
int |
readInt()
Reads a 4-byte integer from the stream.
|
long |
readLong()
Reads an 8-byte integer from the stream.
|
short |
readShort()
Reads a 2-byte integer from the stream.
|
void |
seek(long offset)
Moves the current position of this stream to a given byte offset
(optional operation).
|
void |
skip(long nbyte)
Skips a given number of bytes forwards through the stream.
|
protected BlockInput(int nblock)
nblock
- number of bufferspublic byte readByte() throws java.io.IOException
BasicInput
readByte
in interface BasicInput
java.io.IOException
public short readShort() throws java.io.IOException
BasicInput
readShort
in interface BasicInput
java.io.IOException
public int readInt() throws java.io.IOException
BasicInput
readInt
in interface BasicInput
java.io.IOException
public long readLong() throws java.io.IOException
BasicInput
readLong
in interface BasicInput
java.io.IOException
public float readFloat() throws java.io.IOException
BasicInput
readFloat
in interface BasicInput
java.io.IOException
public double readDouble() throws java.io.IOException
BasicInput
readDouble
in interface BasicInput
java.io.IOException
public void readBytes(byte[] bbuf) throws java.io.IOException
BasicInput
readBytes
in interface BasicInput
bbuf
- array into which the bytes are read;
the number of bytes read is the length of the arrayjava.io.IOException
public void close()
BasicInput
close
in interface BasicInput
public boolean isRandom()
BasicInput
isRandom
in interface BasicInput
public abstract int[] getBlockPos(long offset)
This does the opposite of getBlockOffset
.
offset
- offset into this input streampublic abstract long getBlockOffset(int iblock, int offsetInBlock)
This does the opposite of getBlockPos
.
iblock
- block indexoffsetInBlock
- offset into that blockprotected abstract java.nio.ByteBuffer acquireBlock(int iblock) throws java.io.IOException
iblock
- block indexjava.io.IOException
public void seek(long offset) throws java.io.IOException
BasicInput
seek
in interface BasicInput
java.io.IOException
public long getOffset()
BasicInput
getOffset
in interface BasicInput
public void skip(long nbyte) throws java.io.IOException
BasicInput
skip
in interface BasicInput
nbyte
- number of bytes to skipjava.io.IOException
public int getBlockCount()