public class FileStorage extends Object
Modifier and Type | Field and Description |
---|---|
protected byte[] |
bytes
Byte array holding the data that were read from file
|
protected DataAccessor |
da |
boolean |
fileNotFound |
protected int |
offset
Current offset in the bytes array
|
protected boolean |
opened |
protected boolean |
openedForWrite |
Constructor and Description |
---|
FileStorage(DataAccessor da,
StringCache strCache) |
FileStorage(String fileName) |
FileStorage(String fileName,
StringCache strCache) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkBytesSize(int len)
Check size of bytes[] array
|
void |
close() |
int |
getFileLength() |
String |
getFileName() |
int |
getFilePointer() |
int |
getInteger()
Get the integer value from the bytes[] array
|
int |
getOffset() |
String |
getString()
Get the string value from the bytes[] array
|
void |
lockFile()
Locks the file and disable other threads to write
|
void |
open(boolean requestWrite) |
void |
putInteger(int i)
Put the integer into bytes[] array.
|
void |
putString(String s)
Put the string into bytes[] array.
|
void |
read(int len)
Read some part of the file into the begining of bytes array
and reset offset to zero.
|
void |
resetBytes() |
void |
resetFile()
Reset the size of the file and set current offset to zero.
|
void |
seek(int filePointer) |
void |
setOffset(int offset) |
void |
setVersion(int ver)
Setter for version of Code Completion DB file.
|
String |
toString()
Returns name of the file
|
void |
unlockFile()
Unlocks the file and notifies wqiting threads
|
void |
write()
Write bytes array (with offset length) to the file
|
protected boolean openedForWrite
public boolean fileNotFound
protected DataAccessor da
protected boolean opened
protected int offset
protected byte[] bytes
public FileStorage(String fileName)
fileName
- name of file to operate overpublic FileStorage(String fileName, StringCache strCache)
public FileStorage(DataAccessor da, StringCache strCache)
public void setVersion(int ver)
public void open(boolean requestWrite) throws IOException
IOException
public void close() throws IOException
IOException
protected void checkBytesSize(int len)
public void read(int len) throws IOException
IOException
public void write() throws IOException
IOException
public void seek(int filePointer) throws IOException
IOException
public String getFileName()
public int getFilePointer() throws IOException
IOException
public void setOffset(int offset)
public int getOffset()
public int getFileLength() throws IOException
IOException
public void resetBytes()
public void resetFile() throws IOException
IOException
public int getInteger()
public String getString()
public void putInteger(int i)
public void putString(String s)
public final void lockFile()
public final void unlockFile()