This class contains the data of an in-memory random access file.
Data compression using the LZF algorithm is supported as well.
| Methods |
| boolean |
canWrite()
Check whether writing is allowed.
|
| boolean |
canWrite()
Check whether writing is allowed.
Returns:
true if it is
|
| void |
compress(int page)
Compress the data in a byte array.
|
| void |
compress(int page)
Compress the data in a byte array.
Parameters:
page - which page to compress
|
| int |
getId()
|
| int |
getId()
|
| long |
getLastModified()
Get the last modified time.
|
| long |
getLastModified()
Get the last modified time.
Returns:
the time
|
| String |
getName()
Get the file name
|
| String |
getName()
Get the file name
Returns:
the name
|
| byte[] |
getPage(int page)
Get the page if it exists.
|
| byte[] |
getPage(int page)
Get the page if it exists.
Parameters:
page - the page id
Returns:
the byte array, or null
|
| long |
length()
Get the file length.
|
| long |
length()
Get the file length.
Returns:
the length
|
| boolean |
lockExclusive()
Lock the file in exclusive mode if possible.
|
| boolean |
lockExclusive()
Lock the file in exclusive mode if possible.
Returns:
if locking was successful
|
| boolean |
lockShared()
Lock the file in shared mode if possible.
|
| boolean |
lockShared()
Lock the file in shared mode if possible.
Returns:
if locking was successful
|
| long |
readWrite(long pos, byte[] b, int off, int len, boolean write)
Read or write.
|
| long |
readWrite(long pos, byte[] b, int off, int len, boolean write)
Read or write.
Parameters:
pos - the position
b - the byte array
off - the offset within the byte array
len - the number of bytes
write - true for writing
Returns:
the new position
|
| void |
setName(String name)
Set the file name.
|
| void |
setName(String name)
Set the file name.
Parameters:
name - the name
|
| void |
setPage(int page, byte[] oldData, byte[] newData, boolean force)
Set the page data.
|
| void |
setPage(int page, byte[] oldData, byte[] newData, boolean force)
Set the page data.
Parameters:
page - the page id
oldData - the old data
newData - the new data
force - whether the data should be overwritten even if the old data
doesn't match
|
| boolean |
setReadOnly()
Set the read-only flag.
|
| boolean |
setReadOnly()
Set the read-only flag.
Returns:
true
|
| void |
touch(boolean openReadOnly)
Update the last modified time.
|
| void |
touch(boolean openReadOnly) throws IOException
Update the last modified time.
Parameters:
openReadOnly - if the file was opened in read-only mode
|
| void |
truncate(long newLength)
Truncate the file.
|
| void |
truncate(long newLength)
Truncate the file.
Parameters:
newLength - the new length
|
| void |
unlock()
Unlock the file.
|
| void |
unlock()
Unlock the file.
|