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

alma::acs::logging::dialogs::error::ErrorLogFile Class Reference

List of all members.

Public Member Functions

 ErrorLogFile (int timeout, String prefix, String suffix, String folder, boolean deleteOnExit, boolean retryOnError)
Override synchronized void run ()
synchronized void append (String str) throws IOException
synchronized void copy (OutputStream file) throws FileNotFoundException, IOException
synchronized void clear ()
synchronized String getFileName ()

Protected Member Functions

Override void finalize () throws Throwable

Private Member Functions

void initTmpFile () throws IOException

Private Attributes

Timer timer = new Timer("ErrorLogFile",true)
final int timeout
long lastWriteTime = -1
final boolean deleteOnExit
final boolean retryOnError
final String prefix
final String suffix
final String folder
String fileName
FileOutputStream outFile = null
boolean fileError = false

Detailed Description

ErrorLogFile encapsulates a file adding methods to close the file when it has not been since used for long time.

In case of error while writing or creating the temporary file, the behavior depends on the value of retryOnError. If it is true.

The purpose of this class is to avoid having a file open when no I/O is performed for a long time. This is achieved:

The used file is identified by its name;

Author:
acaproni


Constructor & Destructor Documentation

alma::acs::logging::dialogs::error::ErrorLogFile::ErrorLogFile int  timeout,
String  prefix,
String  suffix,
String  folder,
boolean  deleteOnExit,
boolean  retryOnError
[inline]
 

Constructor.

Parameters:
timeout The number of seconds before closing the file
prefix The prefix of the temporary file
suffix The suffix of the temporary file
folder The name of the folder where the new file must be created; if it is null or empty, then the current folder is used
deleteOnExit if true the file s deleted when the application exits
retryOnError if true tries to open the file even if a previous attempt failed


Member Function Documentation

synchronized void alma::acs::logging::dialogs::error::ErrorLogFile::append String  str  )  throws IOException [inline]
 

Append a string to the temporary file.

Parameters:
str The string to append in the file

synchronized void alma::acs::logging::dialogs::error::ErrorLogFile::clear  )  [inline]
 

Close the file(s) freeing all the resources

This is the last method executed by this class

synchronized void alma::acs::logging::dialogs::error::ErrorLogFile::copy OutputStream  file  )  throws FileNotFoundException, IOException [inline]
 

Copy the file in the passed output stream

Parameters:
file The stream to copy the content of the file into

Override void alma::acs::logging::dialogs::error::ErrorLogFile::finalize  )  throws Throwable [inline, protected]
 

Flush and close the file when the object is destroyed by the GC

synchronized String alma::acs::logging::dialogs::error::ErrorLogFile::getFileName  )  [inline]
 

Returns:
the fileName

void alma::acs::logging::dialogs::error::ErrorLogFile::initTmpFile  )  throws IOException [inline, private]
 

Create the temporary file for flushing the log.

Exceptions:
IOException 

Override synchronized void alma::acs::logging::dialogs::error::ErrorLogFile::run  )  [inline]
 

The method executed by the Timer.

See also:
Timer


Member Data Documentation

final boolean alma::acs::logging::dialogs::error::ErrorLogFile::deleteOnExit [private]
 

If true the file will be deleted when the application terminates.

boolean alma::acs::logging::dialogs::error::ErrorLogFile::fileError = false [private]
 

Remember if there was an error associated to the temporary file for flushing errors.

The behavior of object of this class when an error happens depends on the value of retryonError.

String alma::acs::logging::dialogs::error::ErrorLogFile::fileName [private]
 

The name of the file for I/O.

final String alma::acs::logging::dialogs::error::ErrorLogFile::folder [private]
 

The folder where the temporary file must be written

long alma::acs::logging::dialogs::error::ErrorLogFile::lastWriteTime = -1 [private]
 

The time when the last written has been performed.

This can be indirectly used to know if the file is empty as it happens in copy().

FileOutputStream alma::acs::logging::dialogs::error::ErrorLogFile::outFile = null [private]
 

The file stream for output.

final String alma::acs::logging::dialogs::error::ErrorLogFile::prefix [private]
 

The prefix of the temporary file

final boolean alma::acs::logging::dialogs::error::ErrorLogFile::retryOnError [private]
 

If true the application tries to perform I/O in the file even if a previous attempt resulted in an error.

final String alma::acs::logging::dialogs::error::ErrorLogFile::suffix [private]
 

The suffix of the temporary file

final int alma::acs::logging::dialogs::error::ErrorLogFile::timeout [private]
 

The number of seconds before closing the file

Timer alma::acs::logging::dialogs::error::ErrorLogFile::timer = new Timer("ErrorLogFile",true) [private]
 

The timer to check the time before two flush.


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