Package org.spdx.licenseTemplate
Class SpdxLicenseTemplateHelper
java.lang.Object
org.spdx.licenseTemplate.SpdxLicenseTemplateHelper
public class SpdxLicenseTemplateHelper extends Object
Implements common conversion methods for processing SPDX license templates
- Author:
- Gary O'Neall
-
Field Summary
Fields Modifier and Type Field Description static PatternEND_RULE_PATTERNstatic PatternRULE_PATTERN -
Constructor Summary
Constructors Constructor Description SpdxLicenseTemplateHelper() -
Method Summary
Modifier and Type Method Description static StringaddHtmlFormatting(String text)Adds HTML formatting<br>and<p>static StringaddHtmlFormatting(String text, boolean inParagraph)Adds HTML formatting<br>and<p>static StringformatEscapeHTML(String text)Escapes and formats textstatic StringformatEscapeHTML(String text, boolean inParagraph)Escapes and formats textstatic StringhtmlToText(String html)Converts an HTML string to text preserving line breaks for<br/>tagsstatic voidparseTemplate(String licenseTemplate, ILicenseTemplateOutputHandler templateOutputHandler)Parses the license template calling the templateOutputHandler for any text and rules foundstatic StringtemplateTextToHtml(String licenseTemplate)Converts a license template string to formatted HTML which highlights any rules or tagsstatic StringtemplateToText(String template)Converts template text to standard default text using any default parameters in the rules
-
Field Details
-
Constructor Details
-
SpdxLicenseTemplateHelper
public SpdxLicenseTemplateHelper()
-
-
Method Details
-
parseTemplate
public static void parseTemplate(String licenseTemplate, ILicenseTemplateOutputHandler templateOutputHandler) throws LicenseTemplateRuleException, LicenseParserExceptionParses the license template calling the templateOutputHandler for any text and rules found- Parameters:
licenseTemplate- License template to be parsedtemplateOutputHandler- Handles the text, optional text, and variable rules text found- Throws:
LicenseTemplateRuleExceptionLicenseParserException
-
templateTextToHtml
public static String templateTextToHtml(String licenseTemplate) throws LicenseTemplateRuleExceptionConverts a license template string to formatted HTML which highlights any rules or tags- Parameters:
licenseTemplate-- Returns:
- Throws:
LicenseTemplateRuleException
-
templateToText
Converts template text to standard default text using any default parameters in the rules- Parameters:
template-- Returns:
- Throws:
LicenseTemplateRuleException
-
formatEscapeHTML
Escapes and formats text- Parameters:
text- unformatted text- Returns:
-
formatEscapeHTML
Escapes and formats text- Parameters:
text- unformatted textinParagraph- true if inside a paragraph tag- Returns:
-
addHtmlFormatting
Adds HTML formatting<br>and<p>- Parameters:
text- unformatted text- Returns:
-
addHtmlFormatting
Adds HTML formatting<br>and<p>- Parameters:
text- unformatted textinParagraph- true if inside a paragraph tag- Returns:
-
htmlToText
Converts an HTML string to text preserving line breaks for<br/>tags- Parameters:
html-- Returns:
-