org.jbehave.core.model
Class ExamplesTable

java.lang.Object
  extended by 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.


Field Summary
static ExamplesTable EMPTY
           
 
Constructor Summary
ExamplesTable(String tableAsString)
           
ExamplesTable(String tableAsString, String headerSeparator, String valueSeparator)
           
ExamplesTable(String tableAsString, String headerSeparator, String valueSeparator, String ignorableSeparator, ParameterConverters parameterConverters)
           
 
Method Summary
 String asString()
           
protected  Map<String,String> createRowMap()
           
 List<String> getHeaders()
           
 String getHeaderSeparator()
           
 Properties getProperties()
           
 Map<String,String> getRow(int row)
           
 Parameters getRowAsParameters(int row)
           
 int getRowCount()
           
 List<Map<String,String>> getRows()
           
 List<Parameters> getRowsAsParameters()
           
 String getValueSeparator()
           
 String toString()
           
 ExamplesTable withDefaults(Parameters defaults)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final ExamplesTable EMPTY
Constructor Detail

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)
Method Detail

createRowMap

protected Map<String,String> createRowMap()

withDefaults

public ExamplesTable withDefaults(Parameters defaults)

getProperties

public Properties getProperties()

getHeaders

public List<String> getHeaders()

getRow

public Map<String,String> getRow(int row)

getRowAsParameters

public Parameters getRowAsParameters(int row)

getRowCount

public int getRowCount()

getRows

public List<Map<String,String>> getRows()

getRowsAsParameters

public List<Parameters> getRowsAsParameters()

getHeaderSeparator

public String getHeaderSeparator()

getValueSeparator

public String getValueSeparator()

asString

public String asString()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003-2011. All Rights Reserved.