The fml
package contains the base interface, factory class and
result classes for creating and executing formulas in an MJ application. Formulas
extend Spring Expression Language (SpEL) to support expressions
similar to those used in @CHG
and @ART
.
Classes and Interfaces |
DecimalFormulaResult |
Decimal formula result. |
FloatFormulaResult |
Floating point formula result. |
IFormula |
Defines a formula, expressed as a variant of the Spring Expression Language (SpEL),
that combines MJ variables, functions and literals with standard operators like
+ (addition) and * (multiplication).
|
IntegerFormulaResult |
Integer formula result. |
MJFormulaContext |
Abstract base class for formula contexts, provides MJ variables and other evaluation context to
a formula.
|
MJFormulaFactory |
Abstract base class for creating formulas, all formula factory classes that create
concrete formula implementations derive from this class.
|
MJFormulaResult |
Abstract base formula result class. |
Decimal formula result.
Constructors |
Public ctor for initializing an instance of this class.
- Parameters:
aResultVar - decimal that is the result of a formula evaluation.
public DecimalFormulaResult(java.math.BigDecimal aResultVar)
|
Methods |
public java.math.BigDecimal result()
|
Floating point formula result.
Constructors |
Public ctor for initializing an instance of this class.
- Parameters:
aResultVar - floating point number that is the result of a formula evaluation.
public FloatFormulaResult(java.lang.Double aResultVar)
|
Methods |
public java.lang.Double result()
|
Defines a formula, expressed as a variant of the Spring Expression Language (SpEL),
that combines MJ variables, functions and literals with standard operators like
+
(addition) and *
(multiplication).
Assuming tax
and amt
are MJ variables, the formula below
evaluates to the 10% discount on an taxed purchase.
(amt + tax)* 0.10
- Parameters:
<T>
- the expected return type of the formula upon evaluation (e.g., BigDecimal
,
Integer
, Calendar
).
<C>
- type of formula context expected by formula.
public interface com.arsi.mj.fml.IFormula
Methods |
Parse and evaluate a formula. Options specified during formula creation (see
MJFormulaFactory ) are in effect.
- Parameters:
aFormula - formula expression.
aContext - provides MJ variables and other evaluation context.
- Throws:
MJExecuteException - if an error occurs during formula evaluation.
- Returns:
- result of formula, coerced to type T.
public com.arsi.mj.fml.MJFormulaResult evaluate(java.lang.String aFormula, com.arsi.mj.fml.MJFormulaContext aContext) throws com.arsi.mj.MJExecuteException
|
Integer formula result.
Constructors |
Public ctor for initializing an instance of this class.
- Parameters:
aResultVar - integer that is the result of a formula evaluation.
public IntegerFormulaResult(java.lang.Long aResultVar)
|
Methods |
public java.lang.Long result()
|
Abstract base class for formula contexts, provides MJ variables and other evaluation context to
a formula.
Treat this class as "thread-hostile"; instances should be created, used and discarded by a
single thread at a time.
public abstract class com.arsi.mj.fml.MJFormulaContext
extends java.lang.Object
Methods |
Retrieves an array variable by name, using the provided variable as the source of the name.
The logic for dereferencing takes into account any variable renaming that occurred during the
run translation process.
- Parameters:
aVariable - the name source to dereference
anIndex - the index of the array element
- Returns:
- the obtained variable, or null if none is found
public java.lang.Object elemByName(com.arsi.mj.variable.MJVariable aVariable, int anIndex)
|
Retrieves an array variable by name, using the provided variable as the source of the name.
The logic for dereferencing takes into account any variable renaming that occurred during the
run translation process.
- Parameters:
aVariable - the name source to dereference
anIndexVariable - the index source to dereference
- Returns:
- the obtained variable, or null if none is found
public java.lang.Object elemByName(com.arsi.mj.variable.MJVariable aVariable, com.arsi.mj.variable.MJVariable anIndexVariable)
|
Retrieves an array variable by number, using the provided variable as the source of the number.
The logic for dereferencing takes into account any variable renaming that occurred during the
run translation process.
- Parameters:
aVariable - the name source to dereference
anIndex - the index of the array element
- Returns:
- the obtained variable, or null if none is found
public java.lang.Object elemByNum(com.arsi.mj.variable.MJVariable aVariable, int anIndex)
|
Retrieves an array variable by number, using the provided variable as the source of the number.
The logic for dereferencing takes into account any variable renaming that occurred during the
run translation process.
- Parameters:
aVariable - the name source to dereference
anIndexVariable - the index source to dereference
- Returns:
- the obtained variable, or null if none is found
public java.lang.Object elemByNum(com.arsi.mj.variable.MJVariable aVariable, com.arsi.mj.variable.MJVariable anIndexVariable)
|
Determines the namespace corresponding to the provided scope.
- Parameters:
aScope - the scope for which the namespace will be retrieved
- Returns:
- the matching namespace
public com.arsi.mj.variable.MJVariableNamespace getNamespace(com.arsi.mj.VariableScope aScope)
|
Retrieves a variable by name, using the provided variable as the source of the name. The logic
for dereferencing takes into account any variable renaming that occurred during the run
translation process.
- Parameters:
aVariable - the name source to dereference
- Returns:
- the obtained variable, or null if none is found
public java.lang.Object varByName(com.arsi.mj.variable.MJVariable aVariable)
|
Retrieves a variable by number, using the provided variable as the source of the number. The
logic for dereferencing takes into account any variable renaming that occurred during the run
translation process.
- Parameters:
aVariable - the number source to dereference
- Returns:
- the obtained variable, or null if none is found
public java.lang.Object varByNum(com.arsi.mj.variable.MJVariable aVariable)
|
Abstract base class for creating formulas, all formula factory classes that create
concrete formula implementations derive from this class.
Concrete formula factory classes may change the default options (
EVALUATE_JAVA_TYPE
and
RETURN_JAVA_TYPE
) assumed by the
create
method, but should
document the changed defaults.
public abstract class com.arsi.mj.fml.MJFormulaFactory
extends java.lang.Object
Constructors |
public MJFormulaFactory()
|
Methods |
Create formula where specified options are in effect during evaluation
that returns a decimal.
- Parameters:
someOptions - options that influence formula evaluation. If none specified, defaults to
EVALUATE_JAVA_TYPE and RETURN_JAVA_TYPE .
- Returns:
- formula that returns an decimal as a result.
public abstract com.arsi.mj.fml.IFormula createDecimalFormula(java.util.EnumSet someOptions)
|
Create formula where specified options are in effect during evaluation
that returns a floating point number.
- Parameters:
someOptions - options that influence formula evaluation. If none specified, defaults to
EVALUATE_JAVA_TYPE and RETURN_JAVA_TYPE .
- Returns:
- formula that returns a floating point number as a result.
public abstract com.arsi.mj.fml.IFormula createFloatFormula(java.util.EnumSet someOptions)
|
Create formula where specified options are in effect during evaluation
that returns an opaque object.
- Parameters:
someOptions - options that influence formula evaluation. If none specified, defaults to
EVALUATE_JAVA_TYPE and RETURN_JAVA_TYPE .
- Returns:
- formula that returns an MJ variable as a result.
public abstract com.arsi.mj.fml.IFormula createFormula(java.util.EnumSet someOptions)
|
Create formula where specified options are in effect during evaluation
that returns an integer.
- Parameters:
someOptions - options that influence formula evaluation. If none specified, defaults to
EVALUATE_JAVA_TYPE and RETURN_JAVA_TYPE .
- Returns:
- formula that returns an integer as a result; if present, the
RETURN_EXACT option reports an error if the fractional part
of the formula result would be lost when returning an integer.
public abstract com.arsi.mj.fml.IFormula createIntegerFormula(java.util.EnumSet someOptions)
|
Abstract base formula result class.
- Parameters:
<T>
- expected return type of formula (e.g., BigDecimal
, Integer
,
Calendar
).
public abstract class com.arsi.mj.fml.MJFormulaResult
extends java.lang.Object
Fields |
Result of formula evaluation. protected final java.lang.Object resultVar
|
Constructors |
Public ctor for initializing an instance of this class.
- Parameters:
aResultVar - result of a formula evaluation.
protected MJFormulaResult(java.lang.Object aResultVar)
|
Methods |
Get result of formula evaluation.
- Returns:
- result of formula evaluation.
public abstract java.lang.Object result()
|