Stellent
HowToComponents
JavaDoc

intradoc.common
Class SystemUtils

java.lang.Object
  |
  +--intradoc.common.SystemUtils

public class SystemUtils
extends java.lang.Object


Field Summary
static java.util.Hashtable m_activeTraces
           
static java.util.Vector m_activeTracesList
           
protected static java.util.Properties m_appProperties
           
protected static java.lang.String m_binDir
           
protected static java.lang.String m_cfgFile
           
static boolean m_failOnEncodingFailure
           
static boolean m_failOnReplacementCharacterDefault
           
protected static boolean m_isInitialized
           
protected static java.lang.String m_logFileMsgPrefix
           
protected static Log m_logger
           
protected static java.lang.String m_productBuildInfo
           
protected static java.lang.String m_productCopyright
           
protected static java.lang.String m_productThirdParty
           
protected static java.lang.String m_productVersion
           
protected static java.lang.String m_productVersionInfo
           
protected static java.lang.String m_propertyFile
           
protected static java.lang.String m_propertyFileDes
           
static boolean m_traceEverything
           
static TraceImplementor m_traceImpl
           
static java.text.SimpleDateFormat m_traceLogFormat
           
static java.lang.String m_tracePrefix
           
static boolean m_traceWithoutTimestamp
           
static boolean m_verbose
           
protected static java.util.Random m_waitRandom
           
static boolean m_writeUnicodeSignature
           
static boolean m_writeUTF8Signature
           
static int MSG_ERROR_TYPE
           
static int MSG_FATAL_TYPE
           
static int MSG_INFO_TYPE
           
static int MSG_WARNING_TYPE
           
 
Constructor Summary
SystemUtils()
           
 
Method Summary
static void addAsActiveTrace(java.lang.String section)
          Enable a tracing "section".
static void appendTraceMessage(java.lang.StringBuffer buf, java.lang.String section, java.lang.String message, java.util.Date d, boolean fullTraceInfo)
          Used to build the actual output message created by the trace(...) function.
static boolean checkStartup()
           
static void dumpException(java.lang.String section, java.lang.Throwable t)
          Dumps all information relevant about an exception including stack trace.
static void err(java.lang.Throwable t, java.lang.String msg)
           
static void errEx(java.lang.Throwable t, java.lang.String msg, java.lang.String app)
           
static void error(java.lang.Exception e, java.lang.String msg)
          Deprecated. use err(e,msg)
static void errorEx(java.lang.Exception e, java.lang.String msg, java.lang.String app)
          Deprecated. use errEx(e,msg,app)
static void fatal(java.lang.Throwable t, java.lang.String msg)
           
static void fatalEx(java.lang.Throwable t, java.lang.String msg, java.lang.String app)
           
static java.lang.String formatTraceLogDate(java.util.Date d)
          Formats the date using the trace function's chosen format.
static java.util.Vector getActiveTraces()
          Gets a list of currently active traces.
static java.util.Properties getAppProperties()
           
static java.lang.String getAppProperty(java.lang.String name)
           
static java.lang.String getBinDir()
           
static java.lang.String getCfgFileName()
           
static java.lang.String getCfgFilePath()
           
static boolean getFailOnEncodingFailure()
           
static boolean getFailOnReplacementCharacterDefault()
           
static java.lang.String getLogFileMsgPrefix()
           
static Log getLogger()
           
protected static NativeOsUtils getNativeOsUtils()
           
static java.lang.String getProductBuildInfo()
           
static java.lang.String getProductCopyright()
           
static java.lang.String getProductThirdParty()
           
static java.lang.String getProductVersion()
           
static java.lang.String getProductVersionInfo()
           
static TraceSection getSectionData(java.lang.String section)
          obtain the section data object for a section
static boolean getWriteUnicodeSignature()
           
static boolean getWriteUTF8Signature()
           
static void info(java.lang.String msg)
           
static void infoEx(java.lang.String msg, java.lang.String app)
           
static boolean isActiveTrace(java.lang.String section)
          Tests to see if a particular "section" of trace is active.
static boolean isOlderVersion(java.lang.String info1, java.lang.String info2)
           
protected static void loadProperties()
           
protected static void locateBinDir()
           
static void out(java.lang.String message)
          Sends message to console.
static void outln(java.lang.String message)
          Sends message to console with line feed.
static int[] parseVersion(java.lang.String info)
           
static void removeAsActiveTrace(java.lang.String section)
          Turn off a tracing "section".
static void reportDeprecatedUsage(java.lang.String msg)
          create an Exception and dump it to the deprecation trace section.
static void reportError(int type, java.lang.String msg)
           
static void reportErrorEx(java.lang.Throwable t, int type, java.lang.String msg, java.lang.String app)
           
static void setActiveTraces(java.util.Vector traceList)
          Set the currently active traces.
static void setAppProperty(java.lang.String name, java.lang.String value)
           
static void setExceptionCause(java.lang.Throwable newException, java.lang.Throwable causedByException)
           
static void setFailOnEncodingFailure(boolean newValue)
           
static void setFailOnReplacementCharacterDefault(boolean newValue)
           
static void setLogFileMsgPrefix(java.lang.String prefix)
           
static void setLogger(Log logger)
           
static void setPropertiesFile(java.lang.String fileName, java.lang.String fileDes)
           
static void setWriteUnicodeSignature(boolean newValue)
          setWriteUnicodeSignature() controls the behavior of FileUtils.writeFileEncodingSignatureHeader().
static void setWriteUTF8Signature(boolean newValue)
          setWriteUTF8Signature() controls the behavior of FileUtils.writeFileEncodingSignatureHeader().
static boolean sleep(long millis)
          Wait a specific amount of time.
static boolean sleepRandom(long minMillis, long maxMillis)
          Wait a random amount of time.
static void trace(java.lang.String section, java.lang.String message)
          Standard trace.
static void traceBytes(java.lang.String section, byte[] b, int start, int len)
          Sends bytes to console.
static void traceDirectToOutput(java.lang.String section, java.lang.String message)
          Like trace(...) but does not prefix message with section, date and thread info.
static void traceDumpException(java.lang.String section, java.lang.String message, java.lang.Throwable t)
          Like dumpException(...) except that caller can add an additional message to the dump.
static void traceWithDate(java.lang.String section, java.lang.String message, java.util.Date d)
          Trace that allows the date value to be supplied by caller.
static void warn(java.lang.Throwable t, java.lang.String msg)
           
static void warnEx(java.lang.Throwable t, java.lang.String msg, java.lang.String app)
           
static void warning(java.lang.Exception e, java.lang.String msg)
          Deprecated. use warn(e,msg)
static void warningEx(java.lang.Exception e, java.lang.String msg, java.lang.String app)
          Deprecated. use warnEx(e,msg,app)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_productVersion

protected static java.lang.String m_productVersion

m_productVersionInfo

protected static java.lang.String m_productVersionInfo

m_productBuildInfo

protected static java.lang.String m_productBuildInfo

m_productCopyright

protected static java.lang.String m_productCopyright

m_productThirdParty

protected static java.lang.String m_productThirdParty

MSG_INFO_TYPE

public static final int MSG_INFO_TYPE
See Also:
Constant Field Values

MSG_WARNING_TYPE

public static final int MSG_WARNING_TYPE
See Also:
Constant Field Values

MSG_ERROR_TYPE

public static final int MSG_ERROR_TYPE
See Also:
Constant Field Values

MSG_FATAL_TYPE

public static final int MSG_FATAL_TYPE
See Also:
Constant Field Values

m_logFileMsgPrefix

protected static java.lang.String m_logFileMsgPrefix

m_binDir

protected static java.lang.String m_binDir

m_cfgFile

protected static java.lang.String m_cfgFile

m_propertyFile

protected static java.lang.String m_propertyFile

m_propertyFileDes

protected static java.lang.String m_propertyFileDes

m_appProperties

protected static java.util.Properties m_appProperties

m_isInitialized

protected static boolean m_isInitialized

m_logger

protected static Log m_logger

m_waitRandom

protected static java.util.Random m_waitRandom

m_verbose

public static boolean m_verbose

m_traceEverything

public static boolean m_traceEverything

m_activeTracesList

public static java.util.Vector m_activeTracesList

m_activeTraces

public static java.util.Hashtable m_activeTraces

m_tracePrefix

public static java.lang.String m_tracePrefix

m_traceWithoutTimestamp

public static boolean m_traceWithoutTimestamp

m_traceImpl

