- java.lang.Object
-
- ch.qos.logback.core.util.OptionHelper
-
public class OptionHelper extends Object
- Author:
- Ceki Gulcu
-
-
Constructor Summary
Constructors Constructor Description OptionHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String[]extractDefaultReplacement(String key)Return a String[] of size two.static StringgetEnv(String key)Lookup a key from the environment.static PropertiesgetSystemProperties()Very similar toSystem.getProperties()except that theSecurityExceptionis absorbed.static StringgetSystemProperty(String key)Very similar toSystem.getPropertyexcept that theSecurityExceptionis absorbed.static StringgetSystemProperty(String key, String def)Very similar toSystem.getPropertyexcept that theSecurityExceptionis absorbed.static ObjectinstantiateByClassName(String className, Class<?> superClass, Context context)static ObjectinstantiateByClassName(String className, Class<?> superClass, ClassLoader classLoader)static ObjectinstantiateByClassNameAndParameter(String className, Class<?> superClass, Context context, Class<?> type, Object param)static ObjectinstantiateByClassNameAndParameter(String className, Class<?> superClass, ClassLoader classLoader, Class<?> type, Object parameter)static ObjectinstantiateClassWithSuperclassRestriction(Class<?> classObj, Class<?> superClass)static booleanisEmpty(String str)Deprecated.static booleanisNotEmtpy(Object[] array)static booleanisNullOrEmpty(Object[] array)static booleanisNullOrEmpty(String str)Returns true if input str is null or empty.static booleanisNullOrEmptyOrAllSpaces(String str)isNullOrEmpty xisNullOrEmptyOrAllSpacesstatic StringpropertyLookup(String key, PropertyContainer pc1, PropertyContainer pc2)Try to lookup the property in the following order: pc1 (the local property container, usually theModelInterpretationContext) pc2 (usually thecontext) System properties Environment variablesstatic voidsetSystemProperties(ContextAware contextAware, Properties props)static voidsetSystemProperty(ContextAware contextAware, String key, String value)static StringsubstVars(String val, PropertyContainer pc1)static StringsubstVars(String input, PropertyContainer pc0, PropertyContainer pc1)See http://logback.qos.ch/manual/configuration.html#variableSubstitutionstatic booleantoBoolean(String value, boolean defaultVal)Ifvalueis "true", thentrueis returned.static BooleantoBooleanObject(String value)Converts a string representation of a boolean value to aBooleanobject.
-
-
-
Constructor Detail
-
OptionHelper
public OptionHelper()
-
-
Method Detail
-
instantiateByClassName
public static Object instantiateByClassName(String className, Class<?> superClass, Context context) throws IncompatibleClassException, DynamicClassLoadingException
-
instantiateByClassNameAndParameter
public static Object instantiateByClassNameAndParameter(String className, Class<?> superClass, Context context, Class<?> type, Object param) throws IncompatibleClassException, DynamicClassLoadingException
-
instantiateByClassName
public static Object instantiateByClassName(String className, Class<?> superClass, ClassLoader classLoader) throws IncompatibleClassException, DynamicClassLoadingException
-
instantiateClassWithSuperclassRestriction
public static Object instantiateClassWithSuperclassRestriction(Class<?> classObj, Class<?> superClass) throws IncompatibleClassException, DynamicClassLoadingException
-
instantiateByClassNameAndParameter
public static Object instantiateByClassNameAndParameter(String className, Class<?> superClass, ClassLoader classLoader, Class<?> type, Object parameter) throws IncompatibleClassException, DynamicClassLoadingException
-
substVars
public static String substVars(String val, PropertyContainer pc1) throws ScanException
- Throws:
ScanException- See Also:
substVars(String, PropertyContainer, PropertyContainer)
-
substVars
public static String substVars(String input, PropertyContainer pc0, PropertyContainer pc1) throws ScanException
See http://logback.qos.ch/manual/configuration.html#variableSubstitution- Throws:
ScanException
-
propertyLookup
public static String propertyLookup(String key, PropertyContainer pc1, PropertyContainer pc2)
Try to lookup the property in the following order:- pc1 (the local property container, usually the
ModelInterpretationContext) - pc2 (usually the
context) - System properties
- Environment variables
- Parameters:
key- the property keypc1- the first property container to searchpc2- the second property container to search- Returns:
- the property value or null if not found
- pc1 (the local property container, usually the
-
getSystemProperty
public static String getSystemProperty(String key, String def)
Very similar toSystem.getPropertyexcept that theSecurityExceptionis absorbed.- Parameters:
key- The key to search for.def- The default value to return.- Returns:
- the string value of the system property, or the default value if there is no property with that key.
-
getEnv
public static String getEnv(String key)
Lookup a key from the environment.- Parameters:
key-- Returns:
- value corresponding to key from the OS environment
-
getSystemProperty
public static String getSystemProperty(String key)
Very similar toSystem.getPropertyexcept that theSecurityExceptionis absorbed.- Parameters:
key- The key to search for.- Returns:
- the string value of the system property.
-
setSystemProperties
public static void setSystemProperties(ContextAware contextAware, Properties props)
-
setSystemProperty
public static void setSystemProperty(ContextAware contextAware, String key, String value)
-
getSystemProperties
public static Properties getSystemProperties()
Very similar toSystem.getProperties()except that theSecurityExceptionis absorbed.- Returns:
- the system properties
-
extractDefaultReplacement
public static String[] extractDefaultReplacement(String key)
Return a String[] of size two. The first item containing the key part and the second item containing a default value specified by the user. The second item will be null if no default value is specified.- Parameters:
key-- Returns:
-
toBooleanObject
public static Boolean toBooleanObject(String value)
Converts a string representation of a boolean value to aBooleanobject. If the input string is "true" (case-insensitive), returnsBoolean.TRUE. If the input string is "false" (case-insensitive), returnsBoolean.FALSE. Returnsnullif the input string is null, empty, or does not match "true" or "false".- Parameters:
value- the string representation of a boolean value, may be null or empty- Returns:
- a
Booleanobject corresponding to the input string, ornullif the input is invalid
-
toBoolean
public static boolean toBoolean(String value, boolean defaultVal)
If
valueis "true", thentrueis returned. Ifvalueis "false", thentrueis returned. Otherwise,defaultValis returned.Comparisons are case-insensitive.
- Parameters:
value- a string representation of a boolean valuedefaultVal- the default value to return ifvalueis null, empty or not a valid boolean value
-
isNullOrEmpty
public static boolean isNullOrEmpty(String str)
Returns true if input str is null or empty.- Parameters:
str-- Returns:
-
isNullOrEmptyOrAllSpaces
public static boolean isNullOrEmptyOrAllSpaces(String str)
isNullOrEmpty xisNullOrEmptyOrAllSpaces- Parameters:
str-- Returns:
- Since:
- 1.5.0
-
isNullOrEmpty
public static final boolean isNullOrEmpty(Object[] array)
-
isNotEmtpy
public static final boolean isNotEmtpy(Object[] array)
-
-