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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an error to the resultsvoidAdd a warning to the resultsintReturns the number of errorsstatic ValidationResultfromJSON(org.json.JSONObject jsonData) Deserialize the validation result object from the given JSON datastatic ValidationResultfromJSONString(String jsonString) Deserialize the validation result object from the given JSON stringReturns the list of error itemsReturns the list of warning itemsvoidsetDocumentTypeName(String name) Set the document type name for this validation resultorg.json.JSONObjecttoJSON()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 StringintReturns the number of warnings
-
Constructor Details
-
ValidationResult
public ValidationResult()Constructor
-
-
Method Details
-
setDocumentTypeName
Set the document type name for this validation result- Parameters:
name- The name to set
-
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.JSONObject toJSON()Serialize this ValidationResult to JSON- Returns:
- the JSONObject representing this validation result
-
fromJSON
Deserialize the validation result object from the given JSON data- Parameters:
jsonData- The JSON data object to deserialize- Returns:
- the validation result represented in the json object
- Throws:
ValidatorException
-
fromJSONString
Deserialize the validation result object from the given JSON string- Parameters:
jsonString- The string containing JSON data object to deserialize- Returns:
- the validation result represented in the 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- If there is an XML parse error
-