swpchat.util
Class DiagProps

java.lang.Object
  |
  +--swpchat.util.DiagProps

public class DiagProps
extends java.lang.Object

Class uses Properties to store, save and load debuglevels to certain keys .

Since:
17.11.1999
Author:
Dirk Hesse, David Kensche

Field Summary
static java.lang.String CLS
          The Name of the current class for debugging output.
private static java.lang.String defaultLogFileName
          default log filename.
private  java.util.Properties defaults
           
private  java.lang.String diagFileName
           
private static java.lang.String PKDiagLogFileName
          The property key for log-file filename.
private  java.lang.String STR_DIAG
           
private  java.lang.String STR_LEVEL
           
 
Constructor Summary
DiagProps(java.lang.String diagFileName)
          Constructor for DiagProps.
 
Method Summary
 int getDebuglevel(java.lang.String pkMethodName)
          Returns the default debuglevel of the method specified in pkMethodName.
 java.lang.String getLogFileName()
          returns the specified DiagLogFileName.
 void reload()
          Load the new Properties if the name of the config file changed during runtime.
protected  void save()
          store default properties in diagFileName
 void setConfigFileName(java.lang.String diagFileName)
          set the name of the Properties file
 void setGlobalDebuglevel(int debuglevel)
          Sets the global debublevel.
 void setMethodDebuglevel(java.lang.String pkMethodName, int debuglevel)
          Sets the default debuglevel for the method (or class, package) pkMethodName.
private  java.util.Vector tokenize(java.lang.String pkMethodName)
          Creates the Property keys that could possibly match to pkMethodName and returns them in a Vector.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

PKDiagLogFileName

private static final java.lang.String PKDiagLogFileName
The property key for log-file filename.

defaultLogFileName

private static final java.lang.String defaultLogFileName
default log filename.

defaults

private java.util.Properties defaults

diagFileName

private java.lang.String diagFileName

STR_DIAG

private final java.lang.String STR_DIAG

STR_LEVEL

private final java.lang.String STR_LEVEL

CLS

public static final java.lang.String CLS
The Name of the current class for debugging output.
Constructor Detail

DiagProps

public DiagProps(java.lang.String diagFileName)
Constructor for DiagProps. Loads the saved debuglevels to defaults.
Parameters:
pkDiagFileName - String specifying the complete name of the sourcefile of the Properties.
Method Detail

setConfigFileName

public void setConfigFileName(java.lang.String diagFileName)
set the name of the Properties file
Parameters:
diagFileName - String specifying the new filename

reload

public void reload()
Load the new Properties if the name of the config file changed during runtime.

tokenize

private java.util.Vector tokenize(java.lang.String pkMethodName)
                           throws ParserException
Creates the Property keys that could possibly match to pkMethodName and returns them in a Vector. That is for example, if the given key is "util.Diag.dbg(String,String,int)" than elementAt(1) is "Diag.util.debuglevel", elementAt(2) is "Diag.util.Diag.debuglevel", elementAt(3) is "Diag.util.Diag.dbg.debuglevel", elementAt(4) is "Diag.util.Diag.dbg(String,String,int).debuglevel", elementAt(0) is always "Diag.debuglevel", which is the global debuglevel which is valid, if no other key matches to an existing Property.
Parameters:
pkMethodName - String specifying the complete name of the method whose debuglevel is asked for, i.e. with with Package and class name.
Returns:
the Vector containing the Propertykeys that could possibly match.

getDebuglevel

public int getDebuglevel(java.lang.String pkMethodName)
Returns the default debuglevel of the method specified in pkMethodName. If no matches are found the global debuglevel is returned. If the global debuglevel is not set, then 0 is returned
Parameters:
pkMethodName - String specifying the complete name of the method whose debuglevel is asked for, i.e. with with Package and class name.
Returns:
the the most specific matching debuglevel.

setMethodDebuglevel

public void setMethodDebuglevel(java.lang.String pkMethodName,
                                int debuglevel)
Sets the default debuglevel for the method (or class, package) pkMethodName. The defaults are saved also.
Parameters:
pkMethodName - String specifying the complete name of the method whose debuglevel is asked for, i.e. with with Package and class name.
debuglevel - the new debuglevel

setGlobalDebuglevel

public void setGlobalDebuglevel(int debuglevel)
Sets the global debublevel. That is, the debuglevel valid if no other matchings for a methodname are found.
Parameters:
debuglevel - the new global debuglevel

save

protected void save()
store default properties in diagFileName

getLogFileName

public java.lang.String getLogFileName()
returns the specified DiagLogFileName. If not specified, returns null.