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
IOExceptionpublic RandomAccessDatabaseStream(File file, String mode, boolean ignoreInconsistentState) throws IOException
IOExceptionpublic RandomAccessDatabaseStream(RandomStream stream, String mode) throws InconsistentDatabaseStateException, IOException
public RandomAccessDatabaseStream(RandomStream stream, String mode, boolean ignoreInconsistentState) throws InconsistentDatabaseStateException, IOException
public boolean canWrite()
DatabaseStreamcanWrite in interface DatabaseStreampublic boolean temporaryClose()
throws IOException
DatabaseStreamtemporaryClose in interface DatabaseStreamIOException - if an error occurs.public void reopen()
throws IOException
DatabaseStreamreopen in interface DatabaseStreamIOException - if an error occurs.public int getFirstDataLocation()
DatabaseStreamgetFirstDataLocation in interface DatabaseStreamprotected void write(byte[] data,
int offset,
int length)
throws IOException
IOExceptionprotected int read(byte[] data,
int offset,
int length)
throws IOException
IOExceptionpublic void writeAll(long location,
byte[] data,
int offset,
int length)
throws IOException
writeAll in interface DatabaseStreamIOExceptionpublic void readAll(long location,
byte[] data,
int offset,
int length)
throws IOException
DatabaseStreamreadAll in interface DatabaseStreamIOExceptionpublic void zero(long location,
int numBytes)
throws IOException
DatabaseStreamzero in interface DatabaseStreamIOExceptionpublic void flush()
throws IOException
flush in interface DatabaseStreamIOExceptionpublic boolean truncateTo(long length)
throws IOException
DatabaseStreamtruncateTo in interface DatabaseStreamIOExceptionpublic int readIntAt(long location)
throws IOException
readIntAt in interface DatabaseStreamIOExceptionpublic void writeIntAt(long location,
int value)
throws IOException
writeIntAt in interface DatabaseStreamIOExceptionpublic void safeWrite(long location,
int data)
throws IOException
DatabaseStreamsafeWrite in interface DatabaseStreamIOExceptionpublic void safeWrite(long loc1,
int data1,
long loc2,
int data2)
throws IOException
safeWrite in interface DatabaseStreamIOExceptionpublic void safeWrite(long loc1,
int data1,
long loc2,
int data2,
long loc3,
int data3,
long loc4,
int data4)
throws IOException
safeWrite in interface DatabaseStreamIOExceptionpublic boolean atEOF(long location)
throws IOException
atEOF in interface DatabaseStreamIOExceptionpublic long length()
throws IOException
length in interface DatabaseStreamIOExceptionpublic boolean setDecryptor(DataProcessor decryptor) throws IOException
setDecryptor in interface DatabaseStreamIOExceptionpublic boolean setDecryptorAndEncryptor(DataProcessor decryptor, DataProcessor encryptor) throws IOException
setDecryptorAndEncryptor in interface DatabaseStreamIOExceptionpublic void close()
throws IOException
close in interface DatabaseStreamIOExceptionpublic void delete()
throws IOException
delete in interface DatabaseStreamIOExceptionpublic void rename(String newName) throws IOException
rename in interface DatabaseStreamIOExceptionpublic Time getModifiedTime() throws IOException
getModifiedTime in interface DatabaseStreamIOExceptionpublic boolean setModifiedTime(Time t) throws IOException
setModifiedTime in interface DatabaseStreamIOException