Interface IJavaAssignment

All Superinterfaces:
IJavaElement, IJavaExpression, IJavaStatement

@Ser public interface IJavaAssignment extends IJavaStatement
Java AST interface to represent assignments.

Example of a simple assignment:

 left = right
 

A simple assignment can be modified to represent non-standard assignments:

  • A combined-operator assignment
  • A unary-operator assignment
  • Method Details

    • getLeft

      Get the left part of the assignment.
      Returns:
    • setLeft

      void setLeft(IJavaLeftExpression left)
      Set the left part of the assignment.
      Parameters:
      left - mandatory left expression
    • getRight

      IJavaExpression getRight()
      Get the right part of the assignment.
      Returns:
    • setRight

      void setRight(IJavaExpression right)
      Set the right part of the assignment. The assignment cannot be a unary assignment.
      Parameters:
      right - mandatory right expression
    • isSimpleAssignment

      boolean isSimpleAssignment()
      Determine if the assignment is a regular ('=') assignment.
      Returns:
    • isCombinedOperatorAssignment

      boolean isCombinedOperatorAssignment()
      Determine if the assignment is a combined assignment. There are 11 possible types of combined operators. Examples include: '+=', '-=', etc.
      Returns:
    • getCombinedOperator

      IJavaOperator getCombinedOperator()
      Retrieve the combined operator of a combined assignment.

      Example: for "a += b", the operator returned would be "+"

      Returns:
      the basic operator that is used to make the assignment a combined assignment
      Throws:
      IllegalStateException - if the assignment is not a combined assignment
    • setCombinedOperatorAssignment

      void setCombinedOperatorAssignment(IJavaOperator operator, IJavaExpression right)
      Transform a simple assignment into a combined operator assignment. The current assignment cannot be a unary assignment, else the method will throw.
      Parameters:
      operator - mandatory combined operator, there are eleven possibilities:
      MUL, DIV, ADD, SUB, REM, SHL, SHR, USHR, AND, XOR, OR
      right - optional, updated right member of the assignment
    • setCombinedOperator

      void setCombinedOperator(IJavaOperator operator)
      Transform a simple assignment into a combined operator assignment. The current assignment cannot be a unary assignment, else the method will throw.
      Parameters:
      operator - mandatory combined operator, there are eleven possibilities:
      MUL, DIV, ADD, SUB, REM, SHL, SHR, USHR, AND, XOR, OR
    • isUnaryOperatorAssignment

      boolean isUnaryOperatorAssignment()
      Determine if the assignment is a unary-operator assignment.

      Example: i++ or --j

      Returns:
      true if the assignment is a unary-operator assignment
    • getUnaryOperator

      void getUnaryOperator(boolean[] r)
      Retrieve the unary operator of a unary operator assignment.
      Parameters:
      r - mandatory 2-element array, will be set to {is_increment, is_prefixed}
      Throws:
      IllegalStateException - if the assignment is not a unary assignment
    • setUnaryOperator

      void setUnaryOperator(boolean isIncrement, boolean isPrefixed)
      Transform the non-unary assignment into one of the four unary assignments: postfix increment, postfix decrement, prefix increment, prefix decrement. The right member of the expression is automatically nullified.
      Parameters:
      isIncrement - true for increment, false for decrement
      isPrefixed - true for prefixed, false for postfixed
    • duplicate

      IJavaAssignment duplicate()
      Description copied from interface: IJavaElement
      Duplicate this element.
      Specified by:
      duplicate in interface IJavaElement
      Specified by:
      duplicate in interface IJavaExpression
      Specified by:
      duplicate in interface IJavaStatement
      Returns:
      a (possibly) duplicated object of the same type