Package org.jibx.binding.model
Class ValidationContext
java.lang.Object
org.jibx.binding.model.TreeContext
org.jibx.binding.model.ValidationContext
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Inner class for handling prevalidation.protected class
Inner class for handling validation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Number of errors reported.private int
Number of fatals reported.private ArrayList
List of problem items reported by validation.private int
Number of warnings reported. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add error item for current element.void
Add error item.void
Add fatal item for current element.void
Add fatal item.void
addProblem
(ValidationProblem problem) Add problem report.void
addWarning
(String msg) Add warning item for current element.void
addWarning
(String msg, Object obj) Add warning item.getClassInfo
(String name) Get class information.int
Get number of error problems reported.int
Get number of fatal problems reported.Get list of problems.int
Get number of warning problems reported.void
prevalidate
(BindingElement root) Prevalidate binding model tree.private ElementBase
Peek current element of hierarchy, if any.void
validate
(BindingElement root) Validate binding model tree.Methods inherited from class org.jibx.binding.model.TreeContext
addSkip, getBindingRoot, getChildContext, getContextObject, getCurrentDefinitions, getDefinitions, getFormatDefinitions, getNestingDepth, getParentContainer, getParentElement, getParentElement, getRequiredClassInfo, isInBinding, isLookupSupported, isOutBinding, isSkipped, peekElement, popNode, pushNode, setBindingRoot, setGlobalDefinitions, tourTree, tourTree
-
Field Details
-
m_warningCount
private int m_warningCountNumber of warnings reported. -
m_errorCount
private int m_errorCountNumber of errors reported. -
m_fatalCount
private int m_fatalCountNumber of fatals reported. -
m_problemList
List of problem items reported by validation.
-
-
Constructor Details
-
ValidationContext
Constructor.- Parameters:
iloc
- class locator
-
-
Method Details
-
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
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
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
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
Add warning item. Adds a warning item to the problem list, which is a possible problem that still allows reasonable operation.- Parameters:
msg
- problem descriptionobj
- source object for validation error
-
addError
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
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 descriptionobj
- source object for validation error
-
addFatal
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
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 descriptionobj
- source object for validation error (should be an element)
-
addProblem
Add problem report. The problem is added and counted as appropriate.- Parameters:
problem
- details of problem report
-
getProblems
Get list of problems.- Returns:
- problem list
-
getClassInfo
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 classTreeContext
- Parameters:
name
- fully-qualified name of class to be found- Returns:
- class information, or
null
if class not found
-