Example usage for java.beans Introspector decapitalize

List of usage examples for java.beans Introspector decapitalize

Introduction

In this page you can find the example usage for java.beans Introspector decapitalize.

Prototype

public static String decapitalize(String name) 

Source Link

Document

Utility method to take a string and convert it to normal Java variable name capitalization.

Usage

From source file:org.wings.plaf.AbstractComponentCG.java

/**
 * Recursively configure the component and dependant objects.
 *//*from   w  w  w . j av  a2s .  co  m*/
protected void configure(Object object, String className, CGManager manager) {
    try {
        Class objectClass = object.getClass();

        long introspection_time = System.currentTimeMillis();
        Method[] setters = (Method[]) cache.get(objectClass);
        if (setters == null) {
            synchronized (cache) {
                setters = (Method[]) cache.get(objectClass);
                if (setters == null) {
                    setters = findRelevantSetters(objectClass);
                    cache.put(objectClass, setters);
                }
            }
        }
        logger.debug(objectClass.getName() + " introspection_time "
                + (System.currentTimeMillis() - introspection_time) + " ms");

        long configuration_time = System.currentTimeMillis();
        for (int i = 0; i < setters.length; i++) {
            Object value = null;

            String propertyName = Introspector.decapitalize(setters[i].getName().substring(3));
            String lookupName = className + "." + propertyName;
            Class propertyType = setters[i].getParameterTypes()[0];

            value = manager.getObject(lookupName, propertyType);
            boolean configurable = !propertyType.isPrimitive();

            logger.debug(lookupName + "=" + value);

            if (value != null) {
                setters[i].invoke(object, new Object[] { value });
                if (configurable) {
                    configure(value, lookupName, manager);
                }
            }
        }
        logger.debug(objectClass.getName() + " configuration_time "
                + (System.currentTimeMillis() - configuration_time) + " ms");
    } catch (Exception e) {
        logger.fatal(null, e);
    }
}