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 Details

    • RULE_PATTERN

      public static final Pattern RULE_PATTERN
    • END_RULE_PATTERN

      public static final Pattern END_RULE_PATTERN
  • Constructor Details

    • SpdxLicenseTemplateHelper

      public SpdxLicenseTemplateHelper()
  • Method Details

    • 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 parsed
      templateOutputHandler - Handles the text, optional text, and variable rules text found
      Throws:
      LicenseTemplateRuleException
      LicenseParserException
    • 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 -
      Returns:
      Throws:
      LicenseTemplateRuleException
    • 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 -
      Returns:
      Throws:
      LicenseTemplateRuleException
    • formatEscapeHTML

      public static String formatEscapeHTML(String text)
      Escapes and formats text
      Parameters:
      text - unformatted text
      Returns:
    • formatEscapeHTML

      public static String formatEscapeHTML(String text, boolean inParagraph)
      Escapes and formats text
      Parameters:
      text - unformatted text
      inParagraph - true if inside a paragraph tag
      Returns:
    • addHtmlFormatting

      public static String addHtmlFormatting(String text)
      Adds HTML formatting <br> and <p>
      Parameters:
      text - unformatted text
      Returns:
    • addHtmlFormatting

      public static String addHtmlFormatting(String text, boolean inParagraph)
      Adds HTML formatting <br> and <p>
      Parameters:
      text - unformatted text
      inParagraph - true if inside a paragraph tag
      Returns:
    • htmlToText

      public static String htmlToText(String html)
      Converts an HTML string to text preserving line breaks for <br/> tags
      Parameters:
      html -
      Returns: