本文整理汇总了Java中java.beans.IntrospectionException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java IntrospectionException.getMessage方法的具体用法?Java IntrospectionException.getMessage怎么用?Java IntrospectionException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.IntrospectionException
的用法示例。
在下文中一共展示了IntrospectionException.getMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setter
import java.beans.IntrospectionException; //导入方法依赖的package包/类
/**
*
* 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;
}
示例2: propertyDescriptors
import java.beans.IntrospectionException; //导入方法依赖的package包/类
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();
}
示例3: getter
import java.beans.IntrospectionException; //导入方法依赖的package包/类
/**
*
* 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;
}
示例4: propertyDescriptors
import java.beans.IntrospectionException; //导入方法依赖的package包/类
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();
}
示例5: propertyDescriptors
import java.beans.IntrospectionException; //导入方法依赖的package包/类
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();
}