org.jibx.v2
Class ValidationContext

java.lang.Object
  extended by 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
private  boolean m_continueOnError
          Flag for errors to be ignored.
private  int m_errorCount
          Number of errors reported.
private  int m_fatalCount
          Number of fatals reported.
private  java.util.ArrayList m_problemList
          List of problem items reported by validation.
private  java.util.Set m_skipSet
          Set of elements to be skipped in walking tree.
private  int m_warningCount
          Number of warnings reported.
 
Constructor Summary
ValidationContext()
          Constructor.
 
Method Summary
 boolean addError(java.lang.String msg, java.lang.Object obj)
          Add error item.
 void addFatal(java.lang.String msg, java.lang.Object obj)
          Add fatal item.
 void addProblem(ValidationProblem problem)
          Add problem report.
protected  void addSkip(java.lang.Object skip)
          Add element to set to be skipped.
 void addWarning(java.lang.String msg, java.lang.Object obj)
          Add warning item.
 int getErrorCount()
          Get number of error problems reported.
 int getFatalCount()
          Get number of fatal problems reported.
 java.util.ArrayList getProblems()
          Get list of problems.
 int getWarningCount()
          Get number of warning problems reported.
 void handleMissingElement()
           
 boolean isSkipped(java.lang.Object obj)
          Check if a component is being skipped due to a fatal error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.

Constructor Detail

ValidationContext

public ValidationContext()
Constructor.

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 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(java.lang.String msg,
                        java.lang.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(java.lang.String msg,
                     java.lang.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 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: 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


Project Web Site