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.steps
Class ParameterConverters

    java.lang.Object
      org.jbehave.core.steps.ParameterConverters

    public class ParameterConverters

extends Object

Facade responsible for converting parameter values to Java objects. It allows the registration of several `ParameterConverters.ParameterConverter` instances, and the first one that is found to matches the appropriate parameter type is used.

Converters for several Java types are provided out-of-the-box:

- `NumberConverter`
- `NumberListConverter`
- `StringListConverter`
- `DateConverter`
- `ExamplesTableConverter`
- `MethodReturningConverter`

Nested Class Summary
`static class` | `ParameterConverters.BooleanConverter`
`static class` | `ParameterConverters.BooleanListConverter`
`static class` | `ParameterConverters.DateConverter` Parses value to a `Date` using an injectable `DateFormat` (defaults to new SimpleDateFormat("dd/MM/yyyy"))
`static class` | `ParameterConverters.EnumConverter` Parses value to any `Enum`
`static class` | `ParameterConverters.EnumListConverter` Parses value to list of the same `Enum`, using an injectable value separator (defaults to ",") and trimming each element of the list.
`static class` | `ParameterConverters.ExamplesTableConverter` Converts value to `ExamplesTable` using a `ExamplesTableFactory`.
`static class` | `ParameterConverters.MethodReturningConverter` Invokes method on instance to return value.
`static class` | `ParameterConverters.NumberConverter` Converts values to numbers, supporting any subclass of `Number` (including generic Number type), and it unboxed counterpart, using a `NumberFormat` to parse to a `Number` and to convert it to a specific number type: Byte, byte: `Number.byteValue()` Short, short: `Number.shortValue()` Integer, int: `Number.intValue()` Float, float: `Number.floatValue()` Long, long: `Number.longValue()` Double, double: `Number.doubleValue()` BigInteger: `BigInteger#valueOf(Long)` BigDecimal: `BigDecimal#valueOf(Double)` If no number format is provided, it defaults to `NumberFormat#getInstance(Locale.ENGLISH)`.
`static class` | `ParameterConverters.NumberListConverter` Converts value to list of numbers.
`static interface` | `ParameterConverters.ParameterConverter`
`static class` | `ParameterConverters.ParameterConvertionFailed`
`static class` | `ParameterConverters.StringListConverter` Converts value to list of String.

Field Summary
`static String` | `DEFAULT_LIST_SEPARATOR`
`static Locale` | `DEFAULT_NUMBER_FORMAT_LOCAL`
`static StepMonitor` | `DEFAULT_STEP_MONITOR`
`static boolean` | `DEFAULT_THREAD_SAFETY`

Constructor Summary
`ParameterConverters()` Creates a non-thread-safe instance of ParameterConverters using default dependencies, a SilentStepMonitor, English as Locale and "," as list separator.
`ParameterConverters(boolean threadSafe)` Create a ParameterConverters with given thread-safety
`ParameterConverters(StepMonitor monitor)` Creates a ParameterConverters using given StepMonitor
`ParameterConverters(StepMonitor monitor, Locale locale, String listSeparator, boolean threadSafe)` Creates a ParameterConverters for the given StepMonitor, Locale, list separator and thread-safety.

Method Summary
`ParameterConverters` | `addConverters(List<ParameterConverters.ParameterConverter> converters)`
`ParameterConverters` | `addConverters(ParameterConverters.ParameterConverter... converters)`
`Object` | `convert(String value, Type type)`
`protected ParameterConverters.ParameterConverter[]` | `defaultConverters(Locale locale, String listSeparator)`
`ParameterConverters` | `newInstanceAdding(ParameterConverters.ParameterConverter converter)`
`static List<String>` | `trim(List<String> values)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_STEP_MONITOR

    public static final StepMonitor DEFAULT_STEP_MONITOR

### DEFAULT_NUMBER_FORMAT_LOCAL

    public static final Locale DEFAULT_NUMBER_FORMAT_LOCAL

### DEFAULT_LIST_SEPARATOR

    public static final String DEFAULT_LIST_SEPARATOR

See Also:
  Constant Field Values

### DEFAULT_THREAD_SAFETY

    public static final boolean DEFAULT_THREAD_SAFETY

See Also:
  Constant Field Values

Constructor Detail

### ParameterConverters

    public ParameterConverters()

  Creates a non-thread-safe instance of ParameterConverters using default dependencies, a SilentStepMonitor, English as Locale and "," as list separator.

### ParameterConverters

    public ParameterConverters(StepMonitor monitor)

  Creates a ParameterConverters using given StepMonitor

  Parameters:
    `monitor` - the StepMonitor to use

### ParameterConverters

    public ParameterConverters(boolean threadSafe)

  Create a ParameterConverters with given thread-safety

  Parameters:
    `threadSafe` - the boolean flag to determine if access to `ParameterConverters.ParameterConverter` should be thread-safe

### ParameterConverters

    public ParameterConverters(StepMonitor monitor,
                               Locale locale,
                               String listSeparator,
                               boolean threadSafe)

  Creates a ParameterConverters for the given StepMonitor, Locale, list separator and thread-safety. When selecting a listSeparator, please make sure that this character doesn't have a special meaning in your Locale (for instance "," is used as decimal separator in some Locale)

  Parameters:
    `monitor` - the StepMonitor reporting the conversions
    `locale` - the Locale to use when reading numbers
    `listSeparator` - the String to use as list separator
    `threadSafe` - the boolean flag to determine if modification of `ParameterConverters.ParameterConverter` should be thread-safe

Method Detail

### defaultConverters

    protected ParameterConverters.ParameterConverter[] defaultConverters(Locale locale,
                                                                         String listSeparator)

### addConverters

    public ParameterConverters addConverters(ParameterConverters.ParameterConverter... converters)

### addConverters

    public ParameterConverters addConverters(List<ParameterConverters.ParameterConverter> converters)

### convert

    public Object convert(String value,
                          Type type)

### newInstanceAdding

    public ParameterConverters newInstanceAdding(ParameterConverters.ParameterConverter converter)

### trim

    public static List<String> trim(List<String> values)

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.