org.codehaus.groovy.ast
Class MapOfLists

Field Summary
 def EMPTY_ARRAY
           
 ClassNode SUPER
           
 ClassNode THIS
           
 boolean annotated
           
 Class clazz
           
 CompileUnit compileUnit
           
 ClassNode componentType
           
 List constructors
           
 MethodNode enclosingMethod
           
 Map fieldIndex
           
 List fields
           
 def genericsTypes
           
 def interfaces
           
 boolean isPrimaryNode
           
 boolean lazyInitDone
           
 Object lazyInitLock
           
 Map map
           
 MapOfLists methods
           
 List methodsList
           
 def mixins
           
 int modifiers
           
 ModuleNode module
           
 String name
           
 List objectInitializers
           
 boolean placeholder
           
 List properties
           
 ClassNode redirect
           
 boolean script
           
 boolean scriptBody
           
 boolean staticClass
           
 ClassNode superClass
           
 boolean usesGenerics
           
 
Constructor Summary
MapOfLists()
           
 
Method Summary
def ClassNode(ClassNode componentType)
           Constructor used by makeArray() if no real class is available
def ClassNode(Class c, ClassNode componentType)
           Constructor used by makeArray() if a real class is available
def ClassNode(Class c)
           Creates a ClassNode from a real class.
def ClassNode(String name, int modifiers, ClassNode superClass)
           base class
def ClassNode(String name, int modifiers, ClassNode superClass, def interfaces, def mixins)
           base class
void addConstructor(ConstructorNode node)
          
ConstructorNode addConstructor(int modifiers, def parameters, def exceptions, Statement code)
          
void addField(FieldNode node)
          
FieldNode addField(String name, int modifiers, ClassNode type, Expression initialValue)
          
void addInterface(ClassNode type)
          
void addMethod(MethodNode node)
          
MethodNode addMethod(String name, int modifiers, ClassNode returnType, def parameters, def exceptions, Statement code)
           If a method with the given name and parameters is already defined then it is returned otherwise the given method is added to this node.
void addMixin(MixinNode mixin)
          
void addObjectInitializerStatements(Statement statements)
          
void addProperty(PropertyNode node)
          
PropertyNode addProperty(String name, int modifiers, ClassNode type, Expression initialValueExpression, Statement getterBlock, Statement setterBlock)
          
void addStaticInitializerStatements(List staticStatements, boolean fieldInit)
          
MethodNode addSyntheticMethod(String name, int modifiers, ClassNode returnType, def parameters, def exceptions, Statement code)
           Adds a synthetic method as part of the compilation process
boolean declaresInterface(ClassNode classNode)
           or if one of its interfaces extends directly or indirectly the interface
boolean declaresInterfaceDirect(def interfaces, ClassNode classNode)
          
boolean equals(Object o)
          
List get(Object key)
          
List getAbstractMethods()
           Returns a list containing MethodNode objects for each abstract method in the class represented by this ClassNode
List getAllDeclaredMethods()
          
CompileUnit getCompileUnit()
          
ClassNode getComponentType()
          
List getDeclaredConstructors()
          
FieldNode getDeclaredField(String name)
           Finds a field matching the given name in this class.
MethodNode getDeclaredMethod(String name, def parameters)
           Finds a method matching the given name and parameters in this class.
List getDeclaredMethods(String name)
           This methods returns a list of all methods of the given name defined in the current class
Map getDeclaredMethodsMap()
          
MethodNode getEnclosingMethod()
          
FieldNode getField(String name)
           Finds a field matching the given name in this class or a parent class.
List getFields()
           Returns a list containing FieldNode objects for each field in the class represented by this ClassNode
def getGenericsTypes()
          
MethodNode getGetterMethod(String getterName)
          
def getInterfaces()
           Returns an array of ClassNodes representing the interfaces the class implements
MethodNode getMethod(String name, def parameters)
           Finds a method matching the given name and parameters in this class or any parent class.
List getMethods()
           Returns a list containing MethodNode objects for each method in the class represented by this ClassNode
List getMethods(String name)
           This methods creates a list of all methods with this name of the current class and of all super classes
def getMixins()
          
int getModifiers()
          
