Top Description Inners Methods
org.apache.logging.log4j.util

public Interface PropertySource

Known Direct Implementers
org.apache.logging.log4j.util.SystemPropertiesPropertySource, org.apache.logging.log4j.util.EnvironmentPropertySource, org.apache.logging.log4j.util.PropertiesPropertySource
Static Imports
org.apache.logging.log4j.util.Strings.toRootLowerCase

A source for global configuration properties.
Since
2.10.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
PropertySource.Comparator

Comparator for ordering PropertySource instances by priority.

public static class
PropertySource.Util

Utility methods useful for PropertySource implementations.

Method Summary

Modifier and TypeMethod and Description
public default boolean

Returns:

The value or null;
containsProperty
(String
The key to search for.
key
)

For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.

public default void
forEach(BiConsumer<String, String>
action to perform on each key/value pair
action
)

Iterates over all properties and performs an action for each key/value pair.

public default CharSequence

Returns:

a normalized property name using the given tokens
getNormalForm
(Iterable<? extends CharSequence>
list of property name tokens
tokens
)

Converts a list of property name tokens into a normal form.

public int

Returns:

priority value
getPriority
()

Returns the order in which this PropertySource has priority.

public default String

Returns:

The value or null;
getProperty
(String
The key to search for.
key
)

For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.

public default Collection<String>

Returns:

list of property names
getPropertyNames
()

Returns the list of all property names.

Method Detail

containsPropertyback to summary
public default boolean containsProperty(String key)

For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.

Parameters
key:String

The key to search for.

Returns:boolean

The value or null;

Since
2.13.0
forEachback to summary
public default void forEach(BiConsumer<String, String> action)

Iterates over all properties and performs an action for each key/value pair.

Parameters
action:BiConsumer<String, String>

action to perform on each key/value pair

getNormalFormback to summary
public default CharSequence getNormalForm(Iterable<? extends CharSequence> tokens)

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".

Parameters
tokens:Iterable<? extends CharSequence>

list of property name tokens

Returns:CharSequence

a normalized property name using the given tokens

getPriorityback to summary
public int getPriority()

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.

Returns:int

priority value

getPropertyback to summary
public default String getProperty(String key)

For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.

Parameters
key:String

The key to search for.

Returns:String

The value or null;

Since
2.13.0
getPropertyNamesback to summary
public default Collection<String> getPropertyNames()

Returns the list of all property names.

Returns:Collection<String>

list of property names

org.apache.logging.log4j.util back to summary

public Class PropertySource.Comparator

extends Object
implements Comparator<PropertySource>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.util.Comparator

Comparator for ordering PropertySource instances by priority.
Since
2.10.0

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
compare(final PropertySource
the first object to be compared.
o1
,
final PropertySource
the second object to be compared.
o2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

Comparatorback to summary
public Comparator()

Method Detail

compareback to summary
public int compare(final PropertySource o1, final PropertySource o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
o1:PropertySource

the first object to be compared.

o2:PropertySource

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override
org.apache.logging.log4j.util back to summary

public final Class PropertySource.Util

extends Object
Class Inheritance

Utility methods useful for PropertySource implementations.
Since
2.10.0

Field Summary

Modifier and TypeField and Description
private static final Map<CharSequence, List<CharSequence>>
private static final Pattern
private static final Pattern

Constructor Summary

AccessConstructor and Description
private
Util()

Method Summary

Modifier and TypeMethod and Description
public static CharSequence

Returns:

tokensAsCamelCase
joinAsCamelCase
(final Iterable<? extends CharSequence>
tokens to convert
tokens
)

Joins a list of strings using camelCaseConventions.

public static List<CharSequence>

Returns:

the property broken into lower case tokens
tokenize
(final CharSequence
property name
value
)

Converts a property name string into a list of tokens.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CACHEback to summary
private static final Map<CharSequence, List<CharSequence>> CACHE
PREFIX_PATTERNback to summary
private static final Pattern PREFIX_PATTERN
PROPERTY_TOKENIZERback to summary
private static final Pattern PROPERTY_TOKENIZER

Constructor Detail

Utilback to summary
private Util()

Method Detail

joinAsCamelCaseback to summary
public static CharSequence joinAsCamelCase(final Iterable<? extends CharSequence> tokens)

Joins a list of strings using camelCaseConventions.

Parameters
tokens:Iterable<? extends CharSequence>

tokens to convert

Returns:CharSequence

tokensAsCamelCase

tokenizeback to summary
public static List<CharSequence> tokenize(final CharSequence value)

Converts a property name string into a list of tokens. This will strip a prefix of log4j, log4j2, Log4j, or org.apache.logging.log4j, along with separators of dash -, dot ., underscore _, and slash /. Tokens can also be separated by camel case conventions without needing a separator character in between.

Parameters
value:CharSequence

property name

Returns:List<CharSequence>

the property broken into lower case tokens

Annotations
@SuppressWarnings:CollectionUndefinedEquality