|
http://www.eteks.com | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.eteks.parser.DoubleInterpreter
Runtime interpreter operating on Double objects. This class
implements the computation of all the literals, operators and functions
defined in Syntax with double numbers.
Functions and expressions may use this interpreter to compute values if the
value of their parameters are Number objects (Double,
Integer,...).
This interpreter is used as the default interpreter in CompiledFunction
and CompiledExpression classes.
The methods of this class are thread safe.
Syntax| Field Summary | |
static java.lang.Double |
FALSE_DOUBLE
The double constant matching the constant FALSE (equal to new Double (0)). |
static java.lang.Double |
TRUE_DOUBLE
The double constant matching the constant TRUE (equal to new Double (1)). |
| Constructor Summary | |
DoubleInterpreter()
|
|
| Method Summary | |
java.lang.Object |
getBinaryOperatorValue(java.lang.Object binaryOperatorKey,
java.lang.Object operand1,
java.lang.Object operand2)
Returns the value of the operation of the binary operator binaryOperatorKey applied on
the two operands operand1 and operand2. |
java.lang.Object |
getCommonFunctionValue(java.lang.Object commonFunctionKey,
java.lang.Object param)
Returns the value of the common function commonFunctionKey with
the parameter param. |
java.lang.Object |
getConditionValue(java.lang.Object paramIf,
java.lang.Object paramThen,
java.lang.Object paramElse)
Returns the value paramThen or paramElse depending
on whether isTrue (paramIf) returning true or false.
|
java.lang.Object |
getConstantValue(java.lang.Object constantKey)
Returns the value of the constant constantKey. |
java.lang.Object |
getFunctionValue(Function function,
java.lang.Object[] parametersValue,
boolean recursiveCall)
Returns the value of the function function with its parameters parametersValue.
|
java.lang.Object |
getLiteralValue(java.lang.Object literal)
Returns the value of the literal literal. |
java.lang.Object |
getParameterValue(java.lang.Object parameter)
Returns the value of the parameter parameter. |
java.lang.Object |
getUnaryOperatorValue(java.lang.Object unaryOperatorKey,
java.lang.Object operand)
Returns the value of the operation of the unary operator unaryOperatorKey applied
on the operand operand. |
boolean |
isTrue(java.lang.Object condition)
Returns true or false according to the value of condition. |
boolean |
supportsRecursiveCall()
Returns true thus enabling this interpreter to evaluate the value of recursive
calls. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.Double FALSE_DOUBLE
new Double (0)).public static final java.lang.Double TRUE_DOUBLE
new Double (1)).| Constructor Detail |
public DoubleInterpreter()
| Method Detail |
public java.lang.Object getLiteralValue(java.lang.Object literal)
literal. literal
may be an instance of Number.getLiteralValue in interface Interpreterliteral - an instance of Number.Double.java.lang.IllegalArgumentException - if literal isn't an instance of Number.public java.lang.Object getParameterValue(java.lang.Object parameter)
parameter. parameter
may be an instance of Number.
This method may throw an exception if the interpreter doesn't accept the type of
parameter.getParameterValue in interface Interpreterparameter - an instance of Number.Double.java.lang.IllegalArgumentException - if parameter isn't an instance of Number.public java.lang.Object getConstantValue(java.lang.Object constantKey)
constantKey. constantKey
may be the key of a constant of Syntax (one of CONSTANT_PI,
CONSTANT_E, CONSTANT_FALSE, CONSTANT_TRUE).getConstantValue in interface InterpreterconstantKey - the key of a constant of Syntax.Double.java.lang.IllegalArgumentException - if constantKey isn't a key of a constant of
Syntax.
public java.lang.Object getUnaryOperatorValue(java.lang.Object unaryOperatorKey,
java.lang.Object operand)
unaryOperatorKey applied
on the operand operand. unaryOperatorKey must be the key
of an unary operator of Syntax (one of OPERATOR_POSITIVE,
OPERATOR_OPPOSITE, OPERATOR_LOGICAL_NOT, OPERATOR_BITWISE_NOT).getUnaryOperatorValue in interface InterpreterunaryOperatorKey - the key of an unary operator of Syntax.operand - the operand (instance of Number).Double.java.lang.IllegalArgumentException - if operand isn't an instance of Number,
if operand isn't an integer operand when unaryOperatorKey is the
key Syntax.OPERATOR_BITWISE_NOT or if unaryOperatorKey
isn't the key of an unary operator of Syntax.
public java.lang.Object getBinaryOperatorValue(java.lang.Object binaryOperatorKey,
java.lang.Object operand1,
java.lang.Object operand2)
binaryOperatorKey applied on
the two operands operand1 and operand2. binaryOperatorKey
must be the key of a binary operator of Syntax (one of OPERATOR_ADD,
OPERATOR_SUBSTRACT, OPERATOR_MULTIPLY, OPERATOR_DIVIDE,...).getBinaryOperatorValue in interface InterpreterbinaryOperatorKey - the key of a binary operator of Syntax.operand1 - the first operand (instance of Number).operand2 - the second operand (instance of Number).Double.java.lang.IllegalArgumentException - if operand1 or operand2 aren't
instances of Number, if operand1 or operand2 are
not integer operands when binaryOperatorKey is the key of a bit operator
(Syntax.OPERATOR_BITWISE_... and Syntax.OPERATOR_SHIFT_...)
or if binaryOperatorKey isn't the key of a binary operator of Syntax.
public java.lang.Object getCommonFunctionValue(java.lang.Object commonFunctionKey,
java.lang.Object param)
commonFunctionKey with
the parameter param. commonFunctionKey must be the key
of a commomon function of Syntax (one of FUNCTION_LN,
FUNCTION_LOG, FUNCTION_EXP, FUNCTION_SQR,...).getCommonFunctionValue in interface InterpretercommonFunctionKey - the key of a common function of Syntax.param - the parameter of the function (instance of Number).Double.java.lang.IllegalArgumentException - if param isn't an instance of Number
or if commonFunctionKey isn't the key of a commomon function of Syntax.
public java.lang.Object getConditionValue(java.lang.Object paramIf,
java.lang.Object paramThen,
java.lang.Object paramElse)
paramThen or paramElse depending
on whether isTrue (paramIf) returning true or false.
As the implementation of the supportsRecursiveCall () method in this class returns
true, this method isn't called internally to get the result of a condition.getConditionValue in interface InterpreterparamIf - the condition.paramThen - the true condition value.paramElse - the false condition value.supportsRecursiveCall()public boolean isTrue(java.lang.Object condition)
true or false according to the value of condition.isTrue in interface Interpretercondition - the value to test (instance of Number).false if the double value of condition equals 0.
otherwise true.public boolean supportsRecursiveCall()
true thus enabling this interpreter to evaluate the value of recursive
calls.supportsRecursiveCall in interface Interpretertrue.getConditionValue(java.lang.Object, java.lang.Object, java.lang.Object)
public java.lang.Object getFunctionValue(Function function,
java.lang.Object[] parametersValue,
boolean recursiveCall)
function with its parameters parametersValue.
This method returns the result of function.computeFunction (this, parametersValue).getFunctionValue in interface Interpreterfunction - the function to compute.parametersValue - the value of function's parameters.recursiveCall - true if the call of this function is a recursive call, meaning that
the current evaluated function calls itself.
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||