- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.boolex.PropertyConditionBase
-
- All Implemented Interfaces:
PropertyCondition,Condition,ContextAware,LifeCycle
- Direct Known Subclasses:
ExpressionPropertyCondition,IsPropertyDefinedCondition,IsPropertyNullCondition,PropertyEqualityCondition
public abstract class PropertyConditionBase extends ContextAwareBase implements PropertyCondition
Abstract base class provides some scaffolding. It is intended to ease migration from legacy conditional processing in configuration files (e.g. <if>, <then>, <else>) using the Janino library. Nevertheless, it should also be useful in newly written code.
Properties are looked up in the following order:
- In the local property container, usually the
ModelInterpretationContext - in the logger context
- system properties
- environment variables
- Since:
- 1.5.20
- Author:
- Ceki Gülcü
- See Also:
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)
-
-
Field Summary
-
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
-
Constructor Summary
Constructors Constructor Description PropertyConditionBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PropertyContainergetLocalPropertyContainer()Returns the local property container used by this evaluator.booleanisDefined(String k)Checks if the property with the given key is defined (not null).booleanisNull(String k)Checks if the property with the given key is null.booleanisStarted()Checks if this evaluator has been started.Stringp(String k)Retrieves the property value for the given key, returning an empty string if null.Stringproperty(String k)Retrieves the property value for the given key, returning an empty string if null.booleanpropertyContains(String k, String inclusion)Determine whether the resolved property value contains the given substring.booleanpropertyEquals(String propertyKey, String value)Compare the resolved property value with the provided expected value.voidsetLocalPropertyContainer(PropertyContainer aLocalPropertyContainer)Sets the local property container for this evaluator.voidstart()Starts this evaluator.voidstop()Stops this evaluator.-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
-
-
-
Constructor Detail
-
PropertyConditionBase
public PropertyConditionBase()
-
-
Method Detail
-
getLocalPropertyContainer
public PropertyContainer getLocalPropertyContainer()
Returns the local property container used by this evaluator.Local properties correspond to the properties in the embedding configurator, i.e. usually the
ModelInterpretationContextinstance.- Specified by:
getLocalPropertyContainerin interfacePropertyCondition- Returns:
- the local property container
-
setLocalPropertyContainer
public void setLocalPropertyContainer(PropertyContainer aLocalPropertyContainer)
Sets the local property container for this evaluator.Local properties correspond to the properties in the embedding configurator, i.e. usually the
ModelInterpretationContextinstance.- Specified by:
setLocalPropertyContainerin interfacePropertyCondition- Parameters:
aLocalPropertyContainer- the local property container to set
-
isNull
public boolean isNull(String k)
Checks if the property with the given key is null.The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.- Parameters:
k- the property key- Returns:
- true if the property is null, false otherwise
-
isDefined
public boolean isDefined(String k)
Checks if the property with the given key is defined (not null).The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.- Parameters:
k- the property key- Returns:
- true if the property is defined, false otherwise
-
p
public String p(String k)
Retrieves the property value for the given key, returning an empty string if null. This is a shorthand forproperty(String).- Parameters:
k- the property key- Returns:
- the property value or an empty string
-
property
public String property(String k)
Retrieves the property value for the given key, returning an empty string if null.The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.- Parameters:
k- the property key- Returns:
- the property value or an empty string
-
propertyEquals
public boolean propertyEquals(String propertyKey, String value)
Compare the resolved property value with the provided expected value.The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.Returns
trueif the resolved property value is equal tovalaccording toString.equals(Object). If the resolved property value orvalis null, then false is returned.- Parameters:
propertyKey- the property key to look upvalue- expected string value to compare against; must be non-null- Returns:
trueif the resolved property equalsvalue,falseotherwise or if either the resolved property orvalueis null.- Since:
- 1.5.24
-
propertyContains
public boolean propertyContains(String k, String inclusion)
Determine whether the resolved property value contains the given substring.The property is looked up via the
OptionHelper.propertyLookup(String, PropertyContainer, PropertyContainer)method. See above for the lookup order.This method returns
trueif the resolved property value'sString.contains(CharSequence)returnstruefor the suppliedinclusion. False is returned if either the resolved property value orinclusionparameter is null.- Parameters:
k- the property key to look upinclusion- substring to search for in the resolved property value; must be non-null- Returns:
trueif the property value containsinclusion, false otherwise or if either the resolved property value orinclusionis null- Since:
- 1.5.24
-
isStarted
public boolean isStarted()
Checks if this evaluator has been started.
-
-