Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 "|--".

The separators are also configurable via inlined properties:

     {ignorableSeparator=!--,headerSeparator=!,valueSeparator=!}
     !header 1!header 2! .... !header n!
     !-- A commented row --!
     !value 11!value 12! .... !value 1n!
     ...
     !-- Another commented row --!
     !value m1!value m2! .... !value mn!

By default all column values are trimmed. To avoid trimming the values, use the "trim" inlined property:

     {trim=false}
     | header 1 | header 2 | .... | header n |
     | value 11 | value 12 | .... | value 1n |

The table 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.

The table allows the transformation of its string representation via the "transformer" inlined property:

     {transformer=myTransformerName}
     |header 1|header 2| .... |header n|
     |value 11|value 12| .... |value 1n|
     ...
     |value m1|value m2| .... |value mn|

The transformer needs to be registered by name via the `TableTransformers.useTransformer(String, TableTransformer)`. A few transformers are already registered by default in `TableTransformers`.

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.

The parsing code assumes that the number of columns for data rows is the same as in the header, if a row has less fields, the remaining are filled with empty values, if it has more, the fields are ignored.

Nested Class Summary
`static class` | `ExamplesTable.RowNotFound`

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)`
`ExamplesTable(String tableAsString, String headerSeparator, String valueSeparator, String ignorableSeparator, ParameterConverters parameterConverters, TableTransformers tableTransformers)`

Method Summary
`String` | `asString()`
`List<String>` | `getHeaders()`
`String` | `getHeaderSeparator()`
`Properties` | `getProperties()`
`Map<String,String>` | `getRow(int row)`
`Parameters` | `getRowAsParameters(int row)`
`Parameters` | `getRowAsParameters(int row, boolean replaceNamedParameters)`
`int` | `getRowCount()`
`List<Map<String,String>>` | `getRows()`
`List<Parameters>` | `getRowsAsParameters()`
`List<Parameters>` | `getRowsAsParameters(boolean replaceNamedParameters)`
`String` | `getValueSeparator()`
`void` | `outputTo(PrintStream output)`
`String` | `toString()`
`ExamplesTable` | `withDefaults(Parameters defaults)`
`ExamplesTable` | `withNamedParameters(Map<String,String> namedParameters)`
`ExamplesTable` | `withRows(List<Map<String,String>> values)`
`ExamplesTable` | `withRowValues(int row, Map<String,String> values)`

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)

### ExamplesTable

    public ExamplesTable(String tableAsString,
                         String headerSeparator,
                         String valueSeparator,
                         String ignorableSeparator,
                         ParameterConverters parameterConverters,
                         TableTransformers tableTransformers)

Method Detail

### 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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2013. All Rights Reserved.