|
||||||||||
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 Properties |
getSystemProperties()
Very similar to System.getProperties() except that the
SecurityException is absorbed. |
static String |
getSystemProperty(String key)
Very similar to System.getProperty except that the
SecurityException is absorbed. |
static String |
getSystemProperty(String key,
String def)
Very similar to System.getProperty except that the
SecurityException is absorbed. |
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,
PropertyContainer pc)
Perform variable substitution in string val from the values
of keys found in context property map, and if that fails, then 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, PropertyContainer pc)
val
from the values
of keys found in context property map, and if that fails, then in the
system properties.
The variable substitution delimeters are ${ and }.
For example, if the context property map contains a property "key1" set as "value1", then the call
String s = OptionConverter.substituteVars("Value of key is ${key1}.", context);will set the variable
s
to "Value of key is value1.".
If no value could be found for the specified key in the context map, then the system properties are searched, if that fails, then substitution defaults to appending "_IS_UNDEFINED" to the key name.
For example, if not the context not the system properties contains no value for the key "inexistentKey", then the call
String s = OptionConverter.subsVars( "Value of inexistentKey is [${inexistentKey}]", context);will set
s
to "Value of inexistentKey is
[inexistentKey_IS_UNDEFINED]".
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}]", context);will set
s
to "Value of key is [val2]" even if the "key2"
property is not set.
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 absorbed.
key
- The key to search for.def
- The default value to return.
public static String getSystemProperty(String key)
System.getProperty
except that the
SecurityException
is absorbed.
key
- The key to search for.
public static Properties getSystemProperties()
System.getProperties()
except that the
SecurityException
is absorbed.
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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |