Class Utilities


  • public class Utilities
    extends java.lang.Object
    Author:
    GBEMIRO
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.ArrayList<java.lang.String> whitespaceremover  
    • Constructor Summary

      Constructors 
      Constructor Description
      Utilities()  
    • Method Summary

      Modifier and Type Method Description
      static void evaluateTokens​(java.util.ArrayList<java.lang.String> scan)
      Evaluates products of numbers or divisions of numbers.
      static void freeSpaces​(java.util.List<java.lang.String> scan)  
      static java.lang.String getText​(java.util.ArrayList<java.lang.String> data)  
      static boolean isAutoGenNameFormat​(java.lang.String name)  
      static boolean isBaseVariable​(java.lang.String name)  
      static boolean isDifferentiable​(java.lang.String value)  
      static boolean isFormula​(java.lang.String name)  
      static void main​(java.lang.String[] s)  
      static void multipleBracketRemover​(java.util.ArrayList<java.lang.String> list)  
      static void multipleBracketRemover_​(java.util.ArrayList<java.lang.String> list)  
      void openBrackets​(java.util.ArrayList<java.lang.String> scan)
      Checks for the pattern..
      static void print​(java.lang.Object obj)  
      static void simplifyNegOneProducts​(java.util.ArrayList<java.lang.String> list)
      Simplifies portions of math code that involve products or quotients of -1.
      static void simplifyOneProducts​(java.util.ArrayList<java.lang.String> list)  
      static void simplifyZeroes​(java.util.ArrayList<java.lang.String> array)  
      static void simplifyZeroesAt​(int index, java.util.ArrayList<java.lang.String> list)  
      static void tokenRearranger​(java.util.ArrayList<java.lang.String> scan)
      Condenses numbers and variables to be added within a bracket to the end of the bracket.
      • Methods inherited from class java.lang.Object

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

      • whitespaceremover

        public static final java.util.ArrayList<java.lang.String> whitespaceremover
    • Constructor Detail

      • Utilities

        public Utilities()
    • Method Detail

      • freeSpaces

        public static void freeSpaces​(java.util.List<java.lang.String> scan)
      • print

        public static void print​(java.lang.Object obj)
      • isAutoGenNameFormat

        public static boolean isAutoGenNameFormat​(java.lang.String name)
        Parameters:
        name - The name to check.
        Returns:
        true if the name is automatically generated and so, most likely refers to a stored Differentiable.
      • isBaseVariable

        public static boolean isBaseVariable​(java.lang.String name)
        Parameters:
        name - The name to check.
        Returns:
        true if the name is automatically generated and so, most likely refers to a stored Differentiable.
      • getText

        public static java.lang.String getText​(java.util.ArrayList<java.lang.String> data)
        Parameters:
        data - An ArrayList of Strings. return the Strings in the List concatenated together.
      • isDifferentiable

        public static boolean isDifferentiable​(java.lang.String value)
        Parameters:
        value - The item to check Always double check in the scanner where this item exists that the next token to value is not an open bracket if value is a valid variable name.
        Returns:
        true if it can be differentiated to get a value.
      • isFormula

        public static boolean isFormula​(java.lang.String name)
      • simplifyNegOneProducts

        public static void simplifyNegOneProducts​(java.util.ArrayList<java.lang.String> list)
        Simplifies portions of math code that involve products or quotients of -1.
        Parameters:
        list - The list of math tokens.
      • simplifyZeroes

        public static void simplifyZeroes​(java.util.ArrayList<java.lang.String> array)
        Parameters:
        array - The scanned list containing math tokens. This method seeks to apply the algebraic effect of adding or subtracting or multiplying zeroes to a math expression. e.g. 3*x*0+4*1 becomes 4*1.
      • simplifyZeroesAt

        public static void simplifyZeroesAt​(int index,
                                            java.util.ArrayList<java.lang.String> list)
        Parameters:
        index - The index at which the zero is.
        list - The scanned list containing math tokens. Method that recursively applies the effect of zero at its point of occurrence to a math expression.
      • simplifyOneProducts

        public static void simplifyOneProducts​(java.util.ArrayList<java.lang.String> list)
        Parameters:
        list - The ArrayList containing it. Seeks to calculate the effect of multiplying 1 with quantities in the list...e.g 1*(....) becomes (.....), 1*sin(...) becomes sin(...)
      • openBrackets

        public void openBrackets​(java.util.ArrayList<java.lang.String> scan)
        Checks for the pattern.. ...+,(,.......,)+|- and removes the bracket..if possible.
        Parameters:
        scan - The list of math tokens
      • evaluateTokens

        public static void evaluateTokens​(java.util.ArrayList<java.lang.String> scan)
        Evaluates products of numbers or divisions of numbers.
        Parameters:
        scan - The scanner output.
      • tokenRearranger

        public static void tokenRearranger​(java.util.ArrayList<java.lang.String> scan)
        Condenses numbers and variables to be added within a bracket to the end of the bracket. For instance,(3+x+sin(3*x)+5-7) becomes (sin(3*x)+3+x-2)
        Parameters:
        scan - The scanner output.
      • multipleBracketRemover

        public static void multipleBracketRemover​(java.util.ArrayList<java.lang.String> list)
        Parameters:
        list - The list containing the scanned math tokens.
      • multipleBracketRemover_

        public static void multipleBracketRemover_​(java.util.ArrayList<java.lang.String> list)
        Parameters:
        list - The list containing the scanned math tokens.
      • main

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