Class TryStatement


  • public class TryStatement
    extends Statement
    Try statement AST node type.
     TryStatement:
         try [ ( Resources ) ]
             Block
             [ { CatchClause } ]
             [ finally Block ]
     

    Not all node arrangements will represent legal Java constructs. In particular, at least one resource, catch clause, or finally block must be present.

    A resource is either a VariableDeclarationExpression or (since JLS9) a Name.

    Since:
    2.0
    Restriction:
    This class is not intended to be subclassed by clients.
    Restriction:
    This class is not intended to be instantiated by clients.
    • Method Detail

      • propertyDescriptors

        public static List propertyDescriptors​(int apiLevel)
        Returns a list of structural property descriptors for this node type. Clients must not modify the result.
        Parameters:
        apiLevel - the API level; one of the AST.JLS* constants
        Returns:
        a list of property descriptors (element type: StructuralPropertyDescriptor)
        Since:
        3.0
      • getBody

        public Block getBody()
        Returns the body of this try statement.
        Returns:
        the try body
      • setBody

        public void setBody​(Block body)
        Sets the body of this try statement.
        Parameters:
        body - the block node
        Throws:
        IllegalArgumentException - if:
        • the node belongs to a different AST
        • the node already has a parent
        • a cycle in would be created
      • catchClauses

        public List catchClauses()
        Returns the live ordered list of catch clauses for this try statement.
        Returns:
        the live list of catch clauses (element type: CatchClause)
      • getFinally

        public Block getFinally()
        Returns the finally block of this try statement, or null if this try statement has no finally block.
        Returns:
        the finally block, or null if this try statement has none
      • setFinally

        public void setFinally​(Block block)
        Sets or clears the finally block of this try statement.
        Parameters:
        block - the finally block node, or null if there is none
        Throws:
        IllegalArgumentException - if:
        • the node belongs to a different AST
        • the node already has a parent
        • a cycle in would be created