org.formulacompiler.compiler
Class FormulaCompiler

java.lang.Object
  extended by org.formulacompiler.runtime.FormulaRuntime
      extended by org.formulacompiler.compiler.FormulaCompiler
Direct Known Subclasses:
SpreadsheetCompiler

public class FormulaCompiler
extends FormulaRuntime

Static class defining factory methods for the various elements of the core AFC compiler. This class is extends by FormulaRuntime which provides factory methods for the run-time-only elements.

Author:
peo

Field Summary
static NumericType BIGDECIMAL_SCALE8
          BigDecimal with a fixed scale of 8 and using BigDecimal.ROUND_HALF_UP.
static NumericType BIGDECIMAL_SCALE9
          BigDecimal with a fixed scale of 9 and using BigDecimal.ROUND_HALF_UP.
static NumericType BIGDECIMAL128
          BigDecimal with the MathContext.DECIMAL128 math context.
static NumericType BIGDECIMAL32
          BigDecimal with the MathContext.DECIMAL32 math context.
static NumericType BIGDECIMAL64
          BigDecimal with the MathContext.DECIMAL64 math context.
static NumericType DEFAULT_NUMERIC_TYPE
          Default type used when no explicit type is specified.
static NumericType DOUBLE
          Default type, consistent with the type used internally by Excel and other spreadsheet applications.
static NumericType LONG
          Unscaled long for fast, strictly integer computations.
static NumericType LONG_SCALE4
          long scaled to 4 decimal places for fast, fixed point computations (similar to the currency type found in Borland Delphi).
static NumericType LONG_SCALE6
          long scaled to 6 decimal places for fast, fixed point computations with sufficient precision for seconds in time values.
 
Fields inherited from class org.formulacompiler.runtime.FormulaRuntime
UNDEFINED_SCALE
 
Constructor Summary
FormulaCompiler()
           
 
Method Summary
static NumericType getNumericType(java.lang.Class _valueType)
          Same as getNumericType(Class, int, int) with an undefined scale and truncating results.
static NumericType getNumericType(java.lang.Class _valueType, int _scale)
          Same as getNumericType(Class, int, int) and truncating results.
static NumericType getNumericType(java.lang.Class _valueType, int _scale, int _roundingMode)
          Returns the numeric type instance with the specified attributes.
static NumericType getNumericType(java.lang.Class _valueType, java.math.MathContext _mathContext)
          Returns the numeric type instance with the specified attributes.
static CallFrame newCallFrame(java.lang.reflect.Method _method, java.lang.Object... _args)
          Constructs a call, possibly the initial call in a chain of calls.
 
Methods inherited from class org.formulacompiler.runtime.FormulaRuntime
loadEngine, loadEngine
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOUBLE

public static final NumericType DOUBLE
Default type, consistent with the type used internally by Excel and other spreadsheet applications.


BIGDECIMAL32

public static final NumericType BIGDECIMAL32
BigDecimal with the MathContext.DECIMAL32 math context.


BIGDECIMAL64

public static final NumericType BIGDECIMAL64
BigDecimal with the MathContext.DECIMAL64 math context.


BIGDECIMAL128

public static final NumericType BIGDECIMAL128
BigDecimal with the MathContext.DECIMAL128 math context.


BIGDECIMAL_SCALE8

public static final NumericType BIGDECIMAL_SCALE8
BigDecimal with a fixed scale of 8 and using BigDecimal.ROUND_HALF_UP.


BIGDECIMAL_SCALE9

public static final NumericType BIGDECIMAL_SCALE9
BigDecimal with a fixed scale of 9 and using BigDecimal.ROUND_HALF_UP. This type has the same precision as DOUBLE for the automated tests.


LONG

public static final NumericType LONG
Unscaled long for fast, strictly integer computations. Support for long might be dropped unless we see real demand.


LONG_SCALE4

public static final NumericType LONG_SCALE4
long scaled to 4 decimal places for fast, fixed point computations (similar to the currency type found in Borland Delphi). Beware: this type has insufficient precision for seconds in time values. Support for long might be dropped unless we see real demand.


LONG_SCALE6

public static final NumericType LONG_SCALE6
long scaled to 6 decimal places for fast, fixed point computations with sufficient precision for seconds in time values. Support for long might be dropped unless we see real demand.


DEFAULT_NUMERIC_TYPE

public static final NumericType DEFAULT_NUMERIC_TYPE
Default type used when no explicit type is specified.

Constructor Detail

FormulaCompiler

public FormulaCompiler()
Method Detail

newCallFrame

public static CallFrame newCallFrame(java.lang.reflect.Method _method,
                                     java.lang.Object... _args)
Constructs a call, possibly the initial call in a chain of calls.

Parameters:
_method - is the method to be called.
_args - is the list of arguments for the method's parameters.

getNumericType

public static NumericType getNumericType(java.lang.Class _valueType,
                                         int _scale,
                                         int _roundingMode)
Returns the numeric type instance with the specified attributes.

Parameters:
_valueType - must be either Double.TYPE, Long.TYPE, or BigDecimal.class.
_scale - defines the number of decimal places after the point to which the base type is scaled. Only supported for Long and BigDecimal.
_roundingMode - defines the rounding mode to use when establishing the scale. Only supported for BigDecimal.
Returns:
the instance.

getNumericType

public static NumericType getNumericType(java.lang.Class _valueType)
Same as getNumericType(Class, int, int) with an undefined scale and truncating results.


getNumericType

public static NumericType getNumericType(java.lang.Class _valueType,
                                         int _scale)
Same as getNumericType(Class, int, int) and truncating results.


getNumericType

public static NumericType getNumericType(java.lang.Class _valueType,
                                         java.math.MathContext _mathContext)
Returns the numeric type instance with the specified attributes.

Parameters:
_valueType - must be BigDecimal.class.
_mathContext - defines the precision and rounding mode used to limit intermediate and final results.
Returns:
the instance.