|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jbehave.core.steps.ParameterConverters
public class 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:
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 |
---|
public static final StepMonitor DEFAULT_STEP_MONITOR
public static final Locale DEFAULT_NUMBER_FORMAT_LOCAL
public static final String DEFAULT_LIST_SEPARATOR
public static final boolean DEFAULT_THREAD_SAFETY
Constructor Detail |
---|
public ParameterConverters()
public ParameterConverters(StepMonitor monitor)
monitor
- the StepMonitor to usepublic ParameterConverters(boolean threadSafe)
threadSafe
- the boolean flag to determine if access to ParameterConverters.ParameterConverter
should be thread-safepublic ParameterConverters(StepMonitor monitor, Locale locale, String listSeparator, boolean threadSafe)
monitor
- the StepMonitor reporting the conversionslocale
- the Locale to use when reading numberslistSeparator
- the String to use as list separatorthreadSafe
- the boolean flag to determine if modification of ParameterConverters.ParameterConverter
should be thread-safeMethod Detail |
---|
protected ParameterConverters.ParameterConverter[] defaultConverters(Locale locale, String listSeparator)
public ParameterConverters addConverters(ParameterConverters.ParameterConverter... converters)
public ParameterConverters addConverters(List<ParameterConverters.ParameterConverter> converters)
public Object convert(String value, Type type)
public ParameterConverters newInstanceAdding(ParameterConverters.ParameterConverter converter)
public static List<String> trim(List<String> values)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |