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
convertpackage.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classParses aStringinto aBigDecimal.static classParses aStringinto aBigInteger.static classstatic classConverts aStringinto abyte[].static classstatic classstatic classConverts aStringinto achar[].static classstatic classstatic classstatic classstatic classDeprecated.since 2.24.0.static classstatic classstatic classConverts aStringinto anInetAddress.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classReturns the givenString, no conversion takes place.static classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThePlugin Categoryto use forTypeConverterplugins. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
CATEGORY
ThePlugin Categoryto use forTypeConverterplugins.- 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, thennullis 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
nullif the string is invalid for the given type - Throws:
NullPointerException- ifclazzisnullIllegalArgumentException- if no TypeConverter exists for the given class
-