|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.singularsys.jep.Operator
public class Operator
An Operator with additional information about its commutativity etc.
Operators have a number of properties:
Field Summary | |
---|---|
static int |
ASSOCIATIVE
Associative operators x*(y*z) == (x*y)*z . |
static int |
BINARY
Binary operators, such as x+y, x>y |
static int |
COMMUTATIVE
Commutative operators x*y = y*x. |
static int |
COMPOSITE
composite operators, like a-b which is a+(-b) |
static int |
EQUIVALENCE
Equivalence relations = reflexive, transitive and symmetric. |
static int |
LEFT
Left binding like +: 1+2+3 -> (1+2)+3 |
static int |
NARY
Trinary ops such as ? |
static int |
NO_ARGS
No arguments to operator |
static int |
NOT_IN_PARSER
Non standard operators, like array access. |
static int |
PREFIX
prefix operators -x |
static int |
REFLEXIVE
Reflective relations x=x for all x. |
static int |
RIGHT
Right binding like =: 1=2=3 -> 1=(2=3) |
static int |
SELF_INVERSE
self inverse operators like -(-x) ! |
static int |
SUFFIX
postfix operators x% |
static int |
SYMMETRIC
Symmetric relation x=y implies y=x. |
static int |
TERNARY
three argument operators like java's cond? |
static int |
TRANSITIVE
Transitive relations x=y and y=z implies x=z |
static int |
UNARY
Unary operators, such as -x ! |
static int |
USE_BINDING_FOR_PRINT
For non commutative operators printing can be determined by the left or right binding. |
Constructor Summary | |
---|---|
Operator(java.lang.String name,
PostfixMathCommandI pfmc,
int flags)
Construct a new operator with no precedence set. |
|
Operator(java.lang.String name,
PostfixMathCommandI pfmc,
int flags,
int precedence)
Constructs a new operator with a given precedence. |
|
Operator(java.lang.String name,
java.lang.String symbol,
PostfixMathCommandI pfmc,
int flags)
Constructs a new operator, with a different name and symbol |
|
Operator(java.lang.String name,
java.lang.String symbol,
PostfixMathCommandI pfmc,
int flags,
int precedence)
Constructs a new operator, with a different name and symbol and allows a given precedence to be set. |
Method Summary | |
---|---|
boolean |
addAltSymbol(java.lang.String altSymbol)
Adds an alternate symbol which can be used at parse time. |
java.util.List<java.lang.String> |
getAltSymbols()
|
Operator |
getBinaryInverseOp()
|
int |
getBinding()
Deprecated. |
int |
getFlags()
|
Operator |
getInverseOp()
|
int |
getKey()
Get the key code used to identify the operator in the operator table. |
java.lang.String |
getName()
returns a unique name defining this operator. |
PostfixMathCommandI |
getPFMC()
|
int |
getPrecedence()
Get the precedence of the operator. |
Operator |
getRootOp()
|
java.lang.String |
getSymbol()
returns the symbol used by this operator. |
boolean |
isAssociative()
|
boolean |
isBinary()
|
boolean |
isCommutative()
|
boolean |
isComposite()
|
boolean |
isDistributiveOver(Operator op)
|
boolean |
isEquivalence()
|
boolean |
isLeftBinding()
|
boolean |
isNary()
|
boolean |
isPrefix()
|
boolean |
isReflexive()
|
boolean |
isRightBinding()
|
boolean |
isSelfInverse()
|
boolean |
isSuffix()
|
boolean |
isSymmetric()
|
boolean |
isTernary()
|
boolean |
isTransitive()
|
boolean |
isUnary()
|
boolean |
notInParser()
|
int |
numArgs()
|
void |
setBinaryInverseOp(Operator inv)
|
void |
setDistributiveOver(Operator op)
|
void |
setFlag(int flag,
boolean val)
Set the value of a specific flag. |
void |
setInverseOp(Operator inv)
|
void |
setKey(int key)
Key code used to identify the operator in the operator table. |
void |
setPFMC(PostfixMathCommandI pfmc)
|
void |
setPrecedence(int i)
Set the precedence of the operator. |
void |
setRootOp(Operator root)
|
void |
setSymbol(java.lang.String sym)
Sets the symbol used by the operator. |
java.lang.String |
toFullString()
returns a verbose representation of the operator and all its properties. |
java.lang.String |
toString()
|
boolean |
useBindingForPrint()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int NO_ARGS
public static final int UNARY
public static final int BINARY
public static final int NARY
public static final int LEFT
public static final int RIGHT
public static final int ASSOCIATIVE
public static final int COMMUTATIVE
public static final int REFLEXIVE
public static final int SYMMETRIC
public static final int TRANSITIVE
public static final int EQUIVALENCE
public static final int PREFIX
public static final int SUFFIX
public static final int SELF_INVERSE
public static final int COMPOSITE
public static final int USE_BINDING_FOR_PRINT
public static final int NOT_IN_PARSER
public static final int TERNARY
TernaryOperator
,
Constant Field ValuesConstructor Detail |
---|
public Operator(java.lang.String name, PostfixMathCommandI pfmc, int flags)
name
- printable name of the operatorpfmc
- postfix math command for the operatorflags
- set of flags defining the properties of the operator.public Operator(java.lang.String name, PostfixMathCommandI pfmc, int flags, int precedence)
name
- printable name of the operatorpfmc
- postfix math command for the operatorflags
- set of flags defining the properties of the operatorprecedence
- operator precedence to be setpublic Operator(java.lang.String name, java.lang.String symbol, PostfixMathCommandI pfmc, int flags)
name
- name of operator, must be unique, used when describing operatorsymbol
- printable name of operator, used for printing equationspfmc
- postfix math command for operatorflags
- set of flags defining the properties of the operatorpublic Operator(java.lang.String name, java.lang.String symbol, PostfixMathCommandI pfmc, int flags, int precedence)
name
- name of operator, must be unique, used when describing operatorsymbol
- printable name of operator, used for printing equationspfmc
- postfix math command for operatorflags
- set of flags defining the properties of the operator.precedence
- operator precedence to be setMethod Detail |
---|
public final java.lang.String getSymbol()
public final void setSymbol(java.lang.String sym)
Jep.reinitializeComponents()
must be called after using this method.
sym
- the new symbol to use.public final java.lang.String getName()
public final PostfixMathCommandI getPFMC()
public final void setPFMC(PostfixMathCommandI pfmc)
public final int getPrecedence()
public void setPrecedence(int i)
public final void setDistributiveOver(Operator op)
public boolean isDistributiveOver(Operator op)
public void setRootOp(Operator root)
public void setInverseOp(Operator inv)
public void setBinaryInverseOp(Operator inv)
public Operator getRootOp()
public Operator getInverseOp()
public Operator getBinaryInverseOp()
public final int getFlags()
@Deprecated public final int getBinding()
isLeftBinding()
,
isRightBinding()
public final boolean isLeftBinding()
public final boolean isRightBinding()
public final boolean isAssociative()
public final boolean isCommutative()
public final boolean isBinary()
public final boolean isUnary()
public final boolean isNary()
public final int numArgs()
public final boolean isTransitive()
public final boolean isSymmetric()
public final boolean isReflexive()
public final boolean isEquivalence()
public final boolean isPrefix()
public final boolean isSuffix()
public final boolean isTernary()
public final boolean isComposite()
public final boolean isSelfInverse()
public final boolean useBindingForPrint()
public final boolean notInParser()
public void setFlag(int flag, boolean val)
flag
- val
- public java.lang.String toFullString()
public java.lang.String toString()
toString
in class java.lang.Object
public int getKey()
public void setKey(int key)
public java.util.List<java.lang.String> getAltSymbols()
public boolean addAltSymbol(java.lang.String altSymbol)
altSymbol
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |