org.jbehave.core.model
Class ExamplesTable
java.lang.Object
org.jbehave.core.model.ExamplesTable
public class ExamplesTable
- extends Object
Represents a tabular structure that holds rows of example data for parameters
named via the column headers:
|header 1|header 2| .... |header n|
|value 11|value 12| .... |value 1n|
...
|value m1|value m2| .... |value mn|
Different header and value column separators can be specified to replace the
default separator "|":
!!header 1!!header 2!! .... !!header n!!
!value 11!value 12! .... !value 1n!
...
!value m1!value m2| .... !value mn!
Rows starting with an ignorable separator are allowed and ignored:
|header 1|header 2| .... |header n|
|-- A commented row --|
|value 11|value 12| .... |value 1n|
...
|-- Another commented row --|
|value m1|value m2| .... |value mn|
Ignorable separator is configurable and defaults to "|--".
By default all column values are trimmed. To avoid trimming the values:
{trim=false}
| header 1 | header 2 | .... | header n |
| value 11 | value 12 | .... | value 1n |
The table also allows the retrieval of row values as converted parameters.
Use getRowAsParameters(int)
and invoke
Parameters.valueAs(String, Class)
specifying the header and the class
type of the parameter.
Once created, the table row can be modified, via the
withRowValues(int, Map)
method, by specifying the map of row values
to be changed.
A table can also be created by providing the entire data content, via the
#withRows(List
method.
EMPTY
public static final ExamplesTable EMPTY
ExamplesTable
public ExamplesTable(String tableAsString)
ExamplesTable
public ExamplesTable(String tableAsString,
String headerSeparator,
String valueSeparator)
ExamplesTable
public ExamplesTable(String tableAsString,
String headerSeparator,
String valueSeparator,
String ignorableSeparator,
ParameterConverters parameterConverters)
createRowMap
protected Map<String,String> createRowMap()
withDefaults
public ExamplesTable withDefaults(Parameters defaults)
withNamedParameters
public ExamplesTable withNamedParameters(Map<String,String> namedParameters)
withRowValues
public ExamplesTable withRowValues(int row,
Map<String,String> values)
withRows
public ExamplesTable withRows(List<Map<String,String>> values)
getProperties
public Properties getProperties()
getHeaders
public List<String> getHeaders()
getRow
public Map<String,String> getRow(int row)
getRowAsParameters
public Parameters getRowAsParameters(int row)
getRowAsParameters
public Parameters getRowAsParameters(int row,
boolean replaceNamedParameters)
getRowCount
public int getRowCount()
getRows
public List<Map<String,String>> getRows()
getRowsAsParameters
public List<Parameters> getRowsAsParameters()
getRowsAsParameters
public List<Parameters> getRowsAsParameters(boolean replaceNamedParameters)
getHeaderSeparator
public String getHeaderSeparator()
getValueSeparator
public String getValueSeparator()
asString
public String asString()
outputTo
public void outputTo(PrintStream output)
toString
public String toString()
- Overrides:
toString
in class Object
Copyright © 2003-2012. All Rights Reserved.