Class CompareTemplateOutputHandler

  • All Implemented Interfaces:
    org.spdx.licenseTemplate.ILicenseTemplateOutputHandler

    public class CompareTemplateOutputHandler
    extends Object
    implements org.spdx.licenseTemplate.ILicenseTemplateOutputHandler
    Compares the output of a parsed license template to text. The method matches is called after the document is parsed to determine if the text matches.
    Author:
    Gary O'Neall
    • Constructor Detail

      • CompareTemplateOutputHandler

        public CompareTemplateOutputHandler​(String compareText)
                                     throws IOException
        Parameters:
        compareText - Text to compare the parsed SPDX license template to
        Throws:
        IOException - This is not to be expected since we are using StringReaders
    • Method Detail

      • text

        public void text​(String text)
        Specified by:
        text in interface org.spdx.licenseTemplate.ILicenseTemplateOutputHandler
      • variableRule

        public void variableRule​(org.spdx.licenseTemplate.LicenseTemplateRule rule)
        Specified by:
        variableRule in interface org.spdx.licenseTemplate.ILicenseTemplateOutputHandler
      • beginOptional

        public void beginOptional​(org.spdx.licenseTemplate.LicenseTemplateRule rule)
        Specified by:
        beginOptional in interface org.spdx.licenseTemplate.ILicenseTemplateOutputHandler
      • endOptional

        public void endOptional​(org.spdx.licenseTemplate.LicenseTemplateRule rule)
        Specified by:
        endOptional in interface org.spdx.licenseTemplate.ILicenseTemplateOutputHandler
      • matches

        public boolean matches()
                        throws org.spdx.licenseTemplate.LicenseParserException
        Performs the actual parsing if it has not been completed. NOTE: This should only be called after all text has been added.
        Returns:
        true if no differences were found
        Throws:
        org.spdx.licenseTemplate.LicenseParserException - on license parsing error
      • completeParsing

        public void completeParsing()
                             throws org.spdx.licenseTemplate.LicenseParserException
        Specified by:
        completeParsing in interface org.spdx.licenseTemplate.ILicenseTemplateOutputHandler
        Throws:
        org.spdx.licenseTemplate.LicenseParserException
      • textEquivalent

        public int textEquivalent​(String text,
                                  int startToken)
        Compares the text against the compareText
        Parameters:
        text - text to compare
        startToken - token of the compareText to being the comparison
        Returns:
        next token index (positive) if there is a match, negative first token where this is a miss-match if no match