Package parser.methods
Class Method
java.lang.Object
parser.methods.Method
Models the methods that perform calculations in the parser.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
arrayContains
(String[] array, String str) boolean
static String[]
int
getDRG()
getName()
String[]
static boolean
hasStatsMethod
(String expr) Scans the given expression for statistical operatorsstatic boolean
static boolean
isDefinedMethod
(String methodName) boolean
isDeterminant
(String op) boolean
static boolean
isExpMethod
(String op) static boolean
isFunctionOperatingMethod
(String methodName) private static boolean
static boolean
isInBuiltMethod
(String methodName) static boolean
boolean
isLinearSys
(String op) static boolean
static boolean
static boolean
isLogToAnyBase
(String op) static boolean
isMatrixAdd
(String op) boolean
boolean
static boolean
isMatrixDiv
(String op) static boolean
isMatrixEdit
(String op) boolean
boolean
boolean
isMatrixInvert
(String op) static boolean
isMatrixMethod
(String op) static boolean
isMatrixMul
(String op) static boolean
isMatrixPow
(String op) static boolean
isMatrixSub
(String op) static boolean
isMethodName
(String name) static boolean
isMethodNameBeginner
(String name) static boolean
isMethodNameBuilder
(String name) static boolean
isNaturalLog
(String op) static boolean
boolean
static boolean
static boolean
isStatsMethod
(String op) static boolean
isTranspose
(String op) boolean
static boolean
isUnaryPreOperatorORDefinedMethod
(String methodName) static boolean
private static String[]
Appends the contents of the 2 arrays and returns the result as a new array object.static void
final void
parseExpression
(String expression) private static void
A fix for stuff like sum,(,13,+,3,)...void
setDRG
(int DRG) void
void
setParameters
(String[] parameters) toString()
-
Field Details
-
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
The method parameters. -
DRG
private int DRGThe trig mode. DEGREES,RADIANS OR GRADS.
-
-
Constructor Details
-
Method
- Parameters:
name
- The method nameparameters
- The parameters to the method
-
Method
- 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
- 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
- Returns:
- An array containing the names of all functions defined by the user and inbuilt into the software.
-
parseExpression
- Parameters:
expression
- The expression to parse. The format of expression is: methodname(args_1,args_2,....args_N)
-
setName
-
getName
-
setParameters
-
getParameters
-
setDRG
public void setDRG(int DRG) -
getDRG
public int getDRG() -
isListReturningStatsMethod
- 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
- 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
- Parameters:
op
- the String to check- Returns:
- true if the operator is the random(rnd) operator
-
isLogToAnyBase
- Parameters:
op
- the String to check- Returns:
- true if the operator is the log operator the form is log(num,base)
-
isAntiLogToAnyBase
- Parameters:
op
- the String to check- Returns:
- true if the operator is the log operator the form is log-¹(num,base)
-
isNaturalLog
- Parameters:
op
- the String to check- Returns:
- true if the operator is the natural log operator the form is log-¹(num,base)
-
isInverseNaturalLog
- Parameters:
op
- the String to check- Returns:
- true if the operator is the inverse natural log operator the form is log-¹(num,base)
-
isExpMethod
- Parameters:
op
- the String to check- Returns:
- true if the operator is the inverse natural log operator the form is log-¹(num,base)
-
isLogOrAntiLogToAnyBase
- Parameters:
op
- the String to check- Returns:
- true if the operator is the log operator or the log-¹ operator
-
isDeterminant
-
isMatrixInvert
-
isLinearSys
-
isTriMat
-
isEchelon
-
isMatrixCofactors
-
isMatrixAdjoint
-
isMatrixEigenVec
-
isMatrixEigenPoly
-
isPrint
-
isStatsMethod
- 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
andalog
(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
- Parameters:
op
- The method name- Returns:
- true if the method is capable of acting on one or more matrix functions
-
isMatrixMul
- Parameters:
op
- The method name- Returns:
- true if the method is the matrix multiplication method name
-
isMatrixDiv
- Parameters:
op
- The method name- Returns:
- true if the method is the matrix division method name
-
isMatrixAdd
- Parameters:
op
- The method name- Returns:
- true if the method is the matrix addition method name
-
isMatrixSub
- Parameters:
op
- The method name- Returns:
- true if the method is the matrix subtraction method name
-
isMatrixPow
- Parameters:
op
- The method name- Returns:
- true if the method is the matrix power method name
-
isTranspose
- Parameters:
op
- The method name- Returns:
- true if the method is the transpose method name
-
isMatrixEdit
- Parameters:
op
- The method name- Returns:
- true if the method is the matrix edit method name
-
isUserDefinedFunction
- Returns:
- true if the Function name has been defined by the user in the user's workspace.
-
quickFixCompoundStructuresInStatsExpression
A fix for stuff like sum,(,13,+,3,)... -
run
- 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
- 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
- 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
- Parameters:
methodName
- The name of the method- Returns:
- true if the method is defined by the parser as a core inbuilt function.
-
arrayContains
- Parameters:
array
- An array of stringsstr
- The string to check for.- Returns:
- true if the array contains the specified string.
-
isMethodName
- 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
- 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
- Parameters:
name
- The string to check.- Returns:
- true if the string can be the first character in a method name.
-
toString
-
equals
-
join
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
-
hasStatsMethod
Scans the given expression for statistical operators- Parameters:
expr
- The input expression- Returns:
- true if it finds statistical operators in the expression.
-
main
-