|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.scheinerman.phoenix.interpreter.variables.AbstractVariable
net.scheinerman.phoenix.interpreter.variables.NumberVariable
public class NumberVariable
Field Summary | |
---|---|
private NumberVariable |
FALSE
|
private NumberVariable |
TRUE
|
private double |
value
|
Fields inherited from class net.scheinerman.phoenix.interpreter.variables.AbstractVariable |
---|
constant, functionReference, literal |
Constructor Summary | |
---|---|
NumberVariable()
Creates a new NumberVariable with the default value of 0. |
|
NumberVariable(double value)
Creates a new NumberVariable with the given value. |
|
NumberVariable(double value,
boolean constant)
|
|
NumberVariable(Variable value)
Creates a new NumberVariable with the given value. |
|
NumberVariable(Variable value,
boolean constant)
|
Method Summary | |
---|---|
Variable |
add(Variable v)
Returns a NumberVariable that is a sum of this variable and the
the parameter. |
Variable |
and(Variable v)
Takes two variables and returns the logical and operator solution. |
void |
assign(double value)
Assigns a new value to this variable. |
void |
assign(Variable v)
Assigns a new variable value to this variable. |
void |
check(Variable v)
|
Variable |
copy()
Returns a copy of this variable. |
Variable |
divide(Variable v)
Returns a NumberVariable that is a quotient of this variable and the
the parameter. |
Variable |
exp(Variable v)
Takes two variables and returns the exponentiation operator solution. |
java.lang.String |
getType()
Always returns "num" . |
Variable |
greaterEqual(Variable v)
Takes two variables and returns the greater than or equal to operator solution. |
Variable |
greaterThan(Variable v)
Takes two variables and returns the greater than operator solution. |
Variable |
isEqualTo(Variable v)
Takes two variables and returns the equality operator solution. |
Variable |
lessEqual(Variable v)
Takes two variables and returns the less than or equal to operator solution. |
Variable |
lessThan(Variable v)
Takes two variables and returns the less than operator solution. |
Variable |
mod(Variable v)
Takes two variables and returns the modulus arithmetic operator solution. |
Variable |
multiply(Variable v)
Returns a NumberVariable that is a product of this variable and the
the parameter. |
Variable |
not()
Returns the result of the logical not (complement) of this variable. |
Variable |
notEqualTo(Variable v)
Takes two variables and returns the inequality operator solution. |
Variable |
or(Variable v)
Takes two variables and returns the logical inclusive or operator solution. |
Variable |
round(Variable v)
Takes two variables and returns the rouding operator solution. |
Variable |
subscript(Variable sub)
Returns the result of a simple, one variable subscript of this variable. |
Variable |
subscript(Variable sub1,
Variable sub2)
Returns the result of a two variable subscript of this variable. |
Variable |
subtract(Variable v)
Returns a NumberVariable that is a difference of this variable and the
the parameter. |
java.lang.String |
toString()
|
double |
value()
Returns the double value of this variable. |
Variable |
xor(Variable v)
Takes two variables and returns the logical exclusive operator solution. |
Methods inherited from class net.scheinerman.phoenix.interpreter.variables.AbstractVariable |
---|
equals, isConstant, isFunctionReference, isLiteral, setConstant, setFunctionReference, setLiteral |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final NumberVariable TRUE
private final NumberVariable FALSE
private double value
Constructor Detail |
---|
public NumberVariable()
NumberVariable
with the default value of 0.
public NumberVariable(double value)
NumberVariable
with the given value.
value
- - the initial valuepublic NumberVariable(Variable value)
NumberVariable
with the given value.
value
- - the initial valuepublic NumberVariable(double value, boolean constant)
public NumberVariable(Variable value, boolean constant)
Method Detail |
---|
public void assign(double value)
value
- - the new valuepublic void assign(Variable v)
v
- - the new value
SyntaxException
- if the variable is not a NumberVariable
public double value()
double
value of this variable.
double
value.public java.lang.String getType()
"num"
.
getType
in interface Variable
getType
in class AbstractVariable
"void"
public Variable add(Variable v)
NumberVariable
that is a sum of this variable and the
the parameter. The parameter must be a NumberVariable
otherwise an
exception will be thrown. This is the addition (+) operator.
v
- - the variable to add to
SyntaxException
- if the argument is not a NumberVariable
public Variable subtract(Variable v)
NumberVariable
that is a difference of this variable and the
the parameter. The parameter must be a NumberVariable
otherwise an
exception will be thrown. This is the subtraction (-) operator.
v
- - the variable that will be subtracted
SyntaxException
- if the argument is not a NumberVariable
public Variable multiply(Variable v)
NumberVariable
that is a product of this variable and the
the parameter. The parameter must be a NumberVariable
otherwise an
exception will be thrown. This is the addition (*) operator.
v
- - the variable to multiply by
SyntaxException
- if the argument is not a NumberVariable
public Variable divide(Variable v)
NumberVariable
that is a quotient of this variable and the
the parameter. The parameter must be a NumberVariable
otherwise an
exception will be thrown. This is the addition (*) operator.
v
- - the variable to divide by
SyntaxException
- if the argument is not a NumberVariable
public Variable mod(Variable v)
Variable
x.mod(y)
is equivalent to
x % y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable exp(Variable v)
Variable
x.exp(y)
is equivalent to
x ^ y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable round(Variable v)
Variable
x.round(y)
is equivalent to
x # y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable isEqualTo(Variable v)
Variable
x.isEqualTo(y)
is equivalent to
x == y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable notEqualTo(Variable v)
Variable
x.notEqualTo(y)
is equivalent to
x != y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable greaterThan(Variable v)
Variable
x.greaterThan(y)
is equivalent to
x > y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable greaterEqual(Variable v)
Variable
x.greaterEqual(y)
is equivalent to
x == y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable lessThan(Variable v)
Variable
x.lessThan(y)
is equivalent to
x < y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable lessEqual(Variable v)
Variable
x.lessEqual(y)
is equivalent to
x <= y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable and(Variable v)
Variable
x.and(y)
is equivalent to
x & y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable or(Variable v)
Variable
x.or(y)
is equivalent to
x | y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable xor(Variable v)
Variable
x.xor(y)
is equivalent to
x (+) y
. This operator is not required and can therefore throw the
UnsupportedOperatorException
. If the variable passed to this operator is of a wrong type
a SyntaxException
should be thrown.
v
- - the variable to operate on
public Variable not()
Variable
x.not()
is equivalent to
!x
. This operator is not required and can therefore throw the
UnsupportedOperatorException
.
public Variable subscript(Variable sub)
Variable
x.subscript(y)
is equivalent to
x[y]
. This operator is not required and can therefore throw the
UnsupportedOperatorException
.
sub
- - the variable to operate on
public Variable subscript(Variable sub1, Variable sub2)
Variable
x.subscript(y,z)
is equivalent to
x[y:z]
. This operator is not required and can therefore throw the
UnsupportedOperatorException
.
sub1
- - the first subscript variablesub2
- - the second subscript variable
public void check(Variable v)
public java.lang.String toString()
toString
in class java.lang.Object
public Variable copy()
Variable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |