|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.cosylab.introspection.ClassIntrospector
public class ClassIntrospector
This class provides helper methods to easily manipulate an analyze classes and their members.
Constructor Summary | |
---|---|
ClassIntrospector()
|
Method Summary | |
---|---|
static boolean |
areInModifiers(int targetModifiers,
int modifiers)
Returns true if the targetModifiers contains all
of the specified modifiers |
static java.lang.Class |
forName(java.lang.String className)
|
static java.lang.reflect.Member[] |
getDeclaredMembers(java.lang.Class theClass,
boolean fields,
boolean constructors,
boolean methods)
Returns declared members of the specified class. |
static java.lang.reflect.Field[] |
getEnumFields(java.lang.Class theClass)
Returns array of fields are decleared by Java Enum pattern. |
static java.lang.Object[] |
getEnums(java.lang.Class theClass)
If class can be interpreted as Java enum pattern, then returns array this class instances as they would be enums. |
static java.lang.reflect.Member[] |
getForModifiers(java.lang.reflect.Member[] members,
int modifiers)
Selects members that have the specified modifiers from an array of Member instances. |
static java.lang.reflect.Member[] |
getForParameterTypes(java.lang.reflect.Member[] members,
java.lang.Class[] parameterTypes)
Returns all members (methods and constructors) that take the same parameters. |
static java.lang.reflect.Member[] |
getForReturnType(java.lang.reflect.Member[] members,
java.lang.Class returnType)
Returns all members (methods and fields) that have the same declared return type (or field type). |
static java.lang.reflect.Member[] |
getMembers(java.lang.Class theClass,
boolean fields,
boolean constructors,
boolean methods)
Returns all members of the specified class. |
static java.lang.reflect.Member[] |
getMembers(java.lang.Class theClass,
MemberFilter filter)
Returns all members of the specified class that are accepted by the filter
object passed as a parameter. |
static java.lang.reflect.Method |
getMethod(java.lang.Class targetClass,
java.lang.String name,
java.lang.Class[] paramTypes)
|
static java.lang.String[] |
getParameterNames(java.lang.reflect.Member m)
Returns names of parameters of a given method. |
static java.lang.Class |
getPrimitiveWrapper(java.lang.Class primitiveType)
|
static java.lang.reflect.Member[] |
getPrivate(java.lang.reflect.Member[] members)
Returns all private members from an array of Member instances. |
static java.lang.reflect.Member[] |
getProtected(java.lang.reflect.Member[] members)
Returns all protected members from an array of Member instances. |
static java.lang.reflect.Member[] |
getPublic(java.lang.reflect.Member[] members)
Returns all public members from an array of Member instances. |
static java.lang.reflect.Member[] |
getPublicMembers(java.lang.Class theClass,
boolean fields,
boolean constructors,
boolean methods)
Returns all public members of the specified class. |
static boolean |
isCompatible(java.lang.Class objectType,
java.lang.Class targetType)
Determines whether the objectType class can be used in
introspection operations to set a value which is declared
to be of the targetType class. |
static boolean |
isEnum(java.lang.Class theClass)
Identifies the Java Enum pattern. |
static boolean |
isPrimitiveWrapper(java.lang.Class wrapperType)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClassIntrospector()
Method Detail |
---|
public static java.lang.reflect.Method getMethod(java.lang.Class targetClass, java.lang.String name, java.lang.Class[] paramTypes)
public static java.lang.Class forName(java.lang.String className) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static java.lang.reflect.Member[] getDeclaredMembers(java.lang.Class theClass, boolean fields, boolean constructors, boolean methods)
theClass
- Classfields
- booleanconstructors
- booleanmethods
- boolean
public static boolean isEnum(java.lang.Class theClass)
theClass
- - the class that is to be inspected
public static java.lang.Class getPrimitiveWrapper(java.lang.Class primitiveType)
primitiveType
-
public static boolean isPrimitiveWrapper(java.lang.Class wrapperType)
public static boolean isCompatible(java.lang.Class objectType, java.lang.Class targetType)
objectType
class can be used in
introspection operations to set a value which is declared
to be of the targetType
class.
This method returns targetType.isAssignableFrom(objectType)
for object types, and also returns true when targetType
is primitive and objectType
is its object wrapper.
public static java.lang.reflect.Field[] getEnumFields(java.lang.Class theClass)
theClass
- - the class that is to be inspected and interpreted as enum
java.lang.reflect.Field
objectspublic static java.lang.Object[] getEnums(java.lang.Class theClass) throws java.lang.IllegalAccessException
value()
field.
theClass
- - the class that is to be inspected and interpreted as enum
java.lang.IllegalAccessException
public static java.lang.reflect.Member[] getForModifiers(java.lang.reflect.Member[] members, int modifiers)
Member
instances.
members
- Member[]modifiers
- int - as specified by the java.lang.reflect.Modifier
public static java.lang.reflect.Member[] getForParameterTypes(java.lang.reflect.Member[] members, java.lang.Class[] parameterTypes)
members
- Member[]parameterTypes
- Class[]
public static java.lang.reflect.Member[] getForReturnType(java.lang.reflect.Member[] members, java.lang.Class returnType)
members
- Member[]returnType
- Class
public static java.lang.reflect.Member[] getMembers(java.lang.Class theClass, boolean fields, boolean constructors, boolean methods)
theClass
- Classfields
- booleanconstructors
- booleanmethods
- boolean
public static java.lang.reflect.Member[] getPrivate(java.lang.reflect.Member[] members)
Member
instances.
members
- Member[]
public static java.lang.reflect.Member[] getProtected(java.lang.reflect.Member[] members)
Member
instances.
members
- Member[]
public static java.lang.reflect.Member[] getPublic(java.lang.reflect.Member[] members)
Member
instances.
members
- Member[]
public static java.lang.reflect.Member[] getPublicMembers(java.lang.Class theClass, boolean fields, boolean constructors, boolean methods)
theClass
- Classfields
- booleanconstructors
- booleanmethods
- boolean
public static java.lang.String[] getParameterNames(java.lang.reflect.Member m)
m
- Member
public static boolean areInModifiers(int targetModifiers, int modifiers)
true
if the targetModifiers
contains all
of the specified modifiers.
- Parameters:
targetModifiers
- intmodifiers
- int
- Returns:
- boolean
public static java.lang.reflect.Member[] getMembers(java.lang.Class theClass, MemberFilter filter)
filter
object passed as a parameter.
theClass
- Classfilter
- MemberFilter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |