Class Method

java.lang.Object
parser.methods.Method

public class Method extends Object
Models the methods that perform calculations in the parser.
  • Field Details

    • name

      private String name
      The method name. This is a sequence of letters,digits,underscore, and dollar sign characters,which must start either with a letter,a dollar sign or an underscore.It may end with the inverse symbol,also.
    • parameters

      private String[] parameters
      The method parameters.
    • DRG

      private int DRG
      The trig mode. DEGREES,RADIANS OR GRADS.
  • Constructor Details

    • Method

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

      public Method(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(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 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(String expression)
      Parameters:
      expression - The expression to parse. The format of expression is: methodname(args_1,args_2,....args_N)
    • setName

      public void setName(String name)
    • getName

      public String getName()
    • setParameters

      public void setParameters(String[] parameters)
    • getParameters

      public String[] getParameters()
    • setDRG

      public void setDRG(int DRG)
    • getDRG

      public int getDRG()
    • isListReturningStatsMethod

      public static boolean isListReturningStatsMethod(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(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(String op)
      Parameters:
      op - the String to check
      Returns:
      true if the operator is the random(rnd) operator
    • isLogToAnyBase

      public static boolean isLogToAnyBase(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(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(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(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(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(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(String op)
    • isMatrixInvert

      public boolean isMatrixInvert(String op)
    • isLinearSys

      public boolean isLinearSys(String op)
    • isTriMat

      public boolean isTriMat(String op)
    • isEchelon

      public boolean isEchelon(String op)
    • isMatrixCofactors

      public boolean isMatrixCofactors(String op)
    • isMatrixAdjoint

      public boolean isMatrixAdjoint(String op)
    • isMatrixEigenVec

      public boolean isMatrixEigenVec(String op)
    • isMatrixEigenPoly

      public boolean isMatrixEigenPoly(String op)
    • isPrint

      public boolean isPrint(String op)
    • isStatsMethod

      public static boolean isStatsMethod(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(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(String op)
      Parameters:
      op - The method name
      Returns:
      true if the method is the matrix multiplication method name
    • isMatrixDiv

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

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

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

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

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

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

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

      private static void quickFixCompoundStructuresInStatsExpression(List<String> list)
      A fix for stuff like sum,(,13,+,3,)...
    • run

      public static List<String> run(List<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(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(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(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(String[] array, 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(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(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(String name)
      Parameters:
      name - The string to check.
      Returns:
      true if the string can be the first character in a method name.
    • toString

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • join

      private static String[] join(String[] arr1, String[] arr2)
      Appends the contents of the 2 arrays and returns the result as a new array object.
      Parameters:
      arr1 - The first array.
      arr2 - The second array.
    • isHardcodedStatsMethod

      private static boolean isHardcodedStatsMethod(String op)
    • hasStatsMethod

      public static boolean hasStatsMethod(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(String[] args)