本文整理匯總了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();
}