bluej.extensions
Class BConstructor

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

public class BConstructor
extends java.lang.Object

A wrapper for a constructor of a BlueJ class. Behaviour is similar to reflection API.

Author:
Damiano Bolla, University of Kent at Canterbury, 2003,2004

Method Summary
 java.lang.Class<?>[] getParameterTypes()
          Returns the parameters of this constructor.
 boolean matches(java.lang.Class<?>[] parameter)
          Tests if this constructor matches the given signature.
 BObject newInstance(java.lang.Object[] initargs)
          Creates a new instance of the object described by this constructor.
 java.lang.String toString()
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

matches

public boolean matches(java.lang.Class<?>[] parameter)
Tests if this constructor matches the given signature.

Parameters:
parameter - Description of the Parameter
Returns:
true if it does, false otherwise.

getParameterTypes

public java.lang.Class<?>[] getParameterTypes()
Returns the parameters of this constructor. Similar to reflection API.

Returns:
The parameterTypes value

newInstance

public BObject newInstance(java.lang.Object[] initargs)
                    throws ProjectNotOpenException,
                           PackageNotFoundException,
                           InvocationArgumentException,
                           InvocationErrorException
Creates a new instance of the object described by this constructor. Similar to reflection API. Note that this method should not be called from the AWT/Swing event-dispatching thread.

The arguments passed in the initargs array may have any type, but the type will determine exactly what is passed to the constructor:

An attempt is made to ensure that the argument types are suitable for the constructor. InvocationArgumentException will be thrown if the arguments are clearly unsuitable, however some cases will generate an InvocationErrorException instead. In such cases no expression arguments will be evaluated.

Parameters:
initargs - Description of the Parameter
Returns:
Description of the Return Value
Throws:
ProjectNotOpenException - if the project to which this constructor belongs has been closed by the user.
PackageNotFoundException - if the package to which this constructor belongs has been deleted by the user.
InvocationArgumentException - if the initargs don't match the constructor's arguments.
InvocationErrorException - if an error occurs during the invocation.

toString

public java.lang.String toString()
Description of the Method

Overrides:
toString in class java.lang.Object
Returns:
Description of the Return Value


BlueJ homepage