Class Method

java.lang.Object
parser.methods.Method

public class Method
extends java.lang.Object
Models the methods that perform calculations in the parser.
Author:
JIBOYE OLUWAGBEMIRO OLAOLUWA
  • Constructor Details

    • Method

      public Method​(java.lang.String name, java.lang.String... parameters)
      Parameters:
      name - The method name
      parameters - The parameters to the method
    • Method

      public Method​(java.lang.String expression)
      Parameters:
      expression - Initializes the attributes of objects of this class by parsing the expression parameter. The format of expression is: methodname(args_1,args_2,....args_N)
  • Method Details

    • isFunctionOperatingMethod

      public static boolean isFunctionOperatingMethod​(java.lang.String methodName)
      Parameters:
      methodName - The name of the method.
      Returns:
      true if the method name represents one that can operate on Function objects or anonymous Functions.
    • getAllFunctions

      public static java.lang.String[] getAllFunctions()
      Returns:
      An array containing the names of all functions defined by the user and inbuilt into the software.
    • parseExpression

      public final void parseExpression​(java.lang.String expression)
      Parameters:
      expression - The expression to parse. The format of expression is: methodname(args_1,args_2,....args_N)
    • setName

      public void setName​(java.lang.String name)
    • getName

      public java.lang.String getName()
    • setParameters

      public void setParameters​(java.lang.String[] parameters)
    • getParameters

      public java.lang.String[] getParameters()
    • setDRG

      public void setDRG​(int DRG)
    • getDRG

      public int getDRG()
    • isListReturningStatsMethod

      public static boolean isListReturningStatsMethod​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is a statistical operator that returns items in a list e.g sort(
    • isNumberReturningStatsMethod

      public static boolean isNumberReturningStatsMethod​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is a statistical operator that operates on a data set and returns a single value: e.g sum(4,3,2,2...)
    • isRandom

      public static boolean isRandom​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the random(rnd) operator
    • isLogToAnyBase

      public static boolean isLogToAnyBase​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the log operator the form is log(num,base)
    • isAntiLogToAnyBase

      public static boolean isAntiLogToAnyBase​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the log operator the form is log-¹(num,base)
    • isNaturalLog

      public static boolean isNaturalLog​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the natural log operator the form is log-¹(num,base)
    • isInverseNaturalLog

      public static boolean isInverseNaturalLog​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the inverse natural log operator the form is log-¹(num,base)
    • isExpMethod

      public static boolean isExpMethod​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the inverse natural log operator the form is log-¹(num,base)
    • isLogOrAntiLogToAnyBase

      public static boolean isLogOrAntiLogToAnyBase​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the log operator or the log-¹ operator
    • isDeterminant

      public boolean isDeterminant​(java.lang.String op)
    • isMatrixInvert

      public boolean isMatrixInvert​(java.lang.String op)
    • isLinearSys

      public boolean isLinearSys​(java.lang.String op)
    • isTriMat

      public boolean isTriMat​(java.lang.String op)
    • isEchelon

      public boolean isEchelon​(java.lang.String op)
    • isMatrixCofactors

      public boolean isMatrixCofactors​(java.lang.String op)
    • isMatrixAdjoint

      public boolean isMatrixAdjoint​(java.lang.String op)
    • isMatrixEigenVec

      public boolean isMatrixEigenVec​(java.lang.String op)
    • isMatrixEigenPoly

      public boolean isMatrixEigenPoly​(java.lang.String op)
    • isPrint

      public boolean isPrint​(java.lang.String op)
    • isStatsMethod

      public static boolean isStatsMethod​(java.lang.String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is a statistical operator..basically any system function that takes more than 1 argument. So by definition even the log and alog (and its log-¹ variant) are included here. e.g sum,prod,min,max,avg,var,rms,cov,s_d,st_err,rng,mrng,med,mode,rnd
    • isMatrixMethod

      public static boolean isMatrixMethod​(java.lang.String op)
      Parameters:
      op - The method name
      Returns:
      true if the method is capable of acting on one or more matrix functions
    • isMatrixMul

      public static boolean isMatrixMul​(java.lang.String op)
      Parameters:
      op - The method name
      Returns:
      true if the method is the matrix multiplication method name
    • isMatrixDiv

      public static boolean isMatrixDiv​(java.lang.String op)
      Parameters:
      op - The method name
      Returns:
      true if the method is the matrix division method name
    • isMatrixAdd

      public static boolean isMatrixAdd​(java.lang.String op)
      Parameters:
      op - The method name
      Returns:
      true if the method is the matrix addition method name
    • isMatrixSub

      public static boolean isMatrixSub​(java.lang.String op)
      Parameters:
      op - The method name
      Returns:
      true if the method is the matrix subtraction method name
    • isMatrixPow

      public static boolean isMatrixPow​(java.lang.String op)
      Parameters:
      op - The method name
      Returns:
      true if the method is the matrix power method name
    • isTranspose

      public static boolean isTranspose​(java.lang.String op)
      Parameters:
      op - The method name
      Returns:
      true if the method is the transpose method name
    • isMatrixEdit

      public static boolean isMatrixEdit​(java.lang.String op)
      Parameters:
      op - The method name
      Returns:
      true if the method is the matrix edit method name
    • isUserDefinedFunction

      public static boolean isUserDefinedFunction​(java.lang.String op)
      Returns:
      true if the Function name has been defined by the user in the user's workspace.
    • run

      public static java.util.List<java.lang.String> run​(java.util.List<java.lang.String> list, DRG_MODE DRG)
      Parameters:
      list - A list containing a portion of a scanned function that has information about a method and its parameters..e.g. [sin,(,3.14,)] , or [matrix_edit,(,M,3,4,-90,)] may be grabbed from a scanner output and sent to this method to evaluate.
      DRG - The trigonometric mode in which to run the method.
      Returns:
      a List object which is the output of the method's operation.
    • isUnaryPreOperatorORDefinedMethod

      public static boolean isUnaryPreOperatorORDefinedMethod​(java.lang.String methodName)
      Parameters:
      methodName - The name of the method
      Returns:
      true if the method has been defined by the user or is defined by the parser.
    • isDefinedMethod

      public static boolean isDefinedMethod​(java.lang.String methodName)
      Parameters:
      methodName - The name of the method
      Returns:
      true if the method has been defined by the user or is defined by the parser.
    • isInBuiltMethod

      public static boolean isInBuiltMethod​(java.lang.String methodName)
      Parameters:
      methodName - The name of the method
      Returns:
      true if the method is defined by the parser as a core inbuilt function.
    • arrayContains

      public static boolean arrayContains​(java.lang.String[] array, java.lang.String str)
      Parameters:
      array - An array of strings
      str - The string to check for.
      Returns:
      true if the array contains the specified string.
    • isMethodName

      public static boolean isMethodName​(java.lang.String name)
      Parameters:
      name - The string to check if or not it represents a valid method name.
      The method may or may not have been defined. But once it represents a valid method name, this method will return true. In contrast, the 'isDefinedMethod' checks whether or not the method has been afore-defined.
      Returns:
      true if the string represents a valid method name.
    • isMethodNameBuilder

      public static boolean isMethodNameBuilder​(java.lang.String name)
      Parameters:
      name - The string to check.
      Returns:
      true if the string is part of the valid characters that can be used to build a method name.
    • isMethodNameBeginner

      public static boolean isMethodNameBeginner​(java.lang.String name)
      Parameters:
      name - The string to check.
      Returns:
      true if the string can be the first character in a method name.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hasStatsMethod

      public static boolean hasStatsMethod​(java.lang.String expr)
      Scans the given expression for statistical operators
      Parameters:
      expr - The input expression
      Returns:
      true if it finds statistical operators in the expression.
    • main

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