Class TernaryOperator

  • All Implemented Interfaces:
    PrintVisitor.PrintRulesI, java.io.Serializable

    public class TernaryOperator
    extends Operator
    implements PrintVisitor.PrintRulesI
    A class representing a ternary operator, for example x?y:z. These are represented by a linked pair of operators, a TernaryOperator and the inner class RhsTernaryOperator.
    Author:
    Richard Morris Since 4.0 implements PrintRulesI
    See Also:
    Serialized Form
    • Constructor Detail

      • TernaryOperator

        public TernaryOperator​(java.lang.String name,
                               java.lang.String lhsSymbol,
                               java.lang.String rhsSymbol,
                               PostfixMathCommandI pfmc,
                               int flags)
        Create a Ternary operator. Precedence level set later.
        Parameters:
        name - verbose name for operator
        lhsSymbol - symbol for left hand operator, typically "?"
        rhsSymbol - symbol for right hand operator, typically ":"
        pfmc - function implementing the operation, typically TernaryConditional
        flags - status flags, typically Operator.TERNARY
      • TernaryOperator

        public TernaryOperator​(java.lang.String name,
                               java.lang.String lhsSymbol,
                               java.lang.String rhsSymbol,
                               PostfixMathCommandI pfmc,
                               int flags,
                               int precedence)
        Create a Ternary operator
        Parameters:
        name - verbose name for operator
        lhsSymbol - symbol for left hand operator, typically "?"
        rhsSymbol - symbol for right hand operator, typically ":"
        pfmc - function implementing the operation, typically TernaryConditional
        flags - status flags, typically Operator.TERNARY
        precedence - precedence level
    • Method Detail

      • getRhsSymbol

        public java.lang.String getRhsSymbol()
        Get symbol used to for righthand operator
        Returns:
        the symbol
      • setPrecedence

        public void setPrecedence​(int i)
        Description copied from class: Operator
        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).
        Overrides:
        setPrecedence in class Operator
        Parameters:
        i - the precedence