Public Member Functions | Public Attributes | Static Public Attributes

com.cosylab.logging.engine.cache.CacheFile Class Reference

List of all members.

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()

Detailed Description

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.

Author:
acaproni

Constructor & Destructor Documentation

com.cosylab.logging.engine.cache.CacheFile.CacheFile ( String  fName,
Integer  key,
RandomAccessFile  rf,
File  f,
boolean  binary 
) throws IOException

Constructor

Parameters:
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
Exceptions:
IOException In case of error writing in the file
See also:
CacheFile(String fName, Integer key)

References com.cosylab.logging.engine.cache.CacheFile.fileName, and com.cosylab.logging.engine.cache.CacheFile.key.


Member Function Documentation

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.

Returns:
The file
Exceptions:
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

Returns:
the size of the file

Referenced by com.cosylab.logging.engine.cache.EngineCache.push().

String com.cosylab.logging.engine.cache.CacheFile.maxDate (  ) 
Returns:
the date of the oldest log in this file in ISO format
String com.cosylab.logging.engine.cache.CacheFile.minDate (  ) 
Returns:
the date of the youngest log in this file in ISO format
synchronized String com.cosylab.logging.engine.cache.CacheFile.readFromFile ( CacheEntry  entry  )  throws IOException

Read a string from the file

Parameters:
entry The cache entry to saying how to read the entry
Returns:
The string read from the file

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.

Parameters:
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.

Parameters:
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.

Parameters:
str The string to write in the file
Returns:
The ending position of the string in the file
Exceptions:
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().


Member Data Documentation

The simple date format used to write and read dates from a string


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties