Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.ast
[Java] Class ModuleNode

    java.lang.Object
      org.codehaus.groovy.ast.ASTNode
          org.codehaus.groovy.ast.ModuleNode

All Implemented Interfaces:
  org.objectweb.asm.Opcodes

    public class ModuleNode
    extends ASTNode

Represents a module, which consists typically of a class declaration but could include some imports, some statements and multiple classes intermixed with statements like scripts in Python or Ruby

Authors:
  Jochen Theodorou
  Paul King
  James Strachan

Constructor Summary
`ModuleNode(SourceUnit context)`
`ModuleNode(CompileUnit unit)`

Method Summary
`void` | `addClass(ClassNode node)`
`void` | `addImport(java.lang.String alias, ClassNode type)`
`void` | `addImport(java.lang.String alias, ClassNode type, java.util.List annotations)`
`void` | `addMethod(MethodNode node)`
`void` | `addStarImport(java.lang.String packageName)`
`void` | `addStarImport(java.lang.String packageName, java.util.List annotations)`
`void` | `addStatement(Statement node)`
`void` | `addStaticImport(ClassNode type, java.lang.String fieldName, java.lang.String alias)`
`void` | `addStaticImport(ClassNode type, java.lang.String fieldName, java.lang.String alias, java.util.List annotations)`
`void` | `addStaticStarImport(java.lang.String name, ClassNode type)`
`void` | `addStaticStarImport(java.lang.String name, ClassNode type, java.util.List annotations)`
`protected ClassNode` | `createStatementsClass()`
`protected java.lang.String` | `extractClassFromFileDescription()`
`java.util.List` | `getClasses()`
`SourceUnit` | `getContext()`
`java.lang.String` | `getDescription()` @return the underlying character stream description
`ImportNode` | `getImport(java.lang.String alias)` @param alias the name of interest
`ClassNode` | `getImportType(java.lang.String alias)` @param alias the name of interest
`java.util.List` | `getImports()`
`java.lang.String` | `getMainClassName()`
`java.util.List` | `getMethods()`
`PackageNode` | `getPackage()`
`java.lang.String` | `getPackageName()`
`ClassNode` | `getScriptClassDummy()`
`java.util.List` | `getStarImports()`
`BlockStatement` | `getStatementBlock()`
`java.util.Map` | `getStaticImports()`
`java.util.Map` | `getStaticStarImports()`
`CompileUnit` | `getUnit()`
`boolean` | `hasImportsResolved()`
`boolean` | `hasPackage()`
`boolean` | `hasPackageName()`
`boolean` | `isEmpty()`
`void` | `setDescription(java.lang.String description)`
`void` | `setImportsResolved(boolean importsResolved)`
`void` | `setPackage(PackageNode packageNode)`
`void` | `setPackageName(java.lang.String packageName)`
`void` | `sortClasses()`
`void` | `visit(GroovyCodeVisitor visitor)`

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), java.lang.Object#wait(long, int), 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

### ModuleNode

    public ModuleNode(SourceUnit context)

### ModuleNode

    public ModuleNode(CompileUnit unit)

Method Detail

### addClass

    public void addClass(ClassNode node)

### addImport

    public void addImport(java.lang.String alias, ClassNode type)

### addImport

    public void addImport(java.lang.String alias, ClassNode type, java.util.List annotations)

### addMethod

    public void addMethod(MethodNode node)

### addStarImport

    public void addStarImport(java.lang.String packageName)

### addStarImport

    public void addStarImport(java.lang.String packageName, java.util.List annotations)

### addStatement

    public void addStatement(Statement node)

### addStaticImport

    public void addStaticImport(ClassNode type, java.lang.String fieldName, java.lang.String alias)

### addStaticImport

    public void addStaticImport(ClassNode type, java.lang.String fieldName, java.lang.String alias, java.util.List annotations)

### addStaticStarImport

    public void addStaticStarImport(java.lang.String name, ClassNode type)

### addStaticStarImport

    public void addStaticStarImport(java.lang.String name, ClassNode type, java.util.List annotations)

### createStatementsClass

    protected ClassNode createStatementsClass()

### extractClassFromFileDescription

    protected java.lang.String extractClassFromFileDescription()

### getClasses

    public java.util.List getClasses()

### getContext

    public SourceUnit getContext()

### getDescription

    public java.lang.String getDescription()

  Returns:
    the underlying character stream description

### getImport

    public ImportNode getImport(java.lang.String alias)

  Parameters:
    `alias` - the name of interest
  Returns:
    the import node for the given alias or null if none is available

### getImportType

    public ClassNode getImportType(java.lang.String alias)

  Parameters:
    `alias` - the name of interest
  Returns:
    the class node for the given alias or null if none is available

### getImports

    public java.util.List getImports()

### getMainClassName

    public java.lang.String getMainClassName()

### getMethods

    public java.util.List getMethods()

### getPackage

    public PackageNode getPackage()

### getPackageName

    public java.lang.String getPackageName()

### getScriptClassDummy

    public ClassNode getScriptClassDummy()

### getStarImports

    public java.util.List getStarImports()

### getStatementBlock

    public BlockStatement getStatementBlock()

### getStaticImports

    public java.util.Map getStaticImports()

### getStaticStarImports

    public java.util.Map getStaticStarImports()

### getUnit

    public CompileUnit getUnit()

### hasImportsResolved

    public boolean hasImportsResolved()

### hasPackage

    public boolean hasPackage()

### hasPackageName

    public boolean hasPackageName()

### isEmpty

    public boolean isEmpty()

### setDescription

    public void setDescription(java.lang.String description)

### setImportsResolved

    public void setImportsResolved(boolean importsResolved)

### setPackage

    public void setPackage(PackageNode packageNode)

### setPackageName

    public void setPackageName(java.lang.String packageName)

### sortClasses

    public void sortClasses()

### visit

    public void visit(GroovyCodeVisitor visitor)

Groovy Documentation