bluej.extensions
Class BProject

java.lang.Object
  extended by bluej.extensions.BProject

public class BProject
extends java.lang.Object

A wrapper for a BlueJ project.

Author:
Clive Mille, Univeristy of Kent at Canterbury, 2002, Damiano Bolla, University of Kent at Canterbury, 2003,2004,2005

Method Summary
 void close()
          Saves any open files, then closes all frames belonging to this project.
 java.net.URLClassLoader getClassLoader()
          Returns a URLClassLoader that should be used to load project classes.
 java.io.File getDir()
          Returns the directory in which this project is stored.
 java.lang.String getName()
          Returns the name of this project.
 BPackage getPackage(java.lang.String name)
          Get a package belonging to this project.
 BPackage[] getPackages()
          Returns all packages belonging to this project.
 BPackage newPackage(java.lang.String fullyQualifiedName)
          Create and return a new package with the given fully qualified name.
 void restartVM()
          Restarts the VM used to run user code for this project.
 void save()
          Requests a "save" of all open files in this project.
 java.lang.String toString()
          Returns a string representation of this package object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()
                         throws ProjectNotOpenException
Returns the name of this project. This is what is displayed in the title bar of the frame after 'BlueJ'.

Throws:
ProjectNotOpenException - if the project has been closed by the user.

getDir

public java.io.File getDir()
                    throws ProjectNotOpenException
Returns the directory in which this project is stored.

Throws:
ProjectNotOpenException - if the project has been closed by the user.

save

public void save()
          throws ProjectNotOpenException
Requests a "save" of all open files in this project.

Throws:
ProjectNotOpenException - if the project has been closed by the user.

close

public void close()
           throws ProjectNotOpenException
Saves any open files, then closes all frames belonging to this project.

Throws:
ProjectNotOpenException - if the project has been closed by the user.

restartVM

public void restartVM()
               throws ProjectNotOpenException
Restarts the VM used to run user code for this project. As a side-effect, removes all objects from the object bench.

Throws:
ProjectNotOpenException - if the project has been closed by the user.

newPackage

public BPackage newPackage(java.lang.String fullyQualifiedName)
                    throws ProjectNotOpenException,
                           PackageAlreadyExistsException
Create and return a new package with the given fully qualified name. The necessary directories and files will be created.

Returns:
the requested package, or null if it wasn't found
Throws:
ProjectNotOpenException - if the project has been closed by the user.
PackageAlreadyExistsException - if the named package already exists in the project.

getPackage

public BPackage getPackage(java.lang.String name)
                    throws ProjectNotOpenException
Get a package belonging to this project.

Parameters:
name - the fully-qualified name of the package
Returns:
the requested package, or null if it wasn't found
Throws:
ProjectNotOpenException - if the project has been closed by the user.

getPackages

public BPackage[] getPackages()
                       throws ProjectNotOpenException
Returns all packages belonging to this project.

Returns:
The array of this project's packages, if none exist an empty array is returned.
Throws:
ProjectNotOpenException - if the project has been closed by the user.

getClassLoader

public java.net.URLClassLoader getClassLoader()
                                       throws ProjectNotOpenException
Returns a URLClassLoader that should be used to load project classes. Every time a project is compiled, even when the compilation is started from the GUI, a new URLClassLoader is created and if the Extension currently have a copy of the old one it should discard it and use getClassLoader() to acquire the new one.

Returns:
A class loader that should be used to load project classes.
Throws:
ProjectNotOpenException - if the project has been closed by the user.

toString

public java.lang.String toString()
Returns a string representation of this package object

Overrides:
toString in class java.lang.Object


BlueJ homepage