public final class DataAccess extends Object implements Closeable
Constructor and Description |
---|
DataAccess(IOFile file)
Constructor, initializing the file reader.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
long |
cursor()
Returns the current file position.
|
void |
cursor(long pos)
Sets the disk cursor.
|
void |
flush()
Flushes the buffered data.
|
long |
free(long pos,
int size)
Returns the offset to a free slot for writing an entry with the
specified length.
|
long |
length()
Returns the file length.
|
boolean |
more()
Checks if more bytes can be read.
|
byte |
read1()
Reads a byte value.
|
byte |
read1(long pos)
Reads a byte value from the specified position.
|
int |
read4()
Reads an integer value.
|
int |
read4(long pos)
Reads an integer value from the specified position.
|
long |
read5()
Reads a 5-byte value.
|
long |
read5(long pos)
Reads a 5-byte value from the specified file offset.
|
byte[] |
readBytes(int len)
Reads a number of bytes.
|
byte[] |
readBytes(long pos,
int len)
Reads a number of bytes from the specified offset.
|
int |
readNum()
Reads the next compressed number and returns it as integer.
|
int |
readNum(long p)
Reads a
Num value from disk. |
byte[] |
readToken()
Reads the next token from disk.
|
byte[] |
readToken(long p)
Reads a token from disk.
|
void |
write4(int value)
Writes an integer value to the current position.
|
void |
write4(long pos,
int value)
Writes an integer value to the specified position.
|
void |
write5(long pos,
long value)
Writes a 5-byte value to the specified position.
|
void |
writeBytes(byte[] buffer,
int offset,
int len)
Writes a byte array to the file.
|
void |
writeNum(long pos,
int value)
Write a value to the file.
|
void |
writeNums(long p,
int[] values)
Writes integers to the file in compressed form.
|
void |
writeToken(long pos,
byte[] values)
Appends a value to the file and return it's offset.
|
public DataAccess(IOFile file) throws IOException
file
- the file to be readIOException
- I/O Exceptionpublic void flush()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public long cursor()
public long length()
public boolean more()
public byte read1(long pos)
pos
- positionpublic byte read1()
public int read4(long pos)
pos
- positionpublic int read4()
public long read5(long pos)
pos
- positionpublic long read5()
public int readNum(long p)
Num
value from disk.p
- text positionpublic byte[] readToken(long p)
p
- text positionpublic byte[] readToken()
public byte[] readBytes(long pos, int len)
pos
- positionlen
- lengthpublic byte[] readBytes(int len)
len
- lengthpublic void cursor(long pos)
pos
- read positionpublic int readNum()
public void write5(long pos, long value)
pos
- position in the filevalue
- value to be writtenpublic void write4(long pos, int value)
pos
- write positionvalue
- byte array to be appendedpublic void write4(int value)
value
- value to be writtenpublic void writeNum(long pos, int value)
pos
- write positionvalue
- value to be writtenpublic void writeNums(long p, int[] values)
p
- write positionvalues
- integer valuespublic void writeBytes(byte[] buffer, int offset, int len)
buffer
- buffer containing the tokenoffset
- offset in the buffer where the token startslen
- token lengthpublic void writeToken(long pos, byte[] values)
pos
- write positionvalues
- byte array to be appendedpublic long free(long pos, int size)
pos
- original offsetsize
- size of new text entryCopyright © 2005–2015 BaseX Team. All rights reserved.