com.ibm.etools.logging.util
Class LoggingUtilities

java.lang.Object
  |
  +--com.ibm.etools.logging.util.LoggingUtilities

public final class LoggingUtilities
extends java.lang.Object


Constructor Summary
LoggingUtilities()
           
 
Method Summary
protected static void archiveFile(java.lang.String filePath)
           
protected static void closeFileHandle(java.lang.String filePath)
           
protected static void closeFileHandle(java.lang.String filePath, int dataStructIndicator)
          Closes the previously created file handle and removes the instance from the hashtable of previously created file handles if no other loggers are currently writing to the parameter file.
protected static void closeRAFileHandle(java.lang.String filePath)
           
static java.lang.String currentTimeSeconds()
          Returns the number of seconds (fractional precision) between January 1, 1970, 00:00:00 GMT and the current time represented as a String.
protected static void deleteArchivedFiles(java.lang.String filePath, int archiveExpiryDays)
           
static IConfigurationElement getConfigurationElement(java.lang.String pluginId, java.lang.String extensionPointId, java.lang.String configurationElementName)
          Resolves the first configuration element identified by the parameter configuration element name that is in the first extension to an extension point identified by the parameter extension point ID contributed by the plug-in identified by the parameter plug-in ID.
static java.lang.String getCurrThreadStack()
          Captures the stack trace of the current thread
static java.lang.String getEnvironmentVariable(java.lang.String variableName)
           
static java.util.Properties getEnvironmentVariables()
           
protected static java.io.BufferedWriter getFileHandle(java.lang.String filePath)
          Returns a file handle to the parameter log file either from a hashtable of previously created file handles or creates a new file handle if the parameter file has not been previously opened for writing.
protected static java.io.RandomAccessFile getRandomAFH(java.lang.String filePath)
          Returns a random access file handle to the parameter log file either from a hashtable of previously created file handles or creates a new file handle if the parameter file has not been previously opened for writing.
static java.lang.String getResourceString(java.lang.String key)
           
static java.lang.String getResourceString(java.lang.String key, java.lang.String argument)
           
static java.lang.String getResourceString(java.lang.String key, java.lang.String[] arguments)
           
static java.lang.String getResourceString(java.lang.String key, java.lang.String argumentA, java.lang.String argumentB)
           
static java.lang.String getResourceString(java.lang.String key, java.lang.String argumentA, java.lang.String argumentB, java.lang.String argumentC)
           
static java.lang.String getThreadStackTrace(java.lang.Thread thread)
          Deprecated. This method does not return the stack trace of the passed Thread. It only returns the stack trace of the current thread. (Equivalent to getCurrThreadStack()) Captures the stack trace of the parameter thread in a String.
static java.lang.String getThrowableStackTrace(java.lang.Throwable throwable)
          Captures the stack trace of the parameter throwable (i.e.
protected static void initArchiving(java.lang.String fileName)
          1) Removes the process Id assigned to a given file (that is if a process id has been assigned) 2) Removes 'fileName' from the archive files (if it has been recorded)
static boolean isValidLoggerName(java.lang.String name)
           
static boolean isWorkbench()
           
static java.lang.String objectToString(java.lang.Object obj)
          Converts the parameter Object to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingUtilities

public LoggingUtilities()
Method Detail

archiveFile

protected static void archiveFile(java.lang.String filePath)

deleteArchivedFiles

protected static void deleteArchivedFiles(java.lang.String filePath,
                                          int archiveExpiryDays)

getFileHandle

protected static java.io.BufferedWriter getFileHandle(java.lang.String filePath)
Returns a file handle to the parameter log file either from a hashtable of previously created file handles or creates a new file handle if the parameter file has not been previously opened for writing.

Returns:
BufferedWriter file handle for writing to the parameter file.

getRandomAFH

protected static java.io.RandomAccessFile getRandomAFH(java.lang.String filePath)
Returns a random access file handle to the parameter log file either from a hashtable of previously created file handles or creates a new file handle if the parameter file has not been previously opened for writing.

Parameters:
filePath - name and path of the output log file which to open/retrieve a file handle.
Returns:
RandomAccessFile handle for reading/writing to the parameter file.

closeFileHandle

protected static void closeFileHandle(java.lang.String filePath,
                                      int dataStructIndicator)
Closes the previously created file handle and removes the instance from the hashtable of previously created file handles if no other loggers are currently writing to the parameter file. Otherwise, the event of the caller closing their file handle to the parameter file is registered.

