Groovy Documentation

org.codehaus.groovy.ast
[Java] Class MethodNode

java.lang.Object
  org.codehaus.groovy.ast.ASTNode
      org.codehaus.groovy.ast.AnnotatedNode
          org.codehaus.groovy.ast.MethodNode
All Implemented Interfaces:
org.objectweb.asm.Opcodes

public class MethodNode
extends AnnotatedNode

Represents a method declaration

Authors:
James Strachan
Hamlet D'Arcy
Version:
\$Revision\$


Constructor Summary
MethodNode(java.lang.String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)

 
Method Summary
Statement getCode()

ClassNode[] getExceptions()

Statement getFirstStatement()

GenericsType[] getGenericsTypes()

int getModifiers()

java.lang.String getName()

Parameter[] getParameters()

ClassNode getReturnType()

java.lang.String getText()

Provides a nicely formatted string of the method definition.

java.lang.String getTypeDescriptor()

The type descriptor for a method node is a string containing the name of the method, its return type, and its parameter types in a canonical form.

VariableScope getVariableScope()

boolean hasAnnotationDefault()

boolean hasDefaultValue()

boolean isAbstract()

boolean isDynamicReturnType()

boolean isFinal()

boolean isPrivate()

boolean isProtected()

boolean isPublic()

boolean isScriptBody()

@return true if this method is the run method from a script

boolean isStatic()

boolean isStaticConstructor()

boolean isSyntheticPublic()

Indicates that this method has been "promoted" to public by Groovy when in fact there was no public modifier explicitly in the source code.

boolean isVoidMethod()

void setAnnotationDefault(boolean b)

void setCode(Statement code)

void setGenericsTypes(GenericsType[] genericsTypes)

void setModifiers(int modifiers)

void setParameters(Parameter[] parameters)

void setReturnType(ClassNode returnType)

void setSyntheticPublic(boolean syntheticPublic)

void setVariableScope(VariableScope variableScope)

java.lang.String toString()

 
Methods inherited from class AnnotatedNode
addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic
 
Methods inherited from class ASTNode
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getNodeMetaData, getText, putNodeMetaData, removeNodeMetaData, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setNodeMetaData, setSourcePosition, visit
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Constructor Detail

MethodNode

public MethodNode(java.lang.String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)


 
Method Detail

getCode

public Statement getCode()


getExceptions

public ClassNode[] getExceptions()


getFirstStatement

public Statement getFirstStatement()


getGenericsTypes

public GenericsType[] getGenericsTypes()


getModifiers

public int getModifiers()


getName

public java.lang.String getName()


getParameters

public Parameter[] getParameters()


getReturnType

public ClassNode getReturnType()


getText

String retType = AstToTextHelper.getClassText(returnType);
public java.lang.String getText()
Provides a nicely formatted string of the method definition. For simplicity, generic types on some of the elements are not displayed.
Returns:
string form of node with some generic elements suppressed


getTypeDescriptor

public java.lang.String getTypeDescriptor()
The type descriptor for a method node is a string containing the name of the method, its return type, and its parameter types in a canonical form. For simplicity, I'm using the format of a Java declaration without parameter names.
Returns:
the type descriptor


getVariableScope

public VariableScope getVariableScope()


hasAnnotationDefault

public boolean hasAnnotationDefault()


hasDefaultValue

public boolean hasDefaultValue()


isAbstract

public boolean isAbstract()


isDynamicReturnType

public boolean isDynamicReturnType()


isFinal

public boolean isFinal()


isPrivate

public boolean isPrivate()


isProtected

public boolean isProtected()


isPublic

public boolean isPublic()


isScriptBody

public boolean isScriptBody()
Returns:
true if this method is the run method from a script


isStatic

public boolean isStatic()


isStaticConstructor

public boolean isStaticConstructor()


isSyntheticPublic

public boolean isSyntheticPublic()
Indicates that this method has been "promoted" to public by Groovy when in fact there was no public modifier explicitly in the source code. I.e. it remembers that it has applied Groovy's "public methods by default" rule. This property is typically only of interest to AST transform writers.
Returns:
true if this class is public but had no explicit public modifier


isVoidMethod

public boolean isVoidMethod()


setAnnotationDefault

public void setAnnotationDefault(boolean b)


setCode

public void setCode(Statement code)


setGenericsTypes

public void setGenericsTypes(GenericsType[] genericsTypes)


setModifiers

public void setModifiers(int modifiers)


setParameters

public void setParameters(Parameter[] parameters)


setReturnType

public void setReturnType(ClassNode returnType)


setSyntheticPublic

public void setSyntheticPublic(boolean syntheticPublic)


setVariableScope

public void setVariableScope(VariableScope variableScope)


toString

public java.lang.String toString()


 

Groovy Documentation