net.scheinerman.phoenix.interpreter.variables
Class AbstractVariable

java.lang.Object
  extended by net.scheinerman.phoenix.interpreter.variables.AbstractVariable
All Implemented Interfaces:
Variable
Direct Known Subclasses:
FunctionVariable, NumberVariable, StringVariable

public abstract class AbstractVariable
extends java.lang.Object
implements Variable

Manages several of the methods of the Variable interface so that they don't need to be implemented by the StringVariable and NumberVariable classes. These methods are the simple getter and setter methods for the literal and constant flags.

Since:
1.5
Version:
1.0
Author:
Jonah Scheinerman

Field Summary
(package private)  boolean constant
          Indicates whether or not this is a constant (immutable) variable.
(package private)  boolean functionReference
           
(package private)  boolean literal
          Indicates whether or not this is a literal variable (not assigned to an identifier).
 
Constructor Summary
AbstractVariable()
           
 
Method Summary
 boolean equals(Variable v)
          Tests to see if the type of the two variables are equal by checking the equality of the strings returned by the getType() method.
 java.lang.String getType()
          Returns a string name of this particular variable type.
 boolean isConstant()
          Returns whether or not this variable is a constant variable.
 boolean isFunctionReference()
           
 boolean isLiteral()
          Returns whether or not this variable is a literal variable.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.scheinerman.phoenix.interpreter.variables.Variable
add, and, assign, copy, divide, exp, greaterEqual, greaterThan, isEqualTo, lessEqual, lessThan, mod, multiply, not, notEqualTo, or, round, subscript, subscript, subtract, xor
 

Field Detail

literal

boolean literal
Indicates whether or not this is a literal variable (not assigned to an identifier).


constant

boolean constant
Indicates whether or not this is a constant (immutable) variable.


functionReference

boolean functionReference
Constructor Detail

AbstractVariable

public AbstractVariable()
Method Detail

getType

public java.lang.String getType()
Description copied from interface: Variable
Returns a string name of this particular variable type. For example, for an integer variable type, one might have this method return "int". This method should not vary based on the contents of the variable.

Specified by:
getType in interface Variable
Returns:
"void"

equals

public boolean equals(Variable v)
Tests to see if the type of the two variables are equal by checking the equality of the strings returned by the getType() method.

Parameters:
v - - The other variable
Returns:
true if the types match, false otherwise.

setConstant

public void setConstant(boolean constant)
Description copied from interface: Variable
Defines whether or not this variable is a constant variable. If 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

Specified by:
setConstant in interface Variable
Parameters:
constant - - whether or not this is a constant variable.

setLiteral

public void setLiteral(boolean literal)
Description copied from interface: Variable
Defines whether or not this variable is a literal variable. If 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.

Specified by:
setLiteral in interface Variable
Parameters:
literal - - whether or not this is a literal value.

setFunctionReference

public void setFunctionReference(boolean functionReference)
Specified by:
setFunctionReference in interface Variable

isConstant

public boolean isConstant()
Description copied from interface: Variable
Returns whether or not this variable is a constant variable.

Specified by:
isConstant in interface Variable
Returns:
whether or not this variable is constant.

isLiteral

public boolean isLiteral()
Description copied from interface: Variable
Returns whether or not this variable is a literal variable.

Specified by:
isLiteral in interface Variable
Returns:
whether or not this variable is literal.

isFunctionReference

public boolean isFunctionReference()
Specified by:
isFunctionReference in interface Variable