net.israfil.foundation.dynamic
Class DynamicUtil

java.lang.Object
  extended by net.israfil.foundation.dynamic.DynamicUtil

@Copyright(years={"2003","2004","2005","2006"},
           owner="Israfil Consulting Services Corporation",
           license="BSD")
public final class DynamicUtil
extends java.lang.Object

Utilities used for the implementation of Dynamic and related interfaces.

Author:
Christian Edward Gruber

Field Summary
protected static java.util.Map<java.lang.Class,java.util.Set<java.lang.Class>> classes
           
 
Method Summary
protected static java.lang.reflect.Method _getMethodForSelector(java.lang.Class receiverClass, java.lang.String selector)
           
static void addSuperInterfaces(java.util.Set<java.lang.Class> set, java.lang.Class c)
           
static
<T> T
construct(java.lang.Class<T> c, java.lang.Class[] parameterTypes, java.lang.Object... parameters)
          Construct an object of the given class with the provided constructor parameter types and values.
static
<T> T
construct(java.lang.Class<T> c, java.lang.Object... parameters)
          Construct an object of the given class with the provided constructor parameters.
static java.lang.Object construct(java.lang.String className, java.lang.Class[] parameterTypes, java.lang.Object... parameters)
          Construct an object of the given named class with the provided constructor parameter types and values.
static java.lang.Object construct(java.lang.String className, java.lang.Object... parameters)
          Construct an object of the given named class with the provided constructor parameters.
static java.util.Set<java.lang.Class> getAllParentTypes(java.lang.Class c)
           
static java.lang.Class getBoxedTypeEquivalent(java.lang.Class c)
           
static java.lang.reflect.Field getField(java.lang.Object receiver, java.lang.String attributeName)
          Conveniently get a field from an object, automatically trapping exceptions and returning the Field or null if no such field exists.
static java.lang.reflect.Method getMethodForSelector(java.lang.Class receiverClass, java.lang.String selector)
           
static java.lang.reflect.Method getMethodForSelector(java.lang.Object receiver, java.lang.String selector)
           
static java.lang.Class getPrimitiveTypeEquivalent(java.lang.Class c)
           
static boolean hasBoxedTypeEquivalent(java.lang.Class c)
           
static boolean hasPrimitiveTypeEquivalent(java.lang.Class c)
           
static java.lang.Object performOn(java.lang.Object receiver, java.lang.String selector, java.lang.Object... parameters)
           
static boolean respondsTo(java.lang.Object receiver, java.lang.String selector)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classes

protected static final java.util.Map<java.lang.Class,java.util.Set<java.lang.Class>> classes
Method Detail

hasPrimitiveTypeEquivalent

public static boolean hasPrimitiveTypeEquivalent(java.lang.Class c)

getPrimitiveTypeEquivalent

public static java.lang.Class getPrimitiveTypeEquivalent(java.lang.Class c)

hasBoxedTypeEquivalent

public static boolean hasBoxedTypeEquivalent(java.lang.Class c)

getBoxedTypeEquivalent

public static java.lang.Class getBoxedTypeEquivalent(java.lang.Class c)

getAllParentTypes

public static java.util.Set<java.lang.Class> getAllParentTypes(java.lang.Class c)

addSuperInterfaces

public static void addSuperInterfaces(java.util.Set<java.lang.Class> set,
                                      java.lang.Class c)

getField

public static java.lang.reflect.Field getField(java.lang.Object receiver,
                                               java.lang.String attributeName)
Conveniently get a field from an object, automatically trapping exceptions and returning the Field or null if no such field exists.


respondsTo

public static boolean respondsTo(java.lang.Object receiver,
                                 java.lang.String selector)
See Also:
org.israfil.maveric.Dynamic#respondsTo(java.lang.String)

getMethodForSelector

public static java.lang.reflect.Method getMethodForSelector(java.lang.Object receiver,
                                                            java.lang.String selector)

getMethodForSelector

public static java.lang.reflect.Method getMethodForSelector(java.lang.Class receiverClass,
                                                            java.lang.String selector)

_getMethodForSelector

protected static java.lang.reflect.Method _getMethodForSelector(java.lang.Class receiverClass,
                                                                java.lang.String selector)
                                                         throws java.lang.ClassNotFoundException,
                                                                java.lang.NoSuchMethodException
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException

performOn

public static java.lang.Object performOn(java.lang.Object receiver,
                                         java.lang.String selector,
                                         java.lang.Object... parameters)
See Also:
org.israfil.maveric.Dynamic#perform(java.lang.String, java.lang.Object[])

construct

public static java.lang.Object construct(java.lang.String className,
                                         java.lang.Object... parameters)
Construct an object of the given named class with the provided constructor parameters. If there is no such class or no constructor is found that is appropriate to these parameters, the method will return null;

Parameters:
className - The fully qualified name of a Class object to be instantiated.
parameters - Optional parameters for the discovered constructor
Returns:
an instance of the named class, or null if no such class or constructor is found.

construct

public static <T> T construct(java.lang.Class<T> c,
                              java.lang.Object... parameters)
Construct an object of the given class with the provided constructor parameters. If there is no such class or no constructor is found that is appropriate to these parameters, the method will return null;

Parameters:
c - A Class object to be instantiated.
parameters - Optional parameters for the discovered constructor
Returns:
an instance of the named class, or null if no such class or constructor is found.

construct

public static java.lang.Object construct(java.lang.String className,
                                         java.lang.Class[] parameterTypes,
                                         java.lang.Object... parameters)
Construct an object of the given named class with the provided constructor parameter types and values. If there is no such class or no constructor is found that is appropriate to these parameters, the method will return null;

Parameters:
className - The fully qualified name of a Class object to be instantiated.
parameterTypes - The types that form the desired constructor's method signature
parameters - Optional parameters for the discovered constructor
Returns:
an instance of the named class, or null if no such class or constructor is found.

construct

public static <T> T construct(java.lang.Class<T> c,
                              java.lang.Class[] parameterTypes,
                              java.lang.Object... parameters)
Construct an object of the given class with the provided constructor parameter types and values. If there is no such class or no constructor is found that is appropriate to these parameters, the method will return null;

Parameters:
c - A Class object to be instantiated.
parameterTypes - The types that form the desired constructor's method signature
parameters - Optional parameters for the discovered constructor
Returns:
an instance of the named class, or null if no such class or constructor is found.


Copyright © 2003-2008. All Rights Reserved.