ModuleNode getModule()
          
String getName()
          
String getNameWithoutPackage()
          
List getNotNull(Object key)
          
List getObjectInitializerStatements()
          
ClassNode getOuterClass()
           Helper method to avoid casting to inner class
FieldNode getOuterField(String name)
           inner class
String getPackageName()
          
ClassNode getPlainNodeReference()
          
List getProperties()
          
PropertyNode getProperty(String name)
          
MethodNode getSetterMethod(String setterName)
          
ClassNode getSuperClass()
          
Class getTypeClass()
          
ClassNode getUnresolvedSuperClass()
          
ClassNode getUnresolvedSuperClass(boolean useRedirect)
          
boolean hasDeclaredMethod(String name, def parameters)
          
boolean hasMethod(String name, def parameters)
          
boolean hasPackageName()
          
boolean hasPossibleMethod(String name, Expression arguments)
           Returns true if the given method has a possibly matching method with the given name and arguments
boolean hasPossibleStaticMethod(String name, Expression arguments)
           Returns true if the given method has a possibly matching static method with the given name and arguments
boolean hasProperty(String name)
          
boolean implementsInterface(ClassNode classNode)
          
boolean isAnnotated()
          
boolean isArray()
          
boolean isDerivedFrom(ClassNode type)
          
boolean isDerivedFromGroovyObject()
           i.e. it implements GroovyObject
boolean isGenericsPlaceHolder()
          
boolean isInterface()
          
boolean isPrimaryClassNode()
           Returns if this instance is a primary ClassNode
boolean isResolved()
          
boolean isScript()
          
boolean isScriptBody()
          
boolean isStaticClass()
           Is this class delcared in a static method (such as a closure / inner class declared in a static method)
boolean isUsingGenerics()
          
void lazyClassInit()
           The complete class structure will be initialized only when really needed to avoid having too much objects during compilation
ClassNode makeArray()
           Returns a ClassNode representing an array of the class represented by this ClassNode
boolean parametersEqual(def a, def b)
          
void put(Object key, Object value)
          
ClassNode redirect()
           Returns the ClassNode this ClassNode is redirecting to.
void setAnnotated(boolean flag)
           Marks if the current class uses annotations or not
void setCompileUnit(CompileUnit cu)
          
void setEnclosingMethod(MethodNode enclosingMethod)
          
void setGenericsPlaceHolder(boolean b)
          
void setGenericsTypes(def genericsTypes)
          
void setInterfaces(def interfaces)
          
void setModule(ModuleNode module)
          
String setName(String name)
          
void setRedirect(ClassNode cn)
           Sets this instance as proxy for the given ClassNode.
void setScript(boolean script)
          
void setScriptBody(boolean scriptBody)
          
void setStaticClass(boolean staticClass)
          
void setSuperClass(ClassNode superClass)
           Sets the superclass of this ClassNode
void setUnresolvedSuperClass(ClassNode sn)
          
void setUsingGenerics(boolean b)
          
String toString()
          
void visitContents(GroovyClassVisitor visitor)
          
 

Constructor Detail

MapOfLists

MapOfLists()


Method Detail

ClassNode

def ClassNode(ClassNode componentType)
Constructor used by makeArray() if no real class is available


ClassNode

def ClassNode(Class c, ClassNode componentType)
Constructor used by makeArray() if a real class is available


ClassNode

public def ClassNode(Class c)
Creates a ClassNode from a real class. The resulting ClassNode will be no primary ClassNode.


ClassNode

public def ClassNode(String name, int modifiers, ClassNode superClass)
param:
name is the full name of the class
param:
modifiers the modifiers,
param:
superClass the base class name - use "java.lang.Object" if no direct
base class
see:
org.objectweb.asm.Opcodes


ClassNode

public def ClassNode(String name, int modifiers, ClassNode superClass, def interfaces, def mixins)
param:
name is the full name of the class
param:
modifiers the modifiers,
param:
superClass the base class name - use "java.lang.Object" if no direct
base class
see:
org.objectweb.asm.Opcodes


addConstructor

public void addConstructor(ConstructorNode node)


addConstructor

