org.jbehave.core.steps
Class ParameterConverters

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

public class ParameterConverters
extends Object

Facade responsible for converting parameter values to Java objects.

Several converters are provided out-of-the-box:


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.
 
Constructor Summary
ParameterConverters()
          Default Parameters use a SilentStepMonitor, has English as Locale and use "," as list separator.
ParameterConverters(StepMonitor monitor)
          Default ParameterConverters have English as Locale and use "," as list separator.
ParameterConverters(StepMonitor monitor, Locale locale, String listSeparator)
          Creates an ParameterConvertors for a given Locale.
 
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)
           
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
 

Constructor Detail

ParameterConverters

public ParameterConverters()
Default Parameters use a SilentStepMonitor, has English as Locale and use "," as list separator.


ParameterConverters

public ParameterConverters(StepMonitor monitor)
Default ParameterConverters have English as Locale and use "," as list separator.


ParameterConverters

public ParameterConverters(StepMonitor monitor,
                           Locale locale,
                           String listSeparator)
Creates an ParameterConvertors for a given Locale. 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 - Monitor reporting the conversions
locale - The Locale to use when reading numbers
listSeparator - The list separator
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)

trim

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


Copyright © 2003-2011. All Rights Reserved.