public static TraceImplementor m_traceImpl

m_failOnReplacementCharacterDefault

public static boolean m_failOnReplacementCharacterDefault

m_failOnEncodingFailure

public static boolean m_failOnEncodingFailure

m_writeUTF8Signature

public static boolean m_writeUTF8Signature

m_writeUnicodeSignature

public static boolean m_writeUnicodeSignature

m_traceLogFormat

public static java.text.SimpleDateFormat m_traceLogFormat
Constructor Detail

SystemUtils

public SystemUtils()
Method Detail

checkStartup

public static boolean checkStartup()

getProductVersion

public static java.lang.String getProductVersion()

getProductVersionInfo

public static java.lang.String getProductVersionInfo()

getProductBuildInfo

public static java.lang.String getProductBuildInfo()

getProductCopyright

public static java.lang.String getProductCopyright()

getProductThirdParty

public static java.lang.String getProductThirdParty()

isOlderVersion

public static boolean isOlderVersion(java.lang.String info1,
                                     java.lang.String info2)

parseVersion

public static int[] parseVersion(java.lang.String info)

getLogFileMsgPrefix

public static java.lang.String getLogFileMsgPrefix()

setLogFileMsgPrefix

public static void setLogFileMsgPrefix(java.lang.String prefix)

setPropertiesFile

public static void setPropertiesFile(java.lang.String fileName,
                                     java.lang.String fileDes)

getAppProperties

public static java.util.Properties getAppProperties()

getAppProperty

public static java.lang.String getAppProperty(java.lang.String name)
                                       throws java.io.IOException
java.io.IOException

setAppProperty

public static void setAppProperty(java.lang.String name,
                                  java.lang.String value)

getBinDir

public static java.lang.String getBinDir()

getCfgFileName

public static java.lang.String getCfgFileName()

getCfgFilePath

public static java.lang.String getCfgFilePath()

getLogger

public static Log getLogger()

setLogger

public static void setLogger(Log logger)

locateBinDir

protected static void locateBinDir()

loadProperties

protected static void loadProperties()
                              throws java.io.IOException
java.io.IOException

getNativeOsUtils

protected static NativeOsUtils getNativeOsUtils()

reportError

public static void reportError(int type,
                               java.lang.String msg)

reportErrorEx

public static void reportErrorEx(java.lang.Throwable t,
                                 int type,
                                 java.lang.String msg,
                                 java.lang.String app)

info

public static void info(java.lang.String msg)

infoEx

public static void infoEx(java.lang.String msg,
                          java.lang.String app)

warning

public static void warning(java.lang.Exception e,
                           java.lang.String msg)
Deprecated. use warn(e,msg)


warningEx

public static void warningEx(java.lang.Exception e,
                             java.lang.String msg,
                             java.lang.String app)
Deprecated. use warnEx(e,msg,app)


warn

public static void warn(java.lang.Throwable t,
                        java.lang.String msg)

warnEx

public static void warnEx(java.lang.Throwable t,
                          java.lang.String msg,
                          java.lang.String app)

error

public static void error(java.lang.Exception e,
                         java.lang.String msg)
Deprecated. use err(e,msg)


errorEx

public static void errorEx(java.lang.Exception e,
                           java.lang.String msg,
                           java.lang.String app)
Deprecated. use errEx(e,msg,app)


err

public static void err(java.lang.Throwable t,
                       java.lang.String msg)

errEx

public static void errEx(java.lang.Throwable t,
                         java.lang.String msg,
                         java.lang.String app)

fatal

public static void fatal(java.lang.Throwable t,
                         java.lang.String msg)

fatalEx

public static void fatalEx(java.lang.Throwable t,
                           java.lang.String msg,
                           java.lang.String app)

getFailOnReplacementCharacterDefault

public static boolean getFailOnReplacementCharacterDefault()

setFailOnReplacementCharacterDefault

public static void setFailOnReplacementCharacterDefault(boolean newValue)

getFailOnEncodingFailure

public static boolean getFailOnEncodingFailure()

setFailOnEncodingFailure

public static void setFailOnEncodingFailure(boolean newValue)

setWriteUnicodeSignature

