org.jbehave.core.steps
Class ParameterConverters.NumberConverter
java.lang.Object
org.jbehave.core.steps.ParameterConverters.NumberConverter
- All Implemented Interfaces:
- ParameterConverters.ParameterConverter
- Enclosing class:
- ParameterConverters
public static class ParameterConverters.NumberConverter
- extends java.lang.Object
- implements ParameterConverters.ParameterConverter
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()
.
The localized instance NumberFormat.getInstance(Locale)
can be
used to convert numbers in specific locales.
Method Summary |
boolean |
accept(java.lang.reflect.Type type)
|
java.lang.Object |
convertValue(java.lang.String value,
java.lang.reflect.Type type)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ParameterConverters.NumberConverter
public ParameterConverters.NumberConverter()
ParameterConverters.NumberConverter
public ParameterConverters.NumberConverter(java.text.NumberFormat numberFormat)
accept
public boolean accept(java.lang.reflect.Type type)
- Specified by:
accept
in interface ParameterConverters.ParameterConverter
convertValue
public java.lang.Object convertValue(java.lang.String value,
java.lang.reflect.Type type)
- Specified by:
convertValue
in interface ParameterConverters.ParameterConverter
Copyright © 2003-2010. All Rights Reserved.