private static DataTable create( List<?> raw, Locale locale, String dateFormat, String... columnNames) { TableConverter tableConverter = new TableConverter( new LocalizedXStreams(Thread.currentThread().getContextClassLoader()).get(locale), dateFormat); return tableConverter.toTable(raw, columnNames); }
private Object tableArgument( Step step, int argIndex, LocalizedXStreams.LocalizedXStream xStream) { ParameterInfo parameterInfo = getParameterType(argIndex, DataTable.class); TableConverter tableConverter = new TableConverter(xStream, parameterInfo); DataTable table = new DataTable(step.getRows(), tableConverter); Type type = parameterInfo.getType(); return tableConverter.convert(table, type, parameterInfo.isTransposed()); }
public <T> T convert(Type type) { return tableConverter.<T>convert(type, this); }
/** * Creates another table using the same {@link Locale} and {@link cucumber.api.DateFormat} that * was used to create this table. * * @param raw a list of objects * @param columnNames optional explicit header columns * @return */ public DataTable toTable(List<?> raw, String... columnNames) { return tableConverter.toTable(raw, columnNames); }
/** * Converts the table to a List of objects. The top row is used to identifies the * fields/properties of the objects. * * <p>Backends that support generic types can declare a parameter as a List of a type, and * Cucumber will do the conversion automatically. * * @param type the type of the result (should be a {@link List} generic type) * @param <T> the type of each object * @return a list of objects */ public <T> List<T> asList(Type type) { List<T> result = tableConverter.toList(type, this); return result; }