Package org.spdx.utility.compare
Class CompareTemplateOutputHandler
java.lang.Object
org.spdx.utility.compare.CompareTemplateOutputHandler
- All Implemented Interfaces:
ILicenseTemplateOutputHandler
public class CompareTemplateOutputHandler extends Object implements 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 Classes Modifier and Type Class Description classCompareTemplateOutputHandler.DifferenceDescription -
Constructor Summary
Constructors Constructor Description CompareTemplateOutputHandler(String compareText) -
Method Summary
Modifier and Type Method Description voidbeginOptional(LicenseTemplateRule rule)Begin optional rule foundvoidcompleteParsing()Signals all text has been added and parsing can be completed.voidendOptional(LicenseTemplateRule rule)End optional rule foundCompareTemplateOutputHandler.DifferenceDescriptiongetDifferences()booleanmatches()Performs the actual parsing if it has not been completed.voidtext(String text)Text for processinginttextEquivalent(String text, int startToken)Compares the text against the compareTextvoidvariableRule(LicenseTemplateRule rule)Variable rule found within the template
-
Constructor Details
-
CompareTemplateOutputHandler
- 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 Details
-
text
Description copied from interface:ILicenseTemplateOutputHandlerText for processing- Specified by:
textin interfaceILicenseTemplateOutputHandler
-
variableRule
Description copied from interface:ILicenseTemplateOutputHandlerVariable rule found within the template- Specified by:
variableRulein interfaceILicenseTemplateOutputHandler
-
beginOptional
Description copied from interface:ILicenseTemplateOutputHandlerBegin optional rule found- Specified by:
beginOptionalin interfaceILicenseTemplateOutputHandler
-
endOptional
Description copied from interface:ILicenseTemplateOutputHandlerEnd optional rule found- Specified by:
endOptionalin interfaceILicenseTemplateOutputHandler
-
matches
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:
LicenseParserException
-
getDifferences
- Returns:
- details on the differences found
-
completeParsing
Description copied from interface:ILicenseTemplateOutputHandlerSignals all text has been added and parsing can be completed.- Specified by:
completeParsingin interfaceILicenseTemplateOutputHandler- Throws:
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
-