org.jconfig
Class VariableManager

java.lang.Object
  |
  +--org.jconfig.VariableManager

public class VariableManager
extends java.lang.Object

This class manages all variables for all log configurations. Every handler or formatter can use this class to replace any variables that are used inside of the parameters. Please refer to the specific handler or formatter to see which parameters support the use of variables.

Author:
Andreas Mecky, Terry Dye

Method Summary
 void addIncludedVariable(java.lang.String varName, java.lang.String varValue, java.lang.String configName)
           
 void addVariable(java.lang.String varName, java.lang.String varValue, java.lang.String configName)
          This method adds a variable for a given configuration.
static VariableManager getInstance()
          This method will return an instance of the VariableManager
 java.lang.String getVariable(java.lang.String configName, java.lang.String name)
           
 java.util.HashMap getVariables(java.lang.String configName)
           
 void removeVariable(java.lang.String varName, java.lang.String configName)
          This method removes a variable for a given configuration.
protected  java.lang.String replaceEnvVar(java.lang.String text)
           
protected  java.lang.String replaceSystemVar(java.lang.String text)
           
 java.lang.String replaceVariables(java.lang.String text, java.lang.String configName)
          This method will replace all variables inside one String that are in this configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static VariableManager getInstance()
This method will return an instance of the VariableManager
Returns:
the one and only instance of the VariableManager

getVariables

public java.util.HashMap getVariables(java.lang.String configName)

getVariable

public java.lang.String getVariable(java.lang.String configName,
                                    java.lang.String name)

addVariable

public void addVariable(java.lang.String varName,
                        java.lang.String varValue,
                        java.lang.String configName)
This method adds a variable for a given configuration.
Parameters:
varName - name of the variable
varValue - the value for this variable
configName - the configuration to which this variable belongs

removeVariable

public void removeVariable(java.lang.String varName,
                           java.lang.String configName)
This method removes a variable for a given configuration.
Parameters:
varName - name of the variable
configName - the configuration to which this variable belongs

addIncludedVariable

public void addIncludedVariable(java.lang.String varName,
                                java.lang.String varValue,
                                java.lang.String configName)

replaceVariables

public java.lang.String replaceVariables(java.lang.String text,
                                         java.lang.String configName)
This method will replace all variables inside one String that are in this configuration. A variable is used as ${name}. This occurance will be replaced with the specific value or will be left as is if the variable name is not found in the specific configuration.
Parameters:
text - the line of text which contains variables
configName - the name of the configuration
Returns:
a String where all variables are replaced with their values

replaceEnvVar

protected java.lang.String replaceEnvVar(java.lang.String text)

replaceSystemVar

protected java.lang.String replaceSystemVar(java.lang.String text)


Copyright © 2001-2003 Andreas Mecky, Terry Dye. All Rights Reserved.