Java Code Examples for java.beans.IntrospectionException#toString()

The following examples show how to use java.beans.IntrospectionException#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JiveBeanInfo.java    From Openfire with Apache License 2.0 6 votes vote down vote up
@Override
public PropertyDescriptor[] getPropertyDescriptors() {
    Class beanClass = getBeanClass();
    String[] properties = getPropertyNames();

    PropertyDescriptor[] descriptors = new PropertyDescriptor[properties.length];
    try {
        // For each property, create a property descriptor and set the
        // name and description using the localized data.
        for (int i = 0; i < descriptors.length; i++) {
            PropertyDescriptor newDescriptor =
                    new PropertyDescriptor(properties[i], beanClass);
            if (bundle != null) {
                newDescriptor.setDisplayName(bundle.getString(properties[i] + ".displayName"));
                newDescriptor.setShortDescription(bundle.getString(properties[i] + ".shortDescription"));
            }
            descriptors[i] = newDescriptor;
        }
        return descriptors;
    }
    catch (IntrospectionException ie) {
        Log.error(ie.getMessage(), ie);
        throw new Error(ie.toString());
    }
}
 
Example 2
Source File: FilterBeanInfo.java    From jivejdon with Apache License 2.0 5 votes vote down vote up
public PropertyDescriptor[] getPropertyDescriptors()  {
    Class beanClass = getBeanClass();
    String [] properties = getPropertyNames();

    PropertyDescriptor [] descriptors = new PropertyDescriptor[properties.length];
    try {
        // For each property, create a property descriptor and set the
        // name and description using the localized data.
        for (int i=0; i<descriptors.length; i++) {
            PropertyDescriptor newDescriptor =
                new PropertyDescriptor(properties[i], beanClass);
            if (bundle != null) {
                newDescriptor.setDisplayName(
                    bundle.getString(properties[i] + ".displayName")
                );
                newDescriptor.setShortDescription(
                    bundle.getString(properties[i] + ".shortDescription")
                );
            }
            descriptors[i] = newDescriptor;
        }
        return descriptors;
    }
    catch (IntrospectionException ie) {
        ie.printStackTrace();
        throw new Error(ie.toString());
    }
}
 
Example 3
Source File: BonesOfBeans.java    From hypergraphdb with Apache License 2.0 5 votes vote down vote up
private static Map<String, PropertyDescriptor> getpropmap(Class<?> clazz,
		boolean incl_cls)
{
	HashMap<String, PropertyDescriptor> propmap = null; // cache.get(clazz);
	if (propmap == null)
	{
		try
		{
			BeanInfo bean_info = Introspector.getBeanInfo(clazz);
			propmap = new HashMap<String, PropertyDescriptor>();
			PropertyDescriptor beanprops[] = bean_info
					.getPropertyDescriptors();
			for (int i = 0; i < beanprops.length; i++)
			{
				// filter the Class property which is not used
				if (!incl_cls && "class".equals(beanprops[i].getName()))
					continue;
				propmap.put(beanprops[i].getName(), beanprops[i]);
			}
			// cache.put(clazz, propmap);
		} catch (IntrospectionException ex)
		{
			throw new HGException("The bean " + clazz.getName()
					+ " doesn't want us to introspect it: " + ex.toString());
		}
	}
	return propmap;
}
 
Example 4
Source File: BsfBeanInfo.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
@Override
public PropertyDescriptor[] getPropertyDescriptors() {
	// get properties from default property descriptors
	List<PropertyDescriptor> pdl = new ArrayList<PropertyDescriptor>();
	PropertyDescriptor rv[] = super.getPropertyDescriptors();
	if (rv != null) {
		pdl.addAll(Arrays.asList(rv));
	}

	try {
		// if i have found nothing, i'm trying to get manually
		if (pdl.isEmpty()) {
			BeanInfo bi = Introspector.getBeanInfo(getDecoratedClass(), Introspector.IGNORE_ALL_BEANINFO);
			PropertyDescriptor birv[] = bi.getPropertyDescriptors();
			if (birv != null) {
				pdl.addAll(Arrays.asList(birv));
			}
		}

		add_snake_case_properties(pdl);

		// then add custom properties
		PropertyDescriptor[] customPd = getCustomPropertyDescriptor();
		if (customPd != null)
			pdl.addAll(Arrays.asList(customPd));
	} catch (IntrospectionException e) {
		LOGGER.log(Level.SEVERE, "Couldn't read the property descriptors", e);
		throw new Error(e.toString());
	}

	PropertyDescriptor[] array = new PropertyDescriptor[pdl.size()];
	return pdl.toArray(array);
}