bluej.extensions
Class BMethod

java.lang.Object
  extended bybluej.extensions.BMethod

public class BMethod
extends java.lang.Object

A wrapper for a method of a BlueJ class. Allows an extension to invoke a method on an object that is on the BlueJ object bench. When values representing types are returned, there are two cases: In the case that the returned value is of primitive type (int etc.), it is represented in the appropriate Java wrapper type (Integer etc.). In the case that the returned value is an object type then an appropriate BObject will be returned, allowing the returned object itself to be placed on the BlueJ object bench.

Version:
$Id: BMethod.java,v 1.30 2003/05/23 09:39:10 damiano Exp $

Method Summary
 int getModifiers()
          Returns the modifiers for this method.
 java.lang.String getName()
          Returns the name of this method.
 java.lang.Class[] getParameterTypes()
          Returns the types of the parameters of this method.
 java.lang.Class getReturnType()
          Returns the return type of this method Similar to Reflection API
 java.lang.Object invoke(BObject onThis, java.lang.Object[] params)
          Invoke this method on the given object.
 boolean matches(java.lang.String methodName, java.lang.Class[] parameter)
          Tests if this method matches against the given signature.
 java.lang.String toString()
          Returns a string representing the return type, name and signature of this 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.String methodName,
                       java.lang.Class[] parameter)
Tests if this method matches against the given signature. This is similar to reflection API. Returns true if there is a match, false otherwise. Pass a zero length parameter array if the method takes no arguments.


getParameterTypes

public java.lang.Class[] getParameterTypes()
Returns the types of the parameters of this method. Similar to Reflection API


getName

public java.lang.String getName()
Returns the name of this method. Similar to Reflection API


getReturnType

public java.lang.Class getReturnType()
Returns the return type of this method Similar to Reflection API


getModifiers

public int getModifiers()
Returns the modifiers for this method. The java.lang.reflect.Modifier class can be used to decode the modifiers.


invoke

public java.lang.Object invoke(BObject onThis,
                               java.lang.Object[] params)
                        throws ProjectNotOpenException,
                               PackageNotFoundException,
                               InvocationArgumentException,
                               InvocationErrorException
Invoke this method on the given object.

Parameters:
onThis - The BObject to which the method call should be applied, null if a static method.
params - an array containing the arguments, or null if there are none
Returns:
the resulting Object. It can be a wrapper for a primitive type or a BObject
Throws:
ProjectNotOpenException - if the project to which this object belongs has been closed by the user.
PackageNotFoundException - if the package to which this object belongs has been deleted by the user.
InvocationArgumentException - if the params don't match the object's arguments.
InvocationErrorException - if an error occurs during the invocation.

toString

public java.lang.String toString()
Returns a string representing the return type, name and signature of this method



BlueJ homepage