info.javelot.functionalj.reflect.element
Class ReflectInstanceMethod

java.lang.Object
  extended by info.javelot.functionalj.reflect.element.ReflectInstanceMethod
All Implemented Interfaces:
ReflectElement
Direct Known Subclasses:
ReflectJdkInstanceMethod

public abstract class ReflectInstanceMethod
extends Object
implements ReflectElement

Represents a reflect instance method.

Author:
Copyright © 2006 Frederic Daoud

Constructor Summary
ReflectInstanceMethod(Method p_method)
          Constructs a reflect element for an instance method.
 
Method Summary
 String getName()
          Returns the name of the reflect element.
 Class[] getParameterTypes()
          Returns the types of the parameters to the reflect element.
 Object invoke(Object[] p_params)
          Invokes the target instance method, using the first parameter as the object on which to invoke the method, and passing the rest of the parameters to the method.
protected abstract  Object invoke(Object p_object, Object[] p_params)
          Invokes the target instance method on the specified object, passing the given parameters.
 String toString()
          String representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReflectInstanceMethod

public ReflectInstanceMethod(Method p_method)
Constructs a reflect element for an instance method.

Parameters:
p_method - the reflect instance method.
Method Detail

getName

public String getName()
Description copied from interface: ReflectElement
Returns the name of the reflect element. For a constructor, this is the name of the class. For a method, this is the name of the class and the name of the method.

Specified by:
getName in interface ReflectElement

getParameterTypes

public Class[] getParameterTypes()
Description copied from interface: ReflectElement
Returns the types of the parameters to the reflect element.

Specified by:
getParameterTypes in interface ReflectElement
Returns:
the types of the parameters to the reflect element.

invoke

public Object invoke(Object[] p_params)
              throws Exception
Invokes the target instance method, using the first parameter as the object on which to invoke the method, and passing the rest of the parameters to the method.

Specified by:
invoke in interface ReflectElement
Parameters:
p_params - the target object on which to invoke the method, followed by the parameters to be passed to the method.
Returns:
the result of invoking the method.
Throws:
Exception - thrown if an exception occurs when invoking the method.

invoke

protected abstract Object invoke(Object p_object,
                                 Object[] p_params)
                          throws Exception
Invokes the target instance method on the specified object, passing the given parameters.

Parameters:
p_object - the target object on which to invoke the method.
p_params - the parameters to be passed to the method.
Returns:
the result of invoking the method.
Throws:
Exception - thrown if an exception occurs when invoking the method.

toString

public String toString()
String representation.

Overrides:
toString in class Object