org.safs.logging
Class FileLogItem

java.lang.Object
  extended by org.safs.logging.LogItem
      extended by org.safs.logging.FileLogItem
Direct Known Subclasses:
STAFFileLogItem

public abstract class FileLogItem
extends LogItem

This class is an abstract representation of SAFS log files. In addition to attributes common to all LogItems, FileLogItem supports two more attributes: file spec and parent directory. File spec is the name (with or without path) of the file. It can be specified in absolute or relative form. When a relative path is specified, it is used together with parent directory to determine the full path of the file. If file spec is absolute, the parent directory is ignored.


Field Summary
 
Fields inherited from class org.safs.logging.LogItem
closed, enabled, level, mode, name
 
Constructor Summary
FileLogItem(long mode, java.lang.String parent, java.lang.String file)
          Creates a disabled FileLogItem with file name as the name, and sets its log level to LOGLEVEL_INFO.
FileLogItem(java.lang.String name, long mode, boolean enabled, java.lang.String parent, java.lang.String file)
          Creates a FileLogItem and sets its log level to LOGLEVEL_INFO.
FileLogItem(java.lang.String name, long mode, int level, boolean enabled, java.lang.String parent, java.lang.String file)
          Creates a FileLogItem.
 
Method Summary
 boolean fileExists()
          Tests if the file represented by this log item exists.
 java.lang.String getAbsolutePath()
          Returns the full path to the file represented by this log item.
 java.lang.String getFileSpec()
          Returns the file spec for this log.
 java.lang.String getParentDir()
          Returns the parent directory for this log.
 boolean isFileSpecAbsolute()
          Tests if the file spec of this log is absolute or relative.
 void setParentDir(java.lang.String dir)
          Sets the parent directory for this log.
 
Methods inherited from class org.safs.logging.LogItem
close, dateTime, isClosed, logMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileLogItem

public FileLogItem(java.lang.String name,
                   long mode,
                   int level,
                   boolean enabled,
                   java.lang.String parent,
                   java.lang.String file)
Creates a FileLogItem.

Parameters:
name - the name of this log item. If null, it is set to the file name.
mode - the type of this log (LOGMODE constant defined by AbstractLogFacility).
level - the log level for this log.
enabled - true to enable this log; false to disable.
parent - the parent directory of this log.
file - the file spec of this log.

FileLogItem

public FileLogItem(java.lang.String name,
                   long mode,
                   boolean enabled,
                   java.lang.String parent,
                   java.lang.String file)
Creates a FileLogItem and sets its log level to LOGLEVEL_INFO.

Parameters:
name - the name of this log item. If null, it is set to the file name.
mode - the type of this log (LOGMODE constant defined by AbstractLogFacility).
enabled - true to enable this log; false to disable.
parent - the parent directory of this log.
file - the file spec of this log.

FileLogItem

public FileLogItem(long mode,
                   java.lang.String parent,
                   java.lang.String file)
Creates a disabled FileLogItem with file name as the name, and sets its log level to LOGLEVEL_INFO.

Parameters:
mode - the type of this log (LOGMODE constant defined by AbstractLogFacility).
parent - the parent directory of this log.
file - the file spec of this log.
Method Detail

getFileSpec

public java.lang.String getFileSpec()
Returns the file spec for this log.

Returns:
the file spec of this log.

isFileSpecAbsolute

public boolean isFileSpecAbsolute()
Tests if the file spec of this log is absolute or relative.

Returns:
true if the file spec is absolute; false if it is relative.

getParentDir

public java.lang.String getParentDir()
Returns the parent directory for this log.

Returns:
the full path to the parent directory.

setParentDir

public void setParentDir(java.lang.String dir)
Sets the parent directory for this log.

Parameters:
dir - the new parent directory.

getAbsolutePath

public java.lang.String getAbsolutePath()
Returns the full path to the file represented by this log item.

Returns:
the full path of this log file.

fileExists

public boolean fileExists()
Tests if the file represented by this log item exists.

Returns:
true if getAbsolutePath points to an existing file; false otherwise.