T
- The type to which values are converted.public class StringToNumberConverter<T extends Number> extends org.eclipse.core.internal.databinding.validation.NumberFormatConverter<Object,T>
NumberFormat.parse(...)
.
This class is thread safe.
Note that this class does not have precise type parameters because it
manually handles argument type mismatches and throws
IllegalArgumentException
.
The first type parameter of NumberFormatConverter
is set to
Object
to preserve backwards compability, but the argument is meant
to always be a String
.Modifier and Type | Method and Description |
---|---|
T |
convert(Object fromObject)
Converts the provided
fromObject to the requested
to type . |
static StringToNumberConverter<BigDecimal> |
toBigDecimal() |
static StringToNumberConverter<BigDecimal> |
toBigDecimal(com.ibm.icu.text.NumberFormat numberFormat) |
static StringToNumberConverter<BigInteger> |
toBigInteger() |
static StringToNumberConverter<BigInteger> |
toBigInteger(com.ibm.icu.text.NumberFormat numberFormat) |
static StringToNumberConverter<Byte> |
toByte(boolean primitive) |
static StringToNumberConverter<Byte> |
toByte(com.ibm.icu.text.NumberFormat numberFormat,
boolean primitive) |
static StringToNumberConverter<Double> |
toDouble(boolean primitive) |
static StringToNumberConverter<Double> |
toDouble(com.ibm.icu.text.NumberFormat numberFormat,
boolean primitive) |
static StringToNumberConverter<Float> |
toFloat(boolean primitive) |
static StringToNumberConverter<Float> |
toFloat(com.ibm.icu.text.NumberFormat numberFormat,
boolean primitive) |
static StringToNumberConverter<Integer> |
toInteger(boolean primitive) |
static StringToNumberConverter<Integer> |
toInteger(com.ibm.icu.text.NumberFormat numberFormat,
boolean primitive) |
static StringToNumberConverter<Long> |
toLong(boolean primitive) |
static StringToNumberConverter<Long> |
toLong(com.ibm.icu.text.NumberFormat numberFormat,
boolean primitive) |
static StringToNumberConverter<Short> |
toShort(boolean primitive) |
static StringToNumberConverter<Short> |
toShort(com.ibm.icu.text.NumberFormat numberFormat,
boolean primitive) |
getFromType, getToType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
create
public T convert(Object fromObject)
fromObject
to the requested
to type
.fromObject
- the object to convert, of type IConverter.getFromType()
IConverter.getToType()
IllegalArgumentException
- if the value isn't in the format required by the NumberFormat
or the value is out of range for the to
type
.IllegalArgumentException
- if conversion was not possibleIConverter.convert(java.lang.Object)
public static StringToNumberConverter<Integer> toInteger(boolean primitive)
primitive
- true
if the convert to type is an intpublic static StringToNumberConverter<Integer> toInteger(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)
numberFormat
- primitive
- public static StringToNumberConverter<Double> toDouble(boolean primitive)
primitive
- true
if the convert to type is a doublepublic static StringToNumberConverter<Double> toDouble(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)
numberFormat
- primitive
- public static StringToNumberConverter<Long> toLong(boolean primitive)
primitive
- true
if the convert to type is a longpublic static StringToNumberConverter<Long> toLong(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)
numberFormat
- primitive
- public static StringToNumberConverter<Float> toFloat(boolean primitive)
primitive
- true
if the convert to type is a floatpublic static StringToNumberConverter<Float> toFloat(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)
numberFormat
- primitive
- public static StringToNumberConverter<BigInteger> toBigInteger()
public static StringToNumberConverter<BigInteger> toBigInteger(com.ibm.icu.text.NumberFormat numberFormat)
numberFormat
- public static StringToNumberConverter<BigDecimal> toBigDecimal()
public static StringToNumberConverter<BigDecimal> toBigDecimal(com.ibm.icu.text.NumberFormat numberFormat)
numberFormat
- public static StringToNumberConverter<Short> toShort(boolean primitive)
primitive
- true
if the convert to type is a shortpublic static StringToNumberConverter<Short> toShort(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)
numberFormat
- primitive
- public static StringToNumberConverter<Byte> toByte(boolean primitive)
primitive
- true
if the convert to type is a bytepublic static StringToNumberConverter<Byte> toByte(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)
numberFormat
- primitive
-
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.