Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

openfuture.util.misc
Class Trace  view Trace download Trace.java

java.lang.Object
  extended byopenfuture.util.misc.Trace

public abstract class Trace
extends java.lang.Object

The Trace class provides static methods that can be used in Java Applets and Applications to output trace messages to a trace device. Traces can be activated on a per class basis and for each class a combination of any of the following trace levels is possible: 0.ERROR: should be used in case of severe errors 1.WARNING: should be used in case of warnings and uncritical errors 2.IN: should be used as the first statement in a method 3.OUT: should be used before existing a method 4.PARAMETER: should be used to trace out method parameters 5.MESSAGE: should be used to trace out any message within the method body 6.USER-DEFINED: user defined trace level 7.EXCEPTION: should be used when an exception occurs (is not maskable) The trace mechanism is initialized via a config file that contains a bit mask for each class that uses traces, e.g. util.email.MailData: 0 util.email.MailSender: 0 jawa.fzbewertung.AufnahmeGUI: 255 jawa.fzbewertung.CICSData: 3 jawa.fzbewertung.CreateMapApplet: 3 The value corresponds to the combination of trace levels 0. - 6. where each trace level is activated by setting the appropriate bit to 1, e.g. a value of 3 (0000 0011 in binary mode) means that only ERRORS and WARNING are going to be traced for a given class. The config file can either be read via HTTP using the method readTraceConfig or directly from the local file system using the method readTraceConfigFromFile.

Version:
$Revision: 1.1.1.1 $

Field Summary
private static java.util.GregorianCalendar calendar
           
private static int dateAndTimeMode
           
private static java.lang.String DEFAULT_TRACE_FILENAME
           
private static int defaultBitMask
           
private static java.lang.String[] MESSAGE_TYPE_STRINGS
           
private static int outputMode
           
private static java.io.PrintWriter outputStream
           
private static java.util.Hashtable permissions
           
private static java.lang.String[] TD
           
static int TD_ALL
           
static int TD_CONSOLE
           
static int TD_FILE
           
static int TL_LOW
           
static java.lang.String TL_LOW_STRING
           
static int TL_MEDIUM
           
static java.lang.String TL_MEDIUM_STRING
           
static int TL_OFF
           
static java.lang.String TL_OFF_STRING
           
static int TL_VERBOSE
           
static java.lang.String TL_VERBOSE_STRING
           
private static java.lang.String[] TRACE_BITS
           
private static int TRACE_ERR
           
private static int TRACE_IN
           
private static int TRACE_MSG
           
private static int TRACE_OUT
           
private static int TRACE_PARAM
           
private static int TRACE_USER
           
private static int TRACE_WARN
           
private static java.lang.String traceFilename
           
private static java.lang.String[] TT
           
static int TT_DATE
           
static int TT_OFF
           
static int TT_TIME
           
static int TT_TIME_MS
           
 
Constructor Summary
Trace()
           
 
Method Summary
static void closeOutputFile()
          closes the outputStream in case of TD_FILE & TD_ALL
private static void createOutputFileFile(java.lang.String filename)
          This method is being called by the method setOutputMode and creates a file for the logging of trace information.
static void error(java.lang.Object theObject, java.lang.String msg)
          Describe 'error' method here.
static void error(java.lang.Object theObject, java.lang.String msg, int nRID)
          Describe 'error' method here.
static void exception(java.lang.Object theObject, java.lang.String msg)
          Describe 'exception' method here.
static void exception(java.lang.Object theObject, java.lang.String msg, int nRID)
          Describe 'exception' method here.
private static java.lang.String getCurrentDateAndTimeString()
          Describe 'getCurrentDateAndTimeString' method here.
static java.lang.String getDetailedStatusString()
          is used to retrieve information about the config file that is currently in use.
static java.lang.String getStatusString()
          is used to retrieve information about the config file that is currently in use.
private static boolean hasDebugFlagSet(java.lang.Object theObject, int traceflag)
          is used to perform the check if a class (given as an object instance) has activated a given trace level.
static void in(java.lang.Object theObject, java.lang.String msg)
          Describe 'in' method here.
static void message(java.lang.Object theObject, java.lang.String msg)
          Describe 'message' method here.
static void message(java.lang.Object theObject, java.lang.String msg, int nRID)
          Describe 'message' method here.
static void out(java.lang.Object theObject, java.lang.String msg)
          Describe 'out' method here.
static void param(java.lang.Object theObject, java.lang.String msg)
          Describe 'param' method here.
static java.lang.String printContent()
          is used to retrieve information about the config file that is currently in use.
static int readTraceConfig(java.lang.String urlPrefix, java.lang.String filename)
          tries to read the config file given as a parameter and sets up the internal hashtable.
static int readTraceConfigFromFile(java.lang.String filename)
          tries to read the config file given as a parameter and sets up the internal hashtable.
static void setDateAndTimeMode(int flag)
          determines if date and time (and eventually milliseconds) will be used as a prefix for the trace output.
static void setOutputMode(int flag, java.lang.String filename)
          determines the output mode.
static void setTraceMode(java.lang.Object theObject, int flag)
          sets the trace bit mask for a given class manually.
static void setTraceModeDefault(int flag)
          sets the trace default bit mask.
private static int stringToInt(java.lang.String s, int def)
          private method that does the same as the standard string to int conversion method but catches the NumberFormatException and outputs an appropriate message.
private static java.lang.String substring(java.lang.String s, int start, int end)
          private method that does the same as the standard substring method but catches the StringIndexOutOfBoundsException and outputs an appropriate message and returns an empty string so that the calling instance can continue without worrying.
private static void trace(java.lang.String msg)
          used to output the message to the trace device.
private static void trace(java.lang.String msg, int nRID)
          used to output the message to the trace device.
static void user(java.lang.Object theObject, java.lang.String msg)
          Describe 'user' method here.
static void user(java.lang.Object theObject, java.lang.String msg, int nRID)
          Describe 'user' method here.
static void user(java.lang.Object theObject, java.lang.String prefix, java.lang.String msg)
          Describe 'user' method here.
static void user(java.lang.Object theObject, java.lang.String prefix, java.lang.String msg, int nRID)
          Describe 'user' method here.
static void warning(java.lang.Object theObject, java.lang.String msg)
          Describe 'warning' method here.
static void warning(java.lang.Object theObject, java.lang.String msg, int nRID)
          Describe 'warning' method here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

permissions

private static java.util.Hashtable permissions

MESSAGE_TYPE_STRINGS

private static java.lang.String[] MESSAGE_TYPE_STRINGS

TRACE_ERR

private static final int TRACE_ERR
See Also:
Constant Field Values

TRACE_WARN

private static final int TRACE_WARN
See Also:
Constant Field Values

TRACE_IN

private static final int TRACE_IN
See Also:
Constant Field Values

TRACE_OUT

private static final int TRACE_OUT
See Also:
Constant Field Values

TRACE_PARAM

private static final int TRACE_PARAM
See Also:
Constant Field Values

TRACE_MSG

private static final int TRACE_MSG
See Also:
Constant Field Values

TRACE_USER

private static final int TRACE_USER
See Also:
Constant Field Values

TRACE_BITS

private static final java.lang.String[] TRACE_BITS

TL_OFF

public static final int TL_OFF
See Also:
Constant Field Values

TL_LOW

public static final int TL_LOW
See Also:
Constant Field Values

TL_MEDIUM

public static final int TL_MEDIUM
See Also:
Constant Field Values

TL_VERBOSE

public static final int TL_VERBOSE
See Also:
Constant Field Values

TL_OFF_STRING

public static final java.lang.String TL_OFF_STRING
See Also:
Constant Field Values

TL_LOW_STRING

public static final java.lang.String TL_LOW_STRING
See Also:
Constant Field Values

TL_MEDIUM_STRING

public static final java.lang.String TL_MEDIUM_STRING
See Also:
Constant Field Values

TL_VERBOSE_STRING

public static final java.lang.String TL_VERBOSE_STRING
See Also:
Constant Field Values

TD_CONSOLE

public static final int TD_CONSOLE
See Also:
Constant Field Values

TD_FILE

public static final int TD_FILE
See Also:
Constant Field Values

TD_ALL

public static final int TD_ALL
See Also:
Constant Field Values

TD

private static final java.lang.String[] TD

TT_OFF

public static final int TT_OFF
See Also:
Constant Field Values

TT_DATE

public static final int TT_DATE
See Also:
Constant Field Values

TT_TIME

public static final int TT_TIME
See Also:
Constant Field Values

TT_TIME_MS

public static final int TT_TIME_MS
See Also:
Constant Field Values

TT

private static final java.lang.String[] TT

dateAndTimeMode

private static int dateAndTimeMode

outputMode

private static int outputMode

outputStream

private static java.io.PrintWriter outputStream

defaultBitMask

private static int defaultBitMask

calendar

private static java.util.GregorianCalendar calendar

DEFAULT_TRACE_FILENAME

private static final java.lang.String DEFAULT_TRACE_FILENAME
See Also:
Constant Field Values

traceFilename

private static java.lang.String traceFilename
Constructor Detail

Trace

public Trace()
Method Detail

error

public static void error(java.lang.Object theObject,
                         java.lang.String msg)
