jhplot.math.exp4j.operator
Class Operator
- java.lang.Object
-
- jhplot.math.exp4j.operator.Operator
-
public abstract class Operator extends java.lang.Object
Class representing operators that can be used in an expression
-
-
Field Summary
Fields Modifier and Type Field and Description static char[]
ALLOWED_OPERATOR_CHARS
The set of allowed operator charsstatic int
PRECEDENCE_ADDITION
The precedence value for the addition operationstatic int
PRECEDENCE_DIVISION
The precedence value for the division operationstatic int
PRECEDENCE_MODULO
The precedence value for the modulo operationstatic int
PRECEDENCE_MULTIPLICATION
The precedence value for the multiplication operationstatic int
PRECEDENCE_POWER
The precedence value for the power operationstatic int
PRECEDENCE_SUBTRACTION
The precedence value for the subtraction operationstatic int
PRECEDENCE_UNARY_MINUS
The precedence value for the unary minus operationstatic int
PRECEDENCE_UNARY_PLUS
The precedence value for the unary plus operation
-
Constructor Summary
Constructors Constructor and Description Operator(java.lang.String symbol, int numberOfOperands, boolean leftAssociative, int precedence)
Create a new operator for use in expressions
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract double
apply(double... args)
Apply the operation on the given operandsint
getNumOperands()
Get the number of operandsint
getPrecedence()
Check the precedence value for the operatorjava.lang.String
getSymbol()
Get the operator symbolstatic boolean
isAllowedOperatorChar(char ch)
Check if a character is an allowed operator charboolean
isLeftAssociative()
Check if the operator is left associative
-
-
-
Field Detail
-
PRECEDENCE_ADDITION
public static final int PRECEDENCE_ADDITION
The precedence value for the addition operation- See Also:
- Constant Field Values
-
PRECEDENCE_SUBTRACTION
public static final int PRECEDENCE_SUBTRACTION
The precedence value for the subtraction operation- See Also:
- Constant Field Values
-
PRECEDENCE_MULTIPLICATION
public static final int PRECEDENCE_MULTIPLICATION
The precedence value for the multiplication operation- See Also:
- Constant Field Values
-
PRECEDENCE_DIVISION
public static final int PRECEDENCE_DIVISION
The precedence value for the division operation- See Also:
- Constant Field Values
-
PRECEDENCE_MODULO
public static final int PRECEDENCE_MODULO
The precedence value for the modulo operation- See Also:
- Constant Field Values
-
PRECEDENCE_POWER
public static final int PRECEDENCE_POWER
The precedence value for the power operation- See Also:
- Constant Field Values
-
PRECEDENCE_UNARY_MINUS
public static final int PRECEDENCE_UNARY_MINUS
The precedence value for the unary minus operation- See Also:
- Constant Field Values
-
PRECEDENCE_UNARY_PLUS
public static final int PRECEDENCE_UNARY_PLUS
The precedence value for the unary plus operation- See Also:
- Constant Field Values
-
ALLOWED_OPERATOR_CHARS
public static final char[] ALLOWED_OPERATOR_CHARS
The set of allowed operator chars
-
-
Constructor Detail
-
Operator
public Operator(java.lang.String symbol, int numberOfOperands, boolean leftAssociative, int precedence)
Create a new operator for use in expressions- Parameters:
symbol
- the symbol of the operatornumberOfOperands
- the number of operands the operator takes (1 or 2)leftAssociative
- set to true if the operator is left associative, false if it is right associativeprecedence
- the precedence value of the operator
-
-
Method Detail
-
isAllowedOperatorChar
public static boolean isAllowedOperatorChar(char ch)
Check if a character is an allowed operator char- Parameters:
ch
- the char to check- Returns:
- true if the char is allowed an an operator symbol, false otherwise
-
isLeftAssociative
public boolean isLeftAssociative()
Check if the operator is left associative- Returns:
- true os the operator is left associative, false otherwise
-
getPrecedence
public int getPrecedence()
Check the precedence value for the operator- Returns:
- the precedence value
-
apply
public abstract double apply(double... args)
Apply the operation on the given operands- Parameters:
args
- the operands for the operation- Returns:
- the calculated result of the operation
-
getSymbol
public java.lang.String getSymbol()
Get the operator symbol- Returns:
- the symbol
-
getNumOperands
public int getNumOperands()
Get the number of operands- Returns:
- the number of operands
-
-
DMelt 3.0 © DataMelt by jWork.ORG