List of usage examples for java.beans IntrospectionException getMessage
public String getMessage()
From source file:org.neovera.jdiablo.internal.BeanUtils.java
public static Method getWriteMethod(String fieldName, Class<?> clz) { try {// w w w. j a va 2 s.co m return PropertyUtils.getWriteMethod(new PropertyDescriptor(fieldName, clz)); } catch (IntrospectionException e) { _logger.error(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } }
From source file:no.sesat.search.datamodel.generic.MapDataObjectBeanInfo.java
/** * * @param name//from w ww . j a v a2s .c om * @param cls * @return */ public static PropertyDescriptor[] addSingleMappedPropertyDescriptor(final String name, final Class<?> cls) { try { final PropertyDescriptor[] existing = Introspector.getBeanInfo(cls, Introspector.IGNORE_ALL_BEANINFO) .getPropertyDescriptors(); // remove this introspection from the cache to avoid reuse of the IGNORE_ALL_BEANINFO result Introspector.flushFromCaches(cls); final PropertyDescriptor[] result = new PropertyDescriptor[existing.length + 2]; System.arraycopy(existing, 0, result, 0, existing.length); result[existing.length] = new MappedPropertyDescriptor(name, cls); if (!System.getProperty("java.version").startsWith("1.6")) { fixForJavaBug4984912(cls, (MappedPropertyDescriptor) result[existing.length]); } final String captialised = Character.toUpperCase(name.charAt(0)) + name.substring(1); try { // try plural with "s" first, then fall back onto "es" result[existing.length + 1] = new PropertyDescriptor(name + 's', cls, "get" + captialised + 's', null); } catch (IntrospectionException ie) { // who on earth designed the english language!?? :@ result[existing.length + 1] = new PropertyDescriptor(name + "es", cls, "get" + captialised + 's', null); } return result; } catch (IntrospectionException ex) { LOG.error(ex.getMessage(), ex); throw new IllegalStateException('[' + cls.getSimpleName() + ']' + ex.getMessage(), ex); } }
From source file:kelly.util.BeanUtils.java
/** * Retrieve the JavaBeans {@code PropertyDescriptor}s of a given class. * @param clazz the Class to retrieve the PropertyDescriptors for * @return an array of {@code PropertyDescriptors} for the given class *///ww w .j a v a2 s . co m public static PropertyDescriptor[] getPropertyDescriptors(Class<?> clazz) { Validate.notNull(clazz, "Class must not be null"); try { BeanInfo beanInfo = Introspector.getBeanInfo(clazz); return beanInfo.getPropertyDescriptors(); } catch (IntrospectionException e) { throw new BeanException(e.getMessage(), e); } }
From source file:org.psnively.scala.beans.ScalaBeanInfo.java
private static void addScalaGetter(Map<String, PropertyDescriptor> propertyDescriptors, Method readMethod) { String propertyName = readMethod.getName(); PropertyDescriptor pd = propertyDescriptors.get(propertyName); if (pd != null && pd.getReadMethod() == null) { try {/*from w ww . j a v a 2 s . c om*/ pd.setReadMethod(readMethod); } catch (IntrospectionException ex) { logger.debug("Could not add read method [" + readMethod + "] for " + "property [" + propertyName + "]: " + ex.getMessage()); } } else if (pd == null) { try { pd = new PropertyDescriptor(propertyName, readMethod, null); propertyDescriptors.put(propertyName, pd); } catch (IntrospectionException ex) { logger.debug("Could not create new PropertyDescriptor for " + "readMethod [" + readMethod + "] property [" + propertyName + "]: " + ex.getMessage()); } } }
From source file:org.psnively.scala.beans.ScalaBeanInfo.java
private static void addScalaSetter(Map<String, PropertyDescriptor> propertyDescriptors, Method writeMethod) { String propertyName = writeMethod.getName().substring(0, writeMethod.getName().length() - SCALA_SETTER_SUFFIX.length()); PropertyDescriptor pd = propertyDescriptors.get(propertyName); if (pd != null && pd.getWriteMethod() == null) { try {/* ww w . j a v a 2 s.c om*/ pd.setWriteMethod(writeMethod); } catch (IntrospectionException ex) { logger.debug("Could not add write method [" + writeMethod + "] for " + "property [" + propertyName + "]: " + ex.getMessage()); } } else if (pd == null) { try { pd = new PropertyDescriptor(propertyName, null, writeMethod); propertyDescriptors.put(propertyName, pd); } catch (IntrospectionException ex) { logger.debug("Could not create new PropertyDescriptor for " + "writeMethod [" + writeMethod + "] property [" + propertyName + "]: " + ex.getMessage()); } } }
From source file:edu.harvard.med.screensaver.model.AbstractEntityInstanceTest.java
/** * Subclasses should call this method to build their TestSuite, as it will * include tests for the test methods declared in this class, as well as tests * for each entity property found in the specified AbstractEntity class. * // www . jav a2s. co m * @param entityTestClass * @param entityClass * @return */ public static TestSuite buildTestSuite(Class<? extends AbstractEntityInstanceTest> entityTestClass, Class<? extends AbstractEntity> entityClass) { TestSuite testSuite = new TestSuite(entityTestClass); BeanInfo beanInfo; try { beanInfo = Introspector.getBeanInfo(entityClass); // add all the property-specific tests for this entity class for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) { if (propertyDescriptor.getName().equals("class")) { log.debug("not creating test for \"class\" property " + propertyDescriptor.getDisplayName()); } else if (ModelIntrospectionUtil.isTransientProperty(propertyDescriptor)) { log.debug("not creating test for transient (non-persistent) property " + propertyDescriptor.getDisplayName()); } else /*if (ModelIntrospectionUtil.isToManyEntityRelationship(propertyDescriptor))*/ { propertyDescriptor = new GenericTypeAwarePropertyDescriptor(entityClass, propertyDescriptor); testSuite.addTest(new EntityPropertyTest(entityClass, propertyDescriptor)); } } } catch (IntrospectionException e) { e.printStackTrace(); fail(e.getMessage()); } return testSuite; }
From source file:org.apache.activemq.artemis.utils.uri.FluentPropertyBeanIntrospectorWithIgnores.java
@Override public void introspect(IntrospectionContext icontext) throws IntrospectionException { for (Method m : icontext.getTargetClass().getMethods()) { if (m.getName().startsWith(getWriteMethodPrefix())) { String propertyName = propertyName(m); PropertyDescriptor pd = icontext.getPropertyDescriptor(propertyName); if (isIgnored(icontext.getTargetClass().getName(), m.getName())) { logger.trace(m.getName() + " Ignored for " + icontext.getTargetClass().getName()); continue; }//from w w w.j a v a 2 s. co m try { if (pd == null) { icontext.addPropertyDescriptor(createFluentPropertyDescritor(m, propertyName)); } else if (pd.getWriteMethod() == null) { pd.setWriteMethod(m); } } catch (IntrospectionException e) { logger.debug(e.getMessage(), e); } } } }
From source file:info.magnolia.cms.taglibs.util.ImgTagBeanInfo.java
/** * @see java.beans.BeanInfo#getPropertyDescriptors() *//* ww w . j a v a 2 s. c o m*/ public PropertyDescriptor[] getPropertyDescriptors() { try { List proplist = new ArrayList(); for (int j = 0; j < properties.length; j++) { proplist.add(createPropertyDescriptor(properties[j])); } PropertyDescriptor[] result = new PropertyDescriptor[proplist.size()]; return ((PropertyDescriptor[]) proplist.toArray(result)); } catch (IntrospectionException ex) { // should never happen throw new UnhandledException(ex.getMessage(), ex); } }
From source file:org.springframework.richclient.table.renderer.BeanTableCellRenderer.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value != null) { if (beanWrapper == null) { beanWrapper = new BeanWrapperImpl(value); } else {/*from ww w. j a v a 2 s .c om*/ beanWrapper.setWrappedInstance(value); } try { BeanInfo info = Introspector.getBeanInfo(value.getClass()); int index = info.getDefaultPropertyIndex(); if (index != -1) { String defaultPropName = beanWrapper.getPropertyDescriptors()[index].getName(); Object val = beanWrapper.getPropertyValue(defaultPropName); TableCellRenderer r = table.getDefaultRenderer(val.getClass()); return r.getTableCellRendererComponent(table, val, isSelected, hasFocus, row, column); } } catch (IntrospectionException e) { log.debug("Error during introspection of bean: " + e.getMessage(), e); } } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); }
From source file:org.snaker.engine.access.jdbc.BeanPropertyHandler.java
/** * IntrospectorBeanInfo????PropertyDescriptor[] * @param c// w w w.jav a2s .c o m * @return PropertyDescriptor[] * @throws SQLException */ private PropertyDescriptor[] propertyDescriptors(Class<?> c) throws SQLException { BeanInfo beanInfo = null; try { beanInfo = Introspector.getBeanInfo(c); } catch (IntrospectionException e) { throw new SQLException("Bean introspection failed: " + e.getMessage()); } return beanInfo.getPropertyDescriptors(); }