public class RandomAccessDatabaseStream extends Object implements DatabaseStream
Modifier and Type | Field and Description |
---|---|
int |
maxBufferSize |
static boolean |
unsafe |
Constructor and Description |
---|
RandomAccessDatabaseStream(File file,
String mode) |
RandomAccessDatabaseStream(File file,
String mode,
boolean ignoreInconsistentState) |
RandomAccessDatabaseStream(RandomStream stream,
String mode) |
RandomAccessDatabaseStream(RandomStream stream,
String mode,
boolean ignoreInconsistentState) |
Modifier and Type | Method and Description |
---|---|
boolean |
atEOF(long location) |
boolean |
canWrite()
Tests if the DatabaseStream was opened in read-write mode as opposed to read-ony mode.
|
void |
close() |
void |
delete() |
void |
flush() |
int |
getFirstDataLocation()
Return the location of where you can store your data.
|
Time |
getModifiedTime() |
long |
length() |
protected int |
read(byte[] data,
int offset,
int length) |
void |
readAll(long location,
byte[] data,
int offset,
int length)
This throws an exception if all the specified bytes are not found at the specified
location.
|
int |
readIntAt(long location) |
void |
rename(String newName) |
void |
reopen()
Reopen the stream after a temporaryClose().
|
void |
safeWrite(long location,
int data)
A safeWrite() is one where the integer data is either stored completely at the specified
location or not at all.
|
void |
safeWrite(long loc1,
int data1,
long loc2,
int data2) |
void |
safeWrite(long loc1,
int data1,
long loc2,
int data2,
long loc3,
int data3,
long loc4,
int data4) |
boolean |
setDecryptor(DataProcessor decryptor) |
boolean |
setDecryptorAndEncryptor(DataProcessor decryptor,
DataProcessor encryptor) |
boolean |
setModifiedTime(Time t) |
boolean |
temporaryClose()
Close the stream temporarily.
|
boolean |
truncateTo(long length)
Try to truncate to a particular length.
|
protected void |
write(byte[] data,
int offset,
int length) |
void |
writeAll(long location,
byte[] data,
int offset,
int length) |
void |
writeIntAt(long location,
int value) |
void |
zero(long location,
int numBytes)
This should extend the Stream if necessary.
|
public RandomAccessDatabaseStream(File file, String mode) throws IOException
IOException
public RandomAccessDatabaseStream(File file, String mode, boolean ignoreInconsistentState) throws IOException
IOException
public RandomAccessDatabaseStream(RandomStream stream, String mode) throws InconsistentDatabaseStateException, IOException
public RandomAccessDatabaseStream(RandomStream stream, String mode, boolean ignoreInconsistentState) throws InconsistentDatabaseStateException, IOException
public boolean canWrite()
DatabaseStream
canWrite
in interface DatabaseStream
public boolean temporaryClose() throws IOException
DatabaseStream
temporaryClose
in interface DatabaseStream
IOException
- if an error occurs.public void reopen() throws IOException
DatabaseStream
reopen
in interface DatabaseStream
IOException
- if an error occurs.public int getFirstDataLocation()
DatabaseStream
getFirstDataLocation
in interface DatabaseStream
protected void write(byte[] data, int offset, int length) throws IOException
IOException
protected int read(byte[] data, int offset, int length) throws IOException
IOException
public void writeAll(long location, byte[] data, int offset, int length) throws IOException
writeAll
in interface DatabaseStream
IOException
public void readAll(long location, byte[] data, int offset, int length) throws IOException
DatabaseStream
readAll
in interface DatabaseStream
IOException
public void zero(long location, int numBytes) throws IOException
DatabaseStream
zero
in interface DatabaseStream
IOException
public void flush() throws IOException
flush
in interface DatabaseStream
IOException
public boolean truncateTo(long length) throws IOException
DatabaseStream
truncateTo
in interface DatabaseStream
IOException
public int readIntAt(long location) throws IOException
readIntAt
in interface DatabaseStream
IOException
public void writeIntAt(long location, int value) throws IOException
writeIntAt
in interface DatabaseStream
IOException
public void safeWrite(long location, int data) throws IOException
DatabaseStream
safeWrite
in interface DatabaseStream
IOException
public void safeWrite(long loc1, int data1, long loc2, int data2) throws IOException
safeWrite
in interface DatabaseStream
IOException
public void safeWrite(long loc1, int data1, long loc2, int data2, long loc3, int data3, long loc4, int data4) throws IOException
safeWrite
in interface DatabaseStream
IOException
public boolean atEOF(long location) throws IOException
atEOF
in interface DatabaseStream
IOException
public long length() throws IOException
length
in interface DatabaseStream
IOException
public boolean setDecryptor(DataProcessor decryptor) throws IOException
setDecryptor
in interface DatabaseStream
IOException
public boolean setDecryptorAndEncryptor(DataProcessor decryptor, DataProcessor encryptor) throws IOException
setDecryptorAndEncryptor
in interface DatabaseStream
IOException
public void close() throws IOException
close
in interface DatabaseStream
IOException
public void delete() throws IOException
delete
in interface DatabaseStream
IOException
public void rename(String newName) throws IOException
rename
in interface DatabaseStream
IOException
public Time getModifiedTime() throws IOException
getModifiedTime
in interface DatabaseStream
IOException
public boolean setModifiedTime(Time t) throws IOException
setModifiedTime
in interface DatabaseStream
IOException