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 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

      public void addError(String message, String location, Integer line, Integer column, String test)
      Add an error to the results
      Parameters:
      message - The error message
      location - The error location (an xpath), may be null
      line - The line number of the error, may be null
      column - The column of the error, may be null
      test - 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 message
      location - The error location (an xpath), may be null
      line - The line number of the error, may be null
      column - The column of the error, may be null
      test - 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