cucumber.table.xstream.ListOfListOfSingleValueWriter Maven / Gradle / Ivy
package cucumber.table.xstream;
import cucumber.table.DataTable;
import cucumber.table.TableConverter;
import gherkin.formatter.model.Comment;
import gherkin.formatter.model.DataTableRow;
import java.util.ArrayList;
import java.util.List;
import static java.util.Collections.emptyList;
public class ListOfListOfSingleValueWriter extends DataTableWriter {
private static final List NO_COMMENTS = emptyList();
private final List rows = new ArrayList();
private final TableConverter tableConverter;
private int nodeDepth;
private List cells;
public ListOfListOfSingleValueWriter(TableConverter tableConverter) {
this.tableConverter = tableConverter;
}
@Override
public DataTable getDataTable() {
return new DataTable(rows, tableConverter);
}
@Override
public void startNode(String name) {
nodeDepth++;
if (nodeDepth == 2) {
cells = new ArrayList();
}
}
@Override
public void addAttribute(String name, String value) {
}
@Override
public void setValue(String text) {
cells.add(text);
}
@Override
public void endNode() {
if (nodeDepth == 2) {
DataTableRow row = new DataTableRow(NO_COMMENTS, cells, 0);
rows.add(row);
}
nodeDepth--;
}
@Override
public void flush() {
throw new UnsupportedOperationException();
}
@Override
public void close() {
throw new UnsupportedOperationException();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy