public class OperatorTable extends java.lang.Object implements OperatorTableI
Modifier and Type | Field and Description |
---|---|
protected static int |
baseNumOps
Number operators in this table.
|
protected int |
numOps |
protected static int |
OP_ADD |
protected static int |
OP_AND |
protected static int |
OP_ASSIGN |
protected static int |
OP_CROSS |
protected static int |
OP_DIVIDE |
protected static int |
OP_DOT |
protected static int |
OP_ELEMENT |
protected static int |
OP_EQ |
protected static int |
OP_GE |
protected static int |
OP_GT |
protected static int |
OP_LE |
protected static int |
OP_LIST |
protected static int |
OP_LT |
protected static int |
OP_MOD |
protected static int |
OP_MULTIPLY |
protected static int |
OP_NE |
protected static int |
OP_NEGATE |
protected static int |
OP_NOP |
protected static int |
OP_NOT |
protected static int |
OP_OR |
protected static int |
OP_POWER |
protected static int |
OP_RANGE |
protected static int |
OP_RECIP
unary division i.e. 1/x or x^(-1) *
|
protected static int |
OP_SUBTRACT |
protected static int |
OP_UPLUS |
protected Operator[] |
ops |
Constructor and Description |
---|
OperatorTable() |
Modifier and Type | Method and Description |
---|---|
Operator |
addOperator(int key,
Operator op)
Add a operator with a given key.
|
Operator |
addOperator(int key,
Operator op,
Operator existingOp)
Add operator with the same precedence level as an existing operator.
|
Operator |
addOperator(Operator op)
Add a operator with no key specified.
|
Operator |
addOperator(Operator op,
Operator existingOp)
Add operator with the same precedence level as an existing operator.
|
Operator |
appendOperator(int key,
Operator op,
Operator existingOp)
Add an operator which a new precedence level which is higher than the
existing op
|
Operator |
appendOperator(Operator op,
Operator existingOp)
Add an operator which a new precedence level which is higher than the
existing op
|
Operator |
getAdd() |
Operator |
getAnd() |
Operator |
getAssign() |
Operator |
getCross() |
Operator |
getDivide() |
Operator |
getDot() |
Operator |
getEle() |
Operator |
getEQ() |
Operator |
getGE() |
Operator |
getGT() |
Operator |
getLE() |
JepComponent |
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads.
|
Operator |
getList() |
Operator |
getLT() |
Operator |
getMod() |
Operator |
getMultiply() |
Operator |
getNE() |
Operator |
getNop() |
Operator |
getNot() |
int |
getNumOps() |
Operator |
getOperator(int key)
Get operator by its key code.
|
java.util.Collection<Operator> |
getOperators() |
Operator |
getOperatorsByName(java.lang.String name)
Get the operator with a given name
|
java.util.List<Operator> |
getOperatorsBySymbol(java.lang.String symbol)
Gets all the operators with a given symbol
|
Operator |
getOr() |
Operator |
getPower() |
Operator |
getRange() |
Operator |
getSubtract() |
Operator |
getUDivide()
unary division i.e. 1/x or x^(-1) *
|
Operator |
getUMinus() |
Operator |
getUPlus() |
void |
init(Jep jep)
Initialize the component.
|
Operator |
insertOperator(int key,
Operator op,
Operator existingOp)
Add an operator with a new precedence level which is lower than the
existing op.
|
Operator |
insertOperator(Operator op,
Operator existingOp)
Add an operator which a new precedence level which is lower than the
existing op
|
void |
removeOperator(Operator op)
Remove an operator from the table.
|
Operator |
replaceOperator(Operator oldOp,
Operator op)
replace an existing operator by a new one.
|
protected boolean |
setBinaryInverseOp(int key1,
int key2) |
protected boolean |
setDistributiveOver(int key1,
int key2) |
protected boolean |
setInverseOp(int key1,
int key2) |
protected void |
setNumOps(int size) |
boolean |
setPrecedenceTable(int[][] precArray)
Sets the precedence of all operators at one time.
|
protected boolean |
setRootOp(int key1,
int key2) |
protected void |
setStandardOperatorRelations()
Sets up the standard relations between +,-,*,/
|
java.lang.String |
toString()
String rep operators ordered by precedence, one per line.
|
protected Operator[] ops
protected static final int OP_NOP
protected static final int OP_ADD
protected static final int OP_SUBTRACT
protected static final int OP_NEGATE
protected static final int OP_UPLUS
protected static final int OP_MULTIPLY
protected static final int OP_DIVIDE
protected static final int OP_MOD
protected static final int OP_RECIP
protected static final int OP_POWER
protected static final int OP_GT
protected static final int OP_LT
protected static final int OP_EQ
protected static final int OP_LE
protected static final int OP_GE
protected static final int OP_NE
protected static final int OP_AND
protected static final int OP_OR
protected static final int OP_NOT
protected static final int OP_ASSIGN
protected static final int OP_DOT
protected static final int OP_CROSS
protected static final int OP_LIST
protected static final int OP_ELEMENT
protected static final int OP_RANGE
protected static final int baseNumOps
protected int numOps
public void init(Jep jep)
JepComponent
init
in interface JepComponent
jep
- the current Jep instanceprotected void setNumOps(int size)
public int getNumOps()
public Operator addOperator(int key, Operator op)
key
- integer key valueop
- public Operator addOperator(Operator op)
op
- public Operator addOperator(int key, Operator op, Operator existingOp)
key
- op
- existingOp
- public Operator addOperator(Operator op, Operator existingOp)
op
- existingOp
- public Operator insertOperator(int key, Operator op, Operator existingOp)
key
- op
- existingOp
- public Operator insertOperator(Operator op, Operator existingOp)
op
- existingOp
- public Operator appendOperator(int key, Operator op, Operator existingOp)
key
- op
- existingOp
- public Operator appendOperator(Operator op, Operator existingOp)
op
- existingOp
- public void removeOperator(Operator op)
op
- the operator to be removedpublic Operator replaceOperator(Operator oldOp, Operator op)
oldOp
- the old operatorop
- the new operatorpublic Operator getOperator(int key)
key
- code used in the tablepublic java.util.List<Operator> getOperatorsBySymbol(java.lang.String symbol)
getOperatorsBySymbol
in interface OperatorTableI
symbol
- symbol used for operatorpublic Operator getOperatorsByName(java.lang.String name)
getOperatorsByName
in interface OperatorTableI
name
- unique name of operatorpublic java.util.Collection<Operator> getOperators()
getOperators
in interface OperatorTableI
public final boolean setPrecedenceTable(int[][] precArray)
setPrecedenceTable(new int[][] { { OP_NEGATE, OP_UPLUS, OP_NOT }, { OP_POWER }, { OP_MULTIPLY, OP_DIVIDE, OP_MOD, OP_DOT, OP_CROSS }, { OP_ADD, OP_SUBTRACT }, { OP_LT, OP_LE, OP_GT, OP_GE }, { OP_EQ, OP_NE }, { OP_AND }, { OP_OR }, { OP_ASSIGN }, });
precArray
- protected boolean setInverseOp(int key1, int key2)
protected boolean setBinaryInverseOp(int key1, int key2)
protected boolean setRootOp(int key1, int key2)
protected boolean setDistributiveOver(int key1, int key2)
protected void setStandardOperatorRelations()
public Operator getNop()
getNop
in interface OperatorTableI
public Operator getAdd()
getAdd
in interface OperatorTableI
public Operator getSubtract()
getSubtract
in interface OperatorTableI
public Operator getUMinus()
getUMinus
in interface OperatorTableI
public Operator getUPlus()
getUPlus
in interface OperatorTableI
public Operator getMultiply()
getMultiply
in interface OperatorTableI
public Operator getDivide()
getDivide
in interface OperatorTableI
public Operator getMod()
getMod
in interface OperatorTableI
public Operator getUDivide()
getUDivide
in interface OperatorTableI
public Operator getPower()
getPower
in interface OperatorTableI
public Operator getGT()
getGT
in interface OperatorTableI
public Operator getLT()
getLT
in interface OperatorTableI
public Operator getEQ()
getEQ
in interface OperatorTableI
public Operator getLE()
getLE
in interface OperatorTableI
public Operator getGE()
getGE
in interface OperatorTableI
public Operator getNE()
getNE
in interface OperatorTableI
public Operator getAnd()
getAnd
in interface OperatorTableI
public Operator getOr()
getOr
in interface OperatorTableI
public Operator getNot()
getNot
in interface OperatorTableI
public Operator getAssign()
getAssign
in interface OperatorTableI
public Operator getDot()
getDot
in interface OperatorTableI
public Operator getCross()
getCross
in interface OperatorTableI
public Operator getList()
getList
in interface OperatorTableI
public Operator getEle()
getEle
in interface OperatorTableI
public Operator getRange()
getRange
in interface OperatorTableI
public java.lang.String toString()
toString
in class java.lang.Object
public JepComponent getLightWeightInstance()
JepComponent
getLightWeightInstance
in interface JepComponent
Copyright © 2018 Singular Systems http://www.singularsys.com/jep