Class VariableManager
java.lang.Object
com.github.gbenroscience.util.VariableManager
- Author:
- JIBOYE Oluwagbemiro Olaoluwa
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classObjects of this class parse a variable initialization or modifying command string. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidIntroduces a Variablestatic voidIntroduces an array or variable-args list of VariablevoidClears all constantsstatic voidClears all VariablesvoidClears All Variables and Constantsbooleanstatic voiddeletes a Variable or constant whose name is knownstatic StringgenerateCommandStringFromVariableNamesArray(String[] variableNames) static Stringintstatic VariablegetVariable(String vName) static voidinit()Initializes the variables store and loads them from persistent storagestatic voidload(Collection<Variable> variables) static voidstatic voidstatic VariableAttempts to retrieve a Variable object from a VariableManager based on its name.static voidfinal voidparseCommand(String cmd) Parses a command that creates or changes the value of variables.parseSingleCommand(String cmd) Parses a command that creates a single variable or changes its value.voidreset()static Variablestatic VariablevoidsetCommandParser(VariableManager.CommandInterpreter commandParser) intsize()Returns the total number of slots required for the execution frame.toString()static voidupdate()Saves stored variables and updates the UI that renders the variables.
-
Field Details
-
endOfLine
- See Also:
-
VARIABLES
-
-
Constructor Details
-
VariableManager
public VariableManager()
-
-
Method Details
-
getSlot
-
size
public int size()Returns the total number of slots required for the execution frame. -
reset
public void reset() -
getCommandParser
-
setCommandParser
-
getEndOfLine
-
getVarStore
-
load
- Parameters:
variables- ACollectionofVariableobjects.
-
load
-
load
-
contains
- Parameters:
variableName- The name attribute of the variable we are searching the variable store for.- Returns:
- true if it finds a variable by that name in the store.
-
parseSingleCommand
-
parseCommand
Parses a command that creates or changes the value of variables.- Parameters:
cmd- The command string to parse.
-
update
public static void update()Saves stored variables and updates the UI that renders the variables. -
init
public static void init()Initializes the variables store and loads them from persistent storage -
getVariable
-
lookUp
-
saveIfNotExists
-
saveOrUpdate
-
delete
deletes a Variable or constant whose name is known- Parameters:
varName- the name of the Variable object to be deleted
-
add
Introduces a Variable- Parameters:
var- the name of the Variable object to be added to the Variable Registry
-
add
Introduces an array or variable-args list of Variable- Parameters:
vars- the variable args list of the Variable objects to be added to the Variable Registry
-
clearVariables
public static void clearVariables()Clears all Variables -
clearConstants
public void clearConstants()Clears all constants -
clearVariablesAndConstants
public void clearVariablesAndConstants()Clears All Variables and Constants -
generateCommandStringFromVariableNamesArray
- Parameters:
variableNames- An array containing valid variable names- Returns:
- a command string that initializes the variable names to 0.0 e.g if the array is [a,v,b,m,n], then the output is: a=0.0;v=0.0;b=0.0;m=0.0;n=0.0
-
getVariables
-
toString
-
main
-