Class SinkHelper
java.lang.Object
org.sentrysoftware.maven.metricshub.connector.producer.SinkHelper
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
bootstrapLabel
(@NonNull String content, String customClassname) Create a bootstrap badge with the following content.static String
buildPageFilename
(String connectorId) Builds the HTML page file name corresponding to the specified connector identifier.static String
Returns the HTML code to output a FontAwesome icon
Example:static String
gitHubHyperlinkRef
(String link, String content) Creates an HTML hyperlink reference with the given content.static String
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
replaceCommaWithSpace
(String input) Replaces commas followed by non-whitespace with spaces in the given input string.static String
replaceWithHtmlCode
(String value) 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
Creates an AttributeSet that sets the CSS class to the specified class
-
Constructor Details
-
SinkHelper
public SinkHelper()
-
-
Method Details
-
setClass
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
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
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
Create a bootstrap badge with the following content.- Parameters:
content
- text of the badge.customClassname
- custom class name to apply to the badge.- Returns:
- the HTML code for this badge.
-
buildPageFilename
Builds the HTML page file name corresponding to the specified connector identifier.- Parameters:
connectorId
- The connector identifier.- Returns:
- The corresponding HTML page filename.
-
replaceCommaWithSpace
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
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
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
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.
-