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
    • Field Detail

      • m_warningCount

        private int m_warningCount
        Number of warnings reported.
      • m_errorCount

        private int m_errorCount
        Number of errors reported.
      • m_fatalCount

        private int m_fatalCount
        Number of fatals reported.
      • m_problemList

        private java.util.ArrayList m_problemList
        List of problem items reported by validation.
    • Constructor Detail

      • ValidationContext

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

      • safePeekElement

        private ElementBase safePeekElement()
        Peek current element of hierarchy, if any. This variation should be used for the actual error handling, in case an error occurs during the initialization of the outer context definitions (canned definitions).
        Returns:
        current element, or null if none
      • 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​(java.lang.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​(java.lang.String msg,
                               java.lang.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​(java.lang.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​(java.lang.String msg,
                             java.lang.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​(java.lang.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​(java.lang.String msg,
                             java.lang.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 java.util.ArrayList getProblems()
        Get list of problems.
        Returns:
        problem list
      • getClassInfo

        public IClass getClassInfo​(java.lang.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