Search in sources :

Example 1 with Row

use of gherkin.formatter.model.Row in project cucumber-jvm by cucumber.

the class DataTable method transpose.

public DataTable transpose() {
    List<List<String>> transposed = new ArrayList<List<String>>();
    for (int i = 0; i < gherkinRows.size(); i++) {
        Row gherkinRow = gherkinRows.get(i);
        for (int j = 0; j < gherkinRow.getCells().size(); j++) {
            List<String> row = null;
            if (j < transposed.size()) {
                row = transposed.get(j);
            }
            if (row == null) {
                row = new ArrayList<String>();
                transposed.add(row);
            }
            row.add(gherkinRow.getCells().get(j));
        }
    }
    return new DataTable(this.gherkinRows, transposed, this.tableConverter);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Row(gherkin.formatter.model.Row) DiffableRow(cucumber.runtime.table.DiffableRow) DataTableRow(gherkin.formatter.model.DataTableRow)

Example 2 with Row

use of gherkin.formatter.model.Row in project cucumber-jvm by cucumber.

the class CucumberScenarioOutline method rowsWithTokensReplaced.

private static List<DataTableRow> rowsWithTokensReplaced(List<DataTableRow> rows, List<String> headerCells, List<String> exampleCells, Set<Integer> matchedColumns) {
    if (rows != null) {
        List<DataTableRow> newRows = new ArrayList<DataTableRow>(rows.size());
        for (Row row : rows) {
            List<String> newCells = new ArrayList<String>(row.getCells().size());
            for (String cell : row.getCells()) {
                newCells.add(replaceTokens(matchedColumns, headerCells, exampleCells, cell));
            }
            newRows.add(new DataTableRow(row.getComments(), newCells, row.getLine()));
        }
        return newRows;
    } else {
        return null;
    }
}
Also used : ArrayList(java.util.ArrayList) Row(gherkin.formatter.model.Row) ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) DataTableRow(gherkin.formatter.model.DataTableRow) DocString(gherkin.formatter.model.DocString) DataTableRow(gherkin.formatter.model.DataTableRow)

Aggregations

DataTableRow (gherkin.formatter.model.DataTableRow)2 Row (gherkin.formatter.model.Row)2 ArrayList (java.util.ArrayList)2 DiffableRow (cucumber.runtime.table.DiffableRow)1 DocString (gherkin.formatter.model.DocString)1 ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)1 List (java.util.List)1