Public Member Functions | |
CacheFile (String fName, Integer key, RandomAccessFile rf, File f, boolean binary) throws IOException | |
File | getFile () throws FileNotFoundException |
void | close () |
long | getFileLength () |
synchronized CacheEntry | writeOnFile (String str, Integer key) throws IOException, LogEngineException |
synchronized String | readFromFile (CacheEntry entry) throws IOException |
synchronized void | setReadingMode (boolean reading) |
synchronized void | setWritingMode (boolean writing) |
String | minDate () |
String | maxDate () |
Public Attributes | |
final String | fileName |
final Integer | key |
Static Public Attributes | |
static final SimpleDateFormat | dateFormat = new IsoDateFormat() |
Each file used by the cache.
The cache is composed by
There are two booleans signaling if the file is used for reading and writing. In this way we know when the reads and writes are terminated and the file can be safely closed.
com.cosylab.logging.engine.cache.CacheFile.CacheFile | ( | String | fName, | |
Integer | key, | |||
RandomAccessFile | rf, | |||
File | f, | |||
boolean | binary | |||
) | throws IOException |
Constructor
fName | The name of the file | |
key | The key of this entry | |
rf | The RandomAccessFile used for I/O | |
f | The File used to get the length | |
binary | if the string of logs are in binary format and false if XML strings |
IOException | In case of error writing in the file |
References com.cosylab.logging.engine.cache.CacheFile.fileName, and com.cosylab.logging.engine.cache.CacheFile.key.
void com.cosylab.logging.engine.cache.CacheFile.close | ( | ) |
Release all the resources (for instance it releases the random file).
References com.cosylab.logging.engine.cache.CacheFile.fileName.
Referenced by com.cosylab.logging.engine.cache.EngineCache.close().
File com.cosylab.logging.engine.cache.CacheFile.getFile | ( | ) | throws FileNotFoundException |
An helper methods that returns the File
.
As soon as raFile
is not null
, file
is not null
too.
A new File is built if file
is null
otherwise the method returns a reference to file
.
FileNotFoundException | If the file does not exist |
References com.cosylab.logging.engine.cache.CacheFile.fileName.
long com.cosylab.logging.engine.cache.CacheFile.getFileLength | ( | ) |
Return the size of the file
Referenced by com.cosylab.logging.engine.cache.EngineCache.push().
String com.cosylab.logging.engine.cache.CacheFile.maxDate | ( | ) |
String com.cosylab.logging.engine.cache.CacheFile.minDate | ( | ) |
synchronized String com.cosylab.logging.engine.cache.CacheFile.readFromFile | ( | CacheEntry | entry | ) | throws IOException |
Read a string from the file
entry | The cache entry to saying how to read the entry |
References com.cosylab.logging.engine.cache.CacheFile.key.
Referenced by com.cosylab.logging.engine.cache.EngineCache.pop().
synchronized void com.cosylab.logging.engine.cache.CacheFile.setReadingMode | ( | boolean | reading | ) |
Set the reading mode of the file.
reading | true if the file is used for reading |
Referenced by com.cosylab.logging.engine.cache.EngineCache.pop().
synchronized void com.cosylab.logging.engine.cache.CacheFile.setWritingMode | ( | boolean | writing | ) |
Set the writing mode of the file.
writing | true if the file is used for writing |
Referenced by com.cosylab.logging.engine.cache.EngineCache.push().
synchronized CacheEntry com.cosylab.logging.engine.cache.CacheFile.writeOnFile | ( | String | str, | |
Integer | key | |||
) | throws IOException, LogEngineException |
Write the passed string in the file.
str | The string to write in the file |
IOException | In case of error while performing I/O | |
LogEngineException | In case of error reading the date of the log from str |
References com.cosylab.logging.engine.cache.CacheFile.key.
Referenced by com.cosylab.logging.engine.cache.EngineCache.push().
final SimpleDateFormat com.cosylab.logging.engine.cache.CacheFile.dateFormat = new IsoDateFormat() [static] |
The simple date format used to write and read dates from a string
final String com.cosylab.logging.engine.cache.CacheFile.fileName |
The name of the file
Referenced by com.cosylab.logging.engine.cache.CacheFile.CacheFile(), com.cosylab.logging.engine.cache.CacheFile.close(), and com.cosylab.logging.engine.cache.CacheFile.getFile().
final Integer com.cosylab.logging.engine.cache.CacheFile.key |
The key identifying this file.
The key is stored only to perform run-time tests of correctness.
Referenced by com.cosylab.logging.engine.cache.CacheFile.CacheFile(), com.cosylab.logging.engine.cache.EngineCache.pop(), com.cosylab.logging.engine.cache.EngineCache.push(), com.cosylab.logging.engine.cache.CacheFile.readFromFile(), and com.cosylab.logging.engine.cache.CacheFile.writeOnFile().