Interface IJavaTry

All Superinterfaces:
IJavaCompound, IJavaElement, IJavaExpression, IJavaStatement

@Ser public interface IJavaTry extends IJavaCompound
Java AST interface to represent try-catch elements.
See Also:
  • Method Details

    • getResourceAcqs

      List<IJavaExpression> getResourceAcqs()
      Returns:
      a read-only list of acquisition expressions
    • addResourceAcq

      void addResourceAcq(IJavaExpression exp)
      Parameters:
      exp - an acquisition expression that will be appended to the current list of acquisition expressions
    • addResourceAcq

      void addResourceAcq(int i, IJavaExpression exp)
      Parameters:
      i - insertion index
      exp - an acquisition expression that will be added to the current list of acquisition expressions
    • removeResourceAcq

      void removeResourceAcq(int i)
      Parameters:
      i - acquisition expression index
    • isTryWithResource

      boolean isTryWithResource()
      Returns:
      true if this try-statement is a try-with-resource (a try with resource-acquisition expressions)
    • getTryBody

      IJavaBlock getTryBody()
      Get the try block.
      Returns:
      the try block, never null
    • setTryBody

      void setTryBody(IJavaBlock b)
      Set the try block protected by catch clauses.
      Parameters:
      b - a non-null block
    • getCatchCount

      int getCatchCount()
      Get the number of catch blocks.
      Returns:
      the number of catch blocks.
    • getCatchBlock

      IJavaCatchBlock getCatchBlock(int index)
      Parameters:
      index -
      Returns:
    • removeCatchBlock

      IJavaCatchBlock removeCatchBlock(int index)
      Parameters:
      index -
      Returns:
    • getCatchBody

      IJavaBlock getCatchBody(int index)
      Get a catch body.
      Parameters:
      index - 0-based catch block index
      Returns:
      the catch body
    • getCatchType

      IJavaType getCatchType(int index)
      Get the type of exception caught by a catch block.
      Parameters:
      index - 0-based catch block index
      Returns:
      the caught exception type
    • getCatchIdentifier

      IJavaIdentifier getCatchIdentifier(int index)
      Get the named identifier associated with the caught exception of a catch block.
      Parameters:
      index - 0-based catch block index
      Returns:
      the caught exception identifier, may be null if there is none
    • getCatchByType

      int getCatchByType(String typestring)
      Parameters:
      typestring -
      Returns:
    • getFinallyBlock

      IJavaBlock getFinallyBlock()
      Get the finally block, if there is one.
      Returns:
      the finally block, null if there is none
    • setFinallyBlock

      void setFinallyBlock(IJavaBlock blk)
      Parameters:
      blk -
    • hasFinallyBlock

      boolean hasFinallyBlock()
      Returns:
    • addCatchBlock

      void addCatchBlock(int index, IJavaType type, List<IJavaType> addTypes, IJavaIdentifier ident, IJavaDefinition def, IJavaBlock block)
      Parameters:
      index -
      type -
      addTypes -
      ident -
      def -
      block -
    • addCatchBlock

      void addCatchBlock(IJavaType type, List<IJavaType> addTypes, IJavaIdentifier ident, IJavaDefinition def, IJavaBlock block)
      Parameters:
      type -
      addTypes -
      ident -
      def -
      block -
    • duplicate

      IJavaTry duplicate()
      Description copied from interface: IJavaElement
      Duplicate this element.
      Specified by:
      duplicate in interface IJavaCompound
      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