Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.singularsys.jep
Class Operator

    java.lang.Object
      com.singularsys.jep.Operator

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  TernaryOperator

    public class Operator

extends java.lang.Object
implements java.io.Serializable

An Operator with additional information about its commutativity etc.

Operators have a number of properties:

- A symbol or name of the operator "+".
- The number of arguments NO_ARGS 0, UNARY 1 (e.g. UMINUS -x), BINARY 2 (e.g. x+y), and NARY either 3 ( a>b ? a : b) or unspecified like a list [x,y,z,w].
- The binding of the operator, LEFT 1+2+3 -> (1+2)+3 or RIGHT 1=2=3 -> 1=(2=3).
- Whether the operator is ASSOCIATIVE or COMMUTATIVE.
- The precedence of the operators + has a higher precedence than *.
- For unary operators they can either be PREFIX like -x or SUFIX like x%.
- Comparative operators can be REFLEXIVE, SYMMETRIC, TRANSITIVE or EQUIVILENCE which has all three properties.
- A reference to a PostfixtMathCommandI object which is used to evaluate an equation containing the operator.

various is... and get... methods are provided to query the properties of the operator.

Author:
  Rich Morris Created on 19-Oct-2003
See Also:
  Serialized Form

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` | `EQUIVILENCE` Equivalence relations = reflexive, transitive and symmetric.
`int` | `flags` flags for type of operator
`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.
`Operator(java.lang.String name, PostfixMathCommandI pfmc, int flags, int precedence)` Allows a given precedent to be set.
`Operator(java.lang.String name, java.lang.String symbol, PostfixMathCommandI pfmc, int flags)` construct a new operator, with a different name and symbol
`Operator(java.lang.String name, java.lang.String symbol, PostfixMathCommandI pfmc, int flags, int precedence)` Allows a given precedent to be set.

