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

Inheritance diagram for alma::acs::logging::dialogs::error::ErrorLogFile:
Inheritance graph
[legend]
Collaboration diagram for alma::acs::logging::dialogs::error::ErrorLogFile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

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

Protected Member Functions

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
boolean closed = 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

References timer.


Member Function Documentation

synchronized void alma::acs::logging::dialogs::error::ErrorLogFile::append ( String  str  )  throws IOException [inline]
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

References fileError, fileName, lastWriteTime, and outFile.

Referenced by alma::acs::logging::dialogs::error::ErrorLogDialog::clearAll(), close(), and alma::acs::jlog::test::ErrorLogFileTest::testClear().

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

Close clear the file and stop the timer.

This is the last method to execute.

References clear(), closed, and timer.

Referenced by alma::acs::logging::dialogs::error::ErrorLogDialog::dispose(), and finalize().

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

References fileName, and lastWriteTime.

Referenced by alma::acs::logging::dialogs::error::ErrorLogDialog::saveAllLog(), and alma::acs::jlog::test::ErrorLogFileTest::testCopy().

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

References close().

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

Create the temporary file for flushing the log.

Exceptions:
IOException 

References deleteOnExit, fileName, folder, prefix, and suffix.

Referenced by append().

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

The method executed by the Timer.

See also:
Timer

References fileError, lastWriteTime, outFile, and timeout.


Member Data Documentation

true if the object has been closed

Referenced by append(), and close().

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

Referenced by initTmpFile().

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.

Referenced by append(), clear(), and run().

The name of the file for I/O.

Referenced by append(), clear(), copy(), getFileName(), and initTmpFile().

The folder where the temporary file must be written

Referenced by initTmpFile().

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

Referenced by append(), clear(), copy(), and run().

The file stream for output.

Referenced by append(), clear(), and run().

The prefix of the temporary file

Referenced by initTmpFile().

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

Referenced by append().

The suffix of the temporary file

Referenced by initTmpFile().

The number of seconds before closing the file

Referenced by run().

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

The timer to check the time before two flush.

Referenced by close(), and ErrorLogFile().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2