Class TypeConverters
java.lang.Object
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters
Collection of basic TypeConverter implementations. May be used to register additional TypeConverters or find
registered TypeConverters.
- Since:
- 2.1 Moved to the
convert
package.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Parses aString
into aBigDecimal
.static class
Parses aString
into aBigInteger
.static class
static class
Converts aString
into abyte[]
.static class
static class
static class
Converts aString
into achar[]
.static class
static class
static class
static class
static class
Deprecated.since 2.24.0.static class
static class
static class
Converts aString
into anInetAddress
.static class
static class
static class
static class
static class
static class
static class
static class
Returns the givenString
, no conversion takes place.static class
static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
ThePlugin Category
to use forTypeConverter
plugins. -
Constructor Summary
-
Method Summary
-
Field Details
-
CATEGORY
ThePlugin Category
to use forTypeConverter
plugins.- Since:
- 2.1
- See Also:
-
-
Constructor Details
-
TypeConverters
public TypeConverters()
-
-
Method Details
-
convert
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, thennull
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
- ifclazz
isnull
IllegalArgumentException
- if no TypeConverter exists for the given class
-