Package org.eclipse.core.expressions
Class EvaluationContext
- java.lang.Object
-
- org.eclipse.core.expressions.EvaluationContext
-
- All Implemented Interfaces:
IEvaluationContext
public class EvaluationContext extends java.lang.Object implements IEvaluationContext
A default implementation of an evaluation context.Clients may instantiate this default context. The class is not intended to be subclassed by clients.
- Since:
- 3.0
- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Field Summary
-
Fields inherited from interface org.eclipse.core.expressions.IEvaluationContext
UNDEFINED_VARIABLE
-
-
Constructor Summary
Constructors Constructor Description EvaluationContext(IEvaluationContext parent, java.lang.Object defaultVariable)Create a new evaluation context with the given parent and default variable.EvaluationContext(IEvaluationContext parent, java.lang.Object defaultVariable, IVariableResolver[] resolvers)Create a new evaluation context with the given parent and default variable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddVariable(java.lang.String name, java.lang.Object value)Adds a new named variable to this context.booleangetAllowPluginActivation()Returns whether this evaluation context supports plug-in activation.java.lang.ObjectgetDefaultVariable()Returns the default variable.IEvaluationContextgetParent()Returns the parent context ornullif this is the root of the evaluation context hierarchy.IEvaluationContextgetRoot()Returns the root evaluation context.java.lang.ObjectgetVariable(java.lang.String name)Returns the variable managed under the given name.java.lang.ObjectremoveVariable(java.lang.String name)Removes the variable managed under the given name from this evaluation context.java.lang.ObjectresolveVariable(java.lang.String name, java.lang.Object[] args)Resolves a variable for the given name and arguments.voidsetAllowPluginActivation(boolean value)Specifies whether this evaluation context allows activation of plug-ins for testers used in the expression tree.
-
-
-
Constructor Detail
-
EvaluationContext
public EvaluationContext(IEvaluationContext parent, java.lang.Object defaultVariable)
Create a new evaluation context with the given parent and default variable.- Parameters:
parent- the parent context. Can benull.defaultVariable- the default variable
-
EvaluationContext
public EvaluationContext(IEvaluationContext parent, java.lang.Object defaultVariable, IVariableResolver[] resolvers)
Create a new evaluation context with the given parent and default variable.- Parameters:
parent- the parent context. Can benull.defaultVariable- the default variableresolvers- an array ofIVariableResolversto resolve additional variables.- See Also:
resolveVariable(String, Object[])
-
-
Method Detail
-
getParent
public IEvaluationContext getParent()
Description copied from interface:IEvaluationContextReturns the parent context ornullif this is the root of the evaluation context hierarchy.- Specified by:
getParentin interfaceIEvaluationContext- Returns:
- the parent evaluation context or
null
-
getRoot
public IEvaluationContext getRoot()
Description copied from interface:IEvaluationContextReturns the root evaluation context.- Specified by:
getRootin interfaceIEvaluationContext- Returns:
- the root evaluation context
-
getDefaultVariable
public java.lang.Object getDefaultVariable()
Description copied from interface:IEvaluationContextReturns the default variable.- Specified by:
getDefaultVariablein interfaceIEvaluationContext- Returns:
- the default variable or
nullif no default variable is managed.
-
setAllowPluginActivation
public void setAllowPluginActivation(boolean value)
Description copied from interface:IEvaluationContextSpecifies whether this evaluation context allows activation of plug-ins for testers used in the expression tree. To actual trigger the plug-in loading this flag has to be set totrueand the actual test expression must have the attributeforcePluginActivationset totrueas well.- Specified by:
setAllowPluginActivationin interfaceIEvaluationContext- Parameters:
value- whether this evaluation context allows plug-in activation
-
getAllowPluginActivation
public boolean getAllowPluginActivation()
Description copied from interface:IEvaluationContextReturns whether this evaluation context supports plug-in activation. If not set viaIEvaluationContext.setAllowPluginActivation(boolean)the parent value is returned. If no parent is setfalseis returned.- Specified by:
getAllowPluginActivationin interfaceIEvaluationContext- Returns:
- whether plug-in activation is supported or not
-
addVariable
public void addVariable(java.lang.String name, java.lang.Object value)Description copied from interface:IEvaluationContextAdds a new named variable to this context. If a variable with the name already exists the new one overrides the existing one.- Specified by:
addVariablein interfaceIEvaluationContext- Parameters:
name- the variable's namevalue- the variable's value
-
removeVariable
public java.lang.Object removeVariable(java.lang.String name)
Description copied from interface:IEvaluationContextRemoves the variable managed under the given name from this evaluation context.- Specified by:
removeVariablein interfaceIEvaluationContext- Parameters:
name- the variable's name- Returns:
- the currently stored value or
nullif the variable doesn't exist
-
getVariable
public java.lang.Object getVariable(java.lang.String name)
Description copied from interface:IEvaluationContextReturns the variable managed under the given name.- Specified by:
getVariablein interfaceIEvaluationContext- Parameters:
name- the variable's name- Returns:
- the variable's value or
nullif the content doesn't manage a variable with the given name
-
resolveVariable
public java.lang.Object resolveVariable(java.lang.String name, java.lang.Object[] args) throws CoreExceptionDescription copied from interface:IEvaluationContextResolves a variable for the given name and arguments. This method can be used to dynamically resolve variable such as plug-in descriptors, resources, etc. The method is used by theresolveexpression.- Specified by:
resolveVariablein interfaceIEvaluationContext- Parameters:
name- the variable to resolveargs- an object array of arguments used to resolve the variable- Returns:
- the variable's value or
nullif no variable can be resolved for the given name and arguments - Throws:
CoreException- if an errors occurs while resolving the variable
-
-