public class Argument extends PrimitiveElement
Using Argument class you can define two argument types:
When creating an argument you should avoid names reserved as parser keywords, in general words known in mathematical language as function names, operators (for example: sin, cos, +, -, etc...). Please be informed that after associating the argument with the expression, function or dependent/recursive argument its name will be recognized by the parser as reserved key word. It means that it could not be the same as any other key word known by the parser for this particular expression. Parser is case sensitive.
RecursiveArgument
,
Expression
,
Function
,
Constant
Modifier and Type | Field and Description |
---|---|
static double |
ARGUMENT_INITIAL_VALUE
Double.NaN as initial value of the argument.
|
static int |
DEPENDENT_ARGUMENT
Type indicator for dependent argument.
|
static int |
FREE_ARGUMENT
Type indicator for free argument.
|
static boolean |
NO_SYNTAX_ERRORS
No syntax errors in the dependent argument definition.
|
static int |
NOT_FOUND
When argument was not not found
|
static int |
RECURSIVE_ARGUMENT
Type indicator for recursive argument.
|
static boolean |
SYNTAX_ERROR_OR_STATUS_UNKNOWN
Syntax error in the dependent argument definition.
|
static java.lang.String |
TYPE_DESC |
static int |
TYPE_ID
Argument type id for the definition of key words
known by the parser.
|
Constructor and Description |
---|
Argument(java.lang.String argumentName,
double argumentValue)
Constructor - creates free argument.
|
Argument(java.lang.String argumentDefinitionString,
PrimitiveElement... elements)
Default constructor - creates argument based on the argument definition string.
|
Argument(java.lang.String argumentName,
java.lang.String argumentExpressionString,
PrimitiveElement... elements)
Constructor - creates dependent argument(with hidden
argument expression).
|
Modifier and Type | Method and Description |
---|---|
void |
addArguments(Argument... arguments)
Adds arguments (variadic) to the argument expression definition.
|
void |
addConstants(Constant... constants)
Adds constants (variadic parameters) to the argument expression definition.
|
void |
addConstants(java.util.List<Constant> constantsList)
Adds constants to the argument expression definition.
|
void |
addDefinitions(PrimitiveElement... elements)
Adds user defined elements (such as: Arguments, Constants, Functions)
to the argument expressions.
|
void |
addFunctions(Function... functions)
Adds functions (variadic parameters) to the argument expression definition.
|
boolean |
checkSyntax()
Checks argument syntax
|
Argument |
clone()
Creates cloned object of the this argument.''
|
void |
defineArgument(java.lang.String argumentName,
double argumentValue)
Enables to define the argument (associated with the argument expression)
based on the argument name and the argument value.
|
void |
defineArguments(java.lang.String... argumentsNames)
Enables to define the arguments (associated with
the argument expression) based on the given arguments names.
|
void |
defineConstant(java.lang.String constantName,
double constantValue)
Enables to define the constant (associated with
the argument expression) based on the constant name and
constant value.
|
void |
defineFunction(java.lang.String functionName,
java.lang.String functionExpressionString,
java.lang.String... argumentsNames)
Enables to define the function (associated with
the argument expression) based on the function name,
function expression string and arguments names (variadic parameters).
|
Argument |
getArgument(int argumentIndex)
Gets argument from the argument expression.
|
Argument |
getArgument(java.lang.String argumentName)
Gets argument from the argument expression.
|
java.lang.String |
getArgumentExpressionString()
Gets argument expression string
|
int |
getArgumentIndex(java.lang.String argumentName)
Gets argument index from the argument expression.
|
java.lang.String |
getArgumentName()
Gets argument name
|
int |
getArgumentsNumber()
Gets number of arguments associated with the argument expression.
|
int |
getArgumentType()
Gets argument type
|
double |
getArgumentValue()
Gets argument value.
|
double |
getComputingTime()
Gets computing time
|
Constant |
getConstant(int constantIndex)
Gets constant associated with the argument expression.
|
Constant |
getConstant(java.lang.String constantName)
Gets constant associated with the argument expression.
|
int |
getConstantIndex(java.lang.String constantName)
Gets constant index associated with the argument expression.
|
int |
getConstantsNumber()
Gets number of constants associated with the argument expression.
|
java.lang.String |
getDescription()
Gets argument description.
|
java.lang.String |
getErrorMessage()
Returns error message after checking the syntax
|
Function |
getFunction(int functionIndex)
Gets function associated with the argument expression.
|
Function |
getFunction(java.lang.String functionName)
Gets function associated with the argument expression.
|
int |
getFunctionIndex(java.lang.String functionName)
Gets index of function associated with the argument expression.
|
int |
getFunctionsNumber()
Gets number of functions associated with the argument expression.
|
boolean |
getRecursiveMode()
Gets recursive mode status
|
boolean |
getVerboseMode()
Returns verbose mode status
|
void |
removeAllArguments()
Removes all arguments associated with the argument expression.
|
void |
removeAllConstants()
Removes all constants
associated with the argument expression
|
void |
removeAllFunctions()
Removes all functions
associated with the argument expression.
|
void |
removeArguments(Argument... arguments)
Removes first occurrences of the arguments
associated with the argument expression.
|
void |
removeArguments(java.lang.String... argumentsNames)
Removes first occurrences of the arguments
associated with the argument expression.
|
void |
removeConstants(Constant... constants)
Removes first occurrences of the constants
associated with the argument expression
|
void |
removeConstants(java.lang.String... constantsNames)
Removes first occurrences of the constants
associated with the argument expression.
|
void |
removeDefinitions(PrimitiveElement... elements)
Removes user defined elements (such as: Arguments, Constants, Functions)
from the argument expressions.
|
void |
removeFunctions(Function... functions)
Removes first occurrences of the functions
associated with the argument expression.
|
void |
removeFunctions(java.lang.String... functionsNames)
Removes first occurrences of the functions
associated with the argument expression.
|
void |
setArgumentExpressionString(java.lang.String argumentExpressionString)
Sets argument expression string.
|
void |
setArgumentName(java.lang.String argumentName)
Sets (modifies) argument name.
|
void |
setArgumentValue(double argumentValue)
Sets argument value
|
void |
setDescription(java.lang.String description)
Sets argument description.
|
void |
setSilentMode()
Disables argument verbose mode (sets default silent mode)
|
void |
setVerboseMode()
Enables argument verbose mode
|
getMyTypeId
public static final boolean NO_SYNTAX_ERRORS
public static final boolean SYNTAX_ERROR_OR_STATUS_UNKNOWN
public static final double ARGUMENT_INITIAL_VALUE
public static final int NOT_FOUND
public static final int FREE_ARGUMENT
public static final int DEPENDENT_ARGUMENT
public static final int RECURSIVE_ARGUMENT
public static final int TYPE_ID
public static final java.lang.String TYPE_DESC
public Argument(java.lang.String argumentDefinitionString, PrimitiveElement... elements)
argumentDefinitionString
- Argument definition string, i.e.:
elements
- Optional parameters (comma separated) such as Arguments, Constants, Functionspublic Argument(java.lang.String argumentName, double argumentValue)
argumentName
- the argument nameargumentValue
- the argument valuepublic Argument(java.lang.String argumentName, java.lang.String argumentExpressionString, PrimitiveElement... elements)
argumentName
- the argument nameargumentExpressionString
- the argument expression stringelements
- Optional parameters (comma separated)
such as Arguments, Constants, FunctionsExpression
,
PrimitiveElement
public void setDescription(java.lang.String description)
description
- the argument description.public java.lang.String getDescription()
public void setVerboseMode()
public void setSilentMode()
public boolean getVerboseMode()
public boolean getRecursiveMode()
public double getComputingTime()
public void setArgumentName(java.lang.String argumentName)
argumentName
- the argument namepublic void setArgumentExpressionString(java.lang.String argumentExpressionString)
argumentExpressionString
- the argument expression stringExpression
public java.lang.String getArgumentName()
public java.lang.String getArgumentExpressionString()
public int getArgumentType()
public void setArgumentValue(double argumentValue)
argumentValue
- the value of argumentpublic boolean checkSyntax()
public java.lang.String getErrorMessage()
public double getArgumentValue()
public void addDefinitions(PrimitiveElement... elements)
elements
- Elements list (variadic - comma separated) of types: Argument, Constant, FunctionPrimitiveElement
public void removeDefinitions(PrimitiveElement... elements)
elements
- Elements list (variadic - comma separated) of types: Argument, Constant, FunctionPrimitiveElement
public void addArguments(Argument... arguments)
arguments
- the arguments list
(comma separated list)Argument
,
RecursiveArgument
public void defineArguments(java.lang.String... argumentsNames)
argumentsNames
- the arguments names (variadic)
comma separated listArgument
,
RecursiveArgument
public void defineArgument(java.lang.String argumentName, double argumentValue)
argumentName
- the argument nameargumentValue
- the the argument valueArgument
,
RecursiveArgument
public int getArgumentIndex(java.lang.String argumentName)
argumentName
- the argument nameArgument
,
RecursiveArgument
public Argument getArgument(java.lang.String argumentName)
argumentName
- the argument nameArgument
,
RecursiveArgument
public Argument getArgument(int argumentIndex)
argumentIndex
- the argument indexArgument
,
RecursiveArgument
public int getArgumentsNumber()
Argument
,
RecursiveArgument
public void removeArguments(java.lang.String... argumentsNames)
argumentsNames
- the arguments names
(variadic parameters) comma separated
listArgument
,
RecursiveArgument
public void removeArguments(Argument... arguments)
arguments
- the arguments (variadic parameters)
comma separated listArgument
,
RecursiveArgument
public void removeAllArguments()
Argument
,
RecursiveArgument
public void addConstants(Constant... constants)
constants
- the constants
(comma separated list)Constant
public void addConstants(java.util.List<Constant> constantsList)
constantsList
- the list of constantsConstant
public void defineConstant(java.lang.String constantName, double constantValue)
constantName
- the constant nameconstantValue
- the constant valueConstant
public int getConstantIndex(java.lang.String constantName)
constantName
- the constant nameConstant
public Constant getConstant(java.lang.String constantName)
constantName
- the constant nameConstant
public Constant getConstant(int constantIndex)
constantIndex
- the constant indexConstant
public int getConstantsNumber()
Constant
public void removeConstants(java.lang.String... constantsNames)
constantsNames
- the constants names (variadic parameters)
comma separated listConstant
public void removeConstants(Constant... constants)
constants
- the constants (variadic parameters)
comma separated listConstant
public void removeAllConstants()
Constant
public void addFunctions(Function... functions)
functions
- the functions
(variadic parameters) comma separated listFunction
public void defineFunction(java.lang.String functionName, java.lang.String functionExpressionString, java.lang.String... argumentsNames)
functionName
- the function namefunctionExpressionString
- the expression stringargumentsNames
- the function arguments names
(variadic parameters)
comma separated listFunction
public int getFunctionIndex(java.lang.String functionName)
functionName
- the function nameFunction
public Function getFunction(java.lang.String functionName)
functionName
- the function nameFunction
public Function getFunction(int functionIndex)
functionIndex
- the function indexFunction
public int getFunctionsNumber()
Function
public void removeFunctions(java.lang.String... functionsNames)
functionsNames
- the functions names (variadic parameters)
comma separated listFunction
public void removeFunctions(Function... functions)
functions
- the functions (variadic parameters)
comma separated list.Function
public void removeAllFunctions()
Function
public Argument clone()
clone
in class java.lang.Object