bluej.extensions
Class BClass

java.lang.Object
  extended bybluej.extensions.BClass

public class BClass
extends java.lang.Object

A wrapper for a BlueJ class. From this you can create BlueJ objects and call their methods. Behaviour is similar to the Java reflection API.

Version:
$Id: BClass.java,v 1.42 2003/12/09 12:18:54 mik Exp $

Method Summary
 void beginChangeSource()
          Signal to BlueJ that an extension is about to begin changing the source file of this class.
 void compile(boolean waitCompileEnd)
          Compile this class, and any dependents.
 void endChangeSource()
          Signal to BlueJ that an extension has finished changing the source file of this class.
 java.io.File getClassFile()
          Returns this class's .class file.
 BConstructor getConstructor(java.lang.Class[] signature)
          Returns the constructor for this class which has the given signature.
 BConstructor[] getConstructors()
          Returns all the constructors of this class.
 BMethod getDeclaredMethod(java.lang.String methodName, java.lang.Class[] params)
          Returns the declared method of this class which has the given signature.
 BMethod[] getDeclaredMethods()
          Returns the declared methods of this class.
 BField getField(java.lang.String fieldName)
          Returns the field of this class which has the given name.
 BField[] getFields()
          Returns all the fields of this class.
 java.lang.Class getJavaClass()
          Returns the Java class being wrapped by this BClass.
 java.io.File getJavaFile()
          Returns this class's .java file.
 BPackage getPackage()
          Returns the package this class belongs to.
 BClass getSuperclass()
          Returns the superclass of this class.
 boolean isCompiled()
          Checks to see if this class has been compiled.
 void remove()
          Removes this class from BlueJ, including the underlying files.
 java.lang.String toString()
          Returns a string representation of the Object
   

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Method Detail

remove

public void remove()
            throws ProjectNotOpenException,
                   PackageNotFoundException,
                   ClassNotFoundException
Removes this class from BlueJ, including the underlying files.

Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
PackageNotFoundException - if the package to which this class belongs has been deleted by the user.
ClassNotFoundException - if the class has been deleted by the user.

getJavaClass

public java.lang.Class getJavaClass()
                             throws ProjectNotOpenException,
                                    ClassNotFoundException
Returns the Java class being wrapped by this BClass. Use this method when you need more information about the class than is provided by the BClass interface. E.g.: What is the real class being hidden? Is it an array? What is the type of the array element? Note that this is for information only. If you want to interact with BlueJ you must use the methods provided in BClass.

Returns:
The javaClass value
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
ClassNotFoundException - if the class has been deleted by the user.

getPackage

public BPackage getPackage()
                    throws ProjectNotOpenException,
                           PackageNotFoundException
Returns the package this class belongs to. Similar to reflection API.

Returns:
The package value
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
PackageNotFoundException - if the package to which this class belongs has been deleted by the user.

isCompiled

public boolean isCompiled()
                   throws ProjectNotOpenException,
                          PackageNotFoundException
Checks to see if this class has been compiled.

Returns:
true if it is compiled false othervise.
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
PackageNotFoundException - if the package to which this class belongs has been deleted by the user.

compile

public void compile(boolean waitCompileEnd)
             throws ProjectNotOpenException,
                    PackageNotFoundException,
                    CompilationNotStartedException
Compile this class, and any dependents. After the compilation has finished the method isCompiled() can be used to determined the class status. A single CompileEvent with all dependent files listed will be generated.

Parameters:
waitCompileEnd - true waits for the compilation to be finished.
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
PackageNotFoundException - if the package to which this class belongs has been deleted by the user.
CompilationNotStartedException - if BlueJ is currently executing Java code.

getSuperclass

public BClass getSuperclass()
                     throws ProjectNotOpenException,
                            PackageNotFoundException,
                            ClassNotFoundException
Returns the superclass of this class. Similar to reflection API. If this class represents either the Object class, an interface, a primitive type, or void, then null is returned. If the superclass is not part of a package in the current BlueJ project then null is returned.

Returns:
The superclass value
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
PackageNotFoundException - if the package to which this class belongs has been deleted by the user.
ClassNotFoundException - if the class has been deleted by the user.

getConstructors

public BConstructor[] getConstructors()
                               throws ProjectNotOpenException,
                                      ClassNotFoundException
Returns all the constructors of this class. Similar to reflection API.

Returns:
The constructors value
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
ClassNotFoundException - if the class has been deleted by the user.

getConstructor

public BConstructor getConstructor(java.lang.Class[] signature)
                            throws ProjectNotOpenException,
                                   ClassNotFoundException
Returns the constructor for this class which has the given signature. Similar to reflection API.

Parameters:
signature - the signature of the required constructor.
Returns:
the requested constructor of this class, or null if the class has not been compiled or the constructor cannot be found.
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
ClassNotFoundException - if the class has been deleted by the user.

getDeclaredMethods

public BMethod[] getDeclaredMethods()
                             throws ProjectNotOpenException,
                                    ClassNotFoundException
Returns the declared methods of this class. Similar to reflection API.

Returns:
The declaredMethods value
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
ClassNotFoundException - if the class has been deleted by the user.

getDeclaredMethod

public BMethod getDeclaredMethod(java.lang.String methodName,
                                 java.lang.Class[] params)
                          throws ProjectNotOpenException,
                                 ClassNotFoundException
Returns the declared method of this class which has the given signature. Similar to reflection API.

Parameters:
methodName - Description of the Parameter
params - Description of the Parameter
Returns:
The declaredMethod value
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
ClassNotFoundException - if the class has been deleted by the user.

getFields

public BField[] getFields()
                   throws ProjectNotOpenException,
                          ClassNotFoundException
Returns all the fields of this class. Similar to reflection API.

Returns:
The fields value
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
ClassNotFoundException - if the class has been deleted by the user.

getField

public BField getField(java.lang.String fieldName)
                throws ProjectNotOpenException,
                       ClassNotFoundException
Returns the field of this class which has the given name. Similar to Reflection API.

Parameters:
fieldName - Description of the Parameter
Returns:
The field value
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
ClassNotFoundException - if the class has been deleted by the user.

getClassFile

public java.io.File getClassFile()
                          throws ProjectNotOpenException,
                                 PackageNotFoundException
Returns this class's .class file.

Returns:
the class .class file.
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
PackageNotFoundException - if the package to which this class belongs has been deleted by the user.

getJavaFile

public java.io.File getJavaFile()
                         throws ProjectNotOpenException,
                                PackageNotFoundException
Returns this class's .java file. If the file is currently being edited, calling this method will cause it to be saved.

Returns:
the class .java file.
Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
PackageNotFoundException - if the package to which this class belongs has been deleted by the user.

beginChangeSource

public void beginChangeSource()
                       throws ProjectNotOpenException,
                              PackageNotFoundException
Signal to BlueJ that an extension is about to begin changing the source file of this class. The file containing the source for this class can be found using getJavaFile(); If the file is currently being edited it will be saved and the editor will be set read-only.

Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
PackageNotFoundException - if the package to which this class belongs has been deleted by the user.

endChangeSource

public void endChangeSource()
                     throws ProjectNotOpenException,
                            PackageNotFoundException
Signal to BlueJ that an extension has finished changing the source file of this class. If the file is currently being edited, this will cause it to be re-loaded and the editor to be set read/write.

Throws:
ProjectNotOpenException - if the project to which this class belongs has been closed by the user.
PackageNotFoundException - if the package to which this class belongs has been deleted by the user.

toString

public java.lang.String toString()
Returns a string representation of the Object

Returns:
Description of the Return Value


BlueJ homepage