public ConstructorNode addConstructor(int modifiers, def parameters, def exceptions, Statement code)


addField

public void addField(FieldNode node)


addField

public FieldNode addField(String name, int modifiers, ClassNode type, Expression initialValue)


addInterface

public void addInterface(ClassNode type)


addMethod

public void addMethod(MethodNode node)


addMethod

public MethodNode addMethod(String name, int modifiers, ClassNode returnType, def parameters, def exceptions, Statement code)
If a method with the given name and parameters is already defined then it is returned otherwise the given method is added to this node. This method is useful for default method adding like getProperty() or invokeMethod() where there may already be a method defined in a class and so the default implementations should not be added if already present.


addMixin

public void addMixin(MixinNode mixin)


addObjectInitializerStatements

public void addObjectInitializerStatements(Statement statements)


addProperty

public void addProperty(PropertyNode node)


addProperty

public PropertyNode addProperty(String name, int modifiers, ClassNode type, Expression initialValueExpression, Statement getterBlock, Statement setterBlock)


addStaticInitializerStatements

public void addStaticInitializerStatements(List staticStatements, boolean fieldInit)


addSyntheticMethod

public MethodNode addSyntheticMethod(String name, int modifiers, ClassNode returnType, def parameters, def exceptions, Statement code)
Adds a synthetic method as part of the compilation process


declaresInterface

public boolean declaresInterface(ClassNode classNode)
param:
classNode the class node for the interface
return:
true if this class declares that it implements the given interface
or if one of its interfaces extends directly or indirectly the interface


declaresInterfaceDirect

boolean declaresInterfaceDirect(def interfaces, ClassNode classNode)


equals

public boolean equals(Object o)


get

public List get(Object key)


getAbstractMethods

public List getAbstractMethods()
Returns a list containing MethodNode objects for each abstract method in the class represented by this ClassNode


getAllDeclaredMethods

public List getAllDeclaredMethods()


getCompileUnit

public CompileUnit getCompileUnit()


getComponentType

public ClassNode getComponentType()


getDeclaredConstructors

public List getDeclaredConstructors()


getDeclaredField

public FieldNode getDeclaredField(String name)
Finds a field matching the given name in this class.
param:
name the name of the field of interest
return:
the method matching the given name and parameters or null


getDeclaredMethod

public MethodNode getDeclaredMethod(String name, def parameters)
Finds a method matching the given name and parameters in this class.
return:
the method matching the given name and parameters or null


getDeclaredMethods

public List getDeclaredMethods(String name)
This methods returns a list of all methods of the given name defined in the current class
return:
the method list
see:
#getMethods(String)


getDeclaredMethodsMap

Map getDeclaredMethodsMap()


getEnclosingMethod

public MethodNode getEnclosingMethod()


getField

public FieldNode getField(String name)
Finds a field matching the given name in this class or a parent class.
param:
name the name of the field of interest
return:
the method matching the given name and parameters or null


getFields

public List getFields()
Returns a list containing FieldNode objects for each field in the class represented by this ClassNode


getGenericsTypes

public def getGenericsTypes()


getGetterMethod

public MethodNode getGetterMethod(String getterName)


getInterfaces

public def getInterfaces()
Returns an array of ClassNodes representing the interfaces the class implements


getMethod

public MethodNode getMethod(String name, def parameters)
Finds a method matching the given name and parameters in this class or any parent class.
return:
the method matching the given name and parameters or null


getMethods

public List getMethods()
Returns a list containing MethodNode objects for each method in the class represented by this ClassNode


getMethods

public List getMethods(String name)
This methods creates a list of all methods with this name of the current class and of all super classes
return:
the methods list
see:
#getDeclaredMethods(String)


getMixins

public def getMixins()


getModifiers

public int getModifiers()


getModule

public ModuleNode getModule()


getName

public String getName()


getNameWithoutPackage

public String getNameWithoutPackage()


getNotNull

public List getNotNull(Object key)


getObjectInitializerStatements

public List getObjectInitializerStatements()


getOuterClass

public ClassNode getOuterClass()
Helper method to avoid casting to inner class


getOuterField

public FieldNode getOuterField(String name)
return:
the field node on the outer class or null if this is not an
inner class


