org.lsmp.djep.xjep
Class XOperator

java.lang.Object
  extended by org.nfunk.jep.Operator
      extended by org.lsmp.djep.xjep.XOperator

public class XOperator
extends Operator

An Operator with additional information about its commutativity etc.

Operators have a number of properties:

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

Author:
Rich Morris Created on 19-Oct-2003

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
          Equivilence relations = reflexive, transative and symetric.
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 PREFIX
          prefix operators -x
static int REFLEXIVE
          Reflecive 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 SUFIX
          postfix operators x%, if neiter prefix and postif then infix, if both trifix like x?
static int SYMMETRIC
          Symmetric relation x=y implies y=x.
static int TRANSITIVE
          Transative 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
XOperator(Operator op, int flags)
           
XOperator(Operator op, int flags, int precedence)
           
XOperator(java.lang.String name, PostfixMathCommandI pfmc, int flags)
          construct a new operator.
XOperator(java.lang.String name, PostfixMathCommandI pfmc, int flags, int precedence)
          Allows a given precedent to be set.
XOperator(java.lang.String name, java.lang.String symbol, PostfixMathCommandI pfmc, int flags)
          construct a new operator, with a different name and symbol
XOperator(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()
          When parsing how is x+y+z interpreted.
 Operator getInverseOp()
           
 int getPrecedence()
           
 Operator getRootOp()
           
 boolean isAssociative()
           
 boolean isBinary()
           
 boolean isCommutative()
           
 boolean isComposite()
           
 boolean isDistributiveOver(Operator op)
           
 boolean isEquivilence()
           
 boolean isNary()
           
 boolean isPrefix()
           
 boolean isReflexive()
           
 boolean isSelfInverse()
           
 boolean isSufix()
           
 boolean isSymmetric()
           
 boolean isTransitive()
           
 boolean isUnary()
           
 int numArgs()
           
protected  void setBinaryInverseOp(Operator inv)
           
protected  void setDistributiveOver(Operator op)
           
protected  void setInverseOp(Operator inv)
           
protected  void setPrecedence(int i)
           
protected  void setRootOp(Operator root)
           
 java.lang.String toFullString()
          returns a verbose representation of the operator and all its properties.
 boolean useBindingForPrint()
           
 
Methods inherited from class org.nfunk.jep.Operator
getName, getPFMC, getSymbol, setPFMC, toString
 
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
Reflecive 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
Transative relations x=y and y=z implies x=z

See Also:
Constant Field Values

EQUIVILENCE

public static final int EQUIVILENCE
Equivilence relations = reflexive, transative and symetric.

See Also:
Constant Field Values

PREFIX

public static final int PREFIX
prefix operators -x

See Also:
Constant Field Values

SUFIX

public static final int SUFIX
postfix operators x%, if neiter prefix and postif then infix, if both trifix like x?y:z

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. But a/b/c could be ambiguous so (a/b)/c is printed with brackets.

See Also:
Constant Field Values
Constructor Detail

XOperator

public XOperator(java.lang.String name,
                 PostfixMathCommandI pfmc,
                 int flags)
construct a new operator.

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

XOperator

public XOperator(java.lang.String name,
                 PostfixMathCommandI pfmc,
                 int flags,
                 int precedence)
Allows a given precedent to be set.

Parameters:
name -
pfmc -
flags -
precedence -

XOperator

public XOperator(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 opperator
flags - set of flags defining the porperties of the operator.

XOperator

public XOperator(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 -

XOperator

public XOperator(Operator op,
                 int flags,
                 int precedence)

XOperator

public XOperator(Operator op,
                 int flags)
Method Detail

getPrecedence

public final int getPrecedence()

setPrecedence

protected final void setPrecedence(int i)

setDistributiveOver

protected final void setDistributiveOver(Operator op)

isDistributiveOver

public boolean isDistributiveOver(Operator op)

setRootOp

protected void setRootOp(Operator root)

setInverseOp

protected void setInverseOp(Operator inv)

setBinaryInverseOp

protected void setBinaryInverseOp(Operator inv)

getRootOp

public Operator getRootOp()

getInverseOp

public Operator getInverseOp()

getBinaryInverseOp

public Operator getBinaryInverseOp()

getBinding

public final int getBinding()
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).


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()

isSufix

public final boolean isSufix()

isComposite

public final boolean isComposite()

isSelfInverse

public final boolean isSelfInverse()

useBindingForPrint

public final boolean useBindingForPrint()

toFullString

public java.lang.String toFullString()
returns a verbose representation of the operator and all its properties.



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