Describe 'error' method here.


error

public static void error(java.lang.Object theObject,
                         java.lang.String msg,
                         int nRID)
Describe 'error' method here.


exception

public static void exception(java.lang.Object theObject,
                             java.lang.String msg)
Describe 'exception' method here.


exception

public static void exception(java.lang.Object theObject,
                             java.lang.String msg,
                             int nRID)
Describe 'exception' method here.


in

public static void in(java.lang.Object theObject,
                      java.lang.String msg)
Describe 'in' method here.


message

public static void message(java.lang.Object theObject,
                           java.lang.String msg)
Describe 'message' method here.


message

public static void message(java.lang.Object theObject,
                           java.lang.String msg,
                           int nRID)
Describe 'message' method here.


out

public static void out(java.lang.Object theObject,
                       java.lang.String msg)
Describe 'out' method here.


param

public static void param(java.lang.Object theObject,
                         java.lang.String msg)
Describe 'param' method here.


user

public static void user(java.lang.Object theObject,
                        java.lang.String msg)
Describe 'user' method here.


user

public static void user(java.lang.Object theObject,
                        java.lang.String msg,
                        int nRID)
Describe 'user' method here.


user

public static void user(java.lang.Object theObject,
                        java.lang.String prefix,
                        java.lang.String msg)
Describe 'user' method here.


user

public static void user(java.lang.Object theObject,
                        java.lang.String prefix,
                        java.lang.String msg,
                        int nRID)
Describe 'user' method here.


warning

public static void warning(java.lang.Object theObject,
                           java.lang.String msg)
Describe 'warning' method here.


warning

public static void warning(java.lang.Object theObject,
                           java.lang.String msg,
                           int nRID)
Describe 'warning' method here.


printContent

public static java.lang.String printContent()
is used to retrieve information about the config file that is currently in use. The method returns a string containing the registred class names and the corresponding bit mask value in a somehow 'preformatted' way.


readTraceConfig

public static int readTraceConfig(java.lang.String urlPrefix,
                                  java.lang.String filename)
tries to read the config file given as a parameter and sets up the internal hashtable.


readTraceConfigFromFile

public static int readTraceConfigFromFile(java.lang.String filename)
tries to read the config file given as a parameter and sets up the internal hashtable.


getDetailedStatusString

public static java.lang.String getDetailedStatusString()
is used to retrieve information about the config file that is currently in use. The method returns a string containing the registred class names and the corresponding bit mask value in a somehow 'preformatted' way.


getStatusString

public static java.lang.String getStatusString()
is used to retrieve information about the config file that is currently in use. The method returns a string containing the registred class names and the corresponding bit mask value in a somehow 'preformatted' way.


setDateAndTimeMode

public static void setDateAndTimeMode(int flag)
determines if date and time (and eventually milliseconds) will be used as a prefix for the trace output.


setOutputMode

public static void setOutputMode(int flag,
                                 java.lang.String filename)
determines the output mode. It can either be a file or the console or both.


closeOutputFile

public static void closeOutputFile()
closes the outputStream in case of TD_FILE & TD_ALL


setTraceMode

public static void setTraceMode(java.lang.Object theObject,
                                int flag)
sets the trace bit mask for a given class manually.


setTraceModeDefault

public static void setTraceModeDefault(int flag)
sets the trace default bit mask. This bit mask is used if the trace mechanism encounters a class that has not yet been registered.


createOutputFileFile

private static void createOutputFileFile(java.lang.String filename)
This method is being called by the method setOutputMode and creates a file for the logging of trace information.


getCurrentDateAndTimeString

private static java.lang.String getCurrentDateAndTimeString()
Describe 'getCurrentDateAndTimeString' method here.


hasDebugFlagSet

private static boolean hasDebugFlagSet(java.lang.Object theObject,
                                       int traceflag)
is used to perform the check if a class (given as an object instance) has activated a given trace level.


stringToInt

private static int stringToInt(java.lang.String s,
                               int def)
private method that does the same as the standard string to int conversion method but catches the NumberFormatException and outputs an appropriate message. In case of an exception the method return the default value def that has been passed to the method as a parameter.


substring

private static java.lang.String substring(java.lang.String s,
                                          int start,
                                          int end)
private method that does the same as the standard substring method but catches the StringIndexOutOfBoundsException and outputs an appropriate message and returns an empty string so that the calling instance can continue without worrying.


trace

private static void trace(java.lang.String msg)
used to output the message to the trace device. The output goes either to the system console or to a file or to both devices.


trace

private static void trace(java.lang.String msg,
                          int nRID)
used to output the message to the trace device. The output goes either to the system console or to a file or to both devices.