Because the project needs to be used, some common operations are encapsulated:
/*** Get Attribute Value Based on attribute name **/private object getfieldvaluebyname (string fieldname, object O) {try {string firstletter = fieldname. substring (0, 1 ). touppercase (); string getter = "get" + firstletter + fieldname. substring (1); Method method = O. getclass (). getmethod (getter, new class [] {}); object value = method. invoke (O, new object [] {}); return value;} catch (exception e) {log. error (E. getmessage (), e); return NULL ;}/ *** get attribute name array **/private string [] getfiledname (Object O) {field [] fields = O. getclass (). getdeclaredfields (); string [] fieldnames = new string [fields. length]; for (INT I = 0; I <fields. length; I ++) {system. out. println (fields [I]. getType (); fieldnames [I] = Fields [I]. getname ();} return fieldnames;}/*** get the type, name, and value) list **/private list getfiledsinfo (Object O) {field [] fields = O. getclass (). getdeclaredfields (); string [] fieldnames = new string [fields. length]; List list = new arraylist (); map infomap = NULL; For (INT I = 0; I <fields. length; I ++) {infomap = new hashmap (); infomap. put ("type", fields [I]. getType (). tostring (); infomap. put ("name", fields [I]. getname (); infomap. put ("value", getfieldvaluebyname (fields [I]. getname (), O); list. add (infomap);} return list;}/*** get all attribute values of an object and return an array of objects **/public object [] getfiledvalues (Object O) {string [] fieldnames = This. getfiledname (o); object [] value = new object [fieldnames. length]; for (INT I = 0; I <fieldnames. length; I ++) {value [I] = This. getfieldvaluebyname (fieldnames [I], O);} return value ;}