|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.store.FileStore
public class FileStore
This class is an abstraction of a random access file.
Each file contains a magic header, and reading / writing is done in blocks.
See also SecureFileStore
Field Summary | |
---|---|
protected static byte[] |
EMPTY
An empty buffer to speed up extending the file (it seems that writing 0 bytes is faster then calling setLength). |
protected DataHandler |
handler
The callback object is responsible to check access rights, and free up disk space if required. |
static int |
HEADER_LENGTH
The size of the file header in bytes. |
protected java.lang.String |
name
The file name. |
Constructor Summary | |
---|---|
protected |
FileStore(DataHandler handler,
java.lang.String name,
java.lang.String mode)
Create a new file using the given settings. |
Method Summary | |
---|---|
void |
autoDelete()
Automatically delete the file once it is no longer in use. |
void |
close()
Close the file. |
void |
closeAndDeleteSilently()
Close the file (ignoring exceptions) and delete the file. |
void |
closeFile()
Close the file. |
void |
closeSilently()
Close the file without throwing any exceptions. |
protected byte[] |
generateSalt()
Generate the random salt bytes if required. |
long |
getFilePointer()
Get the current location of the file pointer. |
void |
init()
Initialize the file. |
protected void |
initKey(byte[] salt)
Initialize the key using the given salt. |
boolean |
isEncrypted()
Check if the file is encrypted. |
boolean |
isTextMode()
Check if the file store is in text mode. |
long |
length()
Get the file size in bytes. |
static FileStore |
open(DataHandler handler,
java.lang.String name,
java.lang.String mode)
Open a non encrypted file store with the given settings. |
static FileStore |
open(DataHandler handler,
java.lang.String name,
java.lang.String mode,
java.lang.String cipher,
byte[] key)
Open an encrypted file store with the given settings. |
static FileStore |
open(DataHandler handler,
java.lang.String name,
java.lang.String mode,
java.lang.String cipher,
byte[] key,
int keyIterations)
Open an encrypted file store with the given settings. |
void |
openFile()
Re-open the file. |
void |
readFully(byte[] b,
int off,
int len)
Read a number of bytes. |
protected void |
readFullyDirect(byte[] b,
int off,
int len)
Read a number of bytes without decrypting. |
void |
seek(long pos)
Go to the specified file location. |
void |
setCheckedWriting(boolean value)
|
void |
setLength(long newLength)
Set the length of the file. |
void |
stopAutoDelete()
No longer automatically delete the file once it is no longer in use. |
void |
sync()
Call fsync. |
void |
write(byte[] b,
int off,
int len)
Write a number of bytes. |
protected void |
writeDirect(byte[] b,
int off,
int len)
Write a number of bytes without encrypting. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int HEADER_LENGTH
protected static final byte[] EMPTY
protected java.lang.String name
protected DataHandler handler
Constructor Detail |
---|
protected FileStore(DataHandler handler, java.lang.String name, java.lang.String mode) throws java.sql.SQLException
handler
- the callback objectname
- the file namemode
- the access mode ("r", "rw", "rws", "rwd")
java.sql.SQLException
Method Detail |
---|
public static FileStore open(DataHandler handler, java.lang.String name, java.lang.String mode) throws java.sql.SQLException
handler
- the data handlername
- the file namemode
- the access mode (r, rw, rws, rwd)
java.sql.SQLException
public static FileStore open(DataHandler handler, java.lang.String name, java.lang.String mode, java.lang.String cipher, byte[] key) throws java.sql.SQLException
handler
- the data handlername
- the file namemode
- the access mode (r, rw, rws, rwd)cipher
- the name of the cipher algorithmkey
- the encryption key
java.sql.SQLException
public static FileStore open(DataHandler handler, java.lang.String name, java.lang.String mode, java.lang.String cipher, byte[] key, int keyIterations) throws java.sql.SQLException
handler
- the data handlername
- the file namemode
- the access mode (r, rw, rws, rwd)cipher
- the name of the cipher algorithmkey
- the encryption keykeyIterations
- the number of iterations the key should be hashed
java.sql.SQLException
protected byte[] generateSalt()
protected void initKey(byte[] salt)
salt
- the saltpublic void setCheckedWriting(boolean value)
public void init() throws java.sql.SQLException
java.sql.SQLException
public void close() throws java.io.IOException
java.io.IOException
public void closeSilently()
public void closeAndDeleteSilently()
protected void readFullyDirect(byte[] b, int off, int len) throws java.sql.SQLException
b
- the target bufferoff
- the offsetlen
- the number of bytes to read
java.sql.SQLException
public void readFully(byte[] b, int off, int len) throws java.sql.SQLException
b
- the target bufferoff
- the offsetlen
- the number of bytes to read
java.sql.SQLException
public void seek(long pos) throws java.sql.SQLException
pos
- the location
java.sql.SQLException
protected void writeDirect(byte[] b, int off, int len) throws java.sql.SQLException
b
- the source bufferoff
- the offsetlen
- the number of bytes to write
java.sql.SQLException
public void write(byte[] b, int off, int len) throws java.sql.SQLException
b
- the source bufferoff
- the offsetlen
- the number of bytes to write
java.sql.SQLException
public void setLength(long newLength) throws java.sql.SQLException
newLength
- the new file size
java.sql.SQLException
public long length() throws java.sql.SQLException
java.sql.SQLException
public long getFilePointer() throws java.sql.SQLException
java.sql.SQLException
public void sync()
public void autoDelete()
public void stopAutoDelete()
public boolean isEncrypted()
public void closeFile() throws java.io.IOException
java.io.IOException
public void openFile() throws java.io.IOException
java.io.IOException
public boolean isTextMode()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |