Class BuildContext


  • public class BuildContext
    extends java.lang.Object
    The build context captures knowledge about conditions, variables, etc. during constraint parsing or building.
    • 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)).
      • 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.
      • 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.