2014年3月30日 星期日

從object取參數



public static int isNullSendAutoMail(Object obj,int count,Map argMap,String tableType){
Map calumnValues = new HashMap();
for (Field field : ReflectUtil.getFields(obj.getClass())){//obj.getClass().getDeclaredFields())
String valObject = "";
String attributeName = "";
attributeName = field.getName();
//取column的Value
String getterMethodName = "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1, attributeName.length());
Method m = null;
try {
m = obj.getClass().getMethod(getterMethodName);
valObject = (String) m.invoke(obj);
} catch (Exception e) {
}
//放到Map
calumnValues.put(attributeName,valObject );
}//end for