Class ElementFormatter
java.lang.Object
com.parasoft.findings.jenkins.coverage.api.metrics.model.ElementFormatter
A localized formatter for coverages, metrics, baselines, etc.
- Author:
- Florian Orendi
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionFormats a generic value using a specific rendering method.Formats a generic value using a specific rendering method.formatAdditionalInformation
(Value value) Formats additional information for a generic value using a specific rendering method.Returns a formatted and localized String representation of the specified value prefixed with the metric name.formatDetails
(Value value, Locale locale) Formats a generic value using a specific rendering method.formatPercentage
(Coverage coverage, Locale locale) Formats a coverage as a percentage number.formatValue
(Value value) Returns a formatted and localized String representation of the specified value (without metric).formatValueWithMetric
(Value value) Returns a formatted and localized String representation of the specified value prefixed with the metric name.Returns the fill percentage for the specified value.getBackgroundColorFillPercentage
(String percentage) Transforms percentages with a ',' decimal separator to a representation using a '.' in order to use the percentage for styling HTML tags.getDisplayColors
(Baseline baseline, Value value) Provides the colors to render a given coverage percentage.getDisplayName
(Baseline baseline) Returns a localized human-readable name for the specified baseline.getDisplayName
(Metric metric) Returns a localized human-readable name for the specified metric.getDisplayName
(io.jenkins.plugins.util.QualityGate.QualityGateCriticality criticality) Returns a localized human-readable label for the specified metric.Returns all available baselines as aListBoxModel
.
-
Constructor Details
-
ElementFormatter
public ElementFormatter()
-
-
Method Details
-
format
Formats a generic value using a specific rendering method. The type of the givenValue
instance is used to select the best matching rendering method. This non-object-oriented approach is required since theValue
instances are provided by a library that is not capable of localizing these values for the user.- Parameters:
value
- the value to format- Returns:
- the formatted value as plain text
-
format
Formats a generic value using a specific rendering method. The type of the givenValue
instance is used to select the best matching rendering method. This non-object-oriented approach is required since theValue
instances are provided by a library that is not capable of localizing these values for the user.- Parameters:
value
- the value to formatlocale
- the locale to use to render the values- Returns:
- the formatted value as plain text
-
formatDetails
Formats a generic value using a specific rendering method. The type of the givenValue
instance is used to select the best matching rendering method. This non-object-oriented approach is required since theValue
instances are provided by a library that is not capable of localizing these values for the user.- Parameters:
value
- the value to formatlocale
- the locale to use to render the values- Returns:
- the formatted value as plain text
-
formatAdditionalInformation
Formats additional information for a generic value using a specific rendering method. This information can be added as a tooltip. The type of the givenValue
instance is used to select the best matching rendering method. This non-object-oriented approach is required since theValue
instances are provided by a library that is not capable of localizing these values for the user.- Parameters:
value
- the value to format- Returns:
- the formatted value as plain text
-
getDisplayColors
Provides the colors to render a given coverage percentage.- Parameters:
baseline
- the baseline to showvalue
- the value to format- Returns:
- the display colors to use
-
formatValue
Returns a formatted and localized String representation of the specified value (without metric).- Parameters:
value
- the value to format- Returns:
- the value formatted as a string
-
formatValueWithMetric
Returns a formatted and localized String representation of the specified value prefixed with the metric name.- Parameters:
value
- the value to format- Returns:
- the value formatted as a string
-
formatDetailedValueWithMetric
Returns a formatted and localized String representation of the specified value prefixed with the metric name. The value will be printed with all details (number of covered and missed items).- Parameters:
value
- the value to format- Returns:
- the value formatted as a string
-
getBackgroundColorFillPercentage
Transforms percentages with a ',' decimal separator to a representation using a '.' in order to use the percentage for styling HTML tags.- Parameters:
percentage
- The text representation of a percentage- Returns:
- the formatted percentage string
-
getBackgroundColorFillPercentage
Returns the fill percentage for the specified value.- Parameters:
value
- the value to format- Returns:
- the percentage string
-
formatPercentage
Formats a coverage as a percentage number. The shown value is multiplied by 100 and rounded by two decimals.- Parameters:
coverage
- the coverage to formatlocale
- the locale to use to render the values- Returns:
- the formatted percentage as plain text
-
getDisplayName
Returns a localized human-readable name for the specified metric.- Parameters:
metric
- the metric to get the name for- Returns:
- the display name
-
getLabel
Returns a localized human-readable label for the specified metric.- Parameters:
metric
- the metric to get the label for- Returns:
- the display name
-
getDisplayName
Returns a localized human-readable name for the specified baseline.- Parameters:
baseline
- the baseline to get the name for- Returns:
- the display name
-
getTypeItems
Returns all available baselines as aListBoxModel
.- Returns:
- the baselines in a
ListBoxModel
-
getCriticalityItems
-
getDisplayName
public String getDisplayName(io.jenkins.plugins.util.QualityGate.QualityGateCriticality criticality)
-