The formula impl
package contains internal classes that configure and
extend Spring Expression Language (SpEL) to support MJ's formula syntax and features.
Class: BinaryOperatorOverloader
next
package
Forces overloading of standard operations for mathematical formulae. This allows preservation of
scale and precision throughout a calculation.
Treat this class as "thread-safe".
- See Also:
- Operation
public class com.arsi.mj.fml.impl.BinaryOperatorOverloader
extends java.lang.Object
implements org.springframework.expression.OperatorOverloader
Constructors |
Ctor for initializing an instance of this class.
- Parameters:
someMathOptions - determines if Java or Mapper number is evaluated.
public BinaryOperatorOverloader(java.util.EnumSet someMathOptions)
|
Methods |
Execute the specified operation on two operands, returning a result. See MathOperation
for supported operations.
- Parameters:
anOperation - the operation to be performed
aLeftOperand - the left operand
aRightOperand - the right operand
- Throws:
EvaluationException - if there is a problem performing the operation
- Returns:
- the result of performing the operation on the two operands
public java.lang.Object operate(com.arsi.mj.fml.impl.MathOperation anOperation, java.lang.Object aLeftOperand, java.lang.Object aRightOperand) throws org.springframework.expression.EvaluationException
|
Required implementation; provides hooks to the operator implementations.
- See Also:
- org.springframework.expression.OperatorOverloader#operate(org.springframework.expression.Operation, java.lang.Object, java.lang.Object)
public java.lang.Object operate(org.springframework.expression.Operation anOperation, java.lang.Object aLeftOperand, java.lang.Object aRightOperand) throws org.springframework.expression.EvaluationException
|
Required implementation; accepts all types that support math operations for overloading.
- See Also:
- org.springframework.expression.OperatorOverloader#overridesOperation(org.springframework.expression.Operation, java.lang.Object, java.lang.Object)
public boolean overridesOperation(org.springframework.expression.Operation anOperation, java.lang.Object aLeftOperand, java.lang.Object aRightOperand) throws org.springframework.expression.EvaluationException
|
Provides formula-specific conversions.
public class com.arsi.mj.fml.impl.FormulaConversionService
extends org.springframework.core.convert.support.DefaultConversionService
Constructors |
Ctor for initializing an instance of this class. public FormulaConversionService()
|
Allows customization of the expression result handling so that numeric encapsulation does not
cause errors.
public class com.arsi.mj.fml.impl.FormulaTypeConverter
extends org.springframework.expression.spel.support.StandardTypeConverter
Constructors |
Ctor for initializing an instance of this class. public FormulaTypeConverter()
|
Methods |
Customizes the expression result type handling to support unwrapping of the numeric data
encapsulation used to force custom math operations.
- See Also:
- org.springframework.expression.spel.support.StandardTypeConverter#convertValue(java.lang.Object, org.springframework.core.convert.TypeDescriptor, org.springframework.core.convert.TypeDescriptor)
public java.lang.Object convertValue(java.lang.Object aValue, org.springframework.core.convert.TypeDescriptor aSourceType, org.springframework.core.convert.TypeDescriptor aTargetType)
|
Defines the integration mechanism for binary mathematical operations within Mapper formulae.
Implementations of this interface will group handling for operand tuples by type, and each
interface will handle all possible operations.
- Parameters:
<L>
- the left operand provided to the operation
<R>
- the right operand provided to the operation
<V>
- the data type returned by the operation
public interface com.arsi.mj.fml.impl.IFmlBinaryOperation
Methods |
Executes a binary operation for the provided operands.
- Parameters:
anOperation - the mathematical operation to perform
aLeftOperand - the first operand provided to the operation
aRightOperand - the second operand provided to the operation
someOptions - any options to incorporate into the processing flow
- Throws:
MJExecuteException - if any error occurs in performing the calculation
- Returns:
- the operation result
public java.lang.Object binaryOperation(com.arsi.mj.fml.impl.MathOperation anOperation, java.lang.Object aLeftOperand, java.lang.Object aRightOperand, java.util.EnumSet someOptions) throws com.arsi.mj.MJExecuteException
|
Class: INumericVariableToNumberConverter
previous
next
package
Provides conversion between the implemented types.
s
public class com.arsi.mj.fml.impl.INumericVariableToNumberConverter
extends java.lang.Object
implements org.springframework.core.convert.converter.Converter
Constructors |
public INumericVariableToNumberConverter()
|
Methods |
Required implementation.
- See Also:
- org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
public java.lang.Number convert(com.arsi.mj.variable.INumericVariable source)
|
Number-valued mathematical formula operation where left operand is a
BigDecimal
and right operand is a
BigDecimal
.
Constructors |
public LBigDecimalRBigDecimalMathOp()
|
Number-valued mathematical formula operation where left operand is a
BigDecimal
and right operand is a
Double
.
Constructors |
public LBigDecimalRDoubleMathOp()
|
Number-valued mathematical formula operation where left operand is a
BigDecimal
and right operand is a
Long
.
Constructors |
public LBigDecimalRLongMathOp()
|
Number-valued mathematical formula operation where left operand is a
Double
and right operand is a
BigDecimal
.
Constructors |
public LDoubleRBigDecimalMathOp()
|
Number-valued mathematical formula operation where left operand is a
Double
and right operand is a
Double
.
Constructors |
public LDoubleRDoubleMathOp()
|
Number-valued mathematical formula operation where left operand is a
Double
and right operand is a
Long
.
Constructors |
public LDoubleRLongMathOp()
|
Number-valued mathematical formula operation where left operand is a
Long
and right operand is a
BigDecimal
.
Constructors |
public LLongRBigDecimalMathOp()
|
Number-valued mathematical formula operation where left operand is a
Long
and right operand is a
Double
.
Constructors |
public LLongRDoubleMathOp()
|
Number-valued mathematical formula operation where left operand is a
Long
and right operand is a
Long
.
Constructors |
public LLongRLongMathOp()
|
Number-valued mathematical formula operation where left operand is a
Number
and right operand is an
MJVariable
.
Constructors |
public LNumberRVariableMathOp()
|
Number-valued mathematical formula operation where left operand is an
MJVariable
and right operand is a
Number
.
Constructors |
public LVariableRNumberMathOp()
|
Number-valued mathematical formula operation where left and right operands are both instances of
MJVariable
.
Constructors |
public LVariableRVariableMathOp()
|
Provides a basis for evaluation of non-trivial unary math functions.
- Parameters:
<M>
- the input type to operate on
public abstract class com.arsi.mj.fml.impl.MathFunctionEvaluator
extends java.lang.Object
Constructors |
public MathFunctionEvaluator()
|
Methods |
Absolute value or magnitude of number.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand abs(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Arc cosine of number in radians.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand acos(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Arc sine of number in radians.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand asin(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Arc tangent of number in radians.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand atan(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Cube root of number.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand cbrt(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Cosine of number in radians.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand cos(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Cotangent of number in radians.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand ctn(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Value of number (assumed to be radians) expressed in degrees.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand deg(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Provides appropriate implementations for all supported functions.
- Parameters:
aFunction - the function to evaluate
aValue - the value to operate on
someOptions - any provided options
- Returns:
- the encapsulated function result
protected abstract com.arsi.mj.fml.impl.NumericOperand executeFunction(com.arsi.mj.fml.impl.MathFunctionEvaluator.MathFunction aFunction, java.lang.Object aValue, java.util.EnumSet someOptions)
|
Fractional portion of number.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand frac(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Hyperbolic cosine of number in radians.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand hcos(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Hyperbolic sine of number in radians.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand hsin(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Hyperbolic tangent of number in radians.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand htan(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Logarithm of number in base e.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand log(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Logarithm of number in base 10.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand log10(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Value of number (assumed to be degrees) expressed in radians.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand rad(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Sine of number (assumed to be radians).
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand sin(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Square root of number.
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand sqrt(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Tangent of number (assumed to be radians).
- Parameters:
aValue - value for which function is determined
someOptions - optional argument that determines if decimal or double return value is preferred (if not
specified, default is PREFER_DECIMAL_OVER_FLOAT )
- Returns:
- the function evaluation result
public com.arsi.mj.fml.impl.NumericOperand tan(java.lang.Object aValue, java.util.EnumSet someOptions)
|
Defines the supported binary mathematical operations in the formula framework.
public final class com.arsi.mj.fml.impl.MathOperation
extends java.lang.Enum
Provides conversion between the implemented types.
s
public class com.arsi.mj.fml.impl.MJStringToNumberConverter
extends java.lang.Object
implements org.springframework.core.convert.converter.Converter
Constructors |
Ctor for initializing an instance of this class.
- Parameters:
aConverter - the converter to use for numeric conversion
public MJStringToNumberConverter(org.springframework.expression.spel.support.StandardTypeConverter aConverter)
|
Methods |
Required implementation.
- See Also:
- org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
public java.lang.Number convert(com.arsi.mj.variable.MJString source)
|
Provides a convenient means to look up a variable namespace based on the converted prefix in a
formula.
public class com.arsi.mj.fml.impl.NamespaceAccessor
extends java.lang.Object
implements org.springframework.expression.PropertyAccessor
Constructors |
public NamespaceAccessor()
|
Methods |
Supports evaluation of all potential namespace prefixes.
- See Also:
- org.springframework.expression.PropertyAccessor#canRead(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)
public boolean canRead(org.springframework.expression.EvaluationContext context, java.lang.Object target, java.lang.String name) throws org.springframework.expression.AccessException
|
No write access is permitted.
- See Also:
- org.springframework.expression.PropertyAccessor#canWrite(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)
public boolean canWrite(org.springframework.expression.EvaluationContext context, java.lang.Object target, java.lang.String name) throws org.springframework.expression.AccessException
|
Required implementation.
- See Also:
- org.springframework.expression.PropertyAccessor#getSpecificTargetClasses()
public java.lang.Class getSpecificTargetClasses()
|
Accesses the identified namespace for further variable lookup.
- See Also:
- org.springframework.expression.PropertyAccessor#read(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)
public org.springframework.expression.TypedValue read(org.springframework.expression.EvaluationContext context, java.lang.Object target, java.lang.String name) throws org.springframework.expression.AccessException
|
No write access is permitted.
- See Also:
- org.springframework.expression.PropertyAccessor#write(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String, java.lang.Object)
public void write(org.springframework.expression.EvaluationContext context, java.lang.Object target, java.lang.String name, java.lang.Object newValue) throws org.springframework.expression.AccessException
|
Provides numeric type management utilities for number and string literal content.
public class com.arsi.mj.fml.impl.NumberConverter
extends java.lang.Object
Constructors |
public NumberConverter()
|
Methods |
Converts a numeric literal into an MJ-supported math operand.
- Parameters:
aNumericLiteral - the literal value to process
- Returns:
- the encapsulated result
public static com.arsi.mj.fml.impl.NumericOperand convertNumberToOperand(java.lang.Number aNumericLiteral)
|
Converts a string literal with numeric content into an appropriate numeric type.
- Parameters:
aStringLiteral - the text value to parse
someMathOptions - used to determine the floating-point precision used
- Returns:
- the encapsulated result
public static java.lang.Number convertNumericString(java.lang.String aStringLiteral, java.util.EnumSet someMathOptions)
|
Converts a string literal with numeric content into an MJ-supported math operand.
- Parameters:
aStringLiteral - the text value to parse
someMathOptions - used to determine the floating-point precision used
- Returns:
- the encapsulated result
public static com.arsi.mj.fml.impl.NumericOperand convertNumericStringToOperand(java.lang.String aStringLiteral, java.util.EnumSet someMathOptions)
|
Evaluates the unary math functions for numeric input.
Constructors |
public NumberFunctionEvaluator()
|
Class: NumberToNumericOperandConverter
previous
next
package
Provides conversion between the implemented types.
s
public class com.arsi.mj.fml.impl.NumberToNumericOperandConverter
extends java.lang.Object
implements org.springframework.core.convert.converter.Converter
Constructors |
public NumberToNumericOperandConverter()
|
Methods |
Required implementation.
- See Also:
- org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
public com.arsi.mj.fml.impl.NumericOperand convert(java.lang.Number source)
|
Provides an encapsulation for numeric content; using the encapsulation ensures that type-aware
implementations of basic math operations will be used instead of default operator implementations.
public class com.arsi.mj.fml.impl.NumericOperand
extends java.lang.Object
Fields |
The value of the operand. public final java.lang.Number value
|
Constructors |
public NumericOperand(java.lang.Number value)
|
Class: NumericOperandToBigDecimalConverter
previous
next
package
Provides conversion between the implemented types.
s
public class com.arsi.mj.fml.impl.NumericOperandToBigDecimalConverter
extends java.lang.Object
implements org.springframework.core.convert.converter.Converter
Constructors |
public NumericOperandToBigDecimalConverter()
|
Methods |
Required implementation.
- See Also:
- org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
public java.math.BigDecimal convert(com.arsi.mj.fml.impl.NumericOperand source)
|
Class: NumericOperandToDoubleConverter
previous
next
package
Provides conversion between the implemented types.
s
public class com.arsi.mj.fml.impl.NumericOperandToDoubleConverter
extends java.lang.Object
implements org.springframework.core.convert.converter.Converter
Constructors |
public NumericOperandToDoubleConverter()
|
Methods |
Required implementation.
- See Also:
- org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
public java.lang.Double convert(com.arsi.mj.fml.impl.NumericOperand source)
|
Class: NumericOperandToLongConverter
previous
next
package
Provides conversion between the implemented types.
s
public class com.arsi.mj.fml.impl.NumericOperandToLongConverter
extends java.lang.Object
implements org.springframework.core.convert.converter.Converter
Constructors |
public NumericOperandToLongConverter()
|
Methods |
Required implementation.
- See Also:
- org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
public java.lang.Long convert(com.arsi.mj.fml.impl.NumericOperand source)
|
Class: NumericOperandToNumberConverter
previous
next
package
Provides conversion between the implemented types.
s
public class com.arsi.mj.fml.impl.NumericOperandToNumberConverter
extends java.lang.Object
implements org.springframework.core.convert.converter.Converter
Constructors |
public NumericOperandToNumberConverter()
|
Methods |
Required implementation.
- See Also:
- org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
public java.lang.Number convert(com.arsi.mj.fml.impl.NumericOperand source)
|
Provides a convenient means to look up a Mapper variable from the appropriate namespace for use
in a formula.
public class com.arsi.mj.fml.impl.VariableAccessor
extends java.lang.Object
implements org.springframework.expression.PropertyAccessor
Constructors |
public VariableAccessor()
|
Methods |
Supports local variable resolution if no namespace has been provided.
- See Also:
- org.springframework.expression.PropertyAccessor#canRead(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)
public boolean canRead(org.springframework.expression.EvaluationContext context, java.lang.Object target, java.lang.String name) throws org.springframework.expression.AccessException
|
No write access is permitted.
- See Also:
- org.springframework.expression.PropertyAccessor#canWrite(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)
public boolean canWrite(org.springframework.expression.EvaluationContext context, java.lang.Object target, java.lang.String name) throws org.springframework.expression.AccessException
|
Supports introspection of both the formula context or a namespace.
- See Also:
- org.springframework.expression.PropertyAccessor#getSpecificTargetClasses()
public java.lang.Class getSpecificTargetClasses()
|
Retrieves the variable content.
- See Also:
- org.springframework.expression.PropertyAccessor#read(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)
public org.springframework.expression.TypedValue read(org.springframework.expression.EvaluationContext context, java.lang.Object target, java.lang.String name) throws org.springframework.expression.AccessException
|
No write access is permitted.
- See Also:
- org.springframework.expression.PropertyAccessor#write(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String, java.lang.Object)
public void write(org.springframework.expression.EvaluationContext context, java.lang.Object target, java.lang.String name, java.lang.Object newValue) throws org.springframework.expression.AccessException
|
Evaluates the unary math functions for Mapper variable input.
Constructors |
public VariableFunctionEvaluator()
|
Provides common functionality for math operations with
MJVariable
operands.
public abstract class com.arsi.mj.fml.impl.VariableMathOp
extends java.lang.Object
Constructors |
public VariableMathOp()
|
Methods |
Converts the operand to the desired math calculation type. Unchecked conversion is needed
due to the nature of Java generics.
- Parameters:
<M> - the expected operand implementation type
aMathOperandClass - the class type the operand must implement
anOperand - the target operand
- Returns:
- the converted operand
protected java.lang.Object convertToMathType(java.lang.Class aMathOperandClass, com.arsi.mj.variable.MJVariable anOperand)
|