public final class FilePosition
extends java.lang.Object
| Constructor | Description |
|---|---|
FilePosition(long fileSize,
int blockSize) |
Constructs an instance of
FilePosition. |
| Modifier and Type | Method | Description |
|---|---|---|
long |
absolute() |
Gets the current absolute position within this file.
|
int |
blockNumber() |
Gets the id of the current block.
|
java.nio.ByteBuffer |
buffer() |
|
boolean |
bufferFullyRead() |
Determines whether the current buffer has been fully read.
|
long |
bufferStartOffset() |
Gets the start of the current block's absolute offset.
|
BufferData |
data() |
|
void |
incrementBytesRead(int n) |
|
void |
invalidate() |
Marks the current position as invalid.
|
boolean |
isLastBlock() |
Determines whether the current block is the last block in this file.
|
boolean |
isValid() |
Determines if the current position is valid.
|
boolean |
isWithinCurrentBuffer(long pos) |
Determines whether the given absolute position lies within the current buffer.
|
int |
numBufferReads() |
|
int |
numBytesRead() |
|
int |
numSingleByteReads() |
|
int |
relative() |
Gets the current position within this file relative to the start of the associated buffer.
|
boolean |
setAbsolute(long pos) |
If the given
pos lies within the current buffer, updates the current position to
the specified value and returns true; otherwise returns false without changing the position. |
void |
setData(BufferData bufferData,
long startOffset,
long readOffset) |
Associates a buffer with this file.
|
java.lang.String |
toString() |
public FilePosition(long fileSize,
int blockSize)
FilePosition.fileSize - size of the associated file.blockSize - size of each block within the file.java.lang.IllegalArgumentException - if fileSize is negative.java.lang.IllegalArgumentException - if blockSize is zero or negative.public void setData(BufferData bufferData, long startOffset, long readOffset)
bufferData - the buffer associated with this file.startOffset - Start offset of the buffer relative to the start of a file.readOffset - Offset where reading starts relative to the start of a file.java.lang.IllegalArgumentException - if bufferData is null.java.lang.IllegalArgumentException - if startOffset is negative.java.lang.IllegalArgumentException - if readOffset is negative.java.lang.IllegalArgumentException - if readOffset is outside the range [startOffset, buffer end].public java.nio.ByteBuffer buffer()
public BufferData data()
public long absolute()
public boolean setAbsolute(long pos)
pos lies within the current buffer, updates the current position to
the specified value and returns true; otherwise returns false without changing the position.pos - the absolute position to change the current position to if possible.public int relative()
public boolean isWithinCurrentBuffer(long pos)
pos - the position to check.public int blockNumber()
public boolean isLastBlock()
public boolean isValid()
public void invalidate()
public long bufferStartOffset()
public boolean bufferFullyRead()
public void incrementBytesRead(int n)
public int numBytesRead()
public int numSingleByteReads()
public int numBufferReads()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2008–2025 Apache Software Foundation. All rights reserved.