public class ArrayExpression
extends Expression
Represents an array literal or array construction expression.
Supports both fixed-size array construction (e.g., new String[3] or new Integer[2][3])
and array initialization with explicit elements (e.g., new String[] { "foo", "bar" }).
The expression may be either an initializer-based array or a size-based array, but not both.
| Fields inherited from class | Fields |
|---|---|
class Expression |
EMPTY_ARRAY |
| Constructor and description |
|---|
ArrayExpression(ClassNode elementType, List<Expression> initExpressions, List<Expression> sizeExpressions)Constructs an array expression with either size expressions or initializer expressions. |
ArrayExpression(ClassNode elementType, List<Expression> initExpressions)Creates an array using an initializer list of expressions corresponding to array elements. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
addExpression(Expression initExpression)Adds an element to the initializer expressions. |
|
public ClassNode |
getElementType()Returns the base element type of the array (before array dimensions are applied). |
|
public Expression |
getExpression(int i)Returns the initializer expression at the specified index. |
|
public List<Expression> |
getExpressions()Returns the list of initializer expressions for array elements. |
|
public List<Expression> |
getSizeExpression()Returns the size expressions for each dimension of the array. |
|
public String |
getText() |
|
public boolean |
hasInitializer()Indicates whether this array is defined by an explicit initializer or by size expressions. |
|
public boolean |
isDynamic() |
|
public String |
toString() |
|
public Expression |
transformExpression(ExpressionTransformer transformer) |
|
public void |
visit(GroovyCodeVisitor visitor) |
| Methods inherited from class | Name |
|---|---|
class Expression |
getType, setType, transformExpression, transformExpressions, transformExpressions |
class AnnotatedNode |
addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic |
class ASTNode |
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit |
Constructs an array expression with either size expressions or initializer expressions.
elementType - the base element type of the array (non-null)initExpressions - the list of initializer expressions for array elements, or null for size-based constructionsizeExpressions - the list of size expressions (one per dimension) for fixed-size arrays, or null for initializer-based constructionCreates an array using an initializer list of expressions corresponding to array elements.
elementType - the base element type of the array (non-null)initExpressions - the list of initializer expressions for array elements (non-null)Adds an element to the initializer expressions.
initExpression - the expression to add (non-null)Returns the base element type of the array (before array dimensions are applied).
Returns the initializer expression at the specified index.
i - the index of the elementReturns the list of initializer expressions for array elements.
Returns the size expressions for each dimension of the array.
Indicates whether this array is defined by an explicit initializer or by size expressions.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.