Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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

List of all members.

Public Member Functions

 CacheFile (String fName, Integer key, RandomAccessFile rf, File f)
File getFile () throws FileNotFoundException
void close ()
long getFileLength ()
synchronized CacheEntry writeOnFile (String str, Integer key) throws IOException
synchronized String readFromFile (CacheEntry entry) throws IOException
synchronized void setReadingMode (boolean reading)
synchronized void setWritingMode (boolean writing)

Public Attributes

final String fileName
final Integer key

Private Member Functions

void openFile () throws FileNotFoundException
void checkRaFileUsage ()

Private Attributes

RandomAccessFile raFile = null
File file = null
boolean reading = false
boolean writing = false

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 close the file.

Author:
acaproni


Constructor & Destructor Documentation

com::cosylab::logging::engine::cache::CacheFile::CacheFile String  fName,
Integer  key,
RandomAccessFile  rf,
File  f
[inline]
 

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
See also:
CacheFile(String fName, Integer key)


Member Function Documentation

void com::cosylab::logging::engine::cache::CacheFile::checkRaFileUsage  )  [inline, private]
 

Check if the file is used for reading or writing and if not used, close the random file.

void com::cosylab::logging::engine::cache::CacheFile::close  )  [inline]
 

Release all the resources (for instance it releases the random file).

File com::cosylab::logging::engine::cache::CacheFile::getFile  )  throws FileNotFoundException [inline]
 

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

long com::cosylab::logging::engine::cache::CacheFile::getFileLength  )  [inline]
 

Return the size of the file

Returns:
the size of the file

void com::cosylab::logging::engine::cache::CacheFile::openFile  )  throws FileNotFoundException [inline, private]
 

An helper method that returns a RandomAccessFile by the file name fileName.

The random access file is built from the fileName.

Returns:
The file to read and/or write items
Exceptions:
IOException In case of error creating the File.
FileNotFoundException If the file does not exist

synchronized String com::cosylab::logging::engine::cache::CacheFile::readFromFile CacheEntry  entry  )  throws IOException [inline]
 

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

synchronized void com::cosylab::logging::engine::cache::CacheFile::setReadingMode boolean  reading  )  [inline]
 

Set the reading mode of the file.

Parameters:
reading true if the file is used for reading

synchronized void com::cosylab::logging::engine::cache::CacheFile::setWritingMode boolean  writing  )  [inline]
 

Set the writing mode of the file.

Parameters:
reading true if the file is used for writing

synchronized CacheEntry com::cosylab::logging::engine::cache::CacheFile::writeOnFile String  str,
Integer  key
throws IOException [inline]
 

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


Member Data Documentation

File com::cosylab::logging::engine::cache::CacheFile::file = null [private]
 

The file used to build raFile.

It is not null as soon as raFile is not null

final String com::cosylab::logging::engine::cache::CacheFile::fileName
 

The name of the file

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.

RandomAccessFile com::cosylab::logging::engine::cache::CacheFile::raFile = null [private]
 

The RandomAccessFile of the file of this entry.

This is not null only when used for I/O.

boolean com::cosylab::logging::engine::cache::CacheFile::reading = false [private]
 

Signal if the file is used for reading

boolean com::cosylab::logging::engine::cache::CacheFile::writing = false [private]
 

Signal if the file is used for writing


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 03:13:10 2009 for ACS Java API by doxygen 1.3.8