Class DerivativeScanner

java.lang.Object
math.differentialcalculus.DerivativeScanner

public class DerivativeScanner extends Object
  • Field Details

    • expression

      String expression
    • scanner

      private ArrayList<String> scanner
    • syntaxValid

      private boolean syntaxValid
  • Constructor Details

  • Method Details

    • isNumber

      public static boolean isNumber(String token)
      Parameters:
      token - The token to examine.
      Returns:
      true if it is found to be a number.
    • isValidOperatorOrMethod

      private static boolean isValidOperatorOrMethod(String op)
      Parameters:
      op - The token to examine.
      Returns:
      true if it a valid operator or method in a differentiable function.
    • syntaxAnalyzer

      private boolean syntaxAnalyzer() throws Exception
      Returns:
      true if the tokens found in the array are either of type operator,variable,number or method...e.g sin,cos... At this stage also, we disallow the user from using inbuilt method names in user-defined variable names.
      Throws:
      Exception - if an invalid token is found during scanning,
    • setSyntaxValid

      public void setSyntaxValid(boolean syntaxValid)
    • isSyntaxValid

      public boolean isSyntaxValid()
    • setScanner

      public void setScanner(ArrayList<String> scanner)
    • getScanner

      public ArrayList<String> getScanner()
    • setExpression

      public void setExpression(String expression)
    • getExpression

      public String getExpression()
    • orderNumberTokens

      private void orderNumberTokens()
      Scans the list and arranges scattered parts of a single number token. CustomScanner is not built to leave numbers intact..but rather splits according to the supplied tokens. So since - and + were supplied as splitting tokens here, a number such as 3.2E9 would be left intact, whereas 3.2E-9 would be split into 3.2E,-,9
    • main

      public static void main(String[] args)