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.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The non-breaking space character
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    bootstrapBadge(@NonNull String content, String customClassname)
    Create a bootstrap badge with the following content.
    static String
    bootstrapLabel(@NonNull String content, String customClassname)
    Create a bootstrap badge with the following content.
    static String
    Builds the HTML page file name corresponding to the specified connector identifier.
    static String
    faIcon(String iconName)
    Returns the HTML code to output a FontAwesome icon
    Example:
    static String
    Creates an HTML hyperlink reference with the given content.
    static String
    glyphIcon(String iconName)
    Returns the HTML code to output a Glyphicon (Bootstrap) icon
    Example:
    static String
    hyperlinkRef(String link, String content)
    Creates an HTML hyperlink reference with the given content.
    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.
    static String
    Replaces commas followed by non-whitespace with spaces in the given input string.
    static String
    Replaces special characters in the given string with their corresponding HTML numeric codes.
    This will avoid velocity evaluation errors.
    static org.apache.maven.doxia.sink.SinkEventAttributes
    setAttribute(String attributeName, String value)
    Creates an AttributeSet that sets the specified attribute to the specified value
    static org.apache.maven.doxia.sink.SinkEventAttributes
    setClass(String className)
    Creates an AttributeSet that sets the CSS class to the specified class

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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
    • setAttribute

      public static org.apache.maven.doxia.sink.SinkEventAttributes setAttribute(String attributeName, String value)
      Creates an AttributeSet that sets the specified attribute to the specified value
      Parameters:
      attributeName - The name of the attribute to be set
      value - The value to be set for the attribute
      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 label.
      customClassname - custom class name to apply to the label.
      Returns:
      the HTML code for this badge.
    • bootstrapBadge

      public static String bootstrapBadge(@NonNull @NonNull String content, String customClassname)
      Create a bootstrap badge with the following content.
      Parameters:
      content - text of the label.
      customClassname - custom class name to apply to the label
      Returns:
      the HTML code for this badge.
    • buildPageFilename

      public static String buildPageFilename(String pageId)
      Builds the HTML page file name corresponding to the specified connector identifier.
      Parameters:
      pageId - The page 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.
      Parameters:
      link - the URL to which the hyperlink points.
      content - the text to display as the clickable hyperlink.
      Returns:
      a string containing the HTML code for the hyperlink
    • gitHubHyperlinkRef

      public static String gitHubHyperlinkRef(String link, String content)
      Creates an HTML hyperlink reference with the given content.
      Parameters:
      link - the path in the `connector` directory.
      content - the text to display as the hyperlink.
      Returns:
      string containing the HTML code for the hyperlink.