Package org.jbehave.core.steps
Class ParameterConverters
java.lang.Object
org.jbehave.core.steps.ParameterConverters
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
Parses value to aDate
using an injectableDateFormat
(defaults to new SimpleDateFormat("dd/MM/yyyy"))static class
Parses value to anyEnum
static class
Parses value to list of the sameEnum
, using an injectable value separator (defaults to ",") and trimming each element of the list.static class
Converts value toExamplesTable
using aExamplesTableFactory
.static class
Converts ExamplesTable to list of parameters, mapped to annotated custom types.static class
AnParameterConverters.EnumConverter
allowing stories prose to be more natural.static class
static class
static class
static class
static class
Invokes method on instance to return value.static class
Converts values to numbers, supporting any subclass ofNumber
(including generic Number type), and it unboxed counterpart, using aNumberFormat
to parse to aNumber
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 toNumberFormat.getInstance()
.static class
Converts value to list of numbers.static class
static interface
A parameter converter for generic type of source input and target output.static class
static class
Converts value to list of String. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final Locale
static final StepMonitor
static final boolean
-
Constructor Summary
ConstructorDescriptionCreates a ParameterConverters using the default resource loader and table transformers, a SilentStepMonitor, English as Locale and "," as collection separator.ParameterConverters
(ResourceLoader resourceLoader) Creates a ParameterConverters of ParameterConverters using the given resource loader.ParameterConverters
(ResourceLoader resourceLoader, TableTransformers tableTransformers) Creates a ParameterConverters given resource loader and table transformers.ParameterConverters
(ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers, boolean threadSafe) Create a ParameterConverters with given thread-safetyParameterConverters
(TableTransformers tableTransformers) Creates a ParameterConverters using the given table transformers.ParameterConverters
(StepMonitor monitor, Keywords keywords, ResourceLoader resourceLoader, ParameterControls parameterControls, TableParsers tableParsers, TableTransformers tableTransformers, Locale locale, String collectionSeparator, boolean threadSafe) Creates a ParameterConverters for the given StepMonitor, keywords, Locale, list separator and thread-safety.ParameterConverters
(StepMonitor monitor, Keywords keywords, ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers) Creates a ParameterConverters using given StepMonitor, keywords, resource loader and table transformers.ParameterConverters
(StepMonitor monitor, Keywords keywords, ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers, Locale locale, String collectionSeparator, boolean threadSafe) Creates a ParameterConverters for the given StepMonitor, keywords, Locale, list separator and thread-safety.ParameterConverters
(StepMonitor monitor, ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers) Creates a ParameterConverters using given StepMonitor, resource loader and table transformers.ParameterConverters
(StepMonitor monitor, ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers, Locale locale, String collectionSeparator, boolean threadSafe) Creates a ParameterConverters for the given StepMonitor, Locale, list separator and thread-safety. -
Method Summary
Modifier and TypeMethodDescriptionaddConverters
(List<? extends ParameterConverters.ParameterConverter> converters) addConverters
(ParameterConverters.ParameterConverter... converters) protected ParameterConverters.ParameterConverter[]
defaultConverters
(Keywords keywords, ResourceLoader resourceLoader, ParameterControls parameterControls, TableParsers tableParsers, TableTransformers tableTransformers, Locale locale, String collectionSeparator)
-
Field Details
-
DEFAULT_STEP_MONITOR
-
DEFAULT_NUMBER_FORMAT_LOCAL
-
DEFAULT_COLLECTION_SEPARATOR
- See Also:
-
DEFAULT_THREAD_SAFETY
public static final boolean DEFAULT_THREAD_SAFETY- See Also:
-
-
Constructor Details
-
ParameterConverters
public ParameterConverters()Creates a ParameterConverters using the default resource loader and table transformers, a SilentStepMonitor, English as Locale and "," as collection separator. -
ParameterConverters
Creates a ParameterConverters using the given table transformers.- Parameters:
tableTransformers
- the table transformers
-
ParameterConverters
Creates a ParameterConverters of ParameterConverters using the given resource loader.- Parameters:
resourceLoader
- the resource loader
-
ParameterConverters
Creates a ParameterConverters given resource loader and table transformers.- Parameters:
resourceLoader
- the resource loadertableTransformers
- the table transformers
-
ParameterConverters
public ParameterConverters(StepMonitor monitor, ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers) Creates a ParameterConverters using given StepMonitor, resource loader and table transformers.- Parameters:
monitor
- the StepMonitor to useresourceLoader
- the resource loaderparameterControls
- the parameter controlstableTransformers
- the table transformers
-
ParameterConverters
public ParameterConverters(StepMonitor monitor, Keywords keywords, ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers) Creates a ParameterConverters using given StepMonitor, keywords, resource loader and table transformers.- Parameters:
monitor
- the StepMonitor to usekeywords
- the keywords to useresourceLoader
- the resource loaderparameterControls
- the parameter controlstableTransformers
- the table transformers
-
ParameterConverters
public ParameterConverters(ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers, boolean threadSafe) Create a ParameterConverters with given thread-safety- Parameters:
resourceLoader
- the resource loaderparameterControls
- the parameter controlstableTransformers
- the table transformersthreadSafe
- the boolean flag to determine if access toParameterConverters.ParameterConverter
should be thread-safe
-
ParameterConverters
public ParameterConverters(StepMonitor monitor, ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers, Locale locale, String collectionSeparator, boolean threadSafe) Creates a ParameterConverters for the given StepMonitor, Locale, list separator and thread-safety. When selecting a collectionSeparator, 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 conversionsresourceLoader
- the resource loaderparameterControls
- the parameter controlstableTransformers
- the table transformerslocale
- the Locale to use when reading numberscollectionSeparator
- the String to use as collection separatorthreadSafe
- the boolean flag to determine if modification ofParameterConverters.ParameterConverter
should be thread-safe
-
ParameterConverters
public ParameterConverters(StepMonitor monitor, Keywords keywords, ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers, Locale locale, String collectionSeparator, boolean threadSafe) Creates a ParameterConverters for the given StepMonitor, keywords, Locale, list separator and thread-safety. When selecting a collectionSeparator, 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 conversionsresourceLoader
- the resource loaderkeywords
- the keywordsparameterControls
- the parameter controlstableTransformers
- the table transformerslocale
- the Locale to use when reading numberscollectionSeparator
- the String to use as collection separatorthreadSafe
- the boolean flag to determine if modification ofParameterConverters.ParameterConverter
should be thread-safe
-
ParameterConverters
public ParameterConverters(StepMonitor monitor, Keywords keywords, ResourceLoader resourceLoader, ParameterControls parameterControls, TableParsers tableParsers, TableTransformers tableTransformers, Locale locale, String collectionSeparator, boolean threadSafe) Creates a ParameterConverters for the given StepMonitor, keywords, Locale, list separator and thread-safety. When selecting a collectionSeparator, 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 conversionsresourceLoader
- the resource loaderkeywords
- the keywordsparameterControls
- the parameter controlstableParsers
- the table parserstableTransformers
- the table transformerslocale
- the Locale to use when reading numberscollectionSeparator
- the String to use as collection separatorthreadSafe
- the boolean flag to determine if modification ofParameterConverters.ParameterConverter
should be thread-safe
-
-
Method Details
-
defaultConverters
protected ParameterConverters.ParameterConverter[] defaultConverters(Keywords keywords, ResourceLoader resourceLoader, ParameterControls parameterControls, TableParsers tableParsers, TableTransformers tableTransformers, Locale locale, String collectionSeparator) -
addConverters
-
addConverters
public ParameterConverters addConverters(List<? extends ParameterConverters.ParameterConverter> converters) -
convert
-
convert
-
newInstanceAdding
-