Class Message

  • All Implemented Interfaces:
    IMessage

    public class Message
    extends Message
    Part of the ReasoningResult class, expressing on error/warning of a complete ReasoningResult. Takes a series of lists, which shall be consistent in size. Complex textual representations are calculated on demand when requesting the respective information (rather than calculating this without need beforehand in a reasoner).
    Author:
    El-Sharkawy, Sizonenko
    • Field Detail

      • conflictingElements

        private java.util.List<ModelElement> conflictingElements
      • variablesInConstraints

        private java.util.List<java.util.Set<AbstractVariable>> variablesInConstraints
      • problemVariables

        private java.util.List<java.util.Set<IDecisionVariable>> problemVariables
      • problemConstraints

        private java.util.List<Constraint> problemConstraints
      • conflictingElementProjects

        private java.util.List<Project> conflictingElementProjects
      • errorClassification

        private java.util.List<java.lang.Integer> errorClassification
    • Constructor Detail

      • Message

        public Message​(java.lang.String explanation,
                       java.util.List<ModelElement> conflictingElements,
                       Status status)
        Sole constructor for multiple conflicting elements.
        Parameters:
        explanation - A textual representation of this message
        conflictingElements - A list of model elements which lead to the current message, or null
        status - The status of this message, e. g. Error or Warning
    • Method Detail

      • createList

        public static final java.util.List<ModelElement> createList​(ModelElement element)
        Creates a list with on element.
        Parameters:
        element - the element to put into the list
        Returns:
        the list with element as member if null != element, null else
      • getConflicts

        public java.util.List<ModelElement> getConflicts()
        Returns the list of conflicting items.
        Returns:
        The list of conflicting items
      • getConflictsCount

        public int getConflictsCount()
        Returns the number of conflicting elements.
        Returns:
        Number of conflicting elements.
      • min

        private static int min​(int v1,
                               int v2,
                               int v3)
        Returns the minimum of the three given integer values.
        Parameters:
        v1 - the first value
        v2 - the second value
        v3 - the third value
        Returns:
        the minimum of the three given integer values
      • min

        private static int min​(int v1,
                               int v2,
                               int v3,
                               int v4)
        Returns the minimum of the four given integer values.
        Parameters:
        v1 - the first value
        v2 - the second value
        v3 - the third value
        v4 - the fourth value
        Returns:
        the minimum of the four given integer values
      • getConflictLabels

        public java.util.List<java.lang.String> getConflictLabels()
        Returns the list of conflicting item labels.
        Returns:
        The list of conflicting item labels. The number of entries depends on the minimum number of conflicting element suggestions, conflicting elements, constraint variables and variables in constraints.
      • getConflictComments

        public java.util.List<java.lang.String> getConflictComments()
        Returns the list of conflicting item comments.
        Returns:
        The list of conflicting item comments. The number of entries depends on the minimum number of conflicting element suggestions, conflicting elements, and constraint variables.
      • toString

        private java.lang.String toString​(Constraint constraint,
                                          IDecisionVariable namedVariable)
        Turns a constraint into a string representation. If a named variable is given, use comment or name instead.
        Parameters:
        constraint - the constraint
        namedVariable - the related named variable (may be null)
        Returns:
        the string representation
      • noResult

        private static boolean noResult​(java.lang.String result)
      • traceToTop

        private java.lang.String traceToTop​(ModelElement element)
        Method for creating a msg of trace to the top element of constraint or variable that fail in the reasoning.
        Parameters:
        element - Constraint of Variable.
        Returns:
        text text of the trace.
      • addConflictingElementSuggestions

        public void addConflictingElementSuggestions​(java.util.List<Message.SuggestionType> conflictingElementSuggestions)
        Method for adding conflicting element Suggestions.
        Parameters:
        conflictingElementSuggestions - conflicting element Suggestions.
      • getConflictSuggestionTypes

        public java.util.List<Message.SuggestionType> getConflictSuggestionTypes()
        Returns the list of conflicting item suggestion types.
        Returns:
        The list of conflicting item suggestion types.
      • getConflictSuggestions

        public java.util.List<java.lang.String> getConflictSuggestions()
        Returns the list of conflicting item Suggestions.
        Returns:
        The list of conflicting item Suggestions. The number of entries depends on the minimum number of conflicting element suggestions and variables in constraints.
      • problemPointsToString

        private java.lang.String problemPointsToString​(java.util.Set<AbstractVariable> vars)
        Turns given variables into a problem points description.
        Parameters:
        vars - the variables
        Returns:
        the description
      • addConflictingElementProjects

        public void addConflictingElementProjects​(java.util.List<Project> conflictingElementProjects)
        Method for adding conflicting element Projects.
        Parameters:
        conflictingElementProjects - conflicting element Projects.
      • getConflictProjects

        public java.util.List<Project> getConflictProjects()
        Returns the list of conflicting item Projects.
        Returns:
        The list of conflicting item Projects.
      • addConstraintVariables

        public void addConstraintVariables​(java.util.List<java.util.Set<AbstractVariable>> variables)
        Method for adding a list of AbstractVariables that are involved in each failed constraint.
        Parameters:
        variables - List of variables.
      • getConstraintVariables

        public java.util.List<java.util.Set<AbstractVariable>> getConstraintVariables()
        Method for returning a list of AbstractVariables that are involved in each failed constraint.
        Returns:
        List of variables.
      • addProblemVariables

        public void addProblemVariables​(java.util.List<java.util.Set<IDecisionVariable>> variables)
        Method for adding a list of IDecisionVariables that are involved in each failed constraint.
        Parameters:
        variables - List of variables.
      • getProblemVariables

        public java.util.List<java.util.Set<IDecisionVariable>> getProblemVariables()
        Method for returning a list of IDecisionVariables that are involved in each failed constraint.
        Returns:
        List of variables.
      • addProblemConstraintParts

        public void addProblemConstraintParts​(java.util.List<ConstraintSyntaxTree> constraints)
        Method for adding a list of partial ConstraintSyntaxTrees that are involved in each failed constraint.
        Parameters:
        constraints - List of constraint trees (elements may be null). The entries in this list must correspond to addProblemConstraints(List).
      • addProblemConstraints

        public void addProblemConstraints​(java.util.List<Constraint> constraints)
        Method for adding a list of Constraints that are involved in each failed constraint. The entries in this list must correspond to addProblemConstraintParts(List).
        Parameters:
        constraints - List of constraints.
      • getProblemConstraints

        public java.util.List<Constraint> getProblemConstraints()
        Method for returning a list of full Constraints that are involved in each failed constraint. The result must correspond to getProblemConstraintParts().
        Returns:
        List of constraints.
      • addNamedConstraintVariables

        public void addNamedConstraintVariables​(java.util.List<IDecisionVariable> constraintVariables)
        Method for adding a list of ConstraintVariables of a failed constraint. Null if non.
        Parameters:
        constraintVariables - ConstraintVariable or null.
      • getNamedConstraintVariables

        public java.util.List<IDecisionVariable> getNamedConstraintVariables()
        Method for returning a list of ConstraintVariables of a failed constraint. Null if none.
        Returns:
        List of ConstraintVariable or null.
      • addErrorClassification

        public void addErrorClassification​(java.util.List<java.lang.Integer> errorClassification)
        Method for adding a list of reasoning error classifiers Null if non.
        Parameters:
        errorClassification - defined error codes or null.
      • getErrorClassification

        public java.util.List<java.lang.Integer> getErrorClassification()
        Method for returning a list of reasoning error classifiers. Null if none.
        Returns:
        List of error codes or null.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • append

        private java.lang.String append​(java.lang.String res,
                                        java.lang.String text)
        Appends text and a line end to res.
        Parameters:
        res - the text to append to
        text - the text to append
        Returns:
        the combined text