Class SinkHelper
java.lang.Object
org.metricshub.maven.plugin.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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbootstrapBadge(@NonNull String content, String customClassname) Create a bootstrap badge with the following content.static StringbootstrapLabel(@NonNull String content, String customClassname) Create a bootstrap badge with the following content.static StringbuildPageFilename(String pageId) Builds the HTML page file name corresponding to the specified connector identifier.static StringReturns the HTML code to output a FontAwesome icon
Example:static StringgitHubHyperlinkRef(String link, String content) Creates an HTML hyperlink reference with the given content.static StringReturns the HTML code to output a Glyphicon (Bootstrap) icon
Example:static StringhyperlinkRef(String link, String content) Creates an HTML hyperlink reference with the given content.static voidinsertCodeBlock(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 StringreplaceCommaWithSpace(String input) Replaces commas followed by non-whitespace with spaces in the given input string.static StringreplaceWithHtmlCode(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.SinkEventAttributessetAttribute(String attributeName, String value) Creates an AttributeSet that sets the specified attribute to the specified valuestatic org.apache.maven.doxia.sink.SinkEventAttributesCreates an AttributeSet that sets the CSS class to the specified class
-
Field Details
-
NON_BREAKING_SPACE
The non-breaking space character- See Also:
-
-
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
-
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 setvalue- 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
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 label.customClassname- custom class name to apply to the label.- Returns:
- the HTML code for this badge.
-
bootstrapBadge
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
Builds the HTML page file name corresponding to the specified connector identifier.- Parameters:
pageId- The page 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.
-