Class ValidationContext


  • public class ValidationContext
    extends TreeContext
    Tracks the validation state. This includes the current validation phase, as well as order-dependent state information collected while walking the tree structure of a binding model. Collects all errors and warnings and maintains a summary of the severity of the problems found.
    Version:
    1.0
    Author:
    Dennis M. Sosnoski
    • Constructor Detail

      • ValidationContext

        public ValidationContext​(IClassLocator iloc)
        Constructor.
        Parameters:
        iloc - class locator
    • Method Detail

      • prevalidate

        public void prevalidate​(BindingElement root)
        Prevalidate binding model tree. This calls the prevalidate method for each element in the tree, in preorder traversal order.
        Parameters:
        root - binding node of tree to be prevalidated
      • validate

        public void validate​(BindingElement root)
        Validate binding model tree. This calls the validate method for each element in the tree, in postorder traversal order.
        Parameters:
        root - binding node of tree to be prevalidated
      • getWarningCount

        public int getWarningCount()
        Get number of warning problems reported.
        Returns:
        warning problem count
      • getErrorCount

        public int getErrorCount()
        Get number of error problems reported.
        Returns:
        error problem count
      • getFatalCount

        public int getFatalCount()
        Get number of fatal problems reported.
        Returns:
        fatal problem count
      • addWarning

        public void addWarning​(String msg)
        Add warning item for current element. Adds a warning item to the problem list, which is a possible problem that still allows reasonable operation. This form of the call can only be used during a tree tour being controlled by this context.
        Parameters:
        msg - problem description
      • addWarning

        public void addWarning​(String msg,
                               Object obj)
        Add warning item. Adds a warning item to the problem list, which is a possible problem that still allows reasonable operation.
        Parameters:
        msg - problem description
        obj - source object for validation error
      • addError

        public void addError​(String msg)
        Add error item for current element. Adds an error item to the problem list, which is a definite problem that still allows validation to proceed. This form of the call can only be used during a tree tour being controlled by this context.
        Parameters:
        msg - problem description
      • addError

        public void addError​(String msg,
                             Object obj)
        Add error item. Adds an error item to the problem list, which is a definite problem that still allows validation to proceed.
        Parameters:
        msg - problem description
        obj - source object for validation error
      • addFatal

        public void addFatal​(String msg)
        Add fatal item for current element. Adds a fatal item to the problem list, which is a severe problem that blocks further validation within the tree branch involved. This form of the call can only be used during a tree tour being controlled by this context.
        Parameters:
        msg - problem description
      • addFatal

        public void addFatal​(String msg,
                             Object obj)
        Add fatal item. Adds a fatal item to the problem list, which is a severe problem that blocks further validation within the tree branch involved. The object associated with a fatal error should always be an element.
        Parameters:
        msg - problem description
        obj - source object for validation error (should be an element)
      • addProblem

        public void addProblem​(ValidationProblem problem)
        Add problem report. The problem is added and counted as appropriate.
        Parameters:
        problem - details of problem report
      • getProblems

        public ArrayList getProblems()
        Get list of problems.
        Returns:
        problem list
      • getClassInfo

        public IClass getClassInfo​(String name)
        Get class information. Finds a class by name using the class locator configured by the environment code. This overrides the base class implementation in order to report failures that result in exceptions.
        Overrides:
        getClassInfo in class TreeContext
        Parameters:
        name - fully-qualified name of class to be found
        Returns:
        class information, or null if class not found