|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Variable
A variable is a named data container that can be manipulated through operators. A variable holds some
type of data which can then be mutated through its various operators which are represented here with
methods. The operators are meant to differ between implementations of this interface. Any operator that
is not supported by this can throw an UnsupportedOperatorException
with the instance of
the variable and the operator symbol. For example, if one wanted a class to not support the addition
operator, the add(Variable)
would have the following content:
throw new UnsupportedOperatorException(this, "+")
AbstractVariable}, {@link NumberVariable}, {@link StringVariable},
{@link UnsupportedOperatorException}
Method Summary | |
---|---|
Variable |
add(Variable v)
Takes two variables and returns the addition operator solution. |
Variable |
and(Variable v)
Takes two variables and returns the logical and operator solution. |
void |
assign(Variable v)
Assigns a new variable value to this variable. |
Variable |
copy()
Returns a copy of this variable. |
Variable |
divide(Variable v)
Takes two variables and returns the division operator solution. |
Variable |
exp(Variable v)
Takes two variables and returns the exponentiation operator solution. |
java.lang.String |
getType()
Returns a string name of this particular variable type. |
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. |
boolean |
isConstant()
Returns whether or not this variable is a constant variable. |
Variable |
isEqualTo(Variable v)
Takes two variables and returns the equality operator solution. |
boolean |
isFunctionReference()
|
boolean |
isLiteral()
Returns whether or not this variable is a literal variable. |
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)
Takes two variables and returns the multiplication operator solution. |
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. |
void |
setConstant(boolean constant)
Defines whether or not this variable is a constant variable. |
void |
setFunctionReference(boolean functionReference)
|
void |
setLiteral(boolean literal)
Defines whether or not this variable is a literal variable. |
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)
Takes two variables and returns the subtraction operator solution. |
Variable |
xor(Variable v)
Takes two variables and returns the logical exclusive operator solution. |
Method Detail |
---|
void assign(Variable v)
SyntaxException
if it is not. This method must be
supported, it should not throw a UnsupportedOperatorException
.
v
- - the variable to assign this variable to be
SyntaxException
- if the variable is the wrong type or if the variable is a literal.Variable add(Variable v)
x.add(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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable subtract(Variable v)
x.subtract(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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable multiply(Variable v)
x.multiply(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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable divide(Variable v)
x.divide(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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable mod(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable exp(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable round(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable isEqualTo(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable notEqualTo(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable greaterThan(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable lessThan(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable greaterEqual(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable lessEqual(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable and(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable or(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable xor(Variable v)
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
SyntaxException
- if v
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable not()
x.not()
is equivalent to
!x
. This operator is not required and can therefore throw the
UnsupportedOperatorException
.
v
- - the variable to operate on
UnsupportedOperatorException
- if this operator is not supported.Variable subscript(Variable sub)
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
SyntaxException
- if sub
is the wrong type of variable
UnsupportedOperatorException
- if this operator is not supported.Variable subscript(Variable sub1, Variable sub2)
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
SyntaxException
- if sub1
or sub2
are the wrong types of variables
UnsupportedOperatorException
- if this operator is not supported.void setLiteral(boolean literal)
true
, then the variable cannot be
assigned. If false
, then the variable is a defined variable and can be assigned. If this is set
to true
, than the assign(Variable)
method will throw a SyntaxException
.
literal
- - whether or not this is a literal value.boolean isLiteral()
void setConstant(boolean constant)
true
, then the variable cannot
be assigned, and if false
, then the variable can be assigned. If true
, than the
assign(Variable)
method will throw a SyntaxException
constant
- - whether or not this is a constant variable.boolean isConstant()
void setFunctionReference(boolean functionReference)
boolean isFunctionReference()
java.lang.String getType()
"int"
. This method should not vary based on the contents
of the variable.
Variable copy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |