Java Code Examples for java.beans.IntrospectionException.getMessage()

The following are Jave code examples for showing how to use getMessage() of the java.beans.IntrospectionException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: opencron   File: ReflectUitls.java   View Source Code Vote up 6 votes
/**
 * 
 * java反射bean的set方法
 * 
 * @param clazz
 *            javaBean对象
 * @param fieldName
 *            字段名称
 * 
 * @return set方法
 */
public static Method setter(Class<?> clazz, String fieldName) {
       AssertUtils.notNull(clazz,fieldName);
       try {
           PropertyDescriptor[] objPds = Introspector.getBeanInfo(clazz).getPropertyDescriptors();

           for (int i = 0; objPds.length > 1 && i < objPds.length; i++) {
               //跳出从object继承的class属性,源上必须有get方法
               if (Class.class == objPds[i].getPropertyType()
                       || objPds[i].getReadMethod() == null) {
                   continue;
               }

               if (objPds[i].getName().equals(fieldName)){
                   return objPds[i].getWriteMethod();
               }
           }

       } catch (IntrospectionException e) {
           throw new RuntimeException(e.getMessage());
       }

       return null;
}
 
Example 2
Project: jforgame   File: BeanProcessor.java   View Source Code Vote up 5 votes
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();
}
 
Example 3
Project: opencron   File: ReflectUitls.java   View Source Code Vote up 5 votes
/**
 * 
 * java反射bean的get方法
 * 
 * @param clazz
 *            javaBean对象类型
 * @param fieldName
 *            字段名称
 * 
 * @return get方法
 */
public static Method getter(Class<?> clazz, String fieldName) throws NoSuchMethodException {
	// get+字段名第一个字母小写,得到get方法名

       // 拿到拷贝源上的属性器数组
       try {
           PropertyDescriptor[] objPds = Introspector.getBeanInfo(clazz).getPropertyDescriptors();

           for (int i = 0; objPds.length > 1 && i < objPds.length; i++) {
               //跳出从object继承的class属性,源上必须有get方法
               if (Class.class == objPds[i].getPropertyType()
                       || objPds[i].getReadMethod() == null) {
                   continue;
               }

               if (objPds[i].getName().equals(fieldName)){
                   return objPds[i].getReadMethod();
               }
           }

       } catch (IntrospectionException e) {
           throw new NoSuchMethodException(e.getMessage());
       }

       return null;

}
 
Example 4
Project: lorne_mysql   File: BaseJdbcTemplate.java   View Source Code Vote up 5 votes
private PropertyDescriptor[] propertyDescriptors(Class<?> c) throws SQLException {
    BeanInfo beanInfo = null;

    try {
        beanInfo = Introspector.getBeanInfo(c);
    } catch (IntrospectionException var4) {
        throw new SQLException("Bean introspection failed: " + var4.getMessage());
    }

    return beanInfo.getPropertyDescriptors();
}
 
Example 5
Project: lorne_core   File: MapModel.java   View Source Code Vote up 5 votes
private PropertyDescriptor[] propertyDescriptors(Class<?> c) throws SQLException {
    BeanInfo beanInfo = null;
    try {
        beanInfo = Introspector.getBeanInfo(c);
    } catch (IntrospectionException var4) {
        throw new SQLException("Bean introspection failed: " + var4.getMessage());
    }
    return beanInfo.getPropertyDescriptors();
}