Search in sources :

Example 1 with Listener

use of gherkin.lexer.Listener in project cucumber-jvm by cucumber.

the class TableParser method parse.

public static DataTable parse(String source, ParameterInfo parameterInfo) {
    final List<DataTableRow> rows = new ArrayList<DataTableRow>();
    Lexer l = new En(new Listener() {

        @Override
        public void comment(String comment, Integer line) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void tag(String tag, Integer line) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void feature(String keyword, String name, String description, Integer line) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void background(String keyword, String name, String description, Integer line) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void scenario(String keyword, String name, String description, Integer line) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void scenarioOutline(String keyword, String name, String description, Integer line) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void examples(String keyword, String name, String description, Integer line) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void step(String keyword, String name, Integer line) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void row(List<String> cells, Integer line) {
            rows.add(new DataTableRow(NO_COMMENTS, cells, line));
        }

        @Override
        public void docString(String contentType, String string, Integer line) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void eof() {
        }
    });
    l.scan(source);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    return new DataTable(rows, new TableConverter(new LocalizedXStreams(classLoader).get(Locale.US), parameterInfo));
}
Also used : DataTable(cucumber.api.DataTable) Listener(gherkin.lexer.Listener) ArrayList(java.util.ArrayList) En(gherkin.lexer.En) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) Lexer(gherkin.lexer.Lexer) DataTableRow(gherkin.formatter.model.DataTableRow)

Aggregations

DataTable (cucumber.api.DataTable)1 LocalizedXStreams (cucumber.runtime.xstream.LocalizedXStreams)1 DataTableRow (gherkin.formatter.model.DataTableRow)1 En (gherkin.lexer.En)1 Lexer (gherkin.lexer.Lexer)1 Listener (gherkin.lexer.Listener)1 ArrayList (java.util.ArrayList)1