Class Variable
java.lang.Object
com.github.gbenroscience.parser.Variable
- All Implemented Interfaces:
Savable,Serializable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandoubleget(double[] frame) High-Speed Handle Method: GET Use this in your evaluator loop.static doublegetConstantValue(String str) intgetName()intstatic intgetSimpleVarIndex(String var) static StringgetSystemConstantValue(String name) getType()getUnits()doublegetValue()returns the value of the variablebooleanstatic booleanisExpNumber(String str) static booleanisGoldenRatio(String str) static booleanstatic booleanbooleanstatic booleanisSystemConstant(String str) static booleanisSystemVar(String str) booleanisTheta()static booleanstatic booleanisVariableBeginner(String var) static booleanisVariableBuilder(String unit) static booleanisVariableString(String var) If the name is a string of alphabets and is not an operator name, then it is a valid variable name.static Variablevoidset(double[] frame, double newValue) High-Speed Handle Method: SET Use this in your loops to update values without Map lookups.voidsetConstant(boolean constant) sets the nature of the Variable object to either Variable or constantvoidsetFrameIndex(int frameIndex) voidsetFullName(String fullName) voidvoidvoidfinal voidsetValue(double value) final voidchanges the value stored in the variabletoJSON()toString()
-
Field Details
-
lastResult
-
PI
The constant PI -
PI_ALT
-
PI_ALT_1
-
GOLDEN_RATIO
-
ans
The last answer variable used for flexibility on computational systems. -
e
-
-
Constructor Details
-
Variable
- Parameters:
name- The name of the variable (will create and initialize the variable with the given name to 0.0) or a variable assignment statement like a=4; or b=a; (where a is an existing stored variable)
-
Variable
Creates a non-constant Variable- Parameters:
name- the name of the Variable object e.g A,B...e.t.cvalue- the value stored by the Variable object
-
Variable
- Parameters:
name- the name of the Variable object e.g A,B...e.t.cvalue- the value stored by the Variable objectconstant- the nature of the Variable object whether it is modifiable or not. If constant = true , then the Variable object represents a constant, whose value cannot be altered.Else,it represents a Variable object whose value can change.
-
Variable
- Parameters:
name- the name of the Variable object e.g A,B...e.t.cfullName- the full name of the Variable objectvalue- the value stored by the Variable objectconstant- the nature of the Variable object whether it is modifiable or not. If constant = true , then the Variable object represents a constant, whose value cannot be altered.Else,it represents a Variable object whose value can change.
-
-
Method Details
-
set
public void set(double[] frame, double newValue) High-Speed Handle Method: SET Use this in your loops to update values without Map lookups. -
get
public double get(double[] frame) High-Speed Handle Method: GET Use this in your evaluator loop. -
getFrameIndex
public int getFrameIndex() -
setFrameIndex
public void setFrameIndex(int frameIndex) -
setType
-
getType
-
setFullName
-
getFullName
-
isConstant
public boolean isConstant()- Returns:
- true if the Variable object is a constant.
-
setConstant
public void setConstant(boolean constant) sets the nature of the Variable object to either Variable or constant- Parameters:
constant- = true if the Variable object is to be changed into a constant and constant = false if the Variable object is to be changed into a Variable object
-
isTheta
public boolean isTheta() -
isVariableBeginner
- Parameters:
var-- Returns:
- true if the variable is a valid Variable starting character
-
isVariableString
If the name is a string of alphabets and is not an operator name, then it is a valid variable name. If the name is alphanumeric,it is a valid variable name.- Parameters:
var- the string to check.- Returns:
- true if the variable is a valid Variable object name.
-
isVariableBuilder
-
isSystemVar
- Parameters:
str- the name of the String variable- Returns:
- true if the variable is one that is already defined by the parser for its own purposes. An example of such a variable is any constant parameter recognized by the parser, i.e to which the parser has attached a meaning already. Also any parameter such as the "ans" parameter which returns the last value calculated by the parser is regarded by the parser to be a system variable.
-
isSystemConstant
- Parameters:
str- the name of the String variable- Returns:
- true if the variable is a constant one that is already defined by the parser for its own purposes. An example of such a constant is any constant defined by the parser e.g PI and so on.
-
getSystemConstantValue
-
isExpNumber
- Parameters:
str- the name of the String variable- Returns:
- true if the variable is ë
-
isGoldenRatio
-
isPI
- Parameters:
str- the name of the String variable- Returns:
- true if the variable is PI
-
getConstantValue
-
isTheta
- Parameters:
str- the name of the String variable- Returns:
- true if the variable is theta
-
isLastEvaluatedAnswer
- Parameters:
str- the name of the String variable- Returns:
- true if the variable is the last result evaluated
-
isSimpleVar
public boolean isSimpleVar()- Returns:
- true if the variable is a simple one i.e A-Z or theta
-
setName
- Parameters:
name- mutator method that changes the name of the variable
-
getName
- Returns:
- the String property of the variable
-
setValue
changes the value stored in the variable- Parameters:
value- The value to be stored. Sometimes the value contains a unit. To support this, the user should place a space between the value and the units.
-
setValue
public final void setValue(double value) -
getValue
public double getValue()returns the value of the variable- Returns:
- the value stored in the variable
-
setUnits
-
getUnits
-
getSimpleVarIndex
- Parameters:
var- the String property of the variable.This method returns the index of the Variable object that has this String property.- Returns:
- The index of the Variable object that has this String property.
-
getSimpleVarIndex
public int getSimpleVarIndex()- Returns:
-
equals
-
parse
-
serialize
-
toString
-
toJSON
-