Method Summary
`Operator` | `getBinaryInverseOp()`
`int` | `getBinding()` Deprecated.
`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` | `isEquivilence()`
`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` | `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)`
`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

### NO_ARGS

    public static final int NO_ARGS

  No arguments to operator

  See Also:
    Constant Field Values

### UNARY

    public static final int UNARY

  Unary operators, such as -x !x ~x

  See Also:
    Constant Field Values

### BINARY

    public static final int BINARY

  Binary operators, such as x+y, x>y

  See Also:
    Constant Field Values

### NARY

    public static final int NARY

  Trinary ops such as ?: and or higher like [x,y,z,w]

  See Also:
    Constant Field Values

### LEFT

    public static final int LEFT

  Left binding like +: 1+2+3 -> (1+2)+3

  See Also:
    Constant Field Values

### RIGHT

    public static final int RIGHT

  Right binding like =: 1=2=3 -> 1=(2=3)

  See Also:
    Constant Field Values

### ASSOCIATIVE

    public static final int ASSOCIATIVE

  Associative operators x*(y*z) == (x*y)*z .

  See Also:
    Constant Field Values

### COMMUTATIVE

    public static final int COMMUTATIVE

  Commutative operators x*y = y*x.

  See Also:
    Constant Field Values

### REFLEXIVE

    public static final int REFLEXIVE

  Reflective relations x=x for all x.

  See Also:
    Constant Field Values

### SYMMETRIC

    public static final int SYMMETRIC

  Symmetric relation x=y implies y=x.

  See Also:
    Constant Field Values

### TRANSITIVE

    public static final int TRANSITIVE

  Transitive relations x=y and y=z implies x=z

  See Also:
    Constant Field Values

### EQUIVILENCE

    public static final int EQUIVILENCE

  Equivalence relations = reflexive, transitive and symmetric.

  See Also:
    Constant Field Values

### PREFIX

    public static final int PREFIX

  prefix operators -x

  See Also:
    Constant Field Values

### SUFFIX

    public static final int SUFFIX

  postfix operators x%

  See Also:
    Constant Field Values

### SELF_INVERSE

    public static final int SELF_INVERSE

  self inverse operators like -(-x) !(!x)

  See Also:
    Constant Field Values

### COMPOSITE

    public static final int COMPOSITE

  composite operators, like a-b which is a+(-b)

  See Also:
    Constant Field Values

### USE_BINDING_FOR_PRINT

    public static final int USE_BINDING_FOR_PRINT

  For non commutative operators printing can be determined by the left or right binding. For example (a-b)-c is printed as a-b-c (flag set). But a/b/c could be ambiguous so (a/b)/c is printed with brackets (flag not set).

  See Also:
    Constant Field Values

### NOT_IN_PARSER

    public static final int NOT_IN_PARSER

  Non standard operators, like array access. These will typically require the PrintRulesI interface to print and require special parsing options.

  See Also:
    Constant Field Values

### TERNARY

    public static final int TERNARY

  three argument operators like java's cond?tval:fval

  See Also:
    `TernaryOperator`, Constant Field Values

### flags

    public int flags

  flags for type of operator

Constructor Detail

### Operator

    public Operator(java.lang.String name,
                    PostfixMathCommandI pfmc,
                    int flags)

  construct a new operator.

  Parameters:
    `name` - printable name of operator
    `pfmc` - postfix math command for operator
    `flags` - set of flags defining the properties of the operator.

### Operator

    public Operator(java.lang.String name,
                    PostfixMathCommandI pfmc,
                    int flags,
                    int precedence)

  Allows a given precedent to be set.

  Parameters:
    `name` -
    `pfmc` -
    `flags` -
    `precedence` -

### Operator

    public Operator(java.lang.String name,
                    java.lang.String symbol,
                    PostfixMathCommandI pfmc,
                    int flags)

  construct a new operator, with a different name and symbol

  Parameters:
    `name` - name of operator, must be unique, used when describing operator
    `symbol` - printable name of operator, used for printing equations
    `pfmc` - postfix math command for operator

### Operator

    public Operator(java.lang.String name,
                    java.lang.String symbol,
                    PostfixMathCommandI pfmc,
                    int flags,
                    int precedence)

  Allows a given precedent to be set.

  Parameters:
    `name` -
    `pfmc` -
    `flags` -
    `precedence` -

Method Detail

### getSymbol

    public final java.lang.String getSymbol()

  returns the symbol used by this operator.

### getName

    public final java.lang.String getName()

  returns a unique name defining this operator.

### getPFMC

    public final PostfixMathCommandI getPFMC()

### setPFMC

    public final void setPFMC(PostfixMathCommandI pfmc)

### getPrecedence

    public final int getPrecedence()

  Get the precedence of the operator. Lower values correspond to tighter binding, that is * gives a lower value than + and 1+2*3 is 1+(2*3).

  Returns:
    the precedence

### setPrecedence

    public final void setPrecedence(int i)

  Set the precedence of the operator. Lower values correspond to tighter binding, that is * gives a lower value than + and 1+2*3 is 1+(2*3).

### setDistributiveOver

    public final void setDistributiveOver(Operator op)

### isDistributiveOver

    public boolean isDistributiveOver(Operator op)

### setRootOp

    public void setRootOp(Operator root)

### setInverseOp

    public void setInverseOp(Operator inv)

### setBinaryInverseOp

    public void setBinaryInverseOp(Operator inv)

### getRootOp

    public Operator getRootOp()

### getInverseOp

    public Operator getInverseOp()

### getBinaryInverseOp

    public Operator getBinaryInverseOp()

### getBinding

    @Deprecated
    public final int getBinding()

  Deprecated.

  When parsing how is x+y+z interpreted. Can be Operator.LEFT x+y+z -> (x+y)+z or Operator.RIGHT x=y=z -> x=(y=z). This is now deprecated

  See Also:
    `isLeftBinding()`, `isRightBinding()`

### isLeftBinding

    public final boolean isLeftBinding()

### isRightBinding

    public final boolean isRightBinding()

### isAssociative

    public final boolean isAssociative()

### isCommutative

    public final boolean isCommutative()

### isBinary

    public final boolean isBinary()

### isUnary

    public final boolean isUnary()

### isNary

    public final boolean isNary()

### numArgs

    public final int numArgs()

### isTransitive

    public final boolean isTransitive()

### isSymmetric

    public final boolean isSymmetric()

### isReflexive

    public final boolean isReflexive()

### isEquivilence

    public final boolean isEquivilence()

### isPrefix

    public final boolean isPrefix()

### isSuffix

    public final boolean isSuffix()

### isTernary

    public final boolean isTernary()

### isComposite

    public final boolean isComposite()

### isSelfInverse

    public final boolean isSelfInverse()

### useBindingForPrint

    public final boolean useBindingForPrint()

### notInParser

    public final boolean notInParser()

### toFullString

    public java.lang.String toFullString()

  returns a verbose representation of the operator and all its properties.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getKey

    public int getKey()

  Get the key code used to identify the operator in the operator table.

### setKey

    public void setKey(int key)

  Key code used to identify the operator in the operator table.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 Singular Systems http://www.singularsys.com/jep