|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bluej.extensions.BMethod
public class BMethod
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.
Method Summary | |
---|---|
java.lang.String |
getDeclaringClass()
Returns the class that declares this method. |
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 |
---|
public boolean matches(java.lang.String methodName, java.lang.Class<?>[] parameter)
public java.lang.String getDeclaringClass()
public java.lang.Class<?>[] getParameterTypes()
public java.lang.String getName()
public java.lang.Class<?> getReturnType()
public int getModifiers()
java.lang.reflect.Modifier
class can be used to decode the modifiers.
public java.lang.Object invoke(BObject onThis, java.lang.Object[] params) throws ProjectNotOpenException, PackageNotFoundException, InvocationArgumentException, InvocationErrorException
The arguments passed in the initargs array may have any type, but the type will determine exactly what is passed to the method:
An attempt is made to ensure that the argument types are suitable for the method. 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.
If the method invoked is public static void main(String [] args)
, then the invocation will,
as a side-effect, reset the VM used by BlueJ to run user code in this project, and clear the object bench. This
behaviour matches the effect of invoking a main method through the BlueJ GUI.
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
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.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |