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
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classParses value to aDateusing an injectableDateFormat(defaults to new SimpleDateFormat("dd/MM/yyyy"))static classParses value to anyEnumstatic classParses value to list of the sameEnum, using an injectable value separator (defaults to ",") and trimming each element of the list.static classConverts value toExamplesTableusing aExamplesTableFactory.static classConverts ExamplesTable to list of parameters, mapped to annotated custom types.static classAnParameterConverters.EnumConverterallowing stories prose to be more natural.static classstatic classstatic classstatic classstatic classInvokes method on instance to return value.static classConverts values to numbers, supporting any subclass ofNumber(including generic Number type), and it unboxed counterpart, using aNumberFormatto parse to aNumberand 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 classConverts value to list of numbers.static classstatic interfaceA parameter converter for generic type of source input and target output.static classstatic classConverts value to list of String. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Localestatic final StepMonitorstatic final boolean -
Constructor Summary
ConstructorsConstructorDescriptionCreates 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.ParameterConvertershould 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.ParameterConvertershould 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.ParameterConvertershould 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.ParameterConvertershould 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
-