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 Pattern
END_RULE_PATTERN
static Pattern
RULE_PATTERN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
addHtmlFormatting(String text)
Adds HTML formatting<br>
and<p>
static String
addHtmlFormatting(String text, boolean inParagraph)
Adds HTML formatting<br>
and<p>
static String
formatEscapeHTML(String text)
Escapes and formats textstatic String
formatEscapeHTML(String text, boolean inParagraph)
Escapes and formats textstatic String
htmlToText(String html)
Converts an HTML string to text preserving line breaks for<br/>
tagsstatic void
parseTemplate(String licenseTemplate, ILicenseTemplateOutputHandler templateOutputHandler)
Parses the license template calling the templateOutputHandler for any text and rules foundstatic String
templateTextToHtml(String licenseTemplate)
Converts a license template string to formatted HTML which highlights any rules or tagsstatic String
templateToText(String template)
Converts template text to standard default text using any default parameters in the rules
-
-
-
Method Detail
-
parseTemplate
public static void parseTemplate(String licenseTemplate, ILicenseTemplateOutputHandler templateOutputHandler) throws LicenseTemplateRuleException, LicenseParserException
Parses 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:
LicenseTemplateRuleException
- if the rule can not be parsedLicenseParserException
- if the license can not be parsed
-
templateTextToHtml
public static String templateTextToHtml(String licenseTemplate) throws LicenseTemplateRuleException
Converts a license template string to formatted HTML which highlights any rules or tags- Parameters:
licenseTemplate
- standard license template- Returns:
- an HTML representation of the license template
- Throws:
LicenseTemplateRuleException
- on a rule parsing errors
-
templateToText
public static String templateToText(String template) throws LicenseTemplateRuleException
Converts template text to standard default text using any default parameters in the rules- Parameters:
template
- standard license template- Returns:
- text representation of the license
- Throws:
LicenseTemplateRuleException
- on any rule parsing errors
-
formatEscapeHTML
public static String formatEscapeHTML(String text)
Escapes and formats text- Parameters:
text
- unformatted text- Returns:
- text suitable for inclusion in HTML
-
formatEscapeHTML
public static String formatEscapeHTML(String text, boolean inParagraph)
Escapes and formats text- Parameters:
text
- unformatted textinParagraph
- true if inside a paragraph tag- Returns:
- text escaped and formatted for inclusion in HTML
-
addHtmlFormatting
public static String addHtmlFormatting(String text)
Adds HTML formatting<br>
and<p>
- Parameters:
text
- unformatted text- Returns:
- HTML formatted text
-
addHtmlFormatting
public static String addHtmlFormatting(String text, boolean inParagraph)
Adds HTML formatting<br>
and<p>
- Parameters:
text
- unformatted textinParagraph
- true if inside a paragraph tag- Returns:
- HTML formatted text
-
-