Class Operator

java.lang.Object
org.scijava.parsington.Token
org.scijava.parsington.Operator
All Implemented Interfaces:
Comparable<Operator>
Direct Known Subclasses:
Function, Group

public class Operator extends Token implements Comparable<Operator>
A mathematical operator is a special symbol or "verb" which defines a relation between "nouns" (i.e.: literals and variables). For binary operators, it is infix (between the nouns); for unary operators, it is either prefix (preceding the noun) or postfix (following the noun).
Author:
Curtis Rueden
  • Constructor Details

  • Method Details

    • getArity

      public int getArity()
      Gets the operator's arity.
      Returns:
      The arity of the operator: 1 for unary, 2 for binary, etc.
    • getAssociativity

      public Operator.Associativity getAssociativity()
      Gets the operator's associativity.
      Returns:
      One of Operator.Associativity.EITHER, Operator.Associativity.LEFT, Operator.Associativity.RIGHT, or Operator.Associativity.NONE.
    • isLeftAssociative

      public boolean isLeftAssociative()
      Gets whether the operator is left associative.
      Returns:
      True iff the operator's associativity is Operator.Associativity.LEFT or Operator.Associativity.EITHER.
    • isRightAssociative

      public boolean isRightAssociative()
      Gets whether the operator is right associative.
      Returns:
      True iff the operator's associativity is Operator.Associativity.RIGHT or Operator.Associativity.EITHER.
    • isInfix

      public boolean isInfix()
      Gets whether the operator is an infix operator (e.g., a-b).
      Returns:
      True iff the operator is an infix operator.
    • isPrefix

      public boolean isPrefix()
      Gets whether the operator is a prefix operator (e.g., -a).
      Returns:
      True iff the operator is a prefix operator.
    • isPostfix

      public boolean isPostfix()
      Gets whether the operator is a postfix operator (e.g., a').
      Returns:
      True iff the operator is a postfix operator.
    • getPrecedence

      public double getPrecedence()
      Gets the operator precedence. Larger is higher.
      Returns:
      The operator precedence.
    • instance

      public Operator instance()
      Gets an instance of the operator, using this one as a template.

      For stateless operators, no copy will be made. But for operators with state (e.g. Group), a new instance will be returned.

      Returns:
      this or a new instance, depending on the type of operator.
    • compareTo

      public int compareTo(Operator that)
      Specified by:
      compareTo in interface Comparable<Operator>