public static void setWriteUnicodeSignature(boolean newValue)
setWriteUnicodeSignature() controls the behavior of FileUtils.writeFileEncodingSignatureHeader(). By default this is set to false. Setting this to true will cause FileUtils.openDataWriterEx() to prepend a Unicode zero-length non-breaking space (?) to the beginning of the OutputStream. This normally isn't necessary since Java's Writer objects for Unicode normally write these for you.


getWriteUnicodeSignature

public static boolean getWriteUnicodeSignature()

setWriteUTF8Signature

public static void setWriteUTF8Signature(boolean newValue)
setWriteUTF8Signature() controls the behavior of FileUtils.writeFileEncodingSignatureHeader(). By default this is set to true causing FileUtils.openDataWriterEx() to prepend a UTF8 encoded Unicode zero-length non-breaking space (?) at the beginning of the OutputStream when the encoding is "UTF8".


getWriteUTF8Signature

public static boolean getWriteUTF8Signature()

isActiveTrace

public static boolean isActiveTrace(java.lang.String section)
Tests to see if a particular "section" of trace is active. Useful to allow a big package of tracing code to be skipped if "section" is not active.


getSectionData

public static TraceSection getSectionData(java.lang.String section)
obtain the section data object for a section

Parameters:
section -
Returns:

addAsActiveTrace

public static void addAsActiveTrace(java.lang.String section)
Enable a tracing "section".


removeAsActiveTrace

public static void removeAsActiveTrace(java.lang.String section)
Turn off a tracing "section".


setActiveTraces

public static void setActiveTraces(java.util.Vector traceList)
Set the currently active traces. Replaces the current list.


getActiveTraces

public static java.util.Vector getActiveTraces()
Gets a list of currently active traces.


reportDeprecatedUsage

public static void reportDeprecatedUsage(java.lang.String msg)
create an Exception and dump it to the deprecation trace section. Use this for a common place to report deprecated usage.


formatTraceLogDate

public static java.lang.String formatTraceLogDate(java.util.Date d)
Formats the date using the trace function's chosen format.


trace

public static void trace(java.lang.String section,
                         java.lang.String message)
Standard trace. Adds section, thread-id and date to message before sending it to output. The 'section' parameter MUST be in lower case.


traceWithDate

public static void traceWithDate(java.lang.String section,
                                 java.lang.String message,
                                 java.util.Date d)
Trace that allows the date value to be supplied by caller. Useful if the date is being used by caller to time performance. The 'section' parameter MUST be in lower case.


traceDirectToOutput

public static void traceDirectToOutput(java.lang.String section,
                                       java.lang.String message)
Like trace(...) but does not prefix message with section, date and thread info. It also does not terminate the output with a line feed. The 'section' parameter MUST be in lower case.


traceBytes

public static void traceBytes(java.lang.String section,
                              byte[] b,
                              int start,
                              int len)
Sends bytes to console. How console handles them is up to Java and console.


dumpException

public static void dumpException(java.lang.String section,
                                 java.lang.Throwable t)
Dumps all information relevant about an exception including stack trace.


traceDumpException

public static void traceDumpException(java.lang.String section,
                                      java.lang.String message,
                                      java.lang.Throwable t)
Like dumpException(...) except that caller can add an additional message to the dump.


appendTraceMessage

public static void appendTraceMessage(java.lang.StringBuffer buf,
                                      java.lang.String section,
                                      java.lang.String message,
                                      java.util.Date d,
                                      boolean fullTraceInfo)
Used to build the actual output message created by the trace(...) function. Useful if trace messages need to be saved or send elsewhere.


outln

public static void outln(java.lang.String message)
Sends message to console with line feed. Use in preference to System.out.println. TODO: this should be deprecated, all output should be tracing


out

public static void out(java.lang.String message)
Sends message to console. Use in preference to System.out.print. TODO: this should be deprecated, all output should be tracing


sleep

public static boolean sleep(long millis)
Wait a specific amount of time.

Returns:
true if the sleep() was successful.

sleepRandom

public static boolean sleepRandom(long minMillis,
                                  long maxMillis)
Wait a random amount of time.

Parameters:
minMillis - minimum amount of time to wait
maxMillis - maximum amount of time to wait
Returns:
true if the sleep() was successful.

setExceptionCause

public static void setExceptionCause(java.lang.Throwable newException,
                                     java.lang.Throwable causedByException)


(c) 1996-2005  All rights reserved.  Stellent, Inc.