Projekt

Obecné

Profil

Stáhnout (1.98 KB) Statistiky
| Větev: | Revize:
1
package vldc.aswi.model.table.contingencyTable;
2

    
3
import java.util.ArrayList;
4
import java.util.List;
5

    
6
/**
7
 * Class representing one row in Contingency table. Rows are represented as tree with given level.
8
 */
9
public class ContingencyTableRow {
10

    
11
    /** True if current row is header, false if not. */
12
    private boolean isHeader;
13

    
14
    /** Level of current row. */
15
    private int level;
16

    
17
    /** List of cells in current row. */
18
    private List<ContingencyTableRowCell> cells;
19

    
20
    /**
21
     * Constructor.
22
     * @param isHeader - True if current row is header, false if not.
23
     * @param level - Level of current row.
24
     */
25
    public ContingencyTableRow(boolean isHeader, int level) {
26
        this.isHeader = isHeader;
27
        this.level = level;
28

    
29
        cells = new ArrayList<>();
30
    }
31

    
32
    /**
33
     * Add new cell into current row.
34
     * @param cell - New cell.
35
     */
36
    public void addTableRowCell(ContingencyTableRowCell cell) {
37
        cells.add(cell);
38
    }
39

    
40
    /**
41
     * Add new cells from the list into current row.
42
     * @param cells - List of new cells.
43
     */
44
    public void addTableRowCells(List<ContingencyTableRowCell> cells) {
45
        this.cells.addAll(cells);
46
    }
47

    
48
    /**
49
     * Check if current row is header or not.
50
     * @return True if current row is header, false if not.
51
     */
52
    public boolean isHeader() {
53
        return isHeader;
54
    }
55

    
56
    /**
57
     * Get level of current cell.
58
     * @return
59
     */
60
    public int getLevel() {
61
        return level;
62
    }
63

    
64
    /**
65
     * Get all cells in current row.
66
     * @return List of cells.
67
     */
68
    public List<ContingencyTableRowCell> getCells() {
69
        return cells;
70
    }
71

    
72
    /**
73
     * Overriding toString method for debugging.
74
     * @return String.
75
     */
76
    @Override
77
    public String toString() {
78
        String str = "";
79
        for (ContingencyTableRowCell contingencyTableRowCell : cells) {
80
            str += contingencyTableRowCell.toString();
81
            str += "\t|\t";
82
        }
83

    
84
        return str;
85
    }
86
}
(1-1/2)