Class PercentageColumn
- java.lang.Object
-
- org.jacoco.report.internal.html.table.PercentageColumn
-
- All Implemented Interfaces:
IColumnRenderer
public class PercentageColumn extends java.lang.Object implements 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
Fields Modifier and Type Field Description private java.util.Comparator<ITableItem>
comparator
private ICoverageNode.CounterEntity
entity
private java.text.NumberFormat
percentageFormat
-
Constructor Summary
Constructors Constructor Description PercentageColumn(ICoverageNode.CounterEntity entity, java.util.Locale locale)
Creates a new column that is based on theICounter
for the given entity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
cell(HTMLElement td, ICoverageNode node)
void
footer(HTMLElement td, ICoverageNode total, Resources resources, ReportOutputFolder base)
Renders the footer for this column.private java.lang.String
format(double ratio)
Ratio 199/(1+199)=0.995 must be displayed as "99%", not as "100%".java.util.Comparator<ITableItem>
getComparator()
Returns the comparator to sort this table column.boolean
init(java.util.List<? extends ITableItem> items, ICoverageNode total)
Initializes the column before any output method is called.void
item(HTMLElement td, ITableItem item, Resources resources, ReportOutputFolder base)
Renders a single item in this column.
-
-
-
Field Detail
-
entity
private final ICoverageNode.CounterEntity entity
-
percentageFormat
private final java.text.NumberFormat percentageFormat
-
comparator
private final java.util.Comparator<ITableItem> comparator
-
-
Constructor Detail
-
PercentageColumn
public PercentageColumn(ICoverageNode.CounterEntity entity, java.util.Locale locale)
Creates a new column that is based on theICounter
for the given entity.- Parameters:
entity
- counter entity for this columnlocale
- locale for rendering numbers
-
-
Method Detail
-
init
public boolean init(java.util.List<? extends ITableItem> items, ICoverageNode total)
Description copied from interface:IColumnRenderer
Initializes the column before any output method is called.- Specified by:
init
in interfaceIColumnRenderer
- Parameters:
items
- all items that will be displayed in the tabletotal
- the summary of all coverage data items in the table- Returns:
true
if the column should be visible
-
footer
public void footer(HTMLElement td, ICoverageNode total, Resources resources, ReportOutputFolder base) throws java.io.IOException
Description copied from interface:IColumnRenderer
Renders the footer for this column.- Specified by:
footer
in interfaceIColumnRenderer
- Parameters:
td
- the parent table celltotal
- the summary of all coverage data items in the tableresources
- static resources that might be referencedbase
- base folder of the table- Throws:
java.io.IOException
- in case of IO problems with the element output
-
item
public void item(HTMLElement td, ITableItem item, Resources resources, ReportOutputFolder base) throws java.io.IOException
Description copied from interface:IColumnRenderer
Renders a single item in this column.- Specified by:
item
in interfaceIColumnRenderer
- Parameters:
td
- the parent table cellitem
- the item to displayresources
- static resources that might be referencedbase
- base folder of the table- Throws:
java.io.IOException
- in case of IO problems with the element output
-
cell
private void cell(HTMLElement td, ICoverageNode node) throws java.io.IOException
- Throws:
java.io.IOException
-
format
private java.lang.String format(double ratio)
Ratio 199/(1+199)=0.995 must be displayed as "99%", not as "100%". UnfortunatelyNumberFormat
usesRoundingMode.HALF_EVEN
by default and ability to change available only starting from JDK 6, so perform rounding usingRoundingMode.FLOOR
before formatting.
-
getComparator
public java.util.Comparator<ITableItem> getComparator()
Description copied from interface:IColumnRenderer
Returns the comparator to sort this table column.- Specified by:
getComparator
in interfaceIColumnRenderer
- Returns:
- comparator for this column
-
-