use of java.beans.IntrospectionException in project Openfire by igniterealtime.
the class JiveBeanInfo method getPropertyDescriptors.
@Override
public PropertyDescriptor[] getPropertyDescriptors() {
Class beanClass = getBeanClass();
String[] properties = getPropertyNames();
PropertyDescriptor[] descriptors = new PropertyDescriptor[properties.length];
try {
// 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());
}
}
use of java.beans.IntrospectionException in project tomcat by apache.
the class BeanELResolver method getFeatureDescriptors.
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
if (base == null) {
return null;
}
try {
BeanInfo info = Introspector.getBeanInfo(base.getClass());
PropertyDescriptor[] pds = info.getPropertyDescriptors();
for (int i = 0; i < pds.length; i++) {
pds[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
pds[i].setValue(TYPE, pds[i].getPropertyType());
}
return Arrays.asList((FeatureDescriptor[]) pds).iterator();
} catch (IntrospectionException e) {
//
}
return null;
}
use of java.beans.IntrospectionException in project Openfire by igniterealtime.
the class BeanUtils method setProperties.
/**
* Sets the properties of a Java Bean based on the String name/value pairs in
* the specifieed Map. Because this method has to know how to convert a
* String value into the correct type for the bean, only a few bean property
* types are supported. They are: String, boolean, int, long, float, double,
* Color, and Class.<p>
*
* If key/value pairs exist in the Map that don't correspond to properties
* of the bean, they will be ignored.
*
* @param bean the JavaBean to set properties on.
* @param properties String name/value pairs of the properties to set.
*/
public static void setProperties(Object bean, Map<String, String> properties) {
try {
// Loop through all the property names in the Map
for (String propName : properties.keySet()) {
try {
// Create a property descriptor for the named property. If
// the bean doesn't have the named property, an
// Introspection will be thrown.
PropertyDescriptor descriptor = new PropertyDescriptor(propName, bean.getClass());
// Load the class type of the property.
Class propertyType = descriptor.getPropertyType();
// Get the value of the property by converting it from a
// String to the correct object type.
Object value = decode(propertyType, properties.get(propName));
// Set the value of the bean.
descriptor.getWriteMethod().invoke(bean, value);
} catch (IntrospectionException ie) {
// Ignore. This exception means that the key in the map
// does not correspond to a property of the bean.
} catch (InvocationTargetException ite) {
// Ignore. This exception most often occurs when a
// value in the map is null and the target method doesn't
// support null properties.
}
}
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
use of java.beans.IntrospectionException in project Openfire by igniterealtime.
the class WorkgroupBeanInfo method getPropertyDescriptors.
public PropertyDescriptor[] getPropertyDescriptors() {
Class beanClass = getBeanClass();
String[] properties = getPropertyNames();
PropertyDescriptor[] descriptors = new PropertyDescriptor[properties.length];
try {
// 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) {
try {
newDescriptor.setDisplayName(bundle.getString(properties[i] + ".displayName"));
} catch (MissingResourceException ignored) {
}
try {
newDescriptor.setShortDescription(bundle.getString(properties[i] + ".shortDescription"));
} catch (MissingResourceException ignored) {
}
// used to set this value.
try {
String largeText = bundle.getString(properties[i] + ".useLargeTextField");
if ("true".equals(largeText)) {
newDescriptor.setValue("useLargeTextField", "true");
}
} catch (MissingResourceException ignored) {
}
}
descriptors[i] = newDescriptor;
}
return descriptors;
} catch (IntrospectionException ie) {
Log.error(ie.getMessage(), ie);
throw new Error(ie.toString());
}
}
use of java.beans.IntrospectionException in project SQLWindowing by hbutani.
the class SerializationUtils method makeTransient.
public static void makeTransient(Class<?> beanClass, String pdName) {
BeanInfo info;
try {
info = Introspector.getBeanInfo(beanClass);
PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors();
for (int i = 0; i < propertyDescriptors.length; ++i) {
PropertyDescriptor pd = propertyDescriptors[i];
if (pd.getName().equals(pdName)) {
pd.setValue("transient", Boolean.TRUE);
}
}
} catch (IntrospectionException ie) {
throw new RuntimeException(ie);
}
}
Aggregations