org.codehaus.groovy.ast
Class ClassHelper

This class is a Helper for ClassNode and classes handling ClassNodes. It does contain a set of predefined ClassNodes for the most used types and some code for cached ClassNode creation and basic ClassNode handling

author:
Jochen Theodorou

Field Summary
 ClassNode BigDecimal_TYPE
           
 ClassNode BigInteger_TYPE
           
 ClassNode Boolean_TYPE
           
 ClassNode Byte_TYPE
           
 ClassNode CLASS_Type
           
 ClassNode CLOSURE_TYPE
           
 ClassNode Character_TYPE
           
 ClassNode DYNAMIC_TYPE
           
 ClassNode Double_TYPE
           
 def EMPTY_TYPE_ARRAY
           
 ClassNode Enum_Type
           
 ClassNode Float_TYPE
           
 ClassNode GENERATED_CLOSURE_Type
           
 ClassNode GSTRING_TYPE
           
 ClassNode Integer_TYPE
           
 ClassNode LIST_TYPE
           
 ClassNode Long_TYPE
           
 ClassNode MAP_TYPE
           
 ClassNode METACLASS_TYPE
           
 String OBJECT
           
 ClassNode OBJECT_TYPE
           
 ClassNode PATTERN_TYPE
           
 ClassNode RANGE_TYPE
           
 ClassNode REFERENCE_TYPE
           
 ClassNode SCRIPT_TYPE
           
 ClassNode STRING_TYPE
           
 ClassNode Short_TYPE
           
 ClassNode VOID_TYPE
           
 ClassNode boolean_TYPE
           
 ClassNode byte_TYPE
           
 ClassNode char_TYPE
           
 def classes
           
 ClassNode double_TYPE
           
 ClassNode float_TYPE
           
 ClassNode int_TYPE
           
 ClassNode long_TYPE
           
 def numbers
           
 def primitiveClassNames
           
 ClassNode short_TYPE
           
 def types
           
 ClassNode void_WRAPPER_TYPE
           
 
Constructor Summary
ClassHelper()
           
 
Method Summary
static ClassNode getWrapper(ClassNode cn)
           Creates a ClassNode containing the wrapper of a ClassNode of primitive type.
static boolean isPrimitiveType(ClassNode cn)
           Test to determine if a ClasNode is a primitve type.
static boolean isUnresolvedEnum(ClassNode node)
          
static def make(def classes)
           Creates an array of ClassNodes using an array of classes.
static ClassNode make(Class c)
           Creates a ClassNode using a given class.
static ClassNode make(Class c, boolean includeGenerics)
          
static ClassNode make(String name)
           Creates a ClassNode using a given class.
static ClassNode makeReference()
          
static ClassNode makeWithoutCaching(Class c)
          
static ClassNode makeWithoutCaching(Class c, boolean includeGenerics)
          
static ClassNode makeWithoutCaching(String name)
           Creates a ClassNode using a given class.
 

Constructor Detail

ClassHelper

ClassHelper()


Method Detail

getWrapper

public static ClassNode getWrapper(ClassNode cn)
Creates a ClassNode containing the wrapper of a ClassNode of primitive type. Any ClassNode representing a primitive type should be created using the predefined types used in class. The method will check the parameter for known references of ClassNode representing a primitive type. If Reference is found, then a ClassNode will be contained that represents the wrapper class. For exmaple for boolean, the wrapper class is java.lang.Boolean. If the parameter is no primitve type, the redirected ClassNode will be returned
see:
#make(Class)
see:
#make(String)
param:
cn the ClassNode containing a possible primitive type


isPrimitiveType

public static boolean isPrimitiveType(ClassNode cn)
Test to determine if a ClasNode is a primitve type. Note: this only works for ClassNodes created using a predefined ClassNode
see:
#make(Class)
see:
#make(String)
param:
cn the ClassNode containing a possible primitive type
return:
true if the ClassNode is a primitve type


isUnresolvedEnum

public static boolean isUnresolvedEnum(ClassNode node)


make

public static def make(def classes)
Creates an array of ClassNodes using an array of classes. For each of the given classes a new ClassNode will be created
see:
#make(Class)
param:
classes an array of classes used to create the ClassNodes
return:
an array of ClassNodes


make

public static ClassNode make(Class c)
Creates a ClassNode using a given class. A new ClassNode object is only created if the class is not one of the predefined ones
param:
c class used to created the ClassNode
return:
ClassNode instance created from the given class


make

public static ClassNode make(Class c, boolean includeGenerics)


make

public static ClassNode make(String name)
Creates a ClassNode using a given class. If the name is one of the predefined ClassNodes then the corresponding ClassNode instance will be returned. If the is null of of length 0 the dynamic type is returned
param:
name of the class the ClassNode is representing


makeReference

public static ClassNode makeReference()


makeWithoutCaching

public static ClassNode makeWithoutCaching(Class c)


makeWithoutCaching

public static ClassNode makeWithoutCaching(Class c, boolean includeGenerics)


makeWithoutCaching

public static ClassNode makeWithoutCaching(String name)
Creates a ClassNode using a given class. Unlike make(String) this method will not use the cache to create the ClassNode. This means the ClassNode created from this method using the same name will have a different references
see:
#make(String)
param:
name of the class the ClassNode is representing