Class BuildContext
- java.lang.Object
-
- jadex.rules.parser.conditions.javagrammar.BuildContext
-
public class BuildContext extends java.lang.Object
The build context captures knowledge about conditions, variables, etc. during constraint parsing or building.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map
bcons
The object conditions (variable -> object conditions (object condition with defining bound constraint)).protected java.util.Map
boundconstraints
The bound constraints (variable -> boundconstraint (only variable definitions, i.e.protected ObjectCondition
dummy
The dummy condition (if any).protected java.util.List
lcons
The list of conditions.protected java.util.List
oconstack
Stack for object conditions (for checking if constraints can be generated in current context).protected BuildContext
parent
The parent build context (if any).protected OAVTypeModel
tmodel
The OAV type model.protected java.util.Map
variables
The variables (name -> variable).
-
Constructor Summary
Constructors Constructor Description BuildContext(BuildContext parent)
Create a new build context.BuildContext(ICondition condition, OAVTypeModel tmodel)
Create a new build context.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCondition(ICondition condition)
Add a condition to the context.void
addVariable(Variable var)
Add a variable.ObjectCondition
createObjectCondition(OAVObjectType type, IConstraint[] constraints)
Create a new object condition with the given constraints.Variable
generateVariableBinding(ConstrainableCondition condition, java.lang.Object valuesource)
Create a new variable and bind it using the given object condition and value source.Variable
generateVariableBinding(ConstrainableCondition condition, java.lang.String name, OAVObjectType type, java.lang.Object valuesource)
Create a new variable and bind it using the given object condition and value source.Variable
generateVariableBinding(ConstrainableCondition condition, java.lang.String name, java.lang.Object valuesource)
Create a new variable and bind it using the given object condition and value source.java.lang.String
generateVariableName()
Generate a variable name.BoundConstraint
getBoundConstraint(Variable var)
Get the bound constraint a variable, i.e.java.util.Set
getBoundVariables()
Get the variables, which are available in this build context.java.util.List
getConditions()
Get the conditions.ConstrainableCondition
getConstrainableCondition(Variable var)
Get an object condition for a variable, i.e.ConstrainableCondition
getConstrainableCondition0(Variable var)
Get an object condition for a variable, i.e.ConstrainableCondition
getCurrentCondition()
Get the current condition from the stack.protected BuildContext
getDefiningScope(ICondition con)
Get the context in which the given condition is defined.ObjectCondition
getDummyCondition()
Expressions, which are unrelated to real object conditions should be bound to the dummy condition.BuildContext
getParent()
Return the parent build context (if any).protected static OAVObjectType
getReturnType(ConstrainableCondition cond, java.lang.Object valuesource, OAVTypeModel tmodel)
Get the return type of a value source.OAVTypeModel
getTypeModel()
Get the OAV type model.Variable
getVariable(java.lang.String name)
Get a variable.boolean
hasDummyCondition()
Test if a dummy condition was used in the context.void
popCondition()
Pop a condition from the stack.void
pushCondition(ConstrainableCondition con)
Push a condition on the stack.
-
-
-
Field Detail
-
lcons
protected java.util.List lcons
The list of conditions.
-
variables
protected java.util.Map variables
The variables (name -> variable).
-
boundconstraints
protected java.util.Map boundconstraints
The bound constraints (variable -> boundconstraint (only variable definitions, i.e. EQUAL constraints)).
-
bcons
protected java.util.Map bcons
The object conditions (variable -> object conditions (object condition with defining bound constraint)).
-
tmodel
protected OAVTypeModel tmodel
The OAV type model.
-
dummy
protected ObjectCondition dummy
The dummy condition (if any).
-
parent
protected BuildContext parent
The parent build context (if any).
-
oconstack
protected java.util.List oconstack
Stack for object conditions (for checking if constraints can be generated in current context).
-
-
Constructor Detail
-
BuildContext
public BuildContext(ICondition condition, OAVTypeModel tmodel)
Create a new build context.- Parameters:
condition
- The initial condition.
-
BuildContext
public BuildContext(BuildContext parent)
Create a new build context.- Parameters:
parent
- The parent build context.
-
-
Method Detail
-
getConditions
public java.util.List getConditions()
Get the conditions.
-
getTypeModel
public OAVTypeModel getTypeModel()
Get the OAV type model.
-
getConstrainableCondition
public ConstrainableCondition getConstrainableCondition(Variable var)
Get an object condition for a variable, i.e. a condition, where constraints related to the variable can be added to.- Parameters:
var
- The variable- Returns:
- The object condition.
- Throws:
RuntimeExcpetion
- when no condition was found.
-
getConstrainableCondition0
public ConstrainableCondition getConstrainableCondition0(Variable var)
Get an object condition for a variable, i.e. a condition, where constraints related to the variable can be added to.- Parameters:
var
- The variable- Returns:
- The object condition.
- Throws:
RuntimeExcpetion
- when no condition was found.
-
getBoundConstraint
public BoundConstraint getBoundConstraint(Variable var)
Get the bound constraint a variable, i.e. the value source required for obtaining the variable value from the variables object condition.- Parameters:
var
- The variable- Returns:
- The bound constraint.
- Throws:
RuntimeExcpetion
- when no constraint was found.
-
generateVariableBinding
public Variable generateVariableBinding(ConstrainableCondition condition, java.lang.Object valuesource)
Create a new variable and bind it using the given object condition and value source.- Parameters:
condition
- The object condition.valuesource
- The value source.- Returns:
- The new variable.
-
generateVariableName
public java.lang.String generateVariableName()
Generate a variable name.- Returns:
- An unused variable name.
-
generateVariableBinding
public Variable generateVariableBinding(ConstrainableCondition condition, java.lang.String name, java.lang.Object valuesource)
Create a new variable and bind it using the given object condition and value source.- Parameters:
condition
- The object condition.name
- The variable name.valuesource
- The value source.- Returns:
- The new variable.
-
generateVariableBinding
public Variable generateVariableBinding(ConstrainableCondition condition, java.lang.String name, OAVObjectType type, java.lang.Object valuesource)
Create a new variable and bind it using the given object condition and value source.- Parameters:
condition
- The object condition.name
- The variable name.valuesource
- The value source.- Returns:
- The new variable.
-
createObjectCondition
public ObjectCondition createObjectCondition(OAVObjectType type, IConstraint[] constraints)
Create a new object condition with the given constraints. Also adds mappings corresponding to bound constraints (if any).- Parameters:
type
- The object type.constraints
- The constraints (if any).
-
getVariable
public Variable getVariable(java.lang.String name)
Get a variable.- Parameters:
name
- The name of the variable.- Returns:
- The variable, if any.
-
addVariable
public void addVariable(Variable var)
Add a variable.- Parameters:
var
- The variable.
-
getDummyCondition
public ObjectCondition getDummyCondition()
Expressions, which are unrelated to real object conditions should be bound to the dummy condition. After building all constraints, the dummy condition will be removed by reassigning its constraints to a suitable object condition (respecting variable assignment order).
-
hasDummyCondition
public boolean hasDummyCondition()
Test if a dummy condition was used in the context.
-
addCondition
public void addCondition(ICondition condition)
Add a condition to the context.- Parameters:
condition
- The condition.
-
getReturnType
protected static OAVObjectType getReturnType(ConstrainableCondition cond, java.lang.Object valuesource, OAVTypeModel tmodel)
Get the return type of a value source.- Parameters:
valuesource
- The value source.tmodel
- The type model.- Returns:
- The object type.
-
getParent
public BuildContext getParent()
Return the parent build context (if any).
-
getBoundVariables
public java.util.Set getBoundVariables()
Get the variables, which are available in this build context.
-
pushCondition
public void pushCondition(ConstrainableCondition con)
Push a condition on the stack.
-
popCondition
public void popCondition()
Pop a condition from the stack.
-
getCurrentCondition
public ConstrainableCondition getCurrentCondition()
Get the current condition from the stack.
-
getDefiningScope
protected BuildContext getDefiningScope(ICondition con)
Get the context in which the given condition is defined.
-
-