org.eclipse.core.databinding.conversion

## Class StringToNumberConverter

- java.lang.Object
- - org.eclipse.core.databinding.conversion.Converter
  - - org.eclipse.core.internal.databinding.validation.NumberFormatConverter
    - - org.eclipse.core.databinding.conversion.StringToNumberConverter

All Implemented Interfaces:
  IConverter

    public class StringToNumberConverter
    extends org.eclipse.core.internal.databinding.validation.NumberFormatConverter

Converts a String to a Number using `NumberFormat.parse(...)`. This class is thread safe.

Since:
  1.0

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`Object` `convert(Object fromObject)` Converts the provided `fromObject` to the requested `to type`.
`static StringToNumberConverter` `toBigDecimal()`
`static StringToNumberConverter` `toBigDecimal(com.ibm.icu.text.NumberFormat numberFormat)`
`static StringToNumberConverter` `toBigInteger()`
`static StringToNumberConverter` `toBigInteger(com.ibm.icu.text.NumberFormat numberFormat)`
`static StringToNumberConverter` `toByte(boolean primitive)`
`static StringToNumberConverter` `toByte(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)`
`static StringToNumberConverter` `toDouble(boolean primitive)`
`static StringToNumberConverter` `toDouble(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)`
`static StringToNumberConverter` `toFloat(boolean primitive)`
`static StringToNumberConverter` `toFloat(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)`
`static StringToNumberConverter` `toInteger(boolean primitive)`
`static StringToNumberConverter` `toInteger(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)`
`static StringToNumberConverter` `toLong(boolean primitive)`
`static StringToNumberConverter` `toLong(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)`
`static StringToNumberConverter` `toShort(boolean primitive)`
`static StringToNumberConverter` `toShort(com.ibm.icu.text.NumberFormat numberFormat, boolean primitive)`

### Methods inherited from class org.eclipse.core.databinding.conversion.Converter

`getFromType, getToType`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.eclipse.core.databinding.conversion.IConverter

`create`

### Method Detail

#### convert

    public Object convert(Object fromObject)

Converts the provided `fromObject` to the requested `to type`.

Parameters:
  `fromObject` - the object to convert, of type `IConverter.getFromType()`
Returns:
  the converted object, of type `IConverter.getToType()`
Throws:
  `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 possible
See Also:
  `IConverter.convert(java.lang.Object)`

#### toInteger

    public static StringToNumberConverter toInteger(boolean primitive)

Parameters:
  `primitive` - `true` if the convert to type is an int
Returns:
  to Integer converter for the default locale

#### toInteger

    public static StringToNumberConverter toInteger(com.ibm.icu.text.NumberFormat numberFormat,
                                                    boolean primitive)

Parameters:
  `numberFormat` -
  `primitive` -
Returns:
  to Integer converter with the provided numberFormat

#### toDouble

    public static StringToNumberConverter toDouble(boolean primitive)

Parameters:
  `primitive` - `true` if the convert to type is a double
Returns:
  to Double converter for the default locale

#### toDouble

    public static StringToNumberConverter toDouble(com.ibm.icu.text.NumberFormat numberFormat,
                                                   boolean primitive)

Parameters:
  `numberFormat` -
  `primitive` -
Returns:
  to Double converter with the provided numberFormat

#### toLong

    public static StringToNumberConverter toLong(boolean primitive)

Parameters:
  `primitive` - `true` if the convert to type is a long
Returns:
  to Long converter for the default locale

#### toLong

    public static StringToNumberConverter toLong(com.ibm.icu.text.NumberFormat numberFormat,
                                                 boolean primitive)

Parameters:
  `numberFormat` -
  `primitive` -
Returns:
  to Long converter with the provided numberFormat

#### toFloat

    public static StringToNumberConverter toFloat(boolean primitive)

Parameters:
  `primitive` - `true` if the convert to type is a float
Returns:
  to Float converter for the default locale

#### toFloat

    public static StringToNumberConverter toFloat(com.ibm.icu.text.NumberFormat numberFormat,
                                                  boolean primitive)

Parameters:
  `numberFormat` -
  `primitive` -
Returns:
  to Float converter with the provided numberFormat

#### toBigInteger

    public static StringToNumberConverter toBigInteger()

Returns:
  to BigInteger converter for the default locale

#### toBigInteger

    public static StringToNumberConverter toBigInteger(com.ibm.icu.text.NumberFormat numberFormat)

Parameters:
  `numberFormat` -
Returns:
  to BigInteger converter with the provided numberFormat

#### toBigDecimal

    public static StringToNumberConverter toBigDecimal()

Returns:
  to BigDecimal converter for the default locale
Since:
  1.2

#### toBigDecimal

    public static StringToNumberConverter toBigDecimal(com.ibm.icu.text.NumberFormat numberFormat)

Parameters:
  `numberFormat` -
Returns:
  to BigDecimal converter with the provided numberFormat
Since:
  1.2

#### toShort

    public static StringToNumberConverter toShort(boolean primitive)

Parameters:
  `primitive` - `true` if the convert to type is a short
Returns:
  to Short converter for the default locale
Since:
  1.2

#### toShort

    public static StringToNumberConverter toShort(com.ibm.icu.text.NumberFormat numberFormat,
                                                  boolean primitive)

Parameters:
  `numberFormat` -
  `primitive` -
Returns:
  to Short converter with the provided numberFormat
Since:
  1.2

#### toByte

    public static StringToNumberConverter toByte(boolean primitive)

Parameters:
  `primitive` - `true` if the convert to type is a byte
Returns:
  to Byte converter for the default locale
Since:
  1.2

#### toByte

    public static StringToNumberConverter toByte(com.ibm.icu.text.NumberFormat numberFormat,
                                                 boolean primitive)

Parameters:
  `numberFormat` -
  `primitive` -
Returns:
  to Byte converter with the provided numberFormat
Since:
  1.2