Package parser.methods
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 Summary
-
Method Summary
Modifier and Type Method Description static booleanarrayContains(java.lang.String[] array, java.lang.String str)booleanequals(java.lang.Object obj)static java.lang.String[]getAllFunctions()intgetDRG()java.lang.StringgetName()java.lang.String[]getParameters()static booleanhasStatsMethod(java.lang.String expr)Scans the given expression for statistical operatorsstatic booleanisAntiLogToAnyBase(java.lang.String op)static booleanisDefinedMethod(java.lang.String methodName)booleanisDeterminant(java.lang.String op)booleanisEchelon(java.lang.String op)static booleanisExpMethod(java.lang.String op)static booleanisFunctionOperatingMethod(java.lang.String methodName)static booleanisInBuiltMethod(java.lang.String methodName)static booleanisInverseNaturalLog(java.lang.String op)booleanisLinearSys(java.lang.String op)static booleanisListReturningStatsMethod(java.lang.String op)static booleanisLogOrAntiLogToAnyBase(java.lang.String op)static booleanisLogToAnyBase(java.lang.String op)static booleanisMatrixAdd(java.lang.String op)booleanisMatrixAdjoint(java.lang.String op)booleanisMatrixCofactors(java.lang.String op)static booleanisMatrixDiv(java.lang.String op)static booleanisMatrixEdit(java.lang.String op)booleanisMatrixEigenPoly(java.lang.String op)booleanisMatrixEigenVec(java.lang.String op)booleanisMatrixInvert(java.lang.String op)static booleanisMatrixMethod(java.lang.String op)static booleanisMatrixMul(java.lang.String op)static booleanisMatrixPow(java.lang.String op)static booleanisMatrixSub(java.lang.String op)static booleanisMethodName(java.lang.String name)static booleanisMethodNameBeginner(java.lang.String name)static booleanisMethodNameBuilder(java.lang.String name)static booleanisNaturalLog(java.lang.String op)static booleanisNumberReturningStatsMethod(java.lang.String op)booleanisPrint(java.lang.String op)static booleanisRandom(java.lang.String op)static booleanisStatsMethod(java.lang.String op)static booleanisTranspose(java.lang.String op)booleanisTriMat(java.lang.String op)static booleanisUnaryPreOperatorORDefinedMethod(java.lang.String methodName)static booleanisUserDefinedFunction(java.lang.String op)static voidmain(java.lang.String[] args)voidparseExpression(java.lang.String expression)static java.util.List<java.lang.String>run(java.util.List<java.lang.String> list, DRG_MODE DRG)voidsetDRG(int DRG)voidsetName(java.lang.String name)voidsetParameters(java.lang.String[] parameters)java.lang.StringtoString()
-
Constructor Details
-
Method
public Method(java.lang.String name, java.lang.String... parameters)- Parameters:
name- The method nameparameters- 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
logandalog(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
Listobject 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 stringsstr- 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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.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)
-