Package net.ionite.docval.validation
Class ValidationResult
java.lang.Object
net.ionite.docval.validation.ValidationResult
Collects and serializes validation results.
This class holds results from validation, in the form of a list of errors and
warnings Each ValidationResultItem contains a description, and, if known, a
location (xpath), a line and column number, and the test that was performed.
- Author:
- Ionite
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an error to the resultsvoid
Add a warning to the resultsint
Returns the number of errorsstatic ValidationResult
fromJSON
(org.json.simple.JSONObject jsonData) Deserialize the validation result object from the given JSON datastatic ValidationResult
fromJSONString
(String jsonString) Deserialize the validation result object from the given JSON stringReturns the list of error itemsReturns the list of warning itemsorg.json.simple.JSONObject
toJSON()
Serialize this ValidationResult to JSONSerialize this ValidationResult to JSON, and return the JSON as a StringSerialize this ValidatonResult to XML, and return the XML as a Stringint
Returns the number of warnings
-
Constructor Details
-
ValidationResult
public ValidationResult()Constructor
-
-
Method Details
-
errorCount
public int errorCount()Returns the number of errors- Returns:
- The number of errors
-
warningCount
public int warningCount()Returns the number of warnings- Returns:
- The number of warnings
-
addError
Add an error to the results- Parameters:
message
- The error messagelocation
- The error location (an xpath), may be nullline
- The line number of the error, may be nullcolumn
- The column of the error, may be nulltest
- The test that failed (either an xpath expression or a general String)
-
addWarning
Add a warning to the results- Parameters:
message
- The error messagelocation
- The error location (an xpath), may be nullline
- The line number of the error, may be nullcolumn
- The column of the error, may be nulltest
- The test that failed (either an xpath expression or a general String)
-
getErrors
Returns the list of error items- Returns:
- An ArrayList of ValidationResultItem objects
-
getWarnings
Returns the list of warning items- Returns:
- An ArrayList of ValidationResultItem objects
-
toJSON
public org.json.simple.JSONObject toJSON()Serialize this ValidationResult to JSON- Returns:
- the JSONObject representing this validation result
-
fromJSON
public static ValidationResult fromJSON(org.json.simple.JSONObject jsonData) throws ValidatorException Deserialize the validation result object from the given JSON data- Throws:
ValidatorException
-
fromJSONString
Deserialize the validation result object from the given JSON string- Throws:
ValidatorException
-
toJSONString
Serialize this ValidationResult to JSON, and return the JSON as a String- Returns:
- The String representation of the JSON for this validation result
-
toXMLString
Serialize this ValidatonResult to XML, and return the XML as a String- Returns:
- The String representation of the XML for this validation result
- Throws:
net.sf.saxon.s9api.SaxonApiException
-