Package org.jibx.v2

Class ValidationContext

java.lang.Object
org.jibx.v2.ValidationContext
All Implemented Interfaces:
ISkipElements
Direct Known Subclasses:
SchemaValidationContext

public class ValidationContext extends Object implements ISkipElements
Tracks the schema validation state. This includes order-dependent state information collected while walking the tree structure of a schema model. Collects all errors and warnings and maintains a summary of the severity of the problems found. For ease of use, this also wraps the schema name register with convenience methods for validation.
Author:
Dennis M. Sosnoski
  • Field Details

    • 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 ArrayList m_problemList
      List of problem items reported by validation.
    • m_skipSet

      private Set m_skipSet
      Set of elements to be skipped in walking tree.
    • m_continueOnError

      private boolean m_continueOnError
      Flag for errors to be ignored.
  • Constructor Details

    • ValidationContext

      public ValidationContext()
      Constructor.
  • Method Details

    • 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, Object obj) throws JiBXException
      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
      Throws:
      JiBXException - on unrecoverable error
    • addError

      public boolean addError(String msg, Object obj) throws JiBXException
      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
      Returns:
      true if to continue validation, false if not
      Throws:
      JiBXException - on unrecoverable error
    • addFatal

      public void addFatal(String msg, Object obj) throws JiBXException
      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)
      Throws:
      JiBXException - on unrecoverable error
    • addProblem

      public void addProblem(ValidationProblem problem) throws JiBXException
      Add problem report. The problem is added and counted as appropriate.
      Parameters:
      problem - details of problem report
      Throws:
      JiBXException - on unrecoverable error
    • getProblems

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

      protected void addSkip(Object skip)
      Add element to set to be skipped.
      Parameters:
      skip -
    • isSkipped

      public boolean isSkipped(Object obj)
      Description copied from interface: ISkipElements
      Check if a component is being skipped due to a fatal error.
      Specified by:
      isSkipped in interface ISkipElements
      Parameters:
      obj - component to be checked
      Returns:
      flag for component being skipped
    • handleMissingElement

      public void handleMissingElement() throws JiBXException
      Throws:
      JiBXException