org.apache.logging.log4j.core.config.plugins.convert
Class TypeConverters
java.lang.Object
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters
public final class TypeConverters
- extends Object
Collection of basic TypeConverter implementations. May be used to register additional TypeConverters or find
registered TypeConverters.
- Since:
- 2.1 Moved to the
convert
package.
Method Summary |
static Object |
convert(String s,
Class<?> clazz,
Object defaultValue)
Converts a String to a given class if a TypeConverter is available for that class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CATEGORY
public static final String CATEGORY
- The
Plugin Category
to use for TypeConverter
plugins.
- Since:
- 2.1
- See Also:
- Constant Field Values
TypeConverters
public TypeConverters()
convert
public static Object convert(String s,
Class<?> clazz,
Object defaultValue)
- Converts a String to a given class if a TypeConverter is available for that class. Falls back to the provided
default value if the conversion is unsuccessful. However, if the default value is also invalid, then
null
is returned (along with a nasty status log message).
- Parameters:
s
- the string to convertclazz
- the class to try to convert the string todefaultValue
- the fallback object to use if the conversion is unsuccessful
- Returns:
- the converted object which may be
null
if the string is invalid for the given type
- Throws:
NullPointerException
- if clazz
is null
IllegalArgumentException
- if no TypeConverter exists for the given class
Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.