org.objectweb.fractal.aokell.glue
Class SpoonHelper

java.lang.Object
  extended by org.objectweb.fractal.aokell.glue.SpoonHelper

public class SpoonHelper
extends Object

Helper class for working with Spoon.

Author:
Lionel Seinturier

Constructor Summary
SpoonHelper()
           
 
Method Summary
static boolean deepImpls(spoon.reflect.declaration.CtClass<?> ct, Class<?> itf)
          Return true if one of the subclasses of the given CtClass implements the given interface.
static Class<?>[] getClassParameterTypes(List<spoon.reflect.declaration.CtParameter<?>> params)
          Return the classes of the given list of parameters.
static spoon.reflect.reference.CtTypeReference<?>[] getTypeRefParameterTypes(List<spoon.reflect.declaration.CtParameter<?>> params)
          Return the type references of the given list of parameters.
static boolean impls(spoon.reflect.declaration.CtClass ct, Class<?> itf)
          Return true if the given CtClass implements directly the given interface.
static void insert(spoon.reflect.declaration.CtClass<?> ct, Class<?> typeToMatch, spoon.template.Template template)
          Insert a template in a CtClass if the CtClass implements the given type and if none of the super classes of the CtClass already implements the given type (to avoid duplicate insertion of the template).
static void insert(spoon.reflect.declaration.CtClass<?> ct, spoon.template.Template template)
          Insert a template in a CtClass.
static boolean isInterfaceMethodImplementation(spoon.reflect.declaration.CtClass<?> cl, spoon.reflect.declaration.CtMethod<?> meth)
          If the given method implements a method declared in an interface of the given class, return true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpoonHelper

public SpoonHelper()
Method Detail

isInterfaceMethodImplementation

public static boolean isInterfaceMethodImplementation(spoon.reflect.declaration.CtClass<?> cl,
                                                      spoon.reflect.declaration.CtMethod<?> meth)
If the given method implements a method declared in an interface of the given class, return true. Else return false.


getTypeRefParameterTypes

public static spoon.reflect.reference.CtTypeReference<?>[] getTypeRefParameterTypes(List<spoon.reflect.declaration.CtParameter<?>> params)
Return the type references of the given list of parameters.


getClassParameterTypes

public static Class<?>[] getClassParameterTypes(List<spoon.reflect.declaration.CtParameter<?>> params)
Return the classes of the given list of parameters.


deepImpls

public static boolean deepImpls(spoon.reflect.declaration.CtClass<?> ct,
                                Class<?> itf)
Return true if one of the subclasses of the given CtClass implements the given interface.


impls

public static boolean impls(spoon.reflect.declaration.CtClass ct,
                            Class<?> itf)
Return true if the given CtClass implements directly the given interface. This method does not recurse in super classes and super interfaces and simply checks the presence of the given interface in the list of interfaces of the implements clause.


insert

public static void insert(spoon.reflect.declaration.CtClass<?> ct,
                          Class<?> typeToMatch,
                          spoon.template.Template template)
Insert a template in a CtClass if the CtClass implements the given type and if none of the super classes of the CtClass already implements the given type (to avoid duplicate insertion of the template).

Parameters:
ct - the CtClass where the insertion must be performed
typeToMatch - the type to match (a class or an interface)
template - the Spoon template containing the code to insert

insert

public static void insert(spoon.reflect.declaration.CtClass<?> ct,
                          spoon.template.Template template)
Insert a template in a CtClass.

Parameters:
ct - the CtClass where the insertion must be performed
template - the Spoon template containing the code to insert