Package org.codehaus.groovy.ast
Class ClassHelper
java.lang.Object
org.codehaus.groovy.ast.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
FieldsModifier and TypeFieldDescriptionstatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodeprotected static final ClassNode[]static final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final Stringstatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNodestatic final ClassNode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassNodestatic ClassNodegetWrapper(ClassNode cn) Creates a ClassNode containing the wrapper of a ClassNode of primitive type.static booleanisCachedType(ClassNode type) static booleanstatic booleanTest to determine if a ClassNode is a primitive type.static booleanTest to determine if a ClassNode is a type belongs to the list of types which are allowed to initialize constants directly in bytecode instead of using <cinit> Note: this only works for ClassNodes created using a predefined ClassNodestatic ClassNodeCreates a ClassNode using a given class.static ClassNode[]Creates an array of ClassNodes using an array of classes.static ClassNodestatic ClassNodeCreates a ClassNode using a given class.static ClassNodemakeCached(Class c) static ClassNodestatic ClassNodestatic ClassNodemakeWithoutCaching(Class c, boolean includeGenerics) static ClassNodemakeWithoutCaching(String name) Creates a ClassNode using a given class.
-
Field Details
-
DYNAMIC_TYPE
-
OBJECT_TYPE
-
VOID_TYPE
-
CLOSURE_TYPE
-
GSTRING_TYPE
-
LIST_TYPE
-
MAP_TYPE
-
RANGE_TYPE
-
PATTERN_TYPE
-
STRING_TYPE
-
SCRIPT_TYPE
-
REFERENCE_TYPE
-
boolean_TYPE
-
char_TYPE
-
byte_TYPE
-
int_TYPE
-
long_TYPE
-
short_TYPE
-
double_TYPE
-
float_TYPE
-
Byte_TYPE
-
Short_TYPE
-
Integer_TYPE
-
Long_TYPE
-
Character_TYPE
-
Float_TYPE
-
Double_TYPE
-
Boolean_TYPE
-
BigInteger_TYPE
-
BigDecimal_TYPE
-
Number_TYPE
-
void_WRAPPER_TYPE
-
METACLASS_TYPE
-
Iterator_TYPE
-
CLASS_Type
-
COMPARABLE_TYPE
-
GENERATED_CLOSURE_Type
-
GROOVY_OBJECT_SUPPORT_TYPE
-
GROOVY_OBJECT_TYPE
-
GROOVY_INTERCEPTABLE_TYPE
-
Enum_Type
-
Annotation_TYPE
-
ELEMENT_TYPE_TYPE
-
EMPTY_TYPE_ARRAY
-
OBJECT
- See Also:
-
-
Constructor Details
-
ClassHelper
public ClassHelper()
-
-
Method Details
-
makeCached
-
make
Creates an array of ClassNodes using an array of classes. For each of the given classes a new ClassNode will be created- Parameters:
classes- an array of classes used to create the ClassNodes- Returns:
- an array of ClassNodes
- See Also:
-
make
Creates a ClassNode using a given class. A new ClassNode object is only created if the class is not one of the predefined ones- Parameters:
c- class used to created the ClassNode- Returns:
- ClassNode instance created from the given class
-
make
-
makeWithoutCaching
-
makeWithoutCaching
-
makeWithoutCaching
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 reference- Parameters:
name- of the class the ClassNode is representing- See Also:
-
make
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 name is null or of length 0 the dynamic type is returned- Parameters:
name- of the class the ClassNode is representing
-
getWrapper
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 example for boolean, the wrapper class is java.lang.Boolean. If the parameter is no primitive type, the redirected ClassNode will be returned- Parameters:
cn- the ClassNode containing a possible primitive type- See Also:
-
getUnwrapper
-
isPrimitiveType
Test to determine if a ClassNode is a primitive type. Note: this only works for ClassNodes created using a predefined ClassNode- Parameters:
cn- the ClassNode containing a possible primitive type- Returns:
- true if the ClassNode is a primitive type
- See Also:
-
isStaticConstantInitializerType
Test to determine if a ClassNode is a type belongs to the list of types which are allowed to initialize constants directly in bytecode instead of using <cinit> Note: this only works for ClassNodes created using a predefined ClassNode- Parameters:
cn- the ClassNode to be tested- Returns:
- true if the ClassNode is of int, float, long, double or String type
- See Also:
-
isNumberType
-
makeReference
-
isCachedType
-