java.lang.Object
org.sentrysoftware.maven.metricshub.connector.producer.SinkHelper

public class SinkHelper extends Object
Utility class providing helper methods for generating content in a Sink format.

The class includes methods for setting CSS classes, inserting code blocks with syntax highlighting, outputting FontAwesome and Glyphicon icons, building HTML page filenames, etc.

  • Constructor Details

    • SinkHelper

      public SinkHelper()
  • Method Details

    • setClass

      public static org.apache.maven.doxia.sink.SinkEventAttributes setClass(String className)
      Creates an AttributeSet that sets the CSS class to the specified class
      Parameters:
      className - The class to be set
      Returns:
      the AttributeSet that can be used in any Sink element
    • insertCodeBlock

      public static void insertCodeBlock(org.apache.maven.doxia.sink.Sink sink, String language, String code)
      Inserts a code block into the provided Sink, applying syntax highlighting if a language is specified.
      Parameters:
      sink - The Sink to which the code block will be inserted.
      language - The programming language for syntax highlighting (null or empty for no highlighting).
      code - The code to be inserted into the code block.
    • faIcon

      public static String faIcon(String iconName)
      Returns the HTML code to output a FontAwesome icon
      Example:
       <i class="fa fa-arrows-v" aria-hidden="true"></i>
       

      Note: Returns a question icon if specified icon is empty or null

      Parameters:
      iconName - The name of the FontAwesome icon to insert (without the "fa-" prefix)
      Returns:
      the HTML code for this icon
    • glyphIcon

      public static String glyphIcon(String iconName)
      Returns the HTML code to output a Glyphicon (Bootstrap) icon
      Example:
       <i class="glyphicon glyphicon-info-sign" aria-hidden="true"></i>
       

      Note: Returns a question icon if specified icon is empty or null

      Parameters:
      iconName - The name of the Glyphicon icon to insert (without the "glyphicon-" prefix)
      Returns:
      the HTML code for this icon
    • bootstrapLabel

      public static String bootstrapLabel(@NonNull @NonNull String content, String customClassname)
      Create a bootstrap badge with the following content.
      Parameters:
      content - text of the badge.
      Returns:
      the HTML code for this badge.
    • buildPageFilename

      public static String buildPageFilename(String connectorId)
      Builds the HTML page file name corresponding to the specified connector identifier.
      Parameters:
      connectorId - The connector identifier.
      Returns:
      The corresponding HTML page filename.
    • replaceCommaWithSpace

      public static String replaceCommaWithSpace(String input)
      Replaces commas followed by non-whitespace with spaces in the given input string.
      Parameters:
      input - The input string containing commas to be replaced.
      Returns:
      A new string with commas followed by non-whitespace replaced by spaces.
    • replaceWithHtmlCode

      public static String replaceWithHtmlCode(String value)
      Replaces special characters in the given string with their corresponding HTML numeric codes.
      This will avoid velocity evaluation errors.
      Parameters:
      value - The input string.
      Returns:
      The string with special characters replaced by their HTML numeric codes.
    • hyperlinkRef

      public static String hyperlinkRef(String link, String content)
      Creates an HTML hyperlink reference with the given content.
    • gitHubHyperlinkRef

      public static String gitHubHyperlinkRef(String link, String content)
      Creates an HTMP hyperlink reference with the given content and the specified classes.