Class ArrayCreation


public class ArrayCreation extends Expression
Array creation expression AST node type.
 ArrayCreation:
    new PrimitiveType [ Expression ] { [ Expression ] } { [ ] }
    new TypeName [ < Type { , Type } > ]
        [ Expression ] { [ Expression ] } { [ ] }
    new PrimitiveType [ ] { [ ] } ArrayInitializer
    new TypeName [ < Type { , Type } > ]
        [ ] { [ ] } ArrayInitializer
 

The mapping from Java language syntax to AST nodes is as follows:

  • the type node is the array type of the creation expression, with one level of array per set of square brackets,
  • the dimension expressions are collected into the dimensions list.
Since:
2.0
Restriction:
This class is not intended to be instantiated by clients.
  • Field Details

  • Method Details

    • 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
    • getType

      public ArrayType getType()
      Returns the array type in this array creation expression.
      Returns:
      the array type
    • setType

      public void setType(ArrayType type)
      Sets the array type in this array creation expression.
      Parameters:
      type - the new array type
      Throws:
      IllegalArgumentException - if:
      • the node belongs to a different AST
      • the node already has a parent
    • dimensions

      public List dimensions()
      Returns the live ordered list of dimension expressions in this array initializer.
      Returns:
      the live list of dimension expressions (element type: Expression)
    • getInitializer

      public ArrayInitializer getInitializer()
      Returns the array initializer of this array creation expression, or null if there is none.
      Returns:
      the array initializer node, or null if there is none
    • setInitializer

      public void setInitializer(ArrayInitializer initializer)
      Sets or clears the array initializer of this array creation expression.
      Parameters:
      initializer - the array initializer 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