org.jacoco.report.html.table
Class CounterColumn

java.lang.Object
  extended by org.jacoco.report.html.table.CounterColumn
All Implemented Interfaces:
IColumnRenderer

public abstract class CounterColumn
extends Object
implements IColumnRenderer

Column that prints the counter values of entities for each item and a summary in the footer. If the total number of items is zero, no column is emitted at all. The implementation is stateful, instances must not be used in parallel.

Version:
0.4.1.20101007204400
Author:
Marc R. Hoffmann

Constructor Summary
protected CounterColumn(ICoverageNode.CounterEntity entity, Locale locale, Comparator<ICoverageNode> comparator)
          Creates a new column that is based on the ICounter for the given entity.
 
Method Summary
 void footer(HTMLElement td, ICoverageNode total, Resources resources, ReportOutputFolder base)
          Renders the footer for this column.
 Comparator<ITableItem> getComparator()
          Returns the comparator to sort this table column.
protected abstract  int getValue(ICounter counter)
          Retrieves the respective value from the counter.
 boolean init(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.
static CounterColumn newCovered(ICoverageNode.CounterEntity entity, Locale locale)
          Creates a new column that shows the covered count for the given entity.
static CounterColumn newMissed(ICoverageNode.CounterEntity entity, Locale locale)
          Creates a new column that shows the missed count for the given entity.
static CounterColumn newTotal(ICoverageNode.CounterEntity entity, Locale locale)
          Creates a new column that shows the total count for the given entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CounterColumn

protected CounterColumn(ICoverageNode.CounterEntity entity,
                        Locale locale,
                        Comparator<ICoverageNode> comparator)
Creates a new column that is based on the ICounter for the given entity.

Parameters:
entity - counter entity for this column
locale - locale for rendering numbers
comparator - comparator for the nodes of this column
Method Detail

newTotal

public static CounterColumn newTotal(ICoverageNode.CounterEntity entity,
                                     Locale locale)
Creates a new column that shows the total count for the given entity.

Parameters:
entity - counter entity for this column
locale - locale for rendering numbers
Returns:
column instance

newMissed

public static CounterColumn newMissed(ICoverageNode.CounterEntity entity,
                                      Locale locale)
Creates a new column that shows the missed count for the given entity.

Parameters:
entity - counter entity for this column
locale - locale for rendering numbers
Returns:
column instance

newCovered

public static CounterColumn newCovered(ICoverageNode.CounterEntity entity,
                                       Locale locale)
Creates a new column that shows the covered count for the given entity.

Parameters:
entity - counter entity for this column
locale - locale for rendering numbers
Returns:
column instance

init

public boolean init(List<? extends ITableItem> items,
                    ICoverageNode total)
Description copied from interface: IColumnRenderer
Initializes the column before any output method is called.

Specified by:
init in interface IColumnRenderer
Parameters:
items - all items that will be displayed in the table
total - 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 IOException
Description copied from interface: IColumnRenderer
Renders the footer for this column.

Specified by:
footer in interface IColumnRenderer
Parameters:
td - the parent table cell
total - the summary of all coverage data items in the table
resources - static resources that might be referenced
base - base folder of the table
Throws:
IOException - in case of IO problems with the element output

item

public void item(HTMLElement td,
                 ITableItem item,
                 Resources resources,
                 ReportOutputFolder base)
          throws IOException
Description copied from interface: IColumnRenderer
Renders a single item in this column.

Specified by:
item in interface IColumnRenderer
Parameters:
td - the parent table cell
item - the item to display
resources - static resources that might be referenced
base - base folder of the table
Throws:
IOException - in case of IO problems with the element output

getComparator

public Comparator<ITableItem> getComparator()
Description copied from interface: IColumnRenderer
Returns the comparator to sort this table column.

Specified by:
getComparator in interface IColumnRenderer
Returns:
comparator for this column

getValue

protected abstract int getValue(ICounter counter)
Retrieves the respective value from the counter.

Parameters:
counter - counter object
Returns:
value of interest