| java.lang.Object org.codehaus.groovy.ast.ASTNode org.codehaus.groovy.ast.AnnotatedNode org.codehaus.groovy.ast.ClassNode
All known Subclasses: org.codehaus.groovy.ast.MixinNode, org.codehaus.groovy.ast.InnerClassNode,
ClassNode | public class ClassNode extends AnnotatedNode implements Opcodes(Code) | | Represents a class in the AST.
A ClassNode should be created using the methods in ClassHelper.
This ClassNode may be used to represent a class declaration or
any other type. This class uses a proxy meschanism allowing to
create a class for a plain name at ast creation time. In another
phase of the compiler the real ClassNode for the plain name may be
found. To avoid the need of exchanging this ClassNode with an
instance of the correct ClassNode the correct ClassNode is set as
redirect. All method calls are then redirected to that ClassNode.
Note: the proxy mechanism is only allowed for classes being marked
as primary ClassNode which means they represent no actual class.
The redirect itself can be any type of ClassNode
See Also: org.codehaus.groovy.ast.ClassHelper author: James Strachan author: Jochen Theodorou version: $Revision: 4216 $ |
Method Summary | |
public void | addConstructor(ConstructorNode node) | public ConstructorNode | addConstructor(int modifiers, Parameter[] parameters, ClassNode[] exceptions, Statement code) | public void | addField(FieldNode node) | public FieldNode | addField(String name, int modifiers, ClassNode type, Expression initialValue) | public void | addInterface(ClassNode type) | public void | addMethod(MethodNode node) | public MethodNode | addMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] 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. | public void | addMixin(MixinNode mixin) | public void | addObjectInitializerStatements(Statement statements) | public void | addProperty(PropertyNode node) | public PropertyNode | addProperty(String name, int modifiers, ClassNode type, Expression initialValueExpression, Statement getterBlock, Statement setterBlock) | public void | addStaticInitializerStatements(List staticStatements, boolean fieldInit) | public MethodNode | addSyntheticMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) | protected MethodNode | createMethodNode(Method method) | protected Parameter | createParameter(Class parameterType, int idx) | protected Parameter[] | createParameters(Class[] types) | public boolean | declaresInterface(String name) | public boolean | equals(Object o) | public List | getAbstractMethods() | public List | getAllDeclaredMethods() | public CompileUnit | getCompileUnit() | public ClassNode | getComponentType() | public List | getDeclaredConstructors() | public MethodNode | getDeclaredMethod(String name, Parameter[] parameters) | public List | getDeclaredMethods(String name) | protected Map | getDeclaredMethodsMap() | public MethodNode | getEnclosingMethod() | public FieldNode | getField(String name) | public List | getFields() | public MethodNode | getGetterMethod(String getterName) | public ClassNode[] | getInterfaces() | public List | getMethods() | public List | getMethods(String name) | public MixinNode[] | getMixins() | public int | getModifiers() | public ModuleNode | getModule() | public String | getName() | public String | getNameWithoutPackage() | public List | getObjectInitializerStatements() | public ClassNode | getOuterClass() | public FieldNode | getOuterField(String name) | public String | getPackageName() | public List | getProperties() | public MethodNode | getSetterMethod(String getterName) | public ClassNode | getSuperClass() | public Class | getTypeClass() | public ClassNode | getUnresolvedSuperClass() | public boolean | hasPackageName() | public boolean | hasPossibleMethod(String name, Expression arguments) | public boolean | implementsInterface(String name) | public boolean | isArray() | public boolean | isDerivedFrom(ClassNode type) | public boolean | isDerivedFromGroovyObject() true if this class is derived from a groovy objecti.e. | public boolean | isInterface() | public boolean | isPrimaryClassNode() | public boolean | isResolved() | public boolean | isScript() | public boolean | isScriptBody() | public boolean | isStaticClass() | public ClassNode | makeArray() | protected boolean | parametersEqual(Parameter[] a, Parameter[] b) | protected ClassNode | redirect() Returns the ClassNode this ClassNode is redirecting to. | protected void | setCompileUnit(CompileUnit cu) | public void | setEnclosingMethod(MethodNode enclosingMethod) | public void | setModule(ModuleNode module) | public String | setName(String name) | public void | setRedirect(ClassNode cn) Sets this instance as proxy for the given ClassNode. | public void | setScript(boolean script) | public void | setScriptBody(boolean scriptBody) | public void | setStaticClass(boolean staticClass) | public void | setSuperClass(ClassNode superClass) | public String | toString() | public void | visitContents(GroovyClassVisitor visitor) |
isPrimaryNode | boolean isPrimaryNode(Code) | | |
ClassNode | public ClassNode(Class c)(Code) | | Creates a ClassNode from a real class. The resulting
ClassNode will be no primary ClassNode.
|
ClassNode | public ClassNode(String name, int modifiers, ClassNode superClass)(Code) | | Parameters: name - is the full name of the class Parameters: modifiers - the modifiers, Parameters: superClass - the base class name - use "java.lang.Object" if no directbase class See Also: org.objectweb.asm.Opcodes |
ClassNode | public ClassNode(String name, int modifiers, ClassNode superClass, ClassNode[] interfaces, MixinNode[] mixins)(Code) | | Parameters: name - is the full name of the class Parameters: modifiers - the modifiers, Parameters: superClass - the base class name - use "java.lang.Object" if no directbase class See Also: org.objectweb.asm.Opcodes |
addMethod | public MethodNode addMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)(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.
|
addObjectInitializerStatements | public void addObjectInitializerStatements(Statement statements)(Code) | | |
addStaticInitializerStatements | public void addStaticInitializerStatements(List staticStatements, boolean fieldInit)(Code) | | |
createMethodNode | protected MethodNode createMethodNode(Method method)(Code) | | Factory method to create a new MethodNode via reflection
|
declaresInterface | public boolean declaresInterface(String name)(Code) | | Parameters: name - the fully qualified name of the interface true if this class declares that it implements the given interface |
getAbstractMethods | public List getAbstractMethods()(Code) | | Returns a list containing MethodNode objects for
each abstract method in the class represented by
this ClassNode
|
getAllDeclaredMethods | public List getAllDeclaredMethods()(Code) | | |
getDeclaredConstructors | public List getDeclaredConstructors()(Code) | | |
getDeclaredMethods | public List getDeclaredMethods(String name)(Code) | | a list of methods which match the given name |
getDeclaredMethodsMap | protected Map getDeclaredMethodsMap()(Code) | | |
getFields | public List getFields()(Code) | | Returns a list containing FieldNode objects for
each field in the class represented by this ClassNode
|
getInterfaces | public ClassNode[] getInterfaces()(Code) | | Returns an array of ClassNodes representing the
interfaces the class implements
|
getMethods | public List getMethods()(Code) | | Returns a list containing MethodNode objects for
each method in the class represented by this ClassNode
|
getMethods | public List getMethods(String name)(Code) | | a list of methods which match the given name |
getModifiers | public int getModifiers()(Code) | | |
getNameWithoutPackage | public String getNameWithoutPackage()(Code) | | |
getObjectInitializerStatements | public List getObjectInitializerStatements()(Code) | | |
getOuterClass | public ClassNode getOuterClass()(Code) | | Helper method to avoid casting to inner class
|
getOuterField | public FieldNode getOuterField(String name)(Code) | | the field node on the outer class or null if this is not aninner class |
getPackageName | public String getPackageName()(Code) | | the package name of this class |
getSuperClass | public ClassNode getSuperClass()(Code) | | the ClassNode of the super class of this type |
hasPackageName | public boolean hasPackageName()(Code) | | |
hasPossibleMethod | public boolean hasPossibleMethod(String name, Expression arguments)(Code) | | Returns true if the given method has a possibly matching method with the given name and arguments
|
implementsInterface | public boolean implementsInterface(String name)(Code) | | Parameters: name - the fully qualified name of the interface true if this class or any base class implements the given interface |
isArray | public boolean isArray()(Code) | | |
isDerivedFrom | public boolean isDerivedFrom(ClassNode type)(Code) | | true if this node is derived from the given class node |
isDerivedFromGroovyObject | public boolean isDerivedFromGroovyObject()(Code) | | true if this class is derived from a groovy objecti.e. it implements GroovyObject |
isInterface | public boolean isInterface()(Code) | | |
isPrimaryClassNode | public boolean isPrimaryClassNode()(Code) | | Returns if this instance is a primary ClassNode
|
isResolved | public boolean isResolved()(Code) | | |
isScript | public boolean isScript()(Code) | | |
isScriptBody | public boolean isScriptBody()(Code) | | Returns true if this inner class or closure was declared inside a script body |
isStaticClass | public boolean isStaticClass()(Code) | | Is this class delcared in a static method (such as a closure / inner class declared in a static method)
|
makeArray | public ClassNode makeArray()(Code) | | Returns a ClassNode representing an array of the class
represented by this ClassNode
|
parametersEqual | protected boolean parametersEqual(Parameter[] a, Parameter[] b)(Code) | | true if the two arrays are of the same size and have the same contents |
redirect | protected ClassNode redirect()(Code) | | Returns the ClassNode this ClassNode is redirecting to.
|
setEnclosingMethod | public void setEnclosingMethod(MethodNode enclosingMethod)(Code) | | |
setRedirect | public void setRedirect(ClassNode cn)(Code) | | Sets this instance as proxy for the given ClassNode.
Parameters: cn - the class to redirect to. If set to null the redirect will be removed |
setScript | public void setScript(boolean script)(Code) | | |
setScriptBody | public void setScriptBody(boolean scriptBody)(Code) | | |
setStaticClass | public void setStaticClass(boolean staticClass)(Code) | | |
setSuperClass | public void setSuperClass(ClassNode superClass)(Code) | | Sets the superclass of this ClassNode
|
|
|