Class RuleExecutionContext


  • public class RuleExecutionContext
    extends java.lang.Object
    Implements an execution context for a rule.
    Author:
    Holger Eichelberger
    • Field Detail

      • rule

        private Rule rule
      • result

        private java.util.Set<IArtifact> result
      • allResults

        private java.util.Set<IArtifact> allResults
      • rhsValues

        private java.lang.Object[] rhsValues
      • failReason

        private java.lang.String failReason
      • failCode

        private java.lang.Integer failCode
    • Constructor Detail

      • RuleExecutionContext

        public RuleExecutionContext​(Rule rule,
                                    RuntimeEnvironment environment)
        Creates a rule execution context.
        Parameters:
        rule - the rule being executed
        environment - the runtime environment holding the OTHERPROJECTS variable
    • Method Detail

      • getRule

        public Rule getRule()
        Returns the rule being executed.
        Returns:
        the rule
      • add

        void add​(java.lang.Object value)
        Adds an evaluation result to the immediate results.
        Parameters:
        value - the value to be added
      • add

        void add​(IArtifact artifact)
        Adds a result artifact.
        Parameters:
        artifact - the artifact to be added
      • add

        void add​(RuleExecutionResult executionResult)
        Adds another rule execution result to the results of previous rule executions.
        Parameters:
        executionResult - the result to be added
      • addAllResults

        void addAllResults()
        Aggregates results of the actual execution into all results.
      • allResultsAsCollection

        java.util.Collection<IArtifact> allResultsAsCollection()
        Returns all results collected so far as a Java collection.
        Returns:
        all results
      • resultAsCollection

        java.util.Collection<IArtifact> resultAsCollection()
        Returns the results of the execution of getRule() as a Java collection.
        Returns:
        the immediate results
      • setStatus

        public void setStatus​(RuleExecutionResult.Status status)
        Defines the actual execution status.
        Parameters:
        status - the new execution status
      • setStatus

        public void setStatus​(java.lang.Object object)
        Defines the actual execution status. [convenience]
        Parameters:
        object - the new execution status or execution result
        See Also:
        RuleExecutionResult.Status.toStatus(Object)
      • getStatus

        public RuleExecutionResult.Status getStatus()
        Returns the actual execution status.
        Returns:
        the actual execution status (null if not set)
      • getRhsValues

        public java.lang.Object[] getRhsValues()
        Returns the actual evaluation results of the RHS expressions.
        Returns:
        the actual values (null if not set)
      • setRhsValues

        void setRhsValues​(java.lang.Object[] rhsValues)
        Defines the actual evaluation results of the RHS expressions.
        Parameters:
        rhsValues - the actual values (null if not set)
      • setFailReason

        public void setFailReason​(java.lang.String failReason)
        Sets an optional reason for execution failure.
        Parameters:
        failReason - the reason for failing (may be null for none)
      • getFailReason

        public java.lang.String getFailReason()
        Returns the fail reason (if the execution failed).
        Returns:
        the reason or null if unknown, not set or not failing
      • setFailCode

        public void setFailCode​(java.lang.Integer failCode)
        Defines an optional failure code.
        Parameters:
        failCode - the failure code
      • getFailCode

        public java.lang.Integer getFailCode()
        The failure code.
        Returns:
        the failure code (may be null if not set)