Parameters:
filePath - - name and path of the output log file which to potentially close the file handle. dataStructIndicator - Indicates the data structure to be used for retreiving the file handle

closeFileHandle

protected static void closeFileHandle(java.lang.String filePath)

closeRAFileHandle

protected static void closeRAFileHandle(java.lang.String filePath)

initArchiving

protected static void initArchiving(java.lang.String fileName)
1) Removes the process Id assigned to a given file (that is if a process id has been assigned) 2) Removes 'fileName' from the archive files (if it has been recorded)


getThrowableStackTrace

public static java.lang.String getThrowableStackTrace(java.lang.Throwable throwable)
Captures the stack trace of the parameter throwable (i.e. exception or error) in a String.

Parameters:
throwable - exception or error which the stack trace is captured.
Returns:
String representation of the stack trace of the parameter throwable.

getThreadStackTrace

public static java.lang.String getThreadStackTrace(java.lang.Thread thread)
Deprecated. This method does not return the stack trace of the passed Thread. It only returns the stack trace of the current thread. (Equivalent to getCurrThreadStack()) Captures the stack trace of the parameter thread in a String.

Parameters:
thread - thread which the stack trace is captured.
Returns:
String representation of the stack trace of the parameter thread.

getCurrThreadStack

public static java.lang.String getCurrThreadStack()
Captures the stack trace of the current thread

Returns:
String representation of the stack trace of the current thread.

objectToString

public static java.lang.String objectToString(java.lang.Object obj)
Converts the parameter Object to a String. If the parameter Object is a multidimensional array of any type, all dimensions of the array are traversed and returned as a String in the Java notation for arrays (i.e. [element1, element2]). Special cases handled include printing the stack trace for all thread and throwable Objects, instead of simply calling the parameter Object's toString() method.

Parameters:
obj - Object or array to be converted to a String.
Returns:
String representation of the parameter Object.

isWorkbench

public static boolean isWorkbench()

isValidLoggerName

public static boolean isValidLoggerName(java.lang.String name)

currentTimeSeconds

public static java.lang.String currentTimeSeconds()
Returns the number of seconds (fractional precision) between January 1, 1970, 00:00:00 GMT and the current time represented as a String.

Returns:
String the current time in seconds.

getResourceString

public static java.lang.String getResourceString(java.lang.String key)

getResourceString

public static java.lang.String getResourceString(java.lang.String key,
                                                 java.lang.String argument)

getResourceString

public static java.lang.String getResourceString(java.lang.String key,
                                                 java.lang.String argumentA,
                                                 java.lang.String argumentB)

getResourceString

public static java.lang.String getResourceString(java.lang.String key,
                                                 java.lang.String argumentA,
                                                 java.lang.String argumentB,
                                                 java.lang.String argumentC)

getResourceString

public static java.lang.String getResourceString(java.lang.String key,
                                                 java.lang.String[] arguments)

getEnvironmentVariable

public static java.lang.String getEnvironmentVariable(java.lang.String variableName)

getEnvironmentVariables

public static java.util.Properties getEnvironmentVariables()

getConfigurationElement

public static IConfigurationElement getConfigurationElement(java.lang.String pluginId,
                                                            java.lang.String extensionPointId,
                                                            java.lang.String configurationElementName)
Resolves the first configuration element identified by the parameter configuration element name that is in the first extension to an extension point identified by the parameter extension point ID contributed by the plug-in identified by the parameter plug-in ID.

The same plug-in identified by the parameter plug-in ID will contain zero or a positive number of extensions to an extension point identified by the parameter extension point ID. Furthermore, the same extension to an extension point identified by the parameter extension point ID will contain zero or a positive number of configuration elements identified by the parameter configuration element name. As such, the returned configuration element is the first configuration element identified by the parameter configuration element name that is in the first extension to an extension point identified by the parameter extension point ID contributed by the plug-in identified by the parameter plug-in ID.

If there is no configuration element identified by the parameter configuration element name that is in the first extension to an extension point identified by the parameter extension point ID contributed by the plug-in identified by the parameter plug-in ID, null is returned.

Parameters:
pluginId - The non-null and positive length unique ID of the plug-in that extends the extension point.
extensionPointId - The non-null and positive length unique ID of the extension point that is extended.
configurationElementName - The non-null and positive length unique name of the configuration element in the extension point.
Returns:
The configuration element identified by the parameter configuration element name that is in the first extension to an extension point identified by the parameter extension point ID contributed by the plug-in identified by the parameter plug-in ID, otherwise null.