Package math.matrix

Class MatrixVariableManager


  • public class MatrixVariableManager
    extends java.lang.Object
    Objects of this class have data storing capability and store this data in the form of Constant( Once created its value cannot be changed, neither can they be duplicated in an object of this class.) and Variable objects. The class seres as storage and manages various desirable properties of the class. e.g Display of data on tables, creation, deletion, guarding against de-naturing( of Constant objects by making their values immutable.) The class is created for working with the parser and the releveant calculating ware that will use it. The parser will check with objects of this class (maintained by the calculator as a field) for the value of its variables and place the value in its input before proceeding with parsing operations. This implementation of the class uses a Timer object to remove earlier duplicates of Variable objects that it stores at regular intervals. The definitiion of a duplicate Variable here is that which any calculator user will automatically attach to it.i.e A symbol represented with a particular character sequence to which any value can be assigned. The current value stored by the Variable is the last value assigned to it. In order to avoid confusion and prevent an over-growth of the size of the Variable store, Later duplicates must be removed periodically or just before the user performs important operations like viewing the Variable database, storing the Variable objects on a persistent storage device, closing the program e.t.c. A timer object can do this (remove later duplicates)automatically or the programmer can watch for actions that might require the user or the program to perform the above specified operations and manually remove the duplicates. If you do not wish this action to be automatic please either you remove the object entirely or set the delay to a very large value say 2 billion, or Integer.MAX_VALUE or create objects of this class with the no-argument constructor of the class, which does not start the timer object.
    Author:
    GBEMIRO
    • Constructor Summary

      Constructors 
      Constructor Description
      MatrixVariableManager()  
      MatrixVariableManager​(int interval)
      Creates a new VariableManager object with a given time interval in which it searches through its variable store and removes all duplicate elements.
    • Method Summary

      Modifier and Type Method Description
      void clearVariables()
      Clears all Variables
      void clearVariablesAndConstants()
      Clears All Variables and Constants
      boolean contains​(java.lang.String name)  
      void deleteVar​(int index)
      deletes a Variable or constant whose location in varStore is known
      void deleteVar​(java.lang.String varName)
      deletes a Variable or constant whose name is known
      int getInterval()  
      MatrixVariable getVarFromIndex​(int index)  
      int getVarIndexFromVarName​(java.lang.String name)  
      java.util.ArrayList<MatrixVariable> getVarStore()  
      boolean isIntervalChanged()  
      static boolean isValidCommandString()  
      static void main​(java.lang.String[] args)  
      void removeDuplicates()
      scans the storage for Variables with similar names and removes all earlier occurences (found farther down the storage) from the storage.Note that later or more recent versions of Variables are found towards the beginning of the storage.
      void setInterval​(int interval)  
      void setIntervalChanged​(boolean intervalChanged)  
      static void setValidCommandString​(boolean validCommandString)  
      void setVarStore​(java.util.ArrayList<MatrixVariable> varStore)
      set the storage to the new one specified by the parameter of this method
      void storeVariable​(java.lang.String cmd)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MatrixVariableManager

        public MatrixVariableManager()
      • MatrixVariableManager

        public MatrixVariableManager​(int interval)
        Creates a new VariableManager object with a given time interval in which it searches through its variable store and removes all duplicate elements.
        Parameters:
        interval - the interval between which the object automatically refreshes its Variable store
    • Method Detail

      • getInterval

        public int getInterval()
      • setInterval

        public void setInterval​(int interval)
      • isIntervalChanged

        public boolean isIntervalChanged()
      • setIntervalChanged

        public void setIntervalChanged​(boolean intervalChanged)
      • isValidCommandString

        public static boolean isValidCommandString()
      • setValidCommandString

        public static void setValidCommandString​(boolean validCommandString)
      • getVarFromIndex

        public MatrixVariable getVarFromIndex​(int index)
        Parameters:
        index - the Variable object located at the given index.
        Returns:
        the Variable object located at the index.
      • getVarIndexFromVarName

        public int getVarIndexFromVarName​(java.lang.String name)
        Parameters:
        name - the name of the Variable object whose index in the manager is desired.
        Returns:
        the index of the Variable if found and -1 if not.
      • contains

        public boolean contains​(java.lang.String name)
        Parameters:
        name - the name of the Variable.
        Returns:
        true if the manager contains the Variable that goes by this name.
      • storeVariable

        public void storeVariable​(java.lang.String cmd)
        Parameters:
        cmd - The command used to create and store the variable
      • removeDuplicates

        public void removeDuplicates()
        scans the storage for Variables with similar names and removes all earlier occurences (found farther down the storage) from the storage.Note that later or more recent versions of Variables are found towards the beginning of the storage.
      • getVarStore

        public java.util.ArrayList<MatrixVariable> getVarStore()
        Returns:
        the storage object of this class
      • setVarStore

        public void setVarStore​(java.util.ArrayList<MatrixVariable> varStore)
        set the storage to the new one specified by the parameter of this method
        Parameters:
        varStore - a new storage to be used as the storage for objects of this class
      • deleteVar

        public void deleteVar​(java.lang.String varName)
        deletes a Variable or constant whose name is known
        Parameters:
        varName - the name of the Variable object to be deleted
      • deleteVar

        public void deleteVar​(int index)
        deletes a Variable or constant whose location in varStore is known
        Parameters:
        index - the index of the Variable object to be deleted
      • clearVariables

        public void clearVariables()
        Clears all Variables
      • clearVariablesAndConstants

        public void clearVariablesAndConstants()
        Clears All Variables and Constants
      • main

        public static void main​(java.lang.String[] args)