Class ElementFormatter


  • public final class ElementFormatter
    extends Object
    A localized formatter for coverages, metrics, baselines, etc.
    Author:
    Florian Orendi
    • Constructor Detail

      • ElementFormatter

        public ElementFormatter()
    • Method Detail

      • format

        public String format​(Value value)
        Formats a generic value using a specific rendering method. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value 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

        public String format​(Value value,
                             Locale locale)
        Formats a generic value using a specific rendering method. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value instances are provided by a library that is not capable of localizing these values for the user.
        Parameters:
        value - the value to format
        locale - the locale to use to render the values
        Returns:
        the formatted value as plain text
      • formatDetails

        public String formatDetails​(Value value,
                                    Locale locale)
        Formats a generic value using a specific rendering method. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value instances are provided by a library that is not capable of localizing these values for the user.
        Parameters:
        value - the value to format
        locale - the locale to use to render the values
        Returns:
        the formatted value as plain text
      • formatAdditionalInformation

        public String formatAdditionalInformation​(Value value)
        Formats additional information for a generic value using a specific rendering method. This information can be added as a tooltip. The type of the given Value instance is used to select the best matching rendering method. This non-object-oriented approach is required since the Value 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

        public ColorProvider.DisplayColors getDisplayColors​(Baseline baseline,
                                                            Value value)
        Provides the colors to render a given coverage percentage.
        Parameters:
        baseline - the baseline to show
        value - the value to format
        Returns:
        the display colors to use
      • formatValue

        public String formatValue​(Value value)
        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

        public String formatValueWithMetric​(Value value)
        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

        public String formatDetailedValueWithMetric​(Value value)
        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

        public String getBackgroundColorFillPercentage​(String percentage)
        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

        public String getBackgroundColorFillPercentage​(Value value)
        Returns the fill percentage for the specified value.
        Parameters:
        value - the value to format
        Returns:
        the percentage string
      • formatPercentage

        public String formatPercentage​(Coverage coverage,
                                       Locale locale)
        Formats a coverage as a percentage number. The shown value is multiplied by 100 and rounded by two decimals.
        Parameters:
        coverage - the coverage to format
        locale - the locale to use to render the values
        Returns:
        the formatted percentage as plain text
      • getDisplayName

        public String getDisplayName​(Metric metric)
        Returns a localized human-readable name for the specified metric.
        Parameters:
        metric - the metric to get the name for
        Returns:
        the display name
      • getLabel

        public String getLabel​(Metric metric,
                               String parasoftToolName)
        Returns a localized human-readable label for the specified metric.
        Parameters:
        metric - the metric to get the label for
        Returns:
        the display name
      • getDisplayName

        public String getDisplayName​(Baseline baseline)
        Returns a localized human-readable name for the specified baseline.
        Parameters:
        baseline - the baseline to get the name for
        Returns:
        the display name
      • getCriticalityItems

        public ListBoxModel getCriticalityItems()
      • getDisplayName

        public String getDisplayName​(io.jenkins.plugins.util.QualityGate.QualityGateCriticality criticality)