getPackageName

public String getPackageName()
return:
the package name of this class


getPlainNodeReference

public ClassNode getPlainNodeReference()


getProperties

public List getProperties()


getProperty

public PropertyNode getProperty(String name)


getSetterMethod

public MethodNode getSetterMethod(String setterName)


getSuperClass

public ClassNode getSuperClass()
return:
the ClassNode of the super class of this type


getTypeClass

public Class getTypeClass()


getUnresolvedSuperClass

public ClassNode getUnresolvedSuperClass()


getUnresolvedSuperClass

public ClassNode getUnresolvedSuperClass(boolean useRedirect)


hasDeclaredMethod

public boolean hasDeclaredMethod(String name, def parameters)
see:
#getDeclaredMethod(String, Parameter[])


hasMethod

public boolean hasMethod(String name, def parameters)
see:
#getMethod(String, Parameter[])


hasPackageName

public boolean hasPackageName()


hasPossibleMethod

public boolean hasPossibleMethod(String name, Expression arguments)
Returns true if the given method has a possibly matching method with the given name and arguments


hasPossibleStaticMethod

public boolean hasPossibleStaticMethod(String name, Expression arguments)
Returns true if the given method has a possibly matching static method with the given name and arguments


hasProperty

public boolean hasProperty(String name)


implementsInterface

public boolean implementsInterface(ClassNode classNode)
param:
classNode the class node for the interface
return:
true if this class or any base class implements the given interface


isAnnotated

public boolean isAnnotated()


isArray

public boolean isArray()


isDerivedFrom

public boolean isDerivedFrom(ClassNode type)
return:
true if this node is derived from the given class node


isDerivedFromGroovyObject

public boolean isDerivedFromGroovyObject()
return:
true if this class is derived from a groovy object
i.e. it implements GroovyObject


isGenericsPlaceHolder

public boolean isGenericsPlaceHolder()


isInterface

public boolean isInterface()


isPrimaryClassNode

public boolean isPrimaryClassNode()
Returns if this instance is a primary ClassNode


isResolved

public boolean isResolved()


isScript

public boolean isScript()


isScriptBody

public boolean isScriptBody()
return:
Returns true if this inner class or closure was declared inside a script body


isStaticClass

public boolean isStaticClass()
Is this class delcared in a static method (such as a closure / inner class declared in a static method)


isUsingGenerics

public boolean isUsingGenerics()


lazyClassInit

void lazyClassInit()
The complete class structure will be initialized only when really needed to avoid having too much objects during compilation


makeArray

public ClassNode makeArray()
Returns a ClassNode representing an array of the class represented by this ClassNode


parametersEqual

boolean parametersEqual(def a, def b)
return:
true if the two arrays are of the same size and have the same contents


put

public void put(Object key, Object value)


redirect

public ClassNode redirect()
Returns the ClassNode this ClassNode is redirecting to.


setAnnotated

public void setAnnotated(boolean flag)
Marks if the current class uses annotations or not
param:
flag


setCompileUnit

void setCompileUnit(CompileUnit cu)


setEnclosingMethod

public void setEnclosingMethod(MethodNode enclosingMethod)


setGenericsPlaceHolder

public void setGenericsPlaceHolder(boolean b)


setGenericsTypes

public void setGenericsTypes(def genericsTypes)


setInterfaces

public void setInterfaces(def interfaces)


setModule

public void setModule(ModuleNode module)


setName

public String setName(String name)


setRedirect

public void setRedirect(ClassNode cn)
Sets this instance as proxy for the given ClassNode.
param:
cn the class to redirect to. If set to null the redirect will be removed


setScript

public void setScript(boolean script)


setScriptBody

public void setScriptBody(boolean scriptBody)


setStaticClass

public void setStaticClass(boolean staticClass)


setSuperClass

public void setSuperClass(ClassNode superClass)
Sets the superclass of this ClassNode


setUnresolvedSuperClass

public void setUnresolvedSuperClass(ClassNode sn)


setUsingGenerics

public void setUsingGenerics(boolean b)


toString

public String toString()


visitContents

public void visitContents(GroovyClassVisitor visitor)