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 java.lang.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 Summary
Fields Modifier and Type Field Description private booleanm_continueOnErrorFlag for errors to be ignored.private intm_errorCountNumber of errors reported.private intm_fatalCountNumber of fatals reported.private java.util.ArrayListm_problemListList of problem items reported by validation.private java.util.Setm_skipSetSet of elements to be skipped in walking tree.private intm_warningCountNumber of warnings reported.
-
Constructor Summary
Constructors Constructor Description ValidationContext()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddError(java.lang.String msg, java.lang.Object obj)Add error item.voidaddFatal(java.lang.String msg, java.lang.Object obj)Add fatal item.voidaddProblem(ValidationProblem problem)Add problem report.protected voidaddSkip(java.lang.Object skip)Add element to set to be skipped.voidaddWarning(java.lang.String msg, java.lang.Object obj)Add warning item.intgetErrorCount()Get number of error problems reported.intgetFatalCount()Get number of fatal problems reported.java.util.ArrayListgetProblems()Get list of problems.intgetWarningCount()Get number of warning problems reported.voidhandleMissingElement()booleanisSkipped(java.lang.Object obj)Check if a component is being skipped due to a fatal error.
-
-
-
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.
-
m_skipSet
private java.util.Set m_skipSet
Set of elements to be skipped in walking tree.
-
m_continueOnError
private boolean m_continueOnError
Flag for errors to be ignored.
-
-
Method Detail
-
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, java.lang.Object obj) throws JiBXExceptionAdd 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- Throws:
JiBXException- on unrecoverable error
-
addError
public boolean addError(java.lang.String msg, java.lang.Object obj) throws JiBXExceptionAdd 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- Returns:
trueif to continue validation,falseif not- Throws:
JiBXException- on unrecoverable error
-
addFatal
public void addFatal(java.lang.String msg, java.lang.Object obj) throws JiBXExceptionAdd 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)- 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 java.util.ArrayList getProblems()
Get list of problems.- Returns:
- problem list
-
addSkip
protected void addSkip(java.lang.Object skip)
Add element to set to be skipped.- Parameters:
skip-
-
isSkipped
public boolean isSkipped(java.lang.Object obj)
Description copied from interface:ISkipElementsCheck if a component is being skipped due to a fatal error.- Specified by:
isSkippedin interfaceISkipElements- Parameters:
obj- component to be checked- Returns:
- flag for component being skipped
-
handleMissingElement
public void handleMissingElement() throws JiBXException- Throws:
JiBXException
-
-