JMMF API
pre-release v0.7

fr.umlv.jmmf.reflect
Class CascadeMethod

java.lang.Object
  |
  +--java.lang.reflect.AccessibleObject
        |
        +--fr.umlv.jmmf.reflect.CascadeMethod
All Implemented Interfaces:
java.lang.reflect.Member

public final class CascadeMethod
extends java.lang.reflect.AccessibleObject
implements java.lang.reflect.Member

The cascade-method object.

Version:
0.7.7
Author:
Remi Forax

Field Summary
static java.lang.Class NULL_CLASS
           
 
Fields inherited from interface java.lang.reflect.Member
DECLARED, PUBLIC
 
Method Summary
static CascadeMethod create(java.lang.Class clazz, java.lang.String name, int argLength, boolean topDown)
          construct a cascade-method by taking all method named name with argLength parameter(s) in class clazz.
 boolean equals(java.lang.Object o)
          Compares this MultiMethod against the specified object.
 java.lang.Class getDeclaringClass()
          return class that contains all methods of the current multi-method.
 java.lang.Class[] getExceptionTypes()
          return the exception types of the current method.
 int getModifiers()
          returns the Java language modifiers for the multi-method represented by this MultiMethod object, as an integer.
 java.lang.String getName()
          return the name of the current multi-method.
 java.lang.Class[] getParameterTypes()
          return the parameter types of the current method. a parameter type is the lowest common subtype of all parameter types of the methods that composed the multi-method.
 java.lang.Class getReturnType()
          return the return type of the current method. a return type is the lowest common subtype of all return types of the methods that composed the multi-method.
 int hashCode()
          Returns a hashcode for this MultiMethod.
 java.lang.Object invoke(java.lang.Object target, java.lang.Object[] args)
          call the best method of the multi-method according to the type of all items if args array on a specified target object.
 java.lang.Object invoke(java.lang.Object target, java.lang.Object[] args, java.lang.Class[] types)
          call the best method of the multi-method according to the type of all items if args array on a specified target object.
 java.lang.String toString()
          return a string representation of the multi-method.
 
Methods inherited from class java.lang.reflect.AccessibleObject
isAccessible, setAccessible, setAccessible
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL_CLASS

public static final java.lang.Class NULL_CLASS
Method Detail

equals

public boolean equals(java.lang.Object o)
Compares this MultiMethod against the specified object. Returns true if the objects are the same. Two MultiMethods are the same if they were declared by the same class and have the same name and formal parameter types and return type.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns a hashcode for this MultiMethod. The hashcode is computed as the exclusive-or of the hashcodes for the underlying method's declaring class name and the method's name.
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
return a string representation of the multi-method.
Overrides:
toString in class java.lang.Object

invoke

public java.lang.Object invoke(java.lang.Object target,
                               java.lang.Object[] args)
                        throws java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.NoSuchMethodException,
                               MultipleMethodsException
call the best method of the multi-method according to the type of all items if args array on a specified target object.
Parameters:
target - object on which the best method is called.
args - arguments of the multi-method, the types on this arguments is used to called the best method.
Returns:
the result of the called of the best method.
Throws:
NoSuchMethodException, - there is no method that match the parameter arguments.
MultipleMethodsException - there is no method that match the parameter arguments.
java.lang.reflect.InvocationTargetException - if the best method called raise an exception during its execution, this exception is wrapped into the InvocationTargetException.
java.lang.IllegalAccessException - if best method isn't accessible.
See Also:
Method.invoke(Object,Object[]), invoke(Object, Object[])

invoke

public java.lang.Object invoke(java.lang.Object target,
                               java.lang.Object[] args,
                               java.lang.Class[] types)
                        throws java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.NoSuchMethodException,
                               MultipleMethodsException
call the best method of the multi-method according to the type of all items if args array on a specified target object.
Parameters:
target - object on which the best method is called.
args - arguments of the multi-method,
types - the best method of the multi-method is called according to this types.
Returns:
the result of the called of the best method.
Throws:
NoSuchMethodException, - there is no method that match the parameter types.
MultipleMethodsException, - there is no method that match the parameter types.
java.lang.reflect.InvocationTargetException - if the best method called raise an exception during its execution, this exception is wrapped into the InvocationTargetException.
java.lang.IllegalAccessException - if best method isn't accessible.
See Also:
Method.invoke(Object,Object[])

getModifiers

public int getModifiers()
returns the Java language modifiers for the multi-method represented by this MultiMethod object, as an integer. The Modifier class should be used to decode the modifiers.
Specified by:
getModifiers in interface java.lang.reflect.Member
See Also:
java.lang.reflect.Modifier

getName

public java.lang.String getName()
return the name of the current multi-method.
Specified by:
getName in interface java.lang.reflect.Member

getDeclaringClass

public java.lang.Class getDeclaringClass()
return class that contains all methods of the current multi-method.
Specified by:
getDeclaringClass in interface java.lang.reflect.Member
See Also:
Method.getDeclaringClass()

getParameterTypes

public java.lang.Class[] getParameterTypes()
return the parameter types of the current method. a parameter type is the lowest common subtype of all parameter types of the methods that composed the multi-method.
Returns:
an array of class that contains all parameter types of the current multi-method.
See Also:
Method.getParameterTypes()

getExceptionTypes

public java.lang.Class[] getExceptionTypes()
return the exception types of the current method. The exception types is the union of all exception types of all methods.
Returns:
an array of class that contains all exception types of the current multi-method.
See Also:
Method.getExceptionTypes()

getReturnType

public java.lang.Class getReturnType()
return the return type of the current method. a return type is the lowest common subtype of all return types of the methods that composed the multi-method.
Returns:
a class that contains the return type of the current multi-method.
See Also:
Method.getReturnType()

create

public static CascadeMethod create(java.lang.Class clazz,
                                   java.lang.String name,
                                   int argLength,
                                   boolean topDown)
construct a cascade-method by taking all method named name with argLength parameter(s) in class clazz.
Parameters:
clazz - class which owns the named methods.
name - name of the methods.
argLenth - number of parameters.
topDown - direction of all calls, top-down or bottom-up.
Throws:
java.lang.IllegalArgumentException - if the class clazz contains no method named name or all methods found don't have the same number of parameters.
See Also:
MultiFactory, MultiFactory#createCascadeMethod(Class,String,int)

JMMF API
pre-release v0.7

Rémi Forax 1999,2000 Université de Marne la Vallée