Package org.jibx.binding.model
Class ValidationContext
- java.lang.Object
-
- org.jibx.binding.model.TreeContext
-
- org.jibx.binding.model.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classValidationContext.PrevalidationVisitorInner class for handling prevalidation.protected classValidationContext.ValidationVisitorInner class for handling validation.
-
Constructor Summary
Constructors Constructor Description ValidationContext(IClassLocator iloc)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddError(String msg)Add error item for current element.voidaddError(String msg, Object obj)Add error item.voidaddFatal(String msg)Add fatal item for current element.voidaddFatal(String msg, Object obj)Add fatal item.voidaddProblem(ValidationProblem problem)Add problem report.voidaddWarning(String msg)Add warning item for current element.voidaddWarning(String msg, Object obj)Add warning item.IClassgetClassInfo(String name)Get class information.intgetErrorCount()Get number of error problems reported.intgetFatalCount()Get number of fatal problems reported.ArrayListgetProblems()Get list of problems.intgetWarningCount()Get number of warning problems reported.voidprevalidate(BindingElement root)Prevalidate binding model tree.voidvalidate(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
-
-
-
-
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 descriptionobj- 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 descriptionobj- 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 descriptionobj- 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:
getClassInfoin classTreeContext- Parameters:
name- fully-qualified name of class to be found- Returns:
- class information, or
nullif class not found
-
-