|
||||||||||
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.StringVariable
public class StringVariable
Field Summary | |
---|---|
private NumberVariable |
FALSE
|
private NumberVariable |
TRUE
|
private java.lang.String |
value
The value of the string variable. |
Fields inherited from class net.scheinerman.phoenix.interpreter.variables.AbstractVariable |
---|
constant, functionReference, literal |
Constructor Summary | |
---|---|
StringVariable()
Creates a new, default StringVariable . |
|
StringVariable(java.lang.String value)
Creates a new StringVariable with a given String as a starting
value for the variable. |
|
StringVariable(java.lang.String value,
boolean constant)
Creates a new StringVariable with a given String as a starting
value for the variable and the choice to indicate whether the variable is constant or not. |
|
StringVariable(Variable value)
Creates a new StringVariable with a given Variable as a starting
value for the variable. |
|
StringVariable(Variable value,
boolean constant)
Creates a new StringVariable with a given Variable as a starting
value for the variable and the choice to indicate whether the variable is constant or not. |
Method Summary | |
---|---|
Variable |
add(Variable v)
The add (+) operator on two StrVar objects produces the concatenation of
the two strings. |
Variable |
and(Variable v)
This operator is not supported for String variables. |
void |
assign(java.lang.String value)
|
void |
assign(Variable v)
Assigns a new variable value to this variable. |
void |
check(Variable v)
|
private int |
convertValue(int value)
|
Variable |
copy()
Returns a copy of this variable. |
Variable |
divide(Variable v)
This operator is not supported for String variables. |
Variable |
exp(Variable v)
This operator is not supported for String variables. |
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. |
Variable |
isEqualTo(Variable v)
The equality operator (==) on two strings returns Constants.TRUE if
the two strings are equal and Constants.FALSE otherwise. |
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)
This operator is not supported for String variables. |
Variable |
multiply(Variable v)
The multiply (*) operator on a StrVar takes a NumVar that
must be an integer value. |
Variable |
not()
This operator is not supported for String variables. |
Variable |
notEqualTo(Variable v)
Takes two variables and returns the inequality operator solution. |
Variable |
or(Variable v)
This operator is not supported for String variables. |
Variable |
round(Variable v)
This operator is not supported for String variables. |
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)
This operator is not supported for String variables. |
java.lang.String |
toString()
|
java.lang.String |
value()
|
Variable |
xor(Variable v)
This operator is not supported for String variables. |
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
Constants.TRUE
private final NumberVariable FALSE
Constants.FALSE
private java.lang.String value
Constructor Detail |
---|
public StringVariable()
StringVariable
. By default the value of the string
is the empty string, it is a literal and not constant.
public StringVariable(java.lang.String value)
StringVariable
with a given String
as a starting
value for the variable. By default, this is a literal, non-constant variable.
value
- - The value to be assigned to this StringVariable
.public StringVariable(Variable value)
StringVariable
with a given Variable
as a starting
value for the variable. By default, this is a literal, non-constant variable.
value
- - The value to be assigned to this StringVariable
.public StringVariable(java.lang.String value, boolean constant)
StringVariable
with a given String
as a starting
value for the variable and the choice to indicate whether the variable is constant or not.
By default, this is a literal variable.
value
- - The value to be assigned to this StringVariable
.constant
- - Whether or not this variable is constant.public StringVariable(Variable value, boolean constant)
StringVariable
with a given Variable
as a starting
value for the variable and the choice to indicate whether the variable is constant or not.
By default, this is a literal variable.
value
- - The value to be assigned to this StringVariable
.constant
- - Whether or not this variable is constant.Method Detail |
---|
public void assign(java.lang.String value)
public void assign(Variable v)
Variable
SyntaxException
if it is not. This method must be
supported, it should not throw a UnsupportedOperatorException
.
v
- - the variable to assign this variable to bepublic java.lang.String value()
public java.lang.String getType()
Variable
"int"
. This method should not vary based on the contents
of the variable.
getType
in interface Variable
getType
in class AbstractVariable
"void"
public Variable add(Variable v)
StrVar
objects produces the concatenation of
the two strings.
v
- a StrVar
to concatenate this one with.
StrVar
.
SyntaxException
- if v is not a StrVar
.public Variable subtract(Variable v)
v
- - the variable to operate on
UnsupportedOperatorException
- always.public Variable multiply(Variable v)
StrVar
takes a NumVar
that
must be an integer value. The result is the StrVar
copied the number of
times specified by the argument and concatenated together. So the statements "A"
* 3 == "AAA"
or "AB" * 4 == "ABABABAB"
are both true.
v
- a NumVar
object
v
times.public Variable divide(Variable v)
v
- - the variable to operate on
UnsupportedOperatorException
- always.public Variable mod(Variable v)
v
- - the variable to operate on
UnsupportedOperatorException
- always.public Variable exp(Variable v)
v
- - the variable to operate on
UnsupportedOperatorException
- always.public Variable round(Variable v)
v
- - the variable to operate on
UnsupportedOperatorException
- always.public Variable isEqualTo(Variable v)
Constants.TRUE
if
the two strings are equal and Constants.FALSE
otherwise.
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)
v
- - the variable to operate on
UnsupportedOperatorException
- always.public Variable or(Variable v)
v
- - the variable to operate on
UnsupportedOperatorException
- always.public Variable xor(Variable v)
v
- - the variable to operate on
UnsupportedOperatorException
- always.public Variable not()
UnsupportedOperatorException
- always.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
private int convertValue(int value)
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 |