Package com.pixelmed.validate

## Class DicomSRValidator

- java.lang.Object
- - com.pixelmed.validate.DicomSRValidator

-     public class DicomSRValidator
      extends java.lang.Object

  The `DicomSRValidator` class is for validating SR instances against the standard IOD for the corresponding SOP Class.

  Typically used by reading the list of attributes that comprise an object, validating them and displaying the resulting string results to the user on the standard output, in a dialog box or whatever. The basic implementation of the `main` method (that may be useful as a command line utility in its own right) is as follows:

              AttributeList list = new AttributeList();
              list.read(arg[0],null,true,true);
              DicomSRValidator validator = new DicomSRValidator();
              System.err.print(validator.validate(list));

  See Also:
    `AttributeList`

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DicomSRValidator()` | Create an instance of validator.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `main​(java.lang.String[] arg)` | Read the DICOM file specified on the command line and validate it against the standard IOD for the appropriate storage SOP Class.
    `void` | `setOptionCheckAmbiguousTemplate​(boolean option)` | Whether or not to check and warn about ambiguous inclusion of templates (different templates match same content).
    `void` | `setOptionCheckContentItemOrder​(boolean option)` | Whether or not to check and warn about content item order not matching order in templates.
    `void` | `setOptionCheckTemplateID​(boolean option)` | Whether or not to check if encoded Template ID on CONTAINERs match expected template.
    `void` | `setOptionDescribeChecking​(boolean option)` | Whether or not to describe the details of the validation procedure step by step.
    `void` | `setOptionMatchCaseOfCodeMeaning​(boolean option)` | Whether or not to match the case of code meanings when validating them against the expected values in context groups and templates.
    `java.lang.String` | `validate​(AttributeList list)` | Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
    `java.lang.String` | `validate​(AttributeList list, boolean describe, boolean matchCase, boolean checkAmbiguousTemplate, boolean checkContentItemOrder, boolean checkTemplateID)` | Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
    `java.lang.String` | `validate​(java.lang.String filename)` | Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
    `java.lang.String` | `validate​(java.lang.String filename, boolean describe, boolean matchCase, boolean checkAmbiguousTemplate, boolean checkContentItemOrder, boolean checkTemplateID)` | Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
    `protected java.lang.String` | `validateFirstPass​(org.w3c.dom.Document inputDocument)` | Perform the first pass of the validation.
    `protected java.lang.String` | `validateSecondPass​(org.w3c.dom.Document inputDocument, java.lang.String firstOutputString)` | Perform the second pass of the validation.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DicomSRValidator

          public DicomSRValidator()
                           throws javax.xml.transform.TransformerConfigurationException

      Create an instance of validator.

      Once created, a validator may be reused for as many validations as desired.

      Throws:
        `javax.xml.transform.TransformerConfigurationException`

  - ### Method Detail

    - #### setOptionDescribeChecking

          public void setOptionDescribeChecking​(boolean option)

      Whether or not to describe the details of the validation procedure step by step.

      Default after construction is not to.

      Parameters:
        `option` - true if the steps are to be described

    - #### setOptionMatchCaseOfCodeMeaning

          public void setOptionMatchCaseOfCodeMeaning​(boolean option)

      Whether or not to match the case of code meanings when validating them against the expected values in context groups and templates.

      Default after construction is true, i.e., to be case sensitive.

      Parameters:
        `option` - true if matching is to be case sensitive

    - #### setOptionCheckTemplateID

          public void setOptionCheckTemplateID​(boolean option)

      Whether or not to check if encoded Template ID on CONTAINERs match expected template.

      May emit spurious warnings if template invocation is ambiguous (different templates match same content).

      The explicitly encoded Template ID is NOT used to constrain template matching.

      Default after construction is false, i.e., not to check.

      Parameters:
        `option` - true if checking

    - #### setOptionCheckAmbiguousTemplate

          public void setOptionCheckAmbiguousTemplate​(boolean option)

      Whether or not to check and warn about ambiguous inclusion of templates (different templates match same content).

      Default after construction is false, i.e., not to check.

      Parameters:
        `option` - true if checking

    - #### setOptionCheckContentItemOrder

          public void setOptionCheckContentItemOrder​(boolean option)

      Whether or not to check and warn about content item order not matching order in templates.

      The check is irrespective of whether order deemed significant in template definition.

      May emit spurious warnings if template invocation is ambiguous (different templates match same content) and content item order is different in any of the matching templates.

      Default after construction is false, i.e., not to check.

      Parameters:
        `option` - true if checking

    - #### validateFirstPass

          protected java.lang.String validateFirstPass​(org.w3c.dom.Document inputDocument)
                                                throws javax.xml.parsers.ParserConfigurationException,
                                                       javax.xml.transform.TransformerException,
                                                       java.io.UnsupportedEncodingException

      Perform the first pass of the validation.

      Checks the document against the stylesheet and tracks which nodes matched templates.

      Parameters:
        `inputDocument` - the XML representation of the DICOM SR instance to be validated
      Returns:
        a string describing the results of the first pass of the validation
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`
        `java.io.UnsupportedEncodingException`

    - #### validateSecondPass

          protected java.lang.String validateSecondPass​(org.w3c.dom.Document inputDocument,
                                                        java.lang.String firstOutputString)
                                                 throws javax.xml.parsers.ParserConfigurationException,
                                                        javax.xml.transform.TransformerException,
                                                        java.io.UnsupportedEncodingException,
                                                        java.io.IOException

      Perform the second pass of the validation.

      Checks for unused content items.

      Parameters:
        `inputDocument` - the XML representation of the DICOM SR instance to be validated
        `firstOutputString` - the text output of the first validation pass that contains a list of items found in the first pass
      Returns:
        a string describing the results of the validation
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`
        `java.io.UnsupportedEncodingException`
        `java.io.IOException`

    - #### validate

          public java.lang.String validate​(AttributeList list,
                                           boolean describe,
                                           boolean matchCase,
                                           boolean checkAmbiguousTemplate,
                                           boolean checkContentItemOrder,
                                           boolean checkTemplateID)
                                    throws javax.xml.parsers.ParserConfigurationException,
                                           javax.xml.transform.TransformerException,
                                           java.io.UnsupportedEncodingException,
                                           java.io.IOException

      Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.

      Parameters:
        `list` - the list of attributes comprising the DICOM SR instance to be validated
        `describe` - whether or not to describe the details of the validation procedure step by step
        `matchCase` - whether or not to match the case of code meanings when validating them against the expected values in context groups and templates
        `checkAmbiguousTemplate` - whether or not to check and warn about ambiguous inclusion of templates (different templates match same content)
        `checkContentItemOrder` - whether or not to check and warn about content item order not matching order in templates (irrespective of whether order deemed significant in template definition)
        `checkTemplateID` - whether or not to check if encoded Template ID on CONTAINERs match expected template
      Returns:
        a string describing the results of the validation
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`
        `java.io.UnsupportedEncodingException`
        `java.io.IOException`

    - #### validate

          public java.lang.String validate​(AttributeList list)
                                    throws javax.xml.parsers.ParserConfigurationException,
                                           javax.xml.transform.TransformerException,
                                           java.io.UnsupportedEncodingException,
                                           java.io.IOException

      Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.

      Does not describe the details of the validation procedure step by step, and does match the case of code meanings when validating them against the expected values in context groups and templates.

      Parameters:
        `list` - the list of attributes comprising the DICOM SR instance to be validated
      Returns:
        a string describing the results of the validation
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`
        `java.io.UnsupportedEncodingException`
        `java.io.IOException`

    - #### validate

          public java.lang.String validate​(java.lang.String filename,
                                           boolean describe,
                                           boolean matchCase,
                                           boolean checkAmbiguousTemplate,
                                           boolean checkContentItemOrder,
                                           boolean checkTemplateID)
                                    throws javax.xml.parsers.ParserConfigurationException,
                                           javax.xml.transform.TransformerException,
                                           java.io.UnsupportedEncodingException,
                                           java.io.IOException,
                                           DicomException

      Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.

      Parameters:
        `filename` - the DICOM SR instance to be validated
        `describe` - whether or not to describe the details of the validation procedure step by step
        `matchCase` - whether or not to match the case of code meanings when validating them against the expected values in context groups and templates
        `checkAmbiguousTemplate` - whether or not to check and warn about ambiguous inclusion of templates (different templates match same content)
        `checkContentItemOrder` - whether or not to check and warn about content item order not matching order in templates (irrespective of whether order deemed significant in template definition)
        `checkTemplateID` - whether or not to check if encoded Template ID on CONTAINERs match expected template
      Returns:
        a string describing the results of the validation
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`
        `java.io.UnsupportedEncodingException`
        `java.io.IOException`
        `DicomException`

    - #### validate

          public java.lang.String validate​(java.lang.String filename)
                                    throws javax.xml.parsers.ParserConfigurationException,
                                           javax.xml.transform.TransformerException,
                                           java.io.UnsupportedEncodingException,
                                           java.io.IOException,
                                           DicomException

      Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.

      Does not describe the details of the validation procedure step by step, and does match the case of code meanings when validating them against the expected values in context groups and templates.

      Parameters:
        `filename` - the DICOM SR instance to be validated
      Returns:
        a string describing the results of the validation
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `javax.xml.transform.TransformerException`
        `java.io.UnsupportedEncodingException`
        `java.io.IOException`
        `DicomException`

    - #### main

          public static void main​(java.lang.String[] arg)

      Read the DICOM file specified on the command line and validate it against the standard IOD for the appropriate storage SOP Class.

      The result of the validation is printed to the standard output.

      Parameters:
        `arg` - optionally -describe, -donotmatchcase, -checkambiguoustemplate, -checkcontentitemorder, -checktemplateid, then the name of the file containing the DICOM SR instance to be validated