org.formulacompiler.compiler
Interface NumericType


public interface NumericType

Immutable class representing the type to be used by the numeric computations of generated engines.

This interface is an API only. Do not implement it yourself.

Author:
peo

Nested Class Summary
static interface NumericType.Factory
          Factory interface for ImplementationLocator.getInstance(Class).
 
Field Summary
static int UNDEFINED_SCALE
          For BigDecimal types, indicates that no explicit scaling should be performed by the engine.
static int UNLIMITED_FRACTIONAL_DIGITS
          Indicates no final rounding due to number formats with a maximum number of fractional digits.
 
Method Summary
 java.lang.Number getOne()
          Returns the number 1.
 java.lang.Number getZero()
          Returns the number 0.
 java.math.MathContext mathContext()
          Returns the MathContext to use, or else null.
 int roundingMode()
          Returns the rounding mode.
 int scale()
          Returns the fixed scale, or else UNDEFINED_SCALE.
 java.lang.Number valueOf(java.lang.Number _value)
          Converts a number to this type.
 java.lang.Number valueOf(java.lang.String _value)
          Parses a string into a value using the default environment config.
 java.lang.Number valueOf(java.lang.String _value, Computation.Config _config)
          Parses a string into a value using the given environment config.
 java.lang.String valueToConciseString(java.lang.Number _value)
          Returns the value as a string with no superfluous leading or trailing zeroes and decimal point using the default environment config.
 java.lang.String valueToConciseString(java.lang.Number _value, Computation.Config _config)
          Returns the value as a string with no superfluous leading or trailing zeroes and decimal point using the given environment config.
 java.lang.String valueToString(java.lang.Number _value)
          Returns the value as a string in its canonical representation using the default environment config.
 java.lang.String valueToString(java.lang.Number _value, Computation.Config _config)
          Returns the value as a string in its canonical representation using the given environment config.
 java.lang.Class valueType()
          Returns the Java class of the base type.
 

Field Detail

UNDEFINED_SCALE

static final int UNDEFINED_SCALE
For BigDecimal types, indicates that no explicit scaling should be performed by the engine.

See Also:
Constant Field Values

UNLIMITED_FRACTIONAL_DIGITS

static final int UNLIMITED_FRACTIONAL_DIGITS
Indicates no final rounding due to number formats with a maximum number of fractional digits.

See Also:
Constant Field Values
Method Detail

valueType

java.lang.Class valueType()
Returns the Java class of the base type.


mathContext

java.math.MathContext mathContext()
Returns the MathContext to use, or else null.


scale

int scale()
Returns the fixed scale, or else UNDEFINED_SCALE.


roundingMode

int roundingMode()
Returns the rounding mode.


getZero

java.lang.Number getZero()
Returns the number 0.


getOne

java.lang.Number getOne()
Returns the number 1.


valueOf

java.lang.Number valueOf(java.lang.Number _value)
Converts a number to this type. Null is returned as null.

Returns:
an instance of the corresponding (boxed) Java number type, or null.
See Also:
valueType()

valueOf

java.lang.Number valueOf(java.lang.String _value)
                         throws java.text.ParseException
Parses a string into a value using the default environment config. Null and the empty string return zero (see getZero()).

Returns:
an instance of the corresponding (boxed) Java number type.
Throws:
java.text.ParseException
See Also:
valueOf(String, Computation.Config), valueType()

valueOf

java.lang.Number valueOf(java.lang.String _value,
                         Computation.Config _config)
                         throws java.text.ParseException
Parses a string into a value using the given environment config. Null and the empty string return zero (see getZero()).

Parameters:
_config - determines formatting options; must not be null.
Returns:
an instance of the corresponding (boxed) Java number type.
Throws:
java.text.ParseException
See Also:
valueType()

valueToString

java.lang.String valueToString(java.lang.Number _value)
Returns the value as a string in its canonical representation using the default environment config. Null returns the empty string.

Parameters:
_value - must be an instance of the corresponding (boxed) Java number type, or null.
See Also:
valueToString(Number, Computation.Config), valueType()

valueToString

java.lang.String valueToString(java.lang.Number _value,
                               Computation.Config _config)
Returns the value as a string in its canonical representation using the given environment config. Null returns the empty string.

Parameters:
_value - must be an instance of the corresponding (boxed) Java number type, or null.
_config - determines formatting options; must not be null.
See Also:
valueType()

valueToConciseString

java.lang.String valueToConciseString(java.lang.Number _value)
Returns the value as a string with no superfluous leading or trailing zeroes and decimal point using the default environment config. Null returns the empty string. Uses scientific display the way Excel does.

Parameters:
_value - must be an instance of the corresponding (boxed) Java number type, or null.
See Also:
valueToConciseString(Number, Computation.Config), valueType()

valueToConciseString

java.lang.String valueToConciseString(java.lang.Number _value,
                                      Computation.Config _config)
Returns the value as a string with no superfluous leading or trailing zeroes and decimal point using the given environment config. Null returns the empty string. Uses scientific display the way Excel does.

Parameters:
_value - must be an instance of the corresponding (boxed) Java number type, or null.
_config - determines formatting options; must not be null.
See Also:
valueType()