Class CompareTemplateOutputHandler
java.lang.Object
org.spdx.utility.compare.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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInformation about any difference found -
Constructor Summary
ConstructorsConstructorDescriptionCompareTemplateOutputHandler(String compareText) Construct a newCompareTemplateOutputHandlerwith the specified text to compare -
Method Summary
Modifier and TypeMethodDescriptionvoidbeginOptional(org.spdx.licenseTemplate.LicenseTemplateRule rule) voidvoidendOptional(org.spdx.licenseTemplate.LicenseTemplateRule rule) Retrieve the details of the differences found during the comparison processbooleanmatches()Performs the actual parsing if it has not been completedvoidinttextEquivalent(String text, int startToken) Compares the text against the compareTextvoidvariableRule(org.spdx.licenseTemplate.LicenseTemplateRule rule)
-
Constructor Details
-
CompareTemplateOutputHandler
Construct a newCompareTemplateOutputHandlerwith the specified text to compareThis handler is used to compare the output of a parsed SPDX license template to the provided text. It tokenizes the input text and prepares it for comparison against the parsed license template.
- Parameters:
compareText- The text to compare the parsed SPDX license template to.- Throws:
IOException- This is not to be expected since we are using StringReaders
-
-
Method Details
-
text
- Specified by:
textin interfaceorg.spdx.licenseTemplate.ILicenseTemplateOutputHandler
-
variableRule
public void variableRule(org.spdx.licenseTemplate.LicenseTemplateRule rule) - Specified by:
variableRulein interfaceorg.spdx.licenseTemplate.ILicenseTemplateOutputHandler
-
beginOptional
public void beginOptional(org.spdx.licenseTemplate.LicenseTemplateRule rule) - Specified by:
beginOptionalin interfaceorg.spdx.licenseTemplate.ILicenseTemplateOutputHandler
-
endOptional
public void endOptional(org.spdx.licenseTemplate.LicenseTemplateRule rule) - Specified by:
endOptionalin interfaceorg.spdx.licenseTemplate.ILicenseTemplateOutputHandler
-
matches
public boolean matches() throws org.spdx.licenseTemplate.LicenseParserExceptionPerforms the actual parsing if it has not been completedNOTE: 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
-
getDifferences
Retrieve the details of the differences found during the comparison process- Returns:
- details on the differences found
-
completeParsing
public void completeParsing() throws org.spdx.licenseTemplate.LicenseParserException- Specified by:
completeParsingin interfaceorg.spdx.licenseTemplate.ILicenseTemplateOutputHandler- Throws:
org.spdx.licenseTemplate.LicenseParserException
-
textEquivalent
Compares the text against the compareText- Parameters:
text- text to comparestartToken- 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
-