public class Constant extends PrimitiveElement
When creating a constant you should avoid names reserved as parser keywords, in general words known in mathematical language as function names, operators (for example: sin, cos, +, -, pi, e, etc...). Please be informed that after associating the constant 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.
RecursiveArgument
,
Expression
,
Function
,
Argument
Modifier and Type | Field and Description |
---|---|
static boolean |
NO_SYNTAX_ERRORS
Status of the Expression syntax
|
static int |
NOT_FOUND
When constant could not be found
|
static boolean |
SYNTAX_ERROR_OR_STATUS_UNKNOWN |
static java.lang.String |
TYPE_DESC |
static int |
TYPE_ID
Type identifier for constants
|
Constructor and Description |
---|
Constant(java.lang.String constantName,
double constantValue)
Constructor - creates constant with a given name and given value
|
Constant(java.lang.String constantName,
double constantValue,
java.lang.String description)
Constructor - creates constant with a given name and given value.
|
Constant(java.lang.String constantDefinitionString,
PrimitiveElement... elements)
Constructor for function definition in natural math language,
for instance providing on string "f(x,y) = sin(x) + cos(x)"
is enough to define function "f" with parameters "x and y"
and function body "sin(x) + cos(x)".
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getConstantName()
Gets constant name
|
double |
getConstantValue()
Gets constant value.
|
java.lang.String |
getDescription()
Gets constant description.
|
java.lang.String |
getErrorMessage()
Method return error message after
|
boolean |
getSyntaxStatus()
Gets syntax status of the expression.
|
void |
setConstantName(java.lang.String constantName)
Sets constant name.
|
void |
setDescription(java.lang.String description)
Sets constant description.
|
getMyTypeId
public static final int NOT_FOUND
public static final int TYPE_ID
public static final java.lang.String TYPE_DESC
public static final boolean NO_SYNTAX_ERRORS
public static final boolean SYNTAX_ERROR_OR_STATUS_UNKNOWN
public Constant(java.lang.String constantName, double constantValue)
constantName
- the constant nameconstantValue
- the constant valuepublic Constant(java.lang.String constantName, double constantValue, java.lang.String description)
constantName
- the constant nameconstantValue
- the constant valuedescription
- the constant descriptionpublic Constant(java.lang.String constantDefinitionString, PrimitiveElement... elements)
constantDefinitionString
- Constant definition in the form
of one String, ie "c = 2" or "c = 2*sin(pi/3)"elements
- Optional parameters (comma separated) such as Arguments, Constants, Functionspublic java.lang.String getConstantName()
public void setConstantName(java.lang.String constantName)
constantName
- the constant namepublic double getConstantValue()
public java.lang.String getDescription()
public void setDescription(java.lang.String description)
description
- the constant descriptionpublic java.lang.String getErrorMessage()
public boolean getSyntaxStatus()