org.codehaus.groovy.runtime
Class MetaClassHelper

author:
John Wilson
author:
Jochen Theodorou

Field Summary
 def ARRAY_WITH_NULL
           
 def EMPTY_ARRAY
           
 def EMPTY_TYPE_ARRAY
           
 Logger LOG
           
 int MAX_ARG_LEN
           
 def PRIMITIVES
           
 def PRIMITIVE_DISTANCE_TABLE
           
 int VARGS_SHIFT
           
 
Constructor Summary
MetaClassHelper()
           
 
Method Summary
static boolean accessibleToConstructor(Class at, Constructor constructor)
          
static Object asPrimitiveArray(List list, Class parameterType)
          
static def asWrapperArray(Object parameters, Class componentType)
          
static long calculateParameterDistance(Class argument, CachedClass parameter)
          
static long calculateParameterDistance(def arguments, ParameterTypes pt)
          
static int calculateSimplifiedClassDistanceToObject(Class clazz)
          
static String capitalize(String property)
          
static Boolean checkCompatiblePackages(Class at, Constructor constructor)
          
static Object chooseEmptyMethodParams(FastArray methods)
           object (e.g.
static Object chooseMostGeneralMethodWith1NullParam(FastArray methods)
           object (e.g.
static boolean containsMatchingMethod(List list, MetaMethod method)
           list
static def convertToTypeArray(def args)
           param instance array to the type array
static GroovyRuntimeException createExceptionText(String init, Constructor constructor, def argumentArray, Throwable e, boolean setReason)
          
static GroovyRuntimeException createExceptionText(String init, MetaMethod method, Object object, def args, Throwable reason, boolean setReason)
          
static Object doConstructorInvoke(CachedConstructor constructor, def argumentArray)
          
static Object doMethodInvoke(Object object, MetaMethod method, def argumentArray)
          
static String getClassName(Object object)
          
static int getMaximumInterfaceDistance(Class c, Class interfaceClass)
          
static Closure getMethodPointer(Object object, String methodName)
           Returns a callable object for the given method name on the object.
static ParameterTypes getParameterTypes(Object methodOrConstructor)
          
static int getPrimitiveDistance(Class from, Class to)
          
static int getPrimitiveIndex(Class c)
          
static boolean isAssignableFrom(Class classToTransformTo, Class classToTransformFrom)
          
static boolean isGenericSetMethod(MetaMethod method)
          
static boolean isSuperclass(Class claszz, Class superclass)
          
static boolean isValidMethod(Object method, def arguments)
          
static void logMethodCall(Object object, String methodName, def arguments)
          
static Object makeArray(Object obj, Class secondary, int length)
          
static Object makeCommonArray(def arguments, int offset, Class fallback)
          
static String normalizedValue(Object argument)
          
static boolean parametersAreCompatible(def arguments, def parameters)
          
static String shortName(Object object)
          
static def wrap(def classes)
          
 

Constructor Detail

MetaClassHelper

MetaClassHelper()


Method Detail

accessibleToConstructor

public static boolean accessibleToConstructor(Class at, Constructor constructor)


asPrimitiveArray

public static Object asPrimitiveArray(List list, Class parameterType)
param:
list the original list
param:
parameterType the resulting array type
return:
the constructed array


asWrapperArray

public static def asWrapperArray(Object parameters, Class componentType)


calculateParameterDistance

static long calculateParameterDistance(Class argument, CachedClass parameter)


calculateParameterDistance

public static long calculateParameterDistance(def arguments, ParameterTypes pt)


calculateSimplifiedClassDistanceToObject

static int calculateSimplifiedClassDistanceToObject(Class clazz)


capitalize

public static String capitalize(String property)


checkCompatiblePackages

static Boolean checkCompatiblePackages(Class at, Constructor constructor)


chooseEmptyMethodParams

public static Object chooseEmptyMethodParams(FastArray methods)
param:
methods the methods to choose from
return:
the method with 1 parameter which takes the most general type of
object (e.g. Object)


chooseMostGeneralMethodWith1NullParam

public static Object chooseMostGeneralMethodWith1NullParam(FastArray methods)
param:
methods the methods to choose from
return:
the method with 1 parameter which takes the most general type of
object (e.g. Object) ignoring primitve types


containsMatchingMethod

public static boolean containsMatchingMethod(List list, MetaMethod method)
param:
list a list of MetaMethods
param:
method the MetaMethod of interest
return:
true if a method of the same matching prototype was found in the
list


convertToTypeArray

public static def convertToTypeArray(def args)
param instance array to the type array
param:
args the arguments
return:
the types of the arguments


createExceptionText

static GroovyRuntimeException createExceptionText(String init, Constructor constructor, def argumentArray, Throwable e, boolean setReason)


createExceptionText

public static GroovyRuntimeException createExceptionText(String init, MetaMethod method, Object object, def args, Throwable reason, boolean setReason)


doConstructorInvoke

public static Object doConstructorInvoke(CachedConstructor constructor, def argumentArray)


doMethodInvoke

public static Object doMethodInvoke(Object object, MetaMethod method, def argumentArray)


getClassName

static String getClassName(Object object)


getMaximumInterfaceDistance

static int getMaximumInterfaceDistance(Class c, Class interfaceClass)


getMethodPointer

public static Closure getMethodPointer(Object object, String methodName)
Returns a callable object for the given method name on the object. The object acts like a Closure in that it can be called, like a closure and passed around - though really its a method pointer, not a closure per se.
param:
object the object containing the method
param:
methodName the method of interest
return:
the resulting closure-like method pointer


getParameterTypes

public static ParameterTypes getParameterTypes(Object methodOrConstructor)


getPrimitiveDistance

static int getPrimitiveDistance(Class from, Class to)


getPrimitiveIndex

static int getPrimitiveIndex(Class c)


isAssignableFrom

public static boolean isAssignableFrom(Class classToTransformTo, Class classToTransformFrom)


isGenericSetMethod

public static boolean isGenericSetMethod(MetaMethod method)


isSuperclass

static boolean isSuperclass(Class claszz, Class superclass)


isValidMethod

public static boolean isValidMethod(Object method, def arguments)


logMethodCall

public static void logMethodCall(Object object, String methodName, def arguments)


makeArray

public static Object makeArray(Object obj, Class secondary, int length)


makeCommonArray

public static Object makeCommonArray(def arguments, int offset, Class fallback)


normalizedValue

static String normalizedValue(Object argument)


parametersAreCompatible

public static boolean parametersAreCompatible(def arguments, def parameters)


shortName

static String shortName(Object object)


wrap

public static def wrap(def classes)