JML

org.multijava.mjc
Class CParseCompilationUnitContext

java.lang.Object
  extended byorg.multijava.mjc.CParseCompilationUnitContext

public class CParseCompilationUnitContext
extends Object

This class is used by the parser to collect the contents of a compilation unit. For efficiency (and to avoid memory leaks caused by poor garbage collection in the JVM) a factory method is used to generate instances and old instances are stored on a stack for reuse.


Field Summary
private  CCompilationUnit export
           
static JPackageImportType JAVA_LANG
           
private  JPackageName pack
           
private  ArrayList packageImports
           
private  String packageName
          The name of the package of the compilation unit represented by this.
private  ArrayList singleImports
           
private static Stack stack
           
private  ArrayList tlMethods
           
private  ArrayList typeDeclarations
           
 
Constructor Summary
private CParseCompilationUnitContext()
          Hides the default constructor and ensures that every instance package java.lang.
 
Method Summary
 void addMJTopLevelMethodDeclaration(Main compiler, MJTopLevelMethodDeclaration decl)
           
 void addPackageImport(JPackageImportType pack)
           
 void addSingleImport(JClassOrGFImportType clazz)
           
 void addTypeDeclaration(Main compiler, JTypeDeclarationType decl)
           
private  void clear()
          prepares this instance for recycling by clearing all the data stored in its ArrayLists.
 CCompilationUnit compilationUnitExport()
           
static CParseCompilationUnitContext getInstance()
           
 ArrayList getMJTopLevelMethodDeclarations()
          Returns a list of the top level declarations in this compilation unit context.
 JPackageImportType[] getPackageImports()
           
 JPackageName getPackageName()
           
 ArrayList getSingleImports()
          Returns a list representing all the classes and generic functions imported explicitly in this compilation unit.
 JTypeDeclarationType[] getTypeDeclarations()
           
 void release()
          Calls the static method release(this)
static void release(CParseCompilationUnitContext context)
          Erases the data stored in context and pushes the instance onto a stack for recycling.
 void setPackage(JPackageName pack)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVA_LANG

public static final JPackageImportType JAVA_LANG

pack

private JPackageName pack

packageName

private String packageName
The name of the package of the compilation unit represented by this. Formatted with '/' separators, not '.'.


export

private CCompilationUnit export

packageImports

private ArrayList packageImports

singleImports

private ArrayList singleImports

typeDeclarations

private ArrayList typeDeclarations

tlMethods

private ArrayList tlMethods

stack

private static Stack stack
Constructor Detail

CParseCompilationUnitContext

private CParseCompilationUnitContext()
Hides the default constructor and ensures that every instance package java.lang.

Method Detail

getInstance

public static CParseCompilationUnitContext getInstance()

release

public void release()
Calls the static method release(this)


release

public static void release(CParseCompilationUnitContext context)
Erases the data stored in context and pushes the instance onto a stack for recycling.

Parameters:
context - a used instance to be recycled

clear

private void clear()
prepares this instance for recycling by clearing all the data stored in its ArrayLists.


setPackage

public void setPackage(JPackageName pack)

addPackageImport

public void addPackageImport(JPackageImportType pack)

addSingleImport

public void addSingleImport(JClassOrGFImportType clazz)

addTypeDeclaration

public void addTypeDeclaration(Main compiler,
                               JTypeDeclarationType decl)

addMJTopLevelMethodDeclaration

public void addMJTopLevelMethodDeclaration(Main compiler,
                                           MJTopLevelMethodDeclaration decl)

getPackageImports

public JPackageImportType[] getPackageImports()

getSingleImports

public ArrayList getSingleImports()
Returns a list representing all the classes and generic functions imported explicitly in this compilation unit.

Returns:
a list of JClassOrGFImportType instances

getTypeDeclarations

public JTypeDeclarationType[] getTypeDeclarations()

getMJTopLevelMethodDeclarations

public ArrayList getMJTopLevelMethodDeclarations()
Returns a list of the top level declarations in this compilation unit context.

Returns:
a ArrayList whose elements are all instances of MJTopLevelMethodDeclaration

getPackageName

public JPackageName getPackageName()

compilationUnitExport

public CCompilationUnit compilationUnitExport()

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.