Package org.vedantatree.expressionoasis
Class ExpressionContext
- java.lang.Object
-
- org.vedantatree.expressionoasis.ExpressionContext
-
- Direct Known Subclasses:
CustomExpressionContext
public class ExpressionContext extends Object
Object of this class carry the contextual information for expressions during expression evaluation process. Like it can have information for variable providers, function providers and other properties. This is a thread safe object, hence can be used with multiple expression evaluation process at the same time in multiple threads. Care needs to be taken for the properties if threads are changing them at the same time. It may results in unexpected result.
-
-
Constructor Summary
Constructors Constructor Description ExpressionContext()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFunctionProvider(FunctionProvider functionProvider)
Adds function provider to the expression context.void
addVariableProvider(VariableProvider variableProvider)
Adds variable provider to the expression context.void
addVariableProvider(VariableProvider variableProvider, String providerName)
void
clearVariableProviders()
Object
getContextProperty(String propertyName)
Returns the value for a property.Collection<FunctionProvider>
getFunctionProviders()
Gets the collection of function providers.VariableProvider
getVariableProvider(String providerName)
Collection<VariableProvider>
getVariableProviders()
Gets the collection of variable providers.void
reset()
Resets the expression context.void
setContextProperty(String propertyName, Object propertyValue)
Sets the value for any context property.
-
-
-
Constructor Detail
-
ExpressionContext
public ExpressionContext() throws ExpressionEngineException
Constructor- Throws:
ExpressionEngineException
-
-
Method Detail
-
addVariableProvider
public void addVariableProvider(VariableProvider variableProvider, String providerName)
-
addVariableProvider
public void addVariableProvider(VariableProvider variableProvider)
Adds variable provider to the expression context.- Parameters:
variableProvider
- the variable provider to add
-
addFunctionProvider
public void addFunctionProvider(FunctionProvider functionProvider) throws ExpressionEngineException
Adds function provider to the expression context.- Parameters:
functionProvider
- the function provider to add- Throws:
ExpressionEngineException
-
getFunctionProviders
public Collection<FunctionProvider> getFunctionProviders()
Gets the collection of function providers. It is an unmodifiable list.- Returns:
- Returns the functionProviders.
-
getVariableProviders
public Collection<VariableProvider> getVariableProviders()
Gets the collection of variable providers. It is an unmodifiable list.- Returns:
- Returns the variableProviders
-
getVariableProvider
public VariableProvider getVariableProvider(String providerName)
-
setContextProperty
public void setContextProperty(String propertyName, Object propertyValue)
Sets the value for any context property.- Parameters:
propertyName
- the name of propertypropertyValue
- the value of property
-
getContextProperty
public Object getContextProperty(String propertyName)
Returns the value for a property.- Parameters:
propertyName
- the name of property- Returns:
- the value corresponding to the property.
null
if no property exists in expression context
-
clearVariableProviders
public void clearVariableProviders()
-
reset
public void reset()
Resets the expression context. Cleans all the states of this expression context for further reuse.
-
-