info.javelot.functionalj.reflect.impl
Class DynReflectImpl

java.lang.Object
  extended by info.javelot.functionalj.reflect.impl.DynReflectImpl
All Implemented Interfaces:
DynReflect
Direct Known Subclasses:
CglibDynReflect, JdkDynReflect

public class DynReflectImpl
extends Object
implements DynReflect

A base for implementating "dynamic" reflection that abstracts how to find methods and constructors, and how to produce functions that invoke them.

Author:
Copyright © 2006 Frederic Daoud

Constructor Summary
DynReflectImpl()
          Default constructor, which leaves the helper mechanisms unspecified.
DynReflectImpl(ReflectFinder p_finder, ReflectFactory p_factory, ReflectParameters p_rp)
          Constructor that accepts the mechanisms used for reflection.
 
Method Summary
 FunctionN constructor(Class p_class)
          Produces a function that creates an instance of the specified class, using a constructor.
 FunctionN constructor(String p_class)
          Version of DynReflect.constructor(Class) that accepts a String to specify the class by name.
 FunctionN instanceFunction(Class p_class, String p_name)
          Produces a function that invokes the instance method of specified class which has the specified name, using the parameters passed to the function.
 FunctionN instanceFunction(Object p_object, String p_name)
          Produces a function that invokes the instance method on the provided object which has the specified name.
 FunctionN instanceFunction(String p_class, String p_name)
          Version of DynReflect.instanceFunction(Class,String) that accepts a String to specify the class by name.
 void setReflectFactory(ReflectFactory p_factory)
          Sets the mechanism to use for producing a method or constructor invoker.
 void setReflectFinder(ReflectFinder p_finder)
          Sets the mechanism to use for finding methods and constructors.
 void setReflectParameters(ReflectParameters p_rp)
          Sets the mechanism to use for finding elements that are compatible with parameters.
 FunctionN staticFunction(Class p_class, String p_name)
          Produces a function that invokes the static method of specified class which has the specified name, using the parameters passed to the function.
 FunctionN staticFunction(String p_class, String p_name)
          Version of DynReflect.staticFunction(Class,String) that accepts a String to specify the class by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynReflectImpl

public DynReflectImpl()
Default constructor, which leaves the helper mechanisms unspecified.

The mechanisms to use for finding methods and constructors (ReflectFinder) and for producing a method or constructor invoker (ReflectFactory) are left unspecified when this default constructor is used. Therefore, they must be specified using the appropriate setters: setReflectFinder(info.javelot.functionalj.reflect.helper.ReflectFinder) and setReflectFactory(info.javelot.functionalj.reflect.helper.ReflectFactory).


DynReflectImpl

public DynReflectImpl(ReflectFinder p_finder,
                      ReflectFactory p_factory,
                      ReflectParameters p_rp)
Constructor that accepts the mechanisms used for reflection.

Parameters:
p_finder - the mechanism used for finding methods and constructors.
p_factory - the mechanism used for producing a method or constructor invoker.
p_rp - the mechanism used for finding elements that are compatible with parameters.
Method Detail

setReflectFinder

public void setReflectFinder(ReflectFinder p_finder)
Sets the mechanism to use for finding methods and constructors.


setReflectFactory

public void setReflectFactory(ReflectFactory p_factory)
Sets the mechanism to use for producing a method or constructor invoker.


setReflectParameters

public void setReflectParameters(ReflectParameters p_rp)
Sets the mechanism to use for finding elements that are compatible with parameters.


constructor

public FunctionN constructor(Class p_class)
                      throws FunctionException
Description copied from interface: DynReflect
Produces a function that creates an instance of the specified class, using a constructor.

Specified by:
constructor in interface DynReflect
Parameters:
p_class - an instance of this class will be created by the function. The parameters to the constructor will be the same as the parameters provided to the function.
Returns:
a function that passes its parameters to the constructor and returns an instance of the class.
Throws:
FunctionException - thrown if a matching constructor was not found.

constructor

public FunctionN constructor(String p_class)
                      throws FunctionException
Description copied from interface: DynReflect
Version of DynReflect.constructor(Class) that accepts a String to specify the class by name.

Specified by:
constructor in interface DynReflect
Throws:
FunctionException

instanceFunction

public FunctionN instanceFunction(Class p_class,
                                  String p_name)
                           throws FunctionException
Description copied from interface: DynReflect
Produces a function that invokes the instance method of specified class which has the specified name, using the parameters passed to the function.

Specified by:
instanceFunction in interface DynReflect
Parameters:
p_class - the class which contains the instance method to be invoked by the produced function.
p_name - the name of the method.
Returns:
a function that invokes the method on the object that is specified as its first parameter, passing the rest of its parameters to the method and returning the result of the invocation.
Throws:
FunctionException - thrown if a matching instance method was not found.

instanceFunction

public FunctionN instanceFunction(String p_class,
                                  String p_name)
                           throws FunctionException
Description copied from interface: DynReflect
Version of DynReflect.instanceFunction(Class,String) that accepts a String to specify the class by name.

Specified by:
instanceFunction in interface DynReflect
Throws:
FunctionException

instanceFunction

public FunctionN instanceFunction(Object p_object,
                                  String p_name)
                           throws FunctionException
Description copied from interface: DynReflect
Produces a function that invokes the instance method on the provided object which has the specified name.

Specified by:
instanceFunction in interface DynReflect
Parameters:
p_object - the object on which the instance method will be invoked by the produced function.
p_name - the name of the method.
Returns:
a function that invokes the method on the object, passing its parameters to the method and returning the result.
Throws:
FunctionException - thrown if a matching instance method was not found.

staticFunction

public FunctionN staticFunction(Class p_class,
                                String p_name)
                         throws FunctionException
Description copied from interface: DynReflect
Produces a function that invokes the static method of specified class which has the specified name, using the parameters passed to the function.

Specified by:
staticFunction in interface DynReflect
Parameters:
p_class - the class which contains the static method to be invoked. The parameters to the method will be the same as the parameters provided to the function.
p_name - the name of the method.
Returns:
a function that passes its parameters to the static method and returns the result of invoking it.
Throws:
FunctionException - thrown if a matching static method was not found.

staticFunction

public FunctionN staticFunction(String p_class,
                                String p_name)
                         throws FunctionException
Description copied from interface: DynReflect
Version of DynReflect.staticFunction(Class,String) that accepts a String to specify the class by name.

Specified by:
staticFunction in interface DynReflect
Throws:
FunctionException