info.javelot.functionalj.reflect.impl
Class StdReflectImpl

java.lang.Object
  extended by info.javelot.functionalj.reflect.impl.StdReflectImpl
All Implemented Interfaces:
StdReflect
Direct Known Subclasses:
CglibStdReflect, JdkStdReflect

public class StdReflectImpl
extends Object
implements StdReflect

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

Author:
Copyright © 2006 Frederic Daoud

Constructor Summary
StdReflectImpl()
          Default constructor, which leaves the helper mechanisms unspecified.
StdReflectImpl(ReflectFinder p_finder, ReflectFactory p_factory)
          Constructor that accepts the mechanisms used for reflection.
 
Method Summary
 FunctionN constructor(Class p_class, Class... p_types)
          Produces a function that creates an instance of the specified class, using the constructor that accepts parameters of the given types.
 FunctionN constructor(String p_class, Class... p_types)
          Version of StdReflect.constructor(Class,Class...) that accepts a String to specify the class by name.
 FunctionN instanceFunction(Class p_class, String p_name, Class... p_types)
          Produces a function that invokes the instance method of specified class which has the specified name and accepts parameters of the given types.
 FunctionN instanceFunction(Object p_object, String p_name, Class... p_types)
          Produces a function that invokes the instance method on the provided object which has the specified name and accepts parameters of the given types.
 FunctionN instanceFunction(String p_class, String p_name, Class... p_types)
          Version of StdReflect.instanceFunction(Class,String,Class...) 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.
 FunctionN staticFunction(Class p_class, String p_name, Class... p_types)
          Produces a function that invokes the static method of specified class which has the specified name and accepts parameters of the given types.
 FunctionN staticFunction(String p_class, String p_name, Class... p_types)
          Version of StdReflect.staticFunction(Class,String,Class...) 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

StdReflectImpl

public StdReflectImpl()
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).


StdReflectImpl

public StdReflectImpl(ReflectFinder p_finder,
                      ReflectFactory p_factory)
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.
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.


constructor

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

Specified by:
constructor in interface StdReflect
Parameters:
p_class - an instance of this class will be created by the function.
p_types - the number and types of the parameters to the constructor.
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,
                             Class... p_types)
                      throws FunctionException
Description copied from interface: StdReflect
Version of StdReflect.constructor(Class,Class...) that accepts a String to specify the class by name.

Specified by:
constructor in interface StdReflect
Throws:
FunctionException

instanceFunction

public FunctionN instanceFunction(Class p_class,
                                  String p_name,
                                  Class... p_types)
                           throws FunctionException
Description copied from interface: StdReflect
Produces a function that invokes the instance method of specified class which has the specified name and accepts parameters of the given types.

Specified by:
instanceFunction in interface StdReflect
Parameters:
p_class - the class which contains the instance method to be invoked by the produced function.
p_name - the name of the method.
p_types - the number and types of the parameters to the instance 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,
                                  Class... p_types)
                           throws FunctionException
Description copied from interface: StdReflect
Version of StdReflect.instanceFunction(Class,String,Class...) that accepts a String to specify the class by name.

Specified by:
instanceFunction in interface StdReflect
Throws:
FunctionException

instanceFunction

public FunctionN instanceFunction(Object p_object,
                                  String p_name,
                                  Class... p_types)
                           throws FunctionException
Description copied from interface: StdReflect
Produces a function that invokes the instance method on the provided object which has the specified name and accepts parameters of the given types.

Specified by:
instanceFunction in interface StdReflect
Parameters:
p_object - the object on which the instance method will be invoked by the produced function.
p_name - the name of the method.
p_types - the number and types of the parameters to the instance 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,
                                Class... p_types)
                         throws FunctionException
Description copied from interface: StdReflect
Produces a function that invokes the static method of specified class which has the specified name and accepts parameters of the given types.

Specified by:
staticFunction in interface StdReflect
Parameters:
p_class - the class which contains the static method to be invoked by the produced function.
p_name - the name of the method.
p_types - the number and types of the parameters to the static 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,
                                Class... p_types)
                         throws FunctionException
Description copied from interface: StdReflect
Version of StdReflect.staticFunction(Class,String,Class...) that accepts a String to specify the class by name.

Specified by:
staticFunction in interface StdReflect
Throws:
FunctionException