posts - 15,comments - 0,trackbacks - 0
public void SetValue(Object obj, String fieldName, Object value)
throws SecurityException, NoSuchFieldException,
NoSuchMethodException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
String firstLetter = fieldName.substring(0, 1).toUpperCase();
String setMethodName = "set" + firstLetter + fieldName.substring(1);
Field field = obj.getClass().getDeclaredField(fieldName);
Method setMethod = obj.getClass().getDeclaredMethod(setMethodName,
field.getType());
setMethod.invoke(obj, value);
}
posted on 2011-10-16 21:46 aya000 阅读(1316) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: