Package net.ionite.docval.validation
Class ValidationResult
- java.lang.Object
-
- net.ionite.docval.validation.ValidationResult
-
public class ValidationResult extends Object
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 Constructor Description ValidationResult()
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addError(String message, String location, Integer line, Integer column, String test)
Add an error to the resultsvoid
addWarning(String message, String location, Integer line, Integer column, String test)
Add a warning to the resultsint
errorCount()
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 stringArrayList<ValidationResultItem>
getErrors()
Returns the list of error itemsArrayList<ValidationResultItem>
getWarnings()
Returns the list of warning itemsorg.json.simple.JSONObject
toJSON()
Serialize this ValidationResult to JSONString
toJSONString()
Serialize this ValidationResult to JSON, and return the JSON as a StringString
toXMLString()
Serialize this ValidatonResult to XML, and return the XML as a Stringint
warningCount()
Returns the number of warnings
-
-
-
Method Detail
-
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
public void addError(String message, String location, Integer line, Integer column, String test)
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
public void addWarning(String message, String location, Integer line, Integer column, String test)
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
public ArrayList<ValidationResultItem> getErrors()
Returns the list of error items- Returns:
- An ArrayList of ValidationResultItem objects
-
getWarnings
public ArrayList<ValidationResultItem> 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
public static ValidationResult fromJSONString(String jsonString) throws ValidatorException
Deserialize the validation result object from the given JSON string- Throws:
ValidatorException
-
toJSONString
public String 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
public String toXMLString() throws net.sf.saxon.s9api.SaxonApiException
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
-
-