Top Description Fields Constructors Methods
org.codehaus.groovy.ast.expr

public Class ClosureExpression

extends Expression
Class Inheritance
Known Direct Subclasses
org.codehaus.groovy.ast.expr.LambdaExpression
Imports
org.codehaus.groovy.ast.AstToTextHelper, .ClassHelper, .GroovyCodeVisitor, .Parameter, .VariableScope, org.codehaus.groovy.ast.stmt.Statement, org.codehaus.groovy.runtime.InvokerHelper

Represents a closure expression such as
{ statement }
or { i -> statement } or { i, x, String y -> statement }

Field Summary

Modifier and TypeField and Description
private Statement
private final Parameter[]
private VariableScope
Inherited from org.codehaus.groovy.ast.expr.Expression:
EMPTY_ARRAY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Statement

Returns:

the code statement of the closure
getCode
()

This gets the code statement of the closure.

public Parameter[]

Returns:

an array of zero (for implicit it) or more (when explicit args given) parameters or null otherwise (representing explicit no args)
getParameters
()

public String
public VariableScope
public boolean

Returns:

true if one or more explicit parameters are supplied
isParameterSpecified
()

public void
setCode(Statement
the new Statement
code
)

This sets the code statement of the closure.

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Expression
transformExpression(ExpressionTransformer transformer)

Implements abstract org.codehaus.groovy.ast.expr.Expression.transformExpression.

Return a copy of the expression calling the transformer on any nested expressions
public void
Inherited from org.codehaus.groovy.ast.expr.Expression:
getTypesetTypetransformExpressionstransformExpressions

Field Detail

codeback to summary
private Statement code
parametersback to summary
private final Parameter[] parameters
variableScopeback to summary
private VariableScope variableScope

Constructor Detail

ClosureExpressionback to summary
public ClosureExpression(Parameter[] parameters, Statement code)

Method Detail

getCodeback to summary
public Statement getCode()

This gets the code statement of the closure. You can read this method to find out what actions the closure is going to perform.

Returns:Statement

the code statement of the closure

getParametersback to summary
public Parameter[] getParameters()
Returns:Parameter[]

an array of zero (for implicit it) or more (when explicit args given) parameters or null otherwise (representing explicit no args)

getTextback to summary
public String getText()

Overrides org.codehaus.groovy.ast.ASTNode.getText.

Annotations
@Override
getVariableScopeback to summary
public VariableScope getVariableScope()
isParameterSpecifiedback to summary
public boolean isParameterSpecified()
Returns:boolean

true if one or more explicit parameters are supplied

setCodeback to summary
public void setCode(Statement code)

This sets the code statement of the closure. You can use this method in order to add more actions during the closure execution.

Parameters
code:Statement

the new Statement

setVariableScopeback to summary
public void setVariableScope(VariableScope variableScope)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

transformExpressionback to summary
public Expression transformExpression(ExpressionTransformer transformer)

Implements abstract org.codehaus.groovy.ast.expr.Expression.transformExpression.

Doc from org.codehaus.groovy.ast.expr.Expression.transformExpression.

Return a copy of the expression calling the transformer on any nested expressions

visitback to summary
public void visit(GroovyCodeVisitor visitor)

Overrides org.codehaus.groovy.ast.ASTNode.visit.