Package org.spdx.utility.compare
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 Classes Modifier and Type Class Description class
CompareTemplateOutputHandler.DifferenceDescription
Information obout any difference found
-
Constructor Summary
Constructors Constructor Description CompareTemplateOutputHandler(String compareText)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginOptional(org.spdx.licenseTemplate.LicenseTemplateRule rule)
void
completeParsing()
void
endOptional(org.spdx.licenseTemplate.LicenseTemplateRule rule)
CompareTemplateOutputHandler.DifferenceDescription
getDifferences()
boolean
matches()
Performs the actual parsing if it has not been completed.void
text(String text)
int
textEquivalent(String text, int startToken)
Compares the text against the compareTextvoid
variableRule(org.spdx.licenseTemplate.LicenseTemplateRule rule)
-
-
-
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 interfaceorg.spdx.licenseTemplate.ILicenseTemplateOutputHandler
-
variableRule
public void variableRule(org.spdx.licenseTemplate.LicenseTemplateRule rule)
- Specified by:
variableRule
in interfaceorg.spdx.licenseTemplate.ILicenseTemplateOutputHandler
-
beginOptional
public void beginOptional(org.spdx.licenseTemplate.LicenseTemplateRule rule)
- Specified by:
beginOptional
in interfaceorg.spdx.licenseTemplate.ILicenseTemplateOutputHandler
-
endOptional
public void endOptional(org.spdx.licenseTemplate.LicenseTemplateRule rule)
- Specified by:
endOptional
in interfaceorg.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
-
getDifferences
public CompareTemplateOutputHandler.DifferenceDescription getDifferences()
- Returns:
- details on the differences found
-
completeParsing
public void completeParsing() throws org.spdx.licenseTemplate.LicenseParserException
- Specified by:
completeParsing
in interfaceorg.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 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
-
-