Class PercentageColumn
java.lang.Object
org.jacoco.report.internal.html.table.PercentageColumn
- All Implemented Interfaces:
IColumnRenderer
Column that prints the coverage percentage for each item and the total
percentage in the footer. The implementation is stateless, instances might be
used in parallel.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator<ITableItem> private final ICoverageNode.CounterEntityprivate final NumberFormat -
Constructor Summary
ConstructorsConstructorDescriptionPercentageColumn(ICoverageNode.CounterEntity entity, Locale locale) Creates a new column that is based on theICounterfor the given entity. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcell(HTMLElement td, ICoverageNode node) voidfooter(HTMLElement td, ICoverageNode total, Resources resources, ReportOutputFolder base) Renders the footer for this column.private Stringformat(double ratio) Ratio 199/(1+199)=0.995 must be displayed as "99%", not as "100%".Returns the comparator to sort this table column.booleaninit(List<? extends ITableItem> items, ICoverageNode total) Initializes the column before any output method is called.voiditem(HTMLElement td, ITableItem item, Resources resources, ReportOutputFolder base) Renders a single item in this column.
-
Field Details
-
entity
-
percentageFormat
-
comparator
-
-
Constructor Details
-
PercentageColumn
Creates a new column that is based on theICounterfor the given entity.- Parameters:
entity- counter entity for this columnlocale- locale for rendering numbers
-
-
Method Details
-
init
Description copied from interface:IColumnRendererInitializes the column before any output method is called.- Specified by:
initin interfaceIColumnRenderer- Parameters:
items- all items that will be displayed in the tabletotal- the summary of all coverage data items in the table- Returns:
trueif the column should be visible
-
item
public void item(HTMLElement td, ITableItem item, Resources resources, ReportOutputFolder base) throws IOException Description copied from interface:IColumnRendererRenders a single item in this column.- Specified by:
itemin interfaceIColumnRenderer- Parameters:
td- the parent table cellitem- the item to displayresources- static resources that might be referencedbase- base folder of the table- Throws:
IOException- in case of IO problems with the element output
-
cell
- Throws:
IOException
-
format
Ratio 199/(1+199)=0.995 must be displayed as "99%", not as "100%". UnfortunatelyNumberFormatusesRoundingMode.HALF_EVENby default and ability to change available only starting from JDK 6, so perform rounding usingRoundingMode.FLOORbefore formatting. -
getComparator
Description copied from interface:IColumnRendererReturns the comparator to sort this table column.- Specified by:
getComparatorin interfaceIColumnRenderer- Returns:
- comparator for this column
-