|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.richclient.util.ClassUtils
public class ClassUtils
Misc static utility functions for java classes.
Method Summary | |
---|---|
static Class |
classForName(String name)
Load the class with the specified name. |
static Class |
convertPrimitiveToWrapper(Class clazz)
Gets the equivalent class to convert to if the given clazz is a primitive. |
static Method |
findMethod(String methodName,
Class clazz,
Class[] parmTypes)
|
static String |
getClassFieldNameWithValue(Class clazz,
Object value)
Returns the qualified class field name with the specified value. |
static Object |
getFieldValue(String qualifiedFieldName)
Gets the field value for the specified qualified field name. |
static Class |
getPropertyClass(Class parentClass,
String propertyName)
Returns the class of the property. |
static Method |
getStaticMethod(String name,
Class locatorClass,
Class[] args)
|
static Object |
getValueFromMapForClass(Class typeClass,
Map classMap)
Given a Map where the keys are Class es, search the map
for the closest match of the key to the typeClass. |
static void |
initializeClass(Class clazz)
Intializes the specified class if not initialized already. |
static boolean |
isAProperty(Class theClass,
String propertyName)
Is the given name a property in the class? In other words, does it have a setter and/or a getter method? |
static boolean |
isPrimitiveArray(Class clazz)
Check if the given class represents a primitive array. |
static boolean |
isSimpleScalar(Class clazz)
Does the provided bean class represent a simple scalar property? A simple scalar property is considered a value property; that is, it is not another bean. |
static String |
qualifier(String qualifiedName)
Returns the qualifier for a name separated by dots. |
static String |
unqualify(Class clazz)
Returns the unqualified class name of the specified class. |
static String |
unqualify(String qualifiedName)
|
static String |
unqualify(String qualifiedName,
char separator)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void initializeClass(Class clazz)
public static String getClassFieldNameWithValue(Class clazz, Object value)
public static Object getFieldValue(String qualifiedFieldName)
public static Class classForName(String name) throws ClassNotFoundException
name
-
ClassNotFoundException
public static Method findMethod(String methodName, Class clazz, Class[] parmTypes)
public static String unqualify(String qualifiedName)
public static String unqualify(Class clazz)
clazz
- the class to get the name for
public static String unqualify(String qualifiedName, char separator)
public static String qualifier(String qualifiedName)
qualifiedName
- The qualified name.
public static boolean isPrimitiveArray(Class clazz)
public static boolean isSimpleScalar(Class clazz)
public static Method getStaticMethod(String name, Class locatorClass, Class[] args)
public static Class convertPrimitiveToWrapper(Class clazz)
clazz
- Class to examin.
public static Object getValueFromMapForClass(Class typeClass, Map classMap)
Map
where the keys are Class
es, search the map
for the closest match of the key to the typeClass. This is
extremely useful to support polymorphism (and an absolute requirement to
find proxied classes where classes are acting as keys in a map).
For example: If the Map has keys of Number.class and String.class, using a typeClass of Long.class will find the Number.class entry and return its value.
When doing the search, it looks for the most exact match it can, giving preference to interfaces over class inheritance. As a performance optimiziation, if it finds a match it stores the derived match in the map so it does not have to be derived again.
typeClass
- the kind of class to search forclassMap
- the map where the keys are of type Class
public static boolean isAProperty(Class theClass, String propertyName)
theClass
- the class to look for the property inpropertyName
- the name of the property
IllegalArgumentException
- if either argument is nullpublic static Class getPropertyClass(Class parentClass, String propertyName) throws IllegalArgumentException
For example, getPropertyClass(JFrame.class, "size") would return the java.awt.Dimension class.
parentClass
- the class to look for the property inpropertyName
- the name of the property
IllegalArgumentException
- if either argument is null
IllegalArgumentException
- propertyName is not a
property of parentClass
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |