W3cubDocs

/Groovy 3.0

[Java] Class ArrayExpression

  • org.codehaus.groovy.ast.expr.ArrayExpression
public class ArrayExpression
extends Expression

Represents an array object construction. One of:

  • a fixed size array (e.g. new String[3] or new Integer[2][3])
  • an array with an explicit initializer (e.g. new String[]{ "foo", "bar" })
Inherited fields
Fields inherited from class Fields
class Expression EMPTY_ARRAY

Constructor Summary

Constructors
Constructor and description
ArrayExpression (ClassNode elementType, List<Expression> initExpressions, List<Expression> sizeExpressions)
ArrayExpression (ClassNode elementType, List<Expression> initExpressions)
Creates an array using an initializer (list of expressions corresponding to array elements)

Methods Summary

Methods
Type Params Return Type Name and description
public void addExpression(Expression initExpression)
Add another element to the initializer expressions
public ClassNode getElementType()
public Expression getExpression(int i)
Get a particular initializer expression
public List<Expression> getExpressions()
Get the initializer expressions
public List<Expression> getSizeExpression()
Returns:
a list with elements corresponding to the array's dimensions
public String getText()
public boolean hasInitializer()
Returns:
true if the array expression is defined by an explicit initializer
public boolean isDynamic()
public String toString()
public Expression transformExpression(ExpressionTransformer transformer)
public void visit(GroovyCodeVisitor visitor)

Inherited Methods Summary

Inherited Methods
Methods inherited from class Name
class Expression getType, setType, transformExpression, transformExpressions, transformExpressions
class AnnotatedNode 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

Constructor Detail

public ArrayExpression(ClassNode elementType, List<Expression> initExpressions, List<Expression> sizeExpressions)

public ArrayExpression(ClassNode elementType, List<Expression> initExpressions)

Creates an array using an initializer (list of expressions corresponding to array elements)

Method Detail

public void addExpression(Expression initExpression)

Add another element to the initializer expressions

public ClassNode getElementType()

public Expression getExpression(int i)

Get a particular initializer expression

public List<Expression> getExpressions()

Get the initializer expressions

public List<Expression> getSizeExpression()

Returns:
a list with elements corresponding to the array's dimensions

public String getText()

public boolean hasInitializer()

Returns:
true if the array expression is defined by an explicit initializer

public boolean isDynamic()

public String toString()

public Expression transformExpression(ExpressionTransformer transformer)

public void visit(GroovyCodeVisitor visitor)

© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/org/codehaus/groovy/ast/expr/ArrayExpression.html