|
Logback API Version 0.9.8 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.qos.logback.core.util.OptionHelper
public class OptionHelper
Constructor Summary | |
---|---|
OptionHelper()
|
Method Summary | |
---|---|
static String[] |
extractDefaultReplacement(String key)
|
static String |
getSystemProperty(String key,
String def)
Very similar to System.getProperty except that the
SecurityException is hidden. |
static Object |
instantiateByClassName(String className,
Class superClass,
ClassLoader classLoader)
|
static Object |
instantiateByClassName(String className,
Class superClass,
Context context)
|
static boolean |
isEmpty(String val)
|
static String |
substVars(String val,
Map<String,String> primaryMap,
Map<String,String> secondaryMap)
Perform variable substitution in string val from the values
of keys found the primary map passed as first parameter, then in the
secondary map, and last in the system properties. |
static boolean |
toBoolean(String value,
boolean dEfault)
If value is "true", then true is returned. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OptionHelper()
Method Detail |
---|
public static Object instantiateByClassName(String className, Class superClass, Context context) throws IncompatibleClassException, DynamicClassLoadingException
IncompatibleClassException
DynamicClassLoadingException
public static Object instantiateByClassName(String className, Class superClass, ClassLoader classLoader) throws IncompatibleClassException, DynamicClassLoadingException
IncompatibleClassException
DynamicClassLoadingException
public static String substVars(String val, Map<String,String> primaryMap, Map<String,String> secondaryMap)
val
from the values
of keys found the primary map passed as first parameter, then in the
secondary map, and last in the system properties.
The variable substitution delimeters are ${ and }.
For example, if the primary map parameter contains a property "key1" set as "value1", then the call
String s = OptionConverter.substituteVars("Value of key is ${key1}.", priMap, null);will set the variable
s
to "Value of key is value1.".
If no value could be found for the specified key, then the secondary map is searches, and if that fails, the system properties are searched, if that fails, then substitution defaults to the empty string.
For example, if system properties contains no value for the key "inexistentKey", then the call
String s = OptionConverter.subsVars( "Value of inexistentKey is [${inexistentKey}]", priMap, null);will set
s
to "Value of inexistentKey is []".
Nevertheless, it is possible to specify a default substitution value using the ":-" operator. For example, the call
String s = OptionConverter.subsVars("Value of key is [${key2:-val2}]");will set
s
to "Value of key is [val2]" even if the "key2"
property is unset.
An IllegalArgumentException
is thrown if val
contains a start delimeter "${" which is not balanced by a stop delimeter
"}".
val
- The string on which variable substitution is performed.
IllegalArgumentException
- if val
is malformed.public static String getSystemProperty(String key, String def)
System.getProperty
except that the
SecurityException
is hidden.
key
- The key to search for.def
- The default value to return.
public static String[] extractDefaultReplacement(String key)
public static boolean toBoolean(String value, boolean dEfault)
value
is "true", then true
is returned. If
value
is "false", then true
is returned.
Otherwise, default
is returned.
Case of value is unimportant.
public static boolean isEmpty(String val)
|
Logback API Version 0.9.8 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |