Package org.apache.logging.log4j.util
Class PropertiesPropertySource
java.lang.Object
org.apache.logging.log4j.util.PropertiesPropertySource
- All Implemented Interfaces:
PropertySource
- Direct Known Subclasses:
PropertyFilePropertySource
PropertySource backed by a
Properties
instance. Normalized property names follow a scheme like this:
Log4jContextSelector
would normalize to log4j2.contextSelector
.- Since:
- 2.10.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.logging.log4j.util.PropertySource
PropertySource.Comparator, PropertySource.Util
-
Constructor Summary
ConstructorDescriptionPropertiesPropertySource
(Properties properties) PropertiesPropertySource
(Properties properties, int priority) -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsProperty
(String key) For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.void
forEach
(BiConsumer<String, String> action) Iterates over all properties and performs an action for each key/value pair.getNormalForm
(Iterable<? extends CharSequence> tokens) Converts a list of property name tokens into a normal form.int
Returns the order in which this PropertySource has priority.getProperty
(String key) For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.Returns the list of all property names.
-
Constructor Details
-
PropertiesPropertySource
-
PropertiesPropertySource
- Since:
- 2.18.0
-
-
Method Details
-
getPriority
public int getPriority()Description copied from interface:PropertySource
Returns the order in which this PropertySource has priority. A higher value means that the source will be searched later and can be overridden by other property sources.- Specified by:
getPriority
in interfacePropertySource
- Returns:
- priority value
-
forEach
Description copied from interface:PropertySource
Iterates over all properties and performs an action for each key/value pair.- Specified by:
forEach
in interfacePropertySource
- Parameters:
action
- action to perform on each key/value pair
-
getNormalForm
Description copied from interface:PropertySource
Converts a list of property name tokens into a normal form. For example, a list of tokens such as "foo", "bar", "baz", might be normalized into the property name "log4j2.fooBarBaz".- Specified by:
getNormalForm
in interfacePropertySource
- Parameters:
tokens
- list of property name tokens- Returns:
- a normalized property name using the given tokens
-
getPropertyNames
Description copied from interface:PropertySource
Returns the list of all property names.- Specified by:
getPropertyNames
in interfacePropertySource
- Returns:
- list of property names
-
getProperty
Description copied from interface:PropertySource
For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.- Specified by:
getProperty
in interfacePropertySource
- Parameters:
key
- The key to search for.- Returns:
- The value or null;
-
containsProperty
Description copied from interface:PropertySource
For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.- Specified by:
containsProperty
in interfacePropertySource
- Parameters:
key
- The key to search for.- Returns:
- The value or null;
-