Follow the links below to browse sample Javadoc for MJ classes and tools, including the MJ Runtime Library.

 

Package: com.arsi.mj.fml  previous next contents

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.

Class: DecimalFormulaResult   next package

Decimal formula result.
public class com.arsi.mj.fml.DecimalFormulaResult
  extends com.arsi.mj.fml.MJFormulaResult
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()

Class: FloatFormulaResult   previous next package

Floating point formula result.
public class com.arsi.mj.fml.FloatFormulaResult
  extends com.arsi.mj.fml.MJFormulaResult
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()

Interface: IFormula   previous next package

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

Class: IntegerFormulaResult   previous next package

Integer formula result.
public class com.arsi.mj.fml.IntegerFormulaResult
  extends com.arsi.mj.fml.MJFormulaResult
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()

Class: MJFormulaContext   previous next package

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
Inner Class NamedScope
Enumeration of formula name prefix correspondences with the Mapper variable scopes.
public static final class com.arsi.mj.fml.MJFormulaContext.NamedScope
  extends java.lang.Enum
Used to cross-reference environmentally-scoped variables.
public static final com.arsi.mj.fml.MJFormulaContext.NamedScope ENV

Used to cross-reference globally-scoped variables.
public static final com.arsi.mj.fml.MJFormulaContext.NamedScope GLOB

Used to cross-reference locally-scoped variables.
public static final com.arsi.mj.fml.MJFormulaContext.NamedScope LOCAL

Used to cross-reference temporary (formula-only) variables.
public static final com.arsi.mj.fml.MJFormulaContext.NamedScope TEMP

Obtains the named scope corresponding to a variable scope.
Parameters:
aScope - the variable scope to look up
Returns:
the matching named scope, or null if there is no match
public static com.arsi.mj.fml.MJFormulaContext.NamedScope byVariableScope(com.arsi.mj.VariableScope aScope)
public com.arsi.mj.VariableScope getScope()
Determine if the namespace prefix candidate is supported for namespace cross-referencing.
Parameters:
aScopePrefix - the potential prefix to evaluate, e.g., GLOB.
Returns:
true if scope prefix is recognized as supported, false if not.
public static boolean isSupported(java.lang.String aScopePrefix)
public static com.arsi.mj.fml.MJFormulaContext.NamedScope valueOf(java.lang.String name)
public static com.arsi.mj.fml.MJFormulaContext.NamedScope values()
Fields
Environmental variable namespace.
public final com.arsi.mj.variable.MJVariableNamespace envNamespace
Global variable namespace.
public final com.arsi.mj.variable.MJVariableNamespace globalNamespace
Local variable namespace.
public final com.arsi.mj.variable.MJVariableNamespace localNamespace
TEMP variable namespace (temporary variables created during evaluation of multiple formulae).
public final com.arsi.mj.variable.MJVariableNamespace tempNamespace
Initialized variable transformer.
public final com.arsi.mj.maprpt.vidxform.MJVariableIdentifierTransformer variableIdTransformer
Constructors
Restricted ctor for initializing an instance of this class.
Parameters:
aGlobalNS - global variable namespace
aEnvNS - environmental variable namespace
aLocalNS - local variable namespace
aTempNS - temporary variable namespace
aTransformer - variable transformation utility
protected MJFormulaContext(com.arsi.mj.variable.MJVariableNamespace aGlobalNS, com.arsi.mj.variable.MJVariableNamespace aEnvNS, com.arsi.mj.variable.MJVariableNamespace aLocalNS, com.arsi.mj.variable.MJVariableNamespace aTempNS, com.arsi.mj.maprpt.vidxform.MJVariableIdentifierTransformer aTransformer)
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)

Class: MJFormulaFactory   previous next package

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)

Class: MJFormulaResult   previous package

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()