public final class ClassUtil extends Object
(c) copyright 2002-2005 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl/language
License of use: Lesser
General Public License (LGPL) , no warranty
Modifier and Type | Method and Description |
---|---|
static Constructor[] |
getAllConstructors(Class clazz,
Constructor[] result)
gets all the constructors of a class and adds the result to result
|
static Method[] |
getAllMethods(Class clazz,
String name,
Method[] result)
gets all the methods of a class and adds the result to result
|
static Class[] |
getClass(Object[] array)
converts an array of objects to their corresponding classes
|
static boolean |
isMoreSpecific(Class[] a,
Class[] b)
Determines & returns whether constructor 'a' is more specific than
constructor 'b', as defined in the Java Language Specification §15.12.
|
static boolean |
isMoreSpecific(Constructor a,
Constructor b)
Determines & returns whether constructor 'a' is more specific than
constructor 'b', as defined in the Java Language Specification §15.12.
|
static boolean |
isMoreSpecific(Method a,
Method b)
Determines & returns whether constructor 'a' is more specific than
constructor 'b', as defined in the Java Language Specification §15.12.
|
static boolean |
isVisible(Constructor constructor,
Class caller)
Returns whether a constructor is visible for a caller.
|
static boolean |
isVisible(Field field,
Class caller)
Returns whether a field is visible for a caller.
|
static boolean |
isVisible(int modifiers,
Class declaringClass,
Class caller)
Returns whether a declaringClass is accessible according to the modifiers
|
static boolean |
isVisible(Method method,
Class caller)
Returns whether a method is visible for a caller.
|
static Constructor[] |
matchSignature(Constructor[] constructors,
Class[] argTypes)
Filters an array methods for signatures that are compatible with a given
signature.
|
static boolean |
matchSignature(Constructor constructor,
Class[] argTypes)
Filters an array methods for signatures that are compatible with a given
signature.
|
static Method[] |
matchSignature(Method[] methods,
String name,
Class[] argTypes)
Filters an array methods for signatures that are compatible with a given
signature.
|
static boolean |
matchSignature(Method method,
String name,
Class[] argTypes)
Filters an array methods for signatures that are compatible with a given
signature.
|
static Constructor |
resolveConstructor(Class clazz,
Class[] parameterTypes)
returns the interface method
|
static Constructor |
resolveConstructor(Class clazz,
Class callerClass,
Class[] parameterTypes)
returns the interface method
|
static Constructor |
resolveConstructor(Class clazz,
Object[] arguments)
returns the constructor
|
static Field |
resolveField(Class clazz,
Class callerClass,
String name)
returns the field
|
static Field |
resolveField(Class clazz,
String fieldName)
resolves the field for a class, taking into account inner classes
|
static Field |
resolveField(Object object,
String fieldName)
resolves the field for a given object instance
|
static Method |
resolveMethod(Class clazz,
Class callerClass,
String name,
Class[] parameterTypes)
returns the interface method
|
static Method |
resolveMethod(Class clazz,
String name,
Class[] parameterTypes)
returns the interface method
|
static Method |
resolveMethod(Object object,
String name,
Class[] parameterTypes)
resolves a method the method
|
static Method |
resolveMethod(Object object,
String name,
Object[] arguments)
returns the method
|
public static Constructor[] getAllConstructors(Class clazz, Constructor[] result)
clazz
- the classresult
- the resulting setpublic static Constructor resolveConstructor(Class clazz, Class callerClass, Class[] parameterTypes) throws NoSuchMethodException
clazz
- the class to start withcallerClass
- the calling classparameterTypes
- the parameterTypesNoSuchMethodException
- if the method cannot be resolvedpublic static Constructor resolveConstructor(Class clazz, Class[] parameterTypes) throws NoSuchMethodException
clazz
- the class to start withparameterTypes
- the parameterTypesNoSuchMethodException
- if the method cannot be resolvedpublic static Constructor resolveConstructor(Class clazz, Object[] arguments) throws NoSuchMethodException
clazz
- the clazz to start witharguments
- the argumentsNoSuchMethodException
- on lookup failurepublic static Field resolveField(Class clazz, String fieldName) throws NoSuchFieldException
clazz
- the class to resolve the field for, including inner classesfieldName
- name of the fieldNoSuchFieldException
- on no such fieldpublic static Field resolveField(Class clazz, Class callerClass, String name) throws NoSuchFieldException
clazz
- the class to start withcallerClass
- the calling classname
- the fieldNameNoSuchFieldException
- if the method cannot be resolvedpublic static Field resolveField(Object object, String fieldName) throws NoSuchFieldException
object
- the object to resolve the field forfieldName
- name of the field to resolveNoSuchFieldException
- if the field cannot be resolvedpublic static Method[] getAllMethods(Class clazz, String name, Method[] result)
clazz
- the classname
- the name of the methodresult
- the resulting setpublic static Method resolveMethod(Class clazz, Class callerClass, String name, Class[] parameterTypes) throws NoSuchMethodException
clazz
- the class to start withcallerClass
- the caller classname
- the name of the methodparameterTypes
- the parameterTypesNoSuchMethodException
- on lookup failurepublic static Method resolveMethod(Class clazz, String name, Class[] parameterTypes) throws NoSuchMethodException
clazz
- the class to start withname
- the name of the methodparameterTypes
- the parameterTypesNoSuchMethodException
- on lookup failurepublic static Method resolveMethod(Object object, String name, Class[] parameterTypes) throws NoSuchMethodException
object
- the object to start withname
- the name of the methodparameterTypes
- the parameterTypesNoSuchMethodException
- on lookup failurepublic static Method resolveMethod(Object object, String name, Object[] arguments) throws NoSuchMethodException
object
- the object to start withname
- the name of the methodarguments
- the argumentsNoSuchMethodException
- on lookup failurepublic static boolean isVisible(int modifiers, Class declaringClass, Class caller)
modifiers
- the modifiersdeclaringClass
- the declaringClasscaller
- the callerpublic static boolean isMoreSpecific(Class[] a, Class[] b)
a
- reflects the first constructorb
- reflects the second constructorpublic static boolean isMoreSpecific(Constructor a, Constructor b)
a
- reflects the first constructorb
- reflects the second constructorpublic static boolean isMoreSpecific(Method a, Method b)
a
- reflects the first methodb
- reflects the second methodpublic static boolean isVisible(Field field, Class caller)
field
- The fieldcaller
- The class of the caller for whom invocation visibility is
checked.public static boolean isVisible(Constructor constructor, Class caller)
constructor
- The constructorcaller
- The class of the caller for whom invocation visibility is
checked.public static boolean isVisible(Method method, Class caller)
method
- The methodcaller
- The class of the caller for whom invocation visibility is
checked.public static Method[] matchSignature(Method[] methods, String name, Class[] argTypes)
methods
- which are methods to be filtered.name
- reflects the method's name, part of the signatureargTypes
- are the method's argument typespublic static boolean matchSignature(Method method, String name, Class[] argTypes)
method
- The method to be filtered.name
- reflects the method's name, part of the signatureargTypes
- are the method's argument typespublic static boolean matchSignature(Constructor constructor, Class[] argTypes)
constructor
- which are constructors to be filtered.argTypes
- are the constructor's argument typespublic static Constructor[] matchSignature(Constructor[] constructors, Class[] argTypes)
constructors
- which are constructors to be filtered.argTypes
- are the constructor's argument typesCopyright © 2002-2012 Delft University of Technology, the Netherlands. All Rights Reserved.