com.ibm.ras
Class RASFileHandler

java.lang.Object
  |
  +--com.ibm.ras.RASObject
        |
        +--com.ibm.ras.RASHandler
              |
              +--com.ibm.ras.RASFileHandler

public class RASFileHandler
extends RASHandler

RASFileHandler implements a RASHandler that writes to a file. The name of the file must be specified in the constructor or through the setFileName method, as no default name exists.

See Also:
RASHandler

Fields inherited from class com.ibm.ras.RASHandler
deviceOpen
 
Constructor Summary
RASFileHandler()
          Creates a RASFileHandler.
RASFileHandler(java.lang.String name)
          Creates a RASFileHandler.
RASFileHandler(java.lang.String name, java.lang.String desc)
          Creates a RASFileHandler.
RASFileHandler(java.lang.String name, java.lang.String desc, java.lang.String file)
          Creates a RASFileHandler.
 
Method Summary
 java.util.Hashtable getConfig()
          Gets the configuration of this object.
 java.lang.String getFileName()
          Gets the name of the file used by this handler.
 void openDevice()
          Opens the device to which the handler will send its log entries.
 void setConfig(java.util.Hashtable ht)
          Sets the configuration of this object.
 void setFileName(java.lang.String name)
          Sets the name of the file used by this handler.
 
Methods inherited from class com.ibm.ras.RASHandler
addFormatter, addMaskChangeListener, getFormatters, getMaskChangeListeners, getMessageMask, getTraceMask, logEvent, removeFormatter, removeMaskChangeListener, run, setMessageMask, setTraceMask, stop, writeEvent
 
Methods inherited from class com.ibm.ras.RASObject
getDescription, getName, setDescription, setName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RASFileHandler

public RASFileHandler()
Creates a RASFileHandler. The name and description of this object are empty strings.

RASFileHandler

public RASFileHandler(java.lang.String name)
Creates a RASFileHandler. The description of this object is an empty string.
Parameters:
name - The name of this object.

RASFileHandler

public RASFileHandler(java.lang.String name,
                      java.lang.String desc)
Creates a RASFileHandler.
Parameters:
name - The name of this object.
desc - The description of this object.

RASFileHandler

public RASFileHandler(java.lang.String name,
                      java.lang.String desc,
                      java.lang.String file)
Creates a RASFileHandler.
Parameters:
name - The name of this object.
desc - The description of object.
file - The name of the output file.
Method Detail

getConfig

public java.util.Hashtable getConfig()
Gets the configuration of this object.
Returns:
A Hashtable containing the configuration. This object inserts the following key/value pairs into the configuration:
         "fileName" The name of the output file.
         
All values are Strings. The parent and extensions of this object may add additional keys.
Overrides:
getConfig in class RASHandler

setConfig

public void setConfig(java.util.Hashtable ht)
Sets the configuration of this object. This method is used by a RASManager to initialize a RAS object. It should not be necessary for an application to use this method.
Parameters:
ht - A Hashtable containing the configuration. This object searches for the following keys:
            "fileName" The name of the output file.
            
All values are Strings. If a key is not found, that configuration element is not updated. The parent and extensions of this logger may use additional keys.
Overrides:
setConfig in class RASHandler

getFileName

public java.lang.String getFileName()
Gets the name of the file used by this handler.
Returns:
The name of the output file. If no file name has been set, null is returned.

setFileName

public void setFileName(java.lang.String name)
Sets the name of the file used by this handler. If the file name is null, this current file name is not changed.
Parameters:
name - The name of the output file.

openDevice

public void openDevice()
Opens the device to which the handler will send its log entries. If an error occurs during this process, the handler will write a message to System.err.

The caller should ensure that this method is not called if the device is already open or if cannot tolerate attempts to reopen it.

For the RASFileHandler, the device is the file named on the constructor or through the setFileName method. New log entries are appended to the file, if it already exists. If the file name is changed via setFileName, this method must be called again to open the new file.

Overrides:
openDevice in class RASHandler