{"id":917,"date":"2018-09-17T18:23:52","date_gmt":"2018-09-17T09:23:52","guid":{"rendered":"https:\/\/chat-messenger.com\/?p=917"},"modified":"2018-12-23T02:02:31","modified_gmt":"2018-12-22T17:02:31","slug":"reflect-util","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/en\/blog\/java\/reflect-util","title":{"rendered":"Java Reflection Made Easy"},"content":{"rendered":"<h2 class=\"common_title\">Java Reflection Made Easy<\/h2>\n<p>\n<strong>java<\/strong>(at sentence-end, falling tone) indicates a confident conclusion<strong>reflection<\/strong>Introducing utility classes for easy access to the API.\n<\/p>\n<h2 class=\"common_title\"><a name=\"1\">What is reflection?<\/a><\/h2>\n<p>\n<strong>Reflection API<\/strong>is the \"the<strong>java.lang.reflect<\/strong>\u201d included in the package,<br \/>\nThis is an API that retrieves information such as fields and methods from Java classes.<br \/>\nThe following classes are mainly used.\n<\/p>\n<ul>\n<li><strong>Class<\/strong><\/li>\n<li><strong>Constructor<\/strong><\/li>\n<li><strong>Method<\/strong><\/li>\n<li><strong>Field<\/strong><\/li>\n<\/ul>\n<p>\n<strong>reflection<\/strong>By using , you can create classes or call methods without having to code them directly.<br \/>\nYou can create a class instance from a string or execute a method.<\/p>\n<p>By writing the definitions of class names and method names in external files such as XML, you can dynamically adapt the application to changes in the environment during runtime.<br \/>\nIt is also a very effective API for building highly flexible applications.\n<\/p>\n<p><script type=\"text\/javascript\" src=\"https:\/\/chat-messenger.com\/js\/common.js?dd12sssas2223\" charset=\"UTF-8\"><\/script><br \/>\n<script type=\"text\/javascript\"> writePR(); <\/script><\/p>\n<h2 class=\"common_title\"><a name=\"2\">Purpose of Reflection<\/a><\/h2>\n<p>\n<strong>reflection<\/strong>is not often used directly by users,<br \/>\nIt is widely used in web applications such as Struts and frameworks such as O\/R mapping.<br \/>\n<br \/>\nFor example, when automatically setting web screen input data to JavaBeans properties,<br \/>\nIt is used when issuing SQL that automatically updates based on JavaBeans properties.<\/p>\n<p>In addition, functions such as dynamically loading and registering plug-ins that extend functionality at application startup are<strong>reflection<\/strong>This can be easily achieved by using the\n<\/p>\n<h2 class=\"common_title\"><a name=\"3\">Sample Execution<\/a><\/h2>\n<p>\nNow, please run the sample and experience framework-like programming.<br \/>\n<br \/>\nThe following classes are used here<strong>reflection<\/strong>It shows a simple way to use the utility.<br \/>\n<br \/>\n<a href=\"https:\/\/chat-messenger.com\/other\/java\/Main.txt\" target=\"_blank\"><strong>Main.java<\/strong><\/a>... Class to execute<br \/>\n<a href=\"https:\/\/chat-messenger.com\/other\/java\/BeanUtil.txt\" target=\"_blank\"><strong>BeanUtil.java<\/strong><\/a>Utility class for reflection<br \/>\n<a href=\"https:\/\/chat-messenger.com\/other\/java\/FreeSoft.txt\" target=\"_blank\"><strong>FreeSoft.java<\/strong><\/a>The class representing FreeSoff is used as a reflection.<\/p>\n<p><strong>When executed as usual<\/strong>\n<\/p>\n<div class=\"point\">\nSystem.out.println(<span style=\"color: #0000FF;\">\"&gt;&gt;&gt; Normal case.\"<\/span>); <br \/>\nFreeSoft freeSoft = new FreeSoft(); <br \/>\nfreeSoft.setName<span style=\"color: #0000FF;\">(\"Chat&amp;Messenger Chat and Messenger!!!\"<\/span>); <br \/>\nfreeSoft.showName(); freeSoft. <br \/>\nfreeSoft.showPrice(0); freeSoft.\n<\/div>\n<p>\n<strong>When executed using reflection<\/strong><\/p>\n<div class=\"point\">\nSystem.out.println<span style=\"color: #0000FF;\">(\"&gt;&gt; &gt;&gt; When reflection is used\")<\/span>); <br \/>\n<span style=\"color: #00CC33;\">\/\/ Instance creation of the FreeSoft class <\/span><br \/>\nObject invokeObject = BeanUtil.newInstance<span style=\"color: #0000FF;\">(\"FreeSoft\")<\/span>); <br \/>\n<span style=\"color: #00CC33;\">\/\/ Set a value in the name field. <\/span><br \/>\nBeanUtil.setProperty(invokeObject,. <span style=\"color: #0000FF;\">\"name\".<\/span> , <span style=\"color: #0000FF;\">\"Chat&amp;Messenger Chat and Messenger!\"<\/span>); <br \/>\n<span style=\"color: #00CC33;\">\/\/ FreeSoft's showName() method. <\/span><br \/>\nBeanUtil.invoke(invokeObject, invoke <span style=\"color: #0000FF;\">\"showName\".<\/span>, null); <br \/>\n<span style=\"color: #00CC33;\">\/\/ Execute FreeSoft's showPrice() method. <\/span><br \/>\n<span style=\"color: #00CC33;\">\/\/ If the method has arguments, they must be passed in an array of type Object. <\/span><br \/>\nBeanUtil.invoke(invokeObject, invoke <span style=\"color: #0000FF;\">\"showPrice\".<\/span>,new Object[]{new Integer(0)});\n<\/div>\n\n<p><strong>Execution Result<\/strong><br \/>\n<br \/>The execution result is the same in the normal case and when reflection is used.<\/p>\n<div class=\"console\">\n&gt;&gt;&gt; Normal case<br \/>\n<br \/>Software name: Chat&amp;Messenger Chat and Messenger!<br \/>\n<br \/>Price \uff1a 0 yen<\/p>\n<p>&gt;&gt; &gt;&gt; When using reflection<br \/>\n<br \/>Software name: Chat&amp;Messenger Chat and Messenger!<br \/>\n<br \/>Price \uff1a 0 yen\n<\/div>\n\n<h2 class=\"common_title\"><a name=\"4\">BeanUtil method details<\/a><\/h2>\n<p><a name=\"newInstance(String)\"><!-- --><\/a><\/p>\n<h2>\nnewInstance<\/h2>\n<pre>public static Object <b>newInstance<\/b>(String className)\r\n                                    throws Exception<\/pre>\n<dl>\n<dd>Creates and returns an instance from the string \"className\".<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>className<\/code> - fully qualified class name\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>New instances of fully qualified class names\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>Exception<\/code><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"newInstance(String, Object[])\"><!-- --><\/a><\/p>\n<h2>\nnewInstance<\/h2>\n<pre>public static Object <b>newInstance<\/b>(String className,\r\n                                           Object[] argObj)\r\n                                    throws Exception<\/pre>\n<dl>\n<dd>Creates and returns an instance from the string \"className\".<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>className<\/code> - fully qualified class name<\/dd>\n<dd><code>argObj<\/code> - Constructor Arguments\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>New instances of fully qualified class names\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>Exception<\/code><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"newInstance(Class)\"><!-- --><\/a><\/p>\n<h2>\nnewInstance<\/h2>\n<pre>public static Object <b>newInstance<\/b>(Class clazz)\r\n                                    throws Exception<\/pre>\n<dl>\n<dd>Creates and returns an instance from the class \"clazz\".<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>clazz<\/code> - class\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>New instances of clazz\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>Exception<\/code><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"newInstance(Class, Object[])\"><!-- --><\/a><\/p>\n<h2>\nnewInstance<\/h2>\n<pre>public static Object <b>newInstance<\/b>(Class clazz,\r\n                                           Object[] argObj)\r\n                                    throws Exception<\/pre>\n<dl>\n<dd>Creates and returns an instance from the class \"clazz\".<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>clazz<\/code> - class<\/dd>\n<dd><code>argObj<\/code> - Constructor Arguments\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>New instances of clazz\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>Exception<\/code><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"setProperty(Object, String, Object)\"><!-- --><\/a><\/p>\n<h2>\nsetProperty<\/h2>\n<pre>public static void <b>setProperty<\/b>(Object invokeObject, String fieldName, String\r\n                               String fieldName, Object value)\r\n                               Object value)\r\n                        throws Exception<\/pre>\n<dl>\n<dd>Call the setter method of the field &quot;fieldName&quot; of the object &quot;invokeObject&quot; and store the value &quot;value&quot;.<\/p>\n<p> If there is no setter method, the value will be set directly to the field. However, in this case, the access modifier of the target property must be public.<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>invokeObject<\/code> - Objects to be executed<\/dd>\n<dd><code>fieldName<\/code> - Property name of the object to be executed<\/dd>\n<dd><code>value<\/code> - Value to be set\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>Exception<\/code> - The following exceptions occur\n<\/dd>\n<dd><code>InvocationTargetException<\/code> - If the underlying method throws an exception\n<\/dd>\n<dd><code>IllegalAccessException<\/code> \u2013 This Method object is Java<br \/>\n             When language access control is implemented and the underlying method cannot be accessed\n<\/dd>\n<dd><code>NoSuchMethodException<\/code> - If the method with the specified name is not found<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"getProperty(Object, String)\"><!-- --><\/a><\/p>\n<h2>\ngetProperty<\/h2>\n<pre>public static Object <b>getProperty<\/b>(Object invokeObject, String fieldName)\r\n                                           String fieldName)\r\n                                    throws Exception<\/pre>\n<dl>\n<dd>Calls the getter method of the field fieldName of the object invokeObject to obtain the value.<br \/>\n If there is no getter method, the value will be retrieved directly from the field. However, in this case, the access modifier of the target property must be public.<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>invokeObject<\/code> - Objects to be executed<\/dd>\n<dd><code>fieldName<\/code> - Property name of the object to be executed\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>Return value of getter method\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>Exception<\/code> - The following exceptions occur\n<\/dd>\n<dd><code>InvocationTargetException<\/code> - If the underlying method throws an exception\n<\/dd>\n<dd><code>IllegalAccessException<\/code> \u2013 This Method object is Java<br \/>\n             When language access control is implemented and the underlying method cannot be accessed\n<\/dd>\n<dd><code>NoSuchFieldException<\/code> - If the field with the specified name is not found<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"invoke(Object, String, Object[])\"><!-- --><\/a><\/p>\n<h2>\ninvoke<\/h2>\n<pre>public static Object <b>invoke<\/b>(Object invokeObject, String callMethod, String\r\n                                      String callMethod, String\r\n                                      Object[] argObjects)\r\n                               throws InvocationTargetException, IllegalAccessException, and\r\n                                      IllegalAccessException, NoSuchMethodException\r\n                                      NoSuchMethodException<\/pre>\n<dl>\n<dd>Executes the method &quot;callMethod&quot; of the object &quot;invokeObject&quot;.<br \/>\n If there is a return value, it can be obtained as an Object.<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>invokeObject<\/code> - Objects to be executed<\/dd>\n<dd><code>callMethod<\/code> - Name of method to be executed<\/dd>\n<dd><code>argObjects<\/code> - If there is an argument, pass it as an array of objects. If there are no arguments, pass null.\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>Return value of \"callMethod\" executed\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>InvocationTargetException<\/code> - If the underlying method throws an exception\n<\/dd>\n<dd><code>IllegalAccessException<\/code> \u2013 This Method object is Java<br \/>\n             When language access control is implemented and the underlying method cannot be accessed\n<\/dd>\n<dd><code>NoSuchMethodException<\/code> - If the method with the specified name is not found<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"findMethod(Object, String, Object[])\"><!-- --><\/a><\/p>\n<h2>\nfindMethod<\/h2>\n<pre>public static Method <b>findMethod<\/b>(Object invokeObject, String callMethod, String\r\n                                                  String callMethod, String\r\n                                                  Object[] argObjects)\r\n                                           throws NoSuchMethodException<\/pre>\n<dl>\n<dd>Searches for the method \"callMethod\" of the object \"invokeObject\".<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>invokeObject<\/code> - Objects to be executed<\/dd>\n<dd><code>callMethod<\/code> - Method name of the object to be executed<\/dd>\n<dd><code>argObjects<\/code> - If there is an argument, pass it as an array of objects. If there are no arguments, pass null.\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>Method object matching the specified argument condition\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>NoSuchMethodException<\/code> - If no matching method is found, or if the name is \"\" or \"\".<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"setField(Object, String, Object)\"><!-- --><\/a><\/p>\n<h2>\nsetField<\/h2>\n<pre>public static void <b>setField<\/b>(Object invokeObject, String fieldName, String\r\n                            String fieldName, Object value)\r\n                            Object value)\r\n                     throws IllegalAccessException, NoSuchFieldException\r\n                            NoSuchFieldException<\/pre>\n<dl>\n<dd>Stores the value \"value\" in the field name \"fieldName\" of the object \"invokeObject\" to be executed.<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>invokeObject<\/code> - Objects to be executed<\/dd>\n<dd><code>fieldName<\/code> - Field name of the object to be executed<\/dd>\n<dd><code>value<\/code> - Value to be set\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>IllegalAccessException<\/code> \u2013 The field on which the specified object is based (or its subclass or implementer)<br \/>\n             is not an instance of the class or interface it declares, or if the unwrapping conversion fails\n<\/dd>\n<dd><code>NoSuchFieldException<\/code> - If the field with the specified name is not found<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"getField(Object, String)\"><!-- --><\/a><\/p>\n<h2>\ngetField<\/h2>\n<pre>public static Object <b>getField<\/b>(Object invokeObject, String fieldName)\r\n                                        String fieldName)\r\n                                 throws IllegalAccessException, NoSuchFieldException\r\n                                        NoSuchFieldException<\/pre>\n<dl>\n<dd>Obtains the value of the field name \"fieldName\" of the object \"invokeObject\" to be executed.<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>invokeObject<\/code> - Objects to be executed<\/dd>\n<dd><code>fieldName<\/code> - Field name of the object to be executed\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>return value\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>IllegalAccessException<\/code> \u2013 The field on which the specified object is based (or its subclass or implementer)<br \/>\n             is not an instance of the class or interface it declares, or if the unwrapping conversion fails\n<\/dd>\n<dd><code>NoSuchFieldException<\/code> - If the field with the specified name is not found<\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"hasField(Object, String)\"><!-- --><\/a><\/p>\n<h2>\nhasField<\/h2>\n<pre>public static boolean <b>hasField<\/b>(Object object,\r\n                               String fieldName)\r\n                        throws Exception<\/pre>\n<dl>\n<dd>Check if the object \"object\" declares the field name \"fieldName\".<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>object<\/code> - Objects to be inspected<\/dd>\n<dd><code>fieldName<\/code> - Name of field to be inspected\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>true if declared\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>Exception<\/code><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"getAllFields(Object)\"><!-- --><\/a><\/p>\n<h2>\ngetAllFields<\/h2>\n<pre>public static java.util. <b>getAllFields<\/b>(Object object)\r\n                                      throws Exception<\/pre>\n<dl>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>object<\/code> &#8211;\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>Exception<\/code><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"getShortClassName(Object)\"><!-- --><\/a><\/p>\n<h2>\ngetShortClassName<\/h2>\n<pre>public static String <b>getShortClassName<\/b>(Object object)<\/pre>\n<dl>\n<dd>Obtains the fully unqualified class name from the object.<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>object<\/code> &#8211;\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"getShortClassName(String)\"><!-- --><\/a><\/p>\n<h2>\ngetShortClassName<\/h2>\n<pre>public static String <b>getShortClassName<\/b>(String className)<\/pre>\n<dl>\n<dd>Get the class name from the fully qualified name.<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>className<\/code> &#8211;\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"getFieldName(String)\"><!-- --><\/a><\/p>\n<h2>\ngetFieldName<\/h2>\n<pre>public static String <b>getFieldName<\/b>(String methodName)<\/pre>\n<dl>\n<dd>Change the field name from the method name. Must conform to JavaBeans conventions.<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>methodName<\/code> &#8211;\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"isClassExist(String)\"><!-- --><\/a><\/p>\n<h2>\nisClassExist<\/h2>\n<pre>public static boolean <b>isClassExist<\/b>(String className)<\/pre>\n<dl>\n<dd>Verifies whether the fully qualified name \"className\" is an existing class name.<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>className<\/code> &#8211;\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<hr>\n<p><a name=\"getPropertyDescriptors(Object)\"><!-- --><\/a><\/p>\n<h2>\ngetPropertyDescriptors<\/h2>\n<pre>public static PropertyDescriptor[]. <b>getPropertyDescriptors<\/b>(Object object)\r\n                                                              throws IntrospectionException<\/pre>\n<dl>\n<dd>Returns a PropertyDescriptor holding object information for \"object\".<\/p>\n<\/dd>\n<dd>\n<dl>\n<dt><b>Parameters: A<\/b><\/dt>\n<dd><code>object<\/code> &#8211;\n<\/dd>\n<dt><b>Return value: 1<\/b><\/dt>\n<dd>\n<\/dd>\n<dt><b>Exceptions: The<\/b>\n<\/dt>\n<dd><code>IntrospectionException<\/code><\/dd>\n<\/dl>\n<\/dd>\n<\/dl>\n<h2 class=\"common_title\"><a name=\"5\">BeanUtil Source Code<\/a><\/h2>\n<p><textarea readonly=\"readonly\" style=\"font-size: 13px;height: 400px;\" class=\"src\" onclick=\"this.focus();this.select()\">import java.beans.BeanInfo;<br \/>\nimport java.beans.IntrospectionException;<br \/>\nimport java.beans.Introspector;<br \/>\nimport java.beans.PropertyDescriptor;<br \/>\nimport java.lang.reflect.Constructor;<br \/>\nimport java.lang.reflect.Field;<br \/>\nimport java.lang.reflect.InvocationTargetException;<br \/>\nimport java.lang.reflect.Method;<br \/>\nimport java.math.BigDecimal;<br \/>\nimport java.sql.Timestamp;<br \/>\nimport java.text.SimpleDateFormat;<br \/>\nimport java.util.Calendar;<br \/>\nimport java.util.Date;<br \/>\nimport java.util.HashMap;<br \/>\nimport java.util.Map;<br \/>\nimport java.util.StringTokenizer;<br \/>\nimport java.util.TreeSet;<\/p>\n<p>\/**<br \/>\n * Utility class that allows you to easily use Java&#039;s reflection API<br \/>\n *\/<br \/>\npublic class BeanUtil {<\/p>\n<p>    \/**   *\/<br \/>\n    private static final String GET = \u201cGET\u201d;<br \/>\n    \/**   *\/<br \/>\n    private static final String SET = \u201cSET\u201d;<\/p>\n<p>    \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\u300enewInstance\u300f<br \/>\n    \/**<br \/>\n     * Generates and returns an instance from the string &quot;className&quot;.<br \/>\n     * @param className fully qualified class name<br \/>\n     * @return new instance of fully qualified class name<br \/>\n     * @throws Exception<br \/>\n     *\/<br \/>\n    public static Object newInstance(String className) throws Exception {<br \/>\n        try {<br \/>\n            return Class.forName(className).newInstance();<br \/>\n        } catch (NoClassDefFoundError e) {<br \/>\n            System.err.println(\u201cNoClassDefFoundError : \u201d + className);<br \/>\n            throw e;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Generates and returns an instance from the string &quot;className&quot;.<br \/>\n     * @param className fully qualified class name<br \/>\n     * @param argObj constructor argument<br \/>\n     * @return new instance of fully qualified class name<br \/>\n     * @throws Exception<br \/>\n     *\/<br \/>\n    public static Object newInstance(String className, Object[] argObj)<br \/>\n            throws Exception {<br \/>\n        Class[] argClass = new Class[argObj.length];<br \/>\n        for (int i = 0; i &lt; argObj.length; i++) {<br \/>\n            argClass[i] = argObj[i].getClass();<br \/>\n        }<br \/>\n        Constructor c = Class.forName(className).getConstructor(argClass);<br \/>\n        return c.newInstance(argObj);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Create and return an instance from class &#039;clazz&#039;.<br \/>\n     * @param clazz class<br \/>\n     * @return new instance of clazz<br \/>\n     * @throws Exception<br \/>\n     *\/<br \/>\n    public static Object newInstance(Class clazz) throws Exception {<br \/>\n        return clazz.newInstance();<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Create and return an instance from class &#039;clazz&#039;.<br \/>\n     * @param clazz class<br \/>\n     * @param argObj constructor argument<br \/>\n     * @return new instance of clazz<br \/>\n     * @throws Exception<br \/>\n     *\/<br \/>\n    public static Object newInstance(Class clazz, Object[] argObj)<br \/>\n            throws Exception {<br \/>\n        Class[] argClass = new Class[argObj.length];<br \/>\n        for (int i = 0; i &lt; argObj.length; i++) {<br \/>\n            argClass[i] = argObj[i].getClass();<br \/>\n        }<br \/>\n        Constructor c = clazz.getConstructor(argClass);<br \/>\n        return c.newInstance(argObj);<br \/>\n    }<\/p>\n<p>    \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u300eMethod\u300f<br \/>\n    \/**<br \/>\n     * Setter method of field \u201cfieldName\u201d of object \u201cinvokeObject\u201d<br \/>\n     * Call, store value &#039;value&#039;.<br \/>\n     * &lt;br&gt;<br \/>\n     * If there is no setter method, set the value directly to the field.<br \/>\n     * However, in this case, the access modifier of the target property must be public.<br \/>\n     * @param invokeObject Object to be executed<br \/>\n     * @param fieldName Property name of the object to be executed<br \/>\n     * @param value value to set<br \/>\n     * @throws Exception The following exception occurs.<br \/>\n     * @throws InvocationTargetException if the underlying method throws an exception<br \/>\n     * @throws IllegalAccessException If this Method object is Java<br \/>\n     * When language access control is implemented and the underlying method cannot be accessed<br \/>\n     * @throws NoSuchMethodException if a method with the specified name is not found<br \/>\n     *\/<br \/>\n    public static void setProperty(Object invokeObject, String fieldName,<br \/>\n            Object value) throws Exception {<br \/>\n        try {<br \/>\n            Method method = searchMethod(invokeObject, fieldName, SET);<br \/>\n            Class[] paramClasses = method.getParameterTypes();<br \/>\n            Object[] valueArray = null;<br \/>\n            if (paramClasses[0].isInstance(value)) {<br \/>\n                \/\/Do not convert if the object to be set is a subclass of the argument class.<br \/>\n                valueArray = new Object[] { value };<br \/>\n            } else {<br \/>\n                valueArray = new Object[] { convObject(value, paramClasses[0]<br \/>\n                        .getName()) };<br \/>\n            }<br \/>\n            method.invoke(invokeObject, valueArray);<br \/>\n        } catch (NoSuchMethodException e) {<br \/>\n            try {<br \/>\n                \/\/ If there is no setter method, set it directly to the field.<br \/>\n                setField(invokeObject, fieldName, value);<br \/>\n            } catch (NoSuchFieldException fe) {<br \/>\n                String errorMes = \u201c\\nClass\u201d + getShortClassName(invokeObject)<br \/>\n                        + \u201cis\u201d + \u201cfor field \u201c\u201d + fieldName + \u201c\u201d\\n\u201d<br \/>\n                        + \u201cThere is no accessible setter method, and.\u201d<br \/>\n                        + \u201cField \u201c\u201d + fieldName<br \/>\n                        + \u201c\u201d is also not public. \u201d + \u201c\u201d;<br \/>\n                throw new IllegalAccessException(errorMes);<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Getter method of field fieldName of object invokeObject<br \/>\n     * Get the call value. &lt;br&gt;<br \/>\n     * If there is no getter method, the value will be obtained directly from the field.<br \/>\n     * However, in this case, the access modifier of the target property must be public.<br \/>\n     * @param invokeObject Object to be executed<br \/>\n     * @param fieldName Property name of the object to be executed<br \/>\n     * @return return value of getter method<br \/>\n     * @throws Exception The following exception occurs.<br \/>\n     * @throws InvocationTargetException if the underlying method throws an exception<br \/>\n     * @throws IllegalAccessException If this Method object is Java<br \/>\n     * When language access control is implemented and the underlying method cannot be accessed<br \/>\n     * @throws NoSuchFieldException if a field with the specified name is not found<br \/>\n     *\/<br \/>\n    public static Object getProperty(Object invokeObject, String fieldName)<br \/>\n            throws Exception {<br \/>\n        try {<br \/>\n            Method method = searchMethod(invokeObject, fieldName, GET);<br \/>\n            return method.invoke(invokeObject, null);<br \/>\n        } catch (NoSuchMethodException e) {<br \/>\n            return getField(invokeObject, fieldName);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Executes the method &quot;callMethod&quot; of the object &quot;invokeObject&quot;.<br \/>\n     * If there is a return value, it can be obtained as an Object type.<br \/>\n     * @param invokeObject Object to be executed<br \/>\n     * @param callMethod Method name to be executed<br \/>\n     * @param argObjects If there is an argument, pass it as an array of objects.<br \/>\n     * Pass null if there is no argument.<br \/>\n     * @return Return value of executing &quot;callMethod&quot;<br \/>\n     * @throws InvocationTargetException if the underlying method throws an exception<br \/>\n     * @throws IllegalAccessException If this Method object is Java<br \/>\n     * When language access control is implemented and the underlying method cannot be accessed<br \/>\n     * @throws NoSuchMethodException if a method with the specified name is not found<br \/>\n     *\/<br \/>\n    public static Object invoke(Object invokeObject, String callMethod,<br \/>\n            Object[] argObjects) throws InvocationTargetException,<br \/>\n            IllegalAccessException, NoSuchMethodException {<br \/>\n        Method method = findMethod(invokeObject, callMethod, argObjects);<br \/>\n        return method.invoke(invokeObject, argObjects);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Search for method &#039;callMethod&#039; of object &#039;invokeObject&#039;.<br \/>\n     * @param invokeObject Object to be executed<br \/>\n     * @param callMethod Method name of the object to be executed<br \/>\n     * @param argObjects If there is an argument, pass it as an array of objects.<br \/>\n     * Pass null if there is no argument.<br \/>\n     * @return Method object that matches the specified argument conditions<br \/>\n     * @throws NoSuchMethodException If no matching method is found,<br \/>\n     * Or if the name is \u201c &quot; or &quot; &quot;in the case of<br \/>\n     *\/<br \/>\n    public static Method findMethod(Object invokeObject, String callMethod,<br \/>\n            Object[] argObjects) throws NoSuchMethodException {<br \/>\n        Class[] paramClasses = null;<br \/>\n        Method[] methods = invokeObject.getClass().getMethods();<br \/>\n        top: for (int i = 0; i &lt; methods.length; i++) {<br \/>\n            if (methods[i].getName().equals(callMethod)) {<br \/>\n                if (argObjects == null<br \/>\n                        &amp;&amp; methods[i].getParameterTypes().length == 0) {<br \/>\n                    return methods[i];<br \/>\n                }<br \/>\n                if (argObjects == null) {<br \/>\n                    continue;<br \/>\n                }<br \/>\n                paramClasses = methods[i].getParameterTypes();<br \/>\n                if (paramClasses.length == argObjects.length) {<br \/>\n                    \/\/ Validate all parameter list types and argument types<br \/>\n                    for (int j = 0; j &lt; paramClasses.length; j++) {<br \/>\n                        Class paramClass = paramClasses[j];<br \/>\n                        Object argObj = argObjects[j];<br \/>\n                        \/\/ If the argument type is primitive, the argument object<br \/>\n                        \/\/ is not null and is primitive<br \/>\n                        \/\/If it&#039;s a subclass of Number, it&#039;s OK.<br \/>\n                        if (argObj == null) {<br \/>\n                            continue;<br \/>\n                        }<br \/>\n                        if (paramClass.isPrimitive()<br \/>\n                                &amp;&amp; (argObj instanceof Number || argObj<br \/>\n                                        .getClass().isPrimitive())) {<br \/>\n                            continue;<br \/>\n                        }<br \/>\n                        if (!paramClass.isInstance(argObj)) {<br \/>\n                            \/\/ Proceed to the next method when the types are not compatible with implicit conversion<br \/>\n                            continue top;<br \/>\n                        }<br \/>\n                    }<br \/>\n                    return methods[i];<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n        String paramLength = (paramClasses != null) ? Integer<br \/>\n                .toString(paramClasses.length) : \u201c\u201d;<br \/>\n        String errorMes = getShortClassName(invokeObject) + \u201cmethod\u201d<br \/>\n                + callMethod + \u201cThere is no.\u201d + \u201c[ paramClasses.length ] = \u201d<br \/>\n                + paramLength + \u201c,[ argObjects.length ] = \u201d + argObjects.length<br \/>\n                + &#8220;&#8221;;<br \/>\n        throw new NoSuchMethodException(errorMes);<br \/>\n    }<\/p>\n<p>    \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\u300eField\u300f<br \/>\n    \/**<br \/>\n     * Value for field name &quot;fieldName&quot; of object &quot;invokeObject&quot; to be executed<br \/>\n     * Stores &quot;value&quot;.<br \/>\n     * @param invokeObject Object to be executed<br \/>\n     * @param fieldName Field name of object to be executed<br \/>\n     * @param value value to set<br \/>\n     * @throws IllegalAccessException If the specified object is<br \/>\n     * field (or its subclass or implementer)<br \/>\n     * If it is not an instance of a class or interface, declare<br \/>\n     * or if the unwrapping conversion fails<br \/>\n     * @throws NoSuchFieldException if a field with the specified name is not found<br \/>\n     *\/<br \/>\n    public static void setField(Object invokeObject, String fieldName,<br \/>\n            Object value) throws IllegalAccessException, NoSuchFieldException {<br \/>\n        Field field = searchField(invokeObject, fieldName);<br \/>\n        String className = field.getType().getName();<br \/>\n        Object convObj = null;<br \/>\n        if (field.getType().isInstance(value)) {<br \/>\n            convObj = value;<br \/>\n        } else {<br \/>\n            convObj = convObject(value, className);<br \/>\n        }<br \/>\n        field.set(invokeObject, convObj);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Set the value of the field name &quot;fieldName&quot; of the execution object &quot;invokeObject&quot; to<br \/>\n     * Get.<br \/>\n     * @param invokeObject Object to be executed<br \/>\n     * @param fieldName Field name of object to be executed<br \/>\n     * @return return value<br \/>\n     * @throws IllegalAccessException If the specified object is<br \/>\n     * field (or its subclass or implementer)<br \/>\n     * If it is not an instance of a class or interface, declare<br \/>\n     * or if the unwrapping conversion fails<br \/>\n     * @throws NoSuchFieldException if a field with the specified name is not found<br \/>\n     *\/<br \/>\n    public static Object getField(Object invokeObject, String fieldName)<br \/>\n            throws IllegalAccessException, NoSuchFieldException {<br \/>\n        Field field = searchField(invokeObject, fieldName);<br \/>\n        return field.get(invokeObject);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Check whether the object &quot;object&quot; declares the field name &quot;fieldName&quot;<br \/>\n     * confirm.<br \/>\n     * @param object Object to be inspected<br \/>\n     * @param fieldName Field name to inspect<br \/>\n     * @return true if declared<br \/>\n     * @throws Exception<br \/>\n     *\/<br \/>\n    public static boolean hasField(Object object, String fieldName)<br \/>\n            throws Exception {<br \/>\n        PropertyDescriptor[] props = getPropertyDescriptors(object);<br \/>\n        for (int i = 0; i &lt; props.length; i++) {<br \/>\n            String _fieldName = props[i].getName();<br \/>\n            if (fieldName.equals(_fieldName)) {<br \/>\n                return true;<br \/>\n            }<br \/>\n        }<br \/>\n        return false;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     *<br \/>\n     * @param object<br \/>\n     * @return<br \/>\n     * @throws Exception<br \/>\n     *\/<br \/>\n    public static TreeSet getAllFields(Object object) throws Exception {<\/p>\n<p>        TreeSet fieldSet = new TreeSet();<br \/>\n        \/\/ Get property name from method<br \/>\n        PropertyDescriptor[] props = getPropertyDescriptors(object);<br \/>\n        for (int i = 0; i &lt; props.length; i++) {<br \/>\n            String fieldName = props[i].getName();<br \/>\n            fieldSet.add(fieldName);<\/p>\n<p>        }<\/p>\n<p>        \/\/ Get property name from field<br \/>\n        Field[] fields = object.getClass().getFields();<br \/>\n        for (int i = 0; i &lt; fields.length; i++) {<br \/>\n            String fieldName = fields[i].getName();<br \/>\n            if (!fieldSet.contains(fieldName)) {<br \/>\n                fieldSet.add(fieldName);<br \/>\n            }<br \/>\n        }<br \/>\n        return fieldSet;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     *<br \/>\n     * @param invokeObject Object to be executed<br \/>\n     * @param fieldName Field name of object to be executed<br \/>\n     * @return Filed objects that match the specified argument conditions<br \/>\n     * @throws NoSuchFieldException if a field with the specified name is not found<br \/>\n     *\/<br \/>\n    private static Field searchField(Object invokeObject, String fieldName)<br \/>\n            throws NoSuchFieldException {<br \/>\n        try {<br \/>\n            return invokeObject.getClass().getField(fieldName);<br \/>\n        } catch (NoSuchFieldException e) {<br \/>\n            \/\/ This scope is obtained from the table column name<br \/>\n            fieldName = checkFieldName(fieldName);<br \/>\n            Field[] fields = invokeObject.getClass().getFields();<br \/>\n            for (int i = 0; i &lt; fields.length; i++) {<br \/>\n                if (fields[i].getName().equalsIgnoreCase(fieldName)) {<br \/>\n                    return fields[i];<br \/>\n                }<br \/>\n            }<br \/>\n            throw new NoSuchFieldException(fieldName);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ ----------------------&quot; others &quot;<\/p>\n<p>    \/**<br \/>\n     * Get the unqualified class name from an object.<br \/>\n     * @param object<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    public static String getShortClassName(Object object) {<br \/>\n        if (object == null) {<br \/>\n            return \u201cnull\u201d;<br \/>\n        }<br \/>\n        String name = object.getClass().getName();<br \/>\n        return getShortClassName(name);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Get the class name from the fully qualified name.<br \/>\n     * @param className<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    public static String getShortClassName(String className) {<br \/>\n        int index = className.lastIndexOf(\u201c.\u201d);<br \/>\n        return className.substring(index + 1);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Change the field name from the method name. Conforms to JavaBeans conventions<br \/>\n     * is needed.<br \/>\n     * @param methodName<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    public static String getFieldName(String methodName) {<br \/>\n        String fieldName = null;<br \/>\n        if (methodName.startsWith(\u201cis\u201d)) {<br \/>\n            fieldName = methodName.substring(2);<br \/>\n        } else {<br \/>\n            fieldName = methodName.substring(3);<br \/>\n        }<br \/>\n        fieldName = convString(fieldName, 0, \u201cL\u201d);<br \/>\n        return fieldName;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Verify that the fully qualified name &quot;className&quot; is an existing class name.<br \/>\n     * @param className<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    public static boolean isClassExist(String className) {<br \/>\n        try {<br \/>\n            Class.forName(className);<br \/>\n            return true;<br \/>\n        } catch (Exception e) {<br \/>\n            return false;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    private final static Map beanInfoCache = new HashMap();<\/p>\n<p>    \/**<br \/>\n     * Returns a PropertyDescriptor that holds object information for &quot;object&quot;.<br \/>\n     * @param object<br \/>\n     * @return<br \/>\n     * @throws IntrospectionException<br \/>\n     *\/<br \/>\n    public static PropertyDescriptor[] getPropertyDescriptors(Object object)<br \/>\n            throws IntrospectionException {<\/p>\n<p>        BeanInfo beanInfo = (BeanInfo) beanInfoCache.get(object.getClass());<br \/>\n        if (beanInfo == null) {<br \/>\n            beanInfo = Introspector.getBeanInfo(object.getClass());<br \/>\n            beanInfoCache.put(object.getClass(), beanInfo);<br \/>\n        }<br \/>\n        \/\/ BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());<br \/>\n        return beanInfo.getPropertyDescriptors();<br \/>\n    }<\/p>\n<p>    \/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n    \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u201cPrivate method below\u201d<br \/>\n    \/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n    \/**<br \/>\n     * Search for the accessor method for the argument fieldName based on PropertyDescriptor.<br \/>\n     * @param invokeObject Object to be executed<br \/>\n     * @param fieldName field name<br \/>\n     * @param type Getter method \u21d2 GET Getter method \u21d2 SET<br \/>\n     * @return Method object that matches the specified argument conditions<br \/>\n     * @throws NoSuchMethodException If no matching method is found,<br \/>\n     * Or if the name is \u201c &quot; or &quot; \u201d<br \/>\n     * in the case of<br \/>\n     * @throws IntrospectionException<br \/>\n     *\/<br \/>\n    private static Method searchMethod(Object invokeObject, String fieldName,<br \/>\n            String type) throws NoSuchMethodException, IntrospectionException {<br \/>\n        Method method = null;<br \/>\n        fieldName = checkFieldName(fieldName);<br \/>\n        PropertyDescriptor[] props = getPropertyDescriptors(invokeObject);<br \/>\n        for (int i = 0; i &lt; props.length; i++) {<br \/>\n            String name = props[i].getName();<br \/>\n            if (!name.equalsIgnoreCase(fieldName)) {<br \/>\n                continue;<br \/>\n            }<br \/>\n            if (type.equals(GET)) {<br \/>\n                method = props[i].getReadMethod();<br \/>\n            } else {<br \/>\n                method = props[i].getWriteMethod();<br \/>\n            }<br \/>\n            if (method == null) {<br \/>\n                continue;<br \/>\n            }<br \/>\n            return method;<br \/>\n        }<\/p>\n<p>        \/\/ If the method does not exist.<br \/>\n        throw new NoSuchMethodException(\u201cClass has no methods.\u201d<br \/>\n                + \u201c(Case insensitive.): \u201d + type.toLowerCase()<br \/>\n                + convString(fieldName, 0, \u201cU\u201d) + \u201c()\u201d);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Checks if the argument fieldName is a column name; if it is a column name,<br \/>\n     * Convert back.<br \/>\n     *<br \/>\n     * MAIL_ADDRESS \u21d2 MAILADDRESS \u2193 mailaddress = mailAddress<br \/>\n     * @param fieldName field name or column name<br \/>\n     * @return field name<br \/>\n     *\/<br \/>\n    private static String checkFieldName(String fieldName) {<br \/>\n        int index = fieldName.indexOf(\u201c_\u201d);<br \/>\n        while (true) {<br \/>\n            if (index == -1) {<br \/>\n                return fieldName;<br \/>\n            }<br \/>\n            StringBuffer convcloumn = new StringBuffer(fieldName);<br \/>\n            convcloumn.deleteCharAt(index);<br \/>\n            fieldName = convcloumn.toString();<br \/>\n            index = fieldName.indexOf(\u201c_\u201d);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Converts the object to be converted, object, to the type of convClassName.<br \/>\n     *<br \/>\n     * @param object Object to be converted<br \/>\n     * @param convClassName class string of type to convert<br \/>\n     * @return the converted object<br \/>\n     *\/<br \/>\n    private static Object convObject(Object object, String convClassName) {<br \/>\n        if (object == null) {<br \/>\n            \/\/ Returning null when converting to a primitive type will result in an error.<br \/>\n            \/\/ Make it a wrapper for 0.<br \/>\n            if (convClassName.equals(\u201cint\u201d)) {<br \/>\n                return new Integer(0);<br \/>\n            } else if (convClassName.equals(\u201clong\u201d)) {<br \/>\n                return new Long(0);<br \/>\n            } else {<br \/>\n                return null;<br \/>\n            }<br \/>\n        }<br \/>\n        if (object.getClass().getName().equals(convClassName)) {<br \/>\n            return object;<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\u300eobject instanceof String\u300f<br \/>\n        if (object instanceof String) {<br \/>\n            if (convClassName.equals(\u201cjava.lang.String\u201d)) {<br \/>\n                return object;<br \/>\n            } else if (convClassName.equals(\u201cjava.lang.Long\u201d)<br \/>\n                    || convClassName.equals(\u201clong\u201d)) {<br \/>\n                String str = (String) object;<br \/>\n                if (isExist(str)) {<br \/>\n                    \/\/ It will be bad if you don&#039;t convert it to BigDecimal once<br \/>\n                    \/\/ 1000.00000<br \/>\n                    BigDecimal big = new BigDecimal(str);<br \/>\n                    return new Long(big.longValue());<br \/>\n                } else {<br \/>\n                    \/\/ If str is a shell literal, set the initial value to \u201c0\u201d<br \/>\n                    return new Long(0);<br \/>\n                }<br \/>\n            } else if (convClassName.equals(\u201cjava.sql.Date\u201d)) {<br \/>\n                return toSqlDate((String) object);<br \/>\n            } else if (convClassName.equals(\u201cjava.sql.Timestamp\u201d)) {<br \/>\n                Date date = toSqlDate((String) object);<br \/>\n                return new Timestamp(date.getTime());<br \/>\n            } else if (convClassName.equals(\u201cjava.lang.Integer\u201d)<br \/>\n                    || convClassName.equals(\u201cint\u201d)) {<br \/>\n                \/\/ If str is a shell literal, set the initial value to \u201c0\u201d<br \/>\n                String str = (String) object;<br \/>\n                if (isExist(str)) {<br \/>\n                    BigDecimal big = new BigDecimal(str);<br \/>\n                    return new Integer(big.intValue());<br \/>\n                } else {<br \/>\n                    return new Integer(0);<br \/>\n                }<br \/>\n            } else if (convClassName.equals(\u201cboolean\u201d)) {<br \/>\n                return Boolean.valueOf(object.toString());<br \/>\n            } else if (convClassName.equals(\u201cjava.math.BigDecimal\u201d)) {<br \/>\n                String temp = ((String) object).trim();<br \/>\n                \/\/ If temp.length() == 0, it is safe to set it to null instead of 0.<br \/>\n                if (temp.length() == 0) {<br \/>\n                    return null;<br \/>\n                } else {<br \/>\n                    return new BigDecimal(temp);<br \/>\n                }<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u201c object instanceof java.sql.Date \u201d<br \/>\n        else if (object instanceof java.sql.Date) {<\/p>\n<p>            if (convClassName.equals(\u201cjava.lang.String\u201d)) {<br \/>\n                return toStringDate((java.sql.Date) object, \u201cyyyy\/MM\/dd\u201d);<br \/>\n            } else if (convClassName.equals(\u201cjava.sql.Date\u201d)) {<br \/>\n                return object;<br \/>\n            } else if (convClassName.equals(\u201cjava.sql.Timestamp\u201d)) {<br \/>\n                return new Timestamp(((Date) object).getTime());<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\u300eobject instanceof Timestamp\u300f<br \/>\n        else if (object instanceof Timestamp) {<br \/>\n            long time = ((Timestamp) object).getTime();<br \/>\n            if (convClassName.equals(\u201cjava.lang.String\u201d)) {<br \/>\n                return toStringDate(time, \u201cyyyy\/MM\/dd HH:mm:ss\u201d);<br \/>\n            } else if (convClassName.equals(\u201cjava.sql.Date\u201d)) {<br \/>\n                return new java.sql.Date(time);<br \/>\n            } else if (convClassName.equals(\u201cjava.sql.Timestamp\u201d)) {<br \/>\n                return object;<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\u300eobject instanceof Integer\u300f<br \/>\n        else if (object instanceof Integer) {<br \/>\n            if (convClassName.equals(\u201cjava.lang.Integer\u201d)<br \/>\n                    || convClassName.equals(\u201cint\u201d)) {<br \/>\n                return object;<br \/>\n            } else if (convClassName.equals(\u201cjava.lang.String\u201d)) {<br \/>\n                return object.toString();<br \/>\n            } else if (convClassName.equals(\u201cjava.lang.Long\u201d)<br \/>\n                    || convClassName.equals(\u201clong\u201d)) {<br \/>\n                return new Long(((Integer) object).longValue());<br \/>\n            } else if (convClassName.equals(\u201cjava.math.BigDecimal\u201d)) {<br \/>\n                return new BigDecimal(((Integer) object).intValue());<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u300eobject instanceof Long\u300f<br \/>\n        else if (object instanceof Long) {<br \/>\n            if (convClassName.equals(\u201cjava.lang.Long\u201d)<br \/>\n                    || convClassName.equals(\u201clong\u201d)) {<br \/>\n                return object;<br \/>\n            } else if (convClassName.equals(\u201cjava.lang.String\u201d)) {<br \/>\n                return object.toString();<br \/>\n            } else if (convClassName.equals(\u201cjava.lang.Integer\u201d)<br \/>\n                    || convClassName.equals(\u201cint\u201d)) {<br \/>\n                return new Integer(((Long) object).intValue());<br \/>\n            } else if (convClassName.equals(\u201cjava.math.BigDecimal\u201d)) {<br \/>\n                return new BigDecimal(((Long) object).longValue());<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\u300eobject instanceof Double\u300f<br \/>\n        else if (object instanceof Double) {<br \/>\n            if (convClassName.equals(\u201cjava.lang.String\u201d)) {<br \/>\n                \/\/ COLUMN NUMBER(8,0)<br \/>\n                \/\/ windows oracle &gt; BigDecimal<br \/>\n                \/\/ UNIX oracle &gt; Double<br \/>\n                BigDecimal big = new BigDecimal(((Double) object).doubleValue());<br \/>\n                int scale = big.scale();<br \/>\n                if (scale == 0) {<br \/>\n                    return big.toString();<br \/>\n                } else {<br \/>\n                    \/\/ Not supported if rounding is required.<br \/>\n                    throwNoSupprt(object, convClassName);<br \/>\n                }<br \/>\n            }<br \/>\n            if (convClassName.equals(\u201cjava.lang.Integer\u201d)<br \/>\n                    || convClassName.equals(\u201cint\u201d)) {<br \/>\n                return new Integer(((Double) object).intValue());<br \/>\n            } else if (convClassName.equals(\u201cjava.lang.Long\u201d)<br \/>\n                    || convClassName.equals(\u201clong\u201d)) {<br \/>\n                return new Long(((Double) object).longValue());<br \/>\n            } else if (convClassName.equals(\u201cjava.math.BigDecimal\u201d)) {<br \/>\n                return new BigDecimal(((Double) object).doubleValue());<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u201c object instanceof BigDecimal \u201d<br \/>\n        else if (object instanceof BigDecimal) {<br \/>\n            if (convClassName.equals(\u201cjava.lang.String\u201d)) {<br \/>\n                return object.toString();<br \/>\n            } else if (convClassName.equals(\u201cjava.lang.Long\u201d)<br \/>\n                    || convClassName.equals(\u201clong\u201d)) {<br \/>\n                return new Long(((BigDecimal) object).longValue());<br \/>\n            } else if (convClassName.equals(\u201cjava.lang.Integer\u201d)<br \/>\n                    || convClassName.equals(\u201cint\u201d)) {<br \/>\n                return new Integer(((BigDecimal) object).intValue());<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\u300eobject instanceof byte[]\u300f<br \/>\n        else if (object instanceof byte[]) {<br \/>\n            if (convClassName.equals(\u201cjava.sql.Blob\u201d)) {<br \/>\n                return object;<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u201c object is Boolean\u201d<br \/>\n        else if (object instanceof Boolean) {<br \/>\n            if (convClassName.equals(\u201cboolean\u201d)) {<br \/>\n                return object;<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<\/p>\n<p>        \/\/ \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\u300eobject is boolean[]\u300f<br \/>\n        else if (object instanceof boolean[]) {<br \/>\n            if (convClassName.equals(\u201cjava.lang.String\u201d)) {<br \/>\n                boolean[] bs = (boolean[]) object;<br \/>\n                StringBuffer buff = new StringBuffer(\u201c[\u201c);<br \/>\n                for (int i = 0; i &lt; bs.length; i++) {<br \/>\n                    buff.append(bs[i] + \u201c,\u201d);<br \/>\n                }<br \/>\n                buff.deleteCharAt(buff.length() \u2013 1);<br \/>\n                buff.append(\u201c]\u201d);<br \/>\n                return buff.toString();<br \/>\n            }<br \/>\n            throwNoSupprt(object, convClassName);<br \/>\n        }<br \/>\n        throwNoSupprt(object, convClassName);<br \/>\n        return null;<\/p>\n<p>    }<\/p>\n<p>    \/**<br \/>\n     *Throws if the conversion is not supported.<br \/>\n     *<br \/>\n     * @param object Object to be converted<br \/>\n     * @param convClassName Type to convert<br \/>\n     *\/<br \/>\n    private static void throwNoSupprt(Object object, String convClassName) {<br \/>\n        String className = (object != null) ? object.getClass().getName()<br \/>\n                : \u201cnull\u201d;<br \/>\n        String errorMess = \u201c\\nType conversion processing for this Object is not yet supported.\\n\u201d<br \/>\n                + \u201d [ Object ] = \u201d + object + \u201c,[ Object type ] = \u201d + className<br \/>\n                + \u201c,[ convertClass ] = \u201d + convClassName + \u201c\u201d;<br \/>\n        throw new UnsupportedOperationException(errorMess);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Converts the character at position [index] of string [str] to uppercase or lowercase.<br \/>\n     * &lt;p&gt;<br \/>\n     * @param str String to be evaluated<br \/>\n     * @param index Specified position<br \/>\n     * @param toCase Convert to upper case \u21d2 U | u Convert to lower case \u21d2 L | l<br \/>\n     * @return String after conversion<br \/>\n     *\/<br \/>\n    private static String convString(String str, int index, String toCase) {<br \/>\n        if (str == null || str.trim().length() == 0) {<br \/>\n            return str;<br \/>\n        } else {<br \/>\n            String temp = str.substring(index, index + 1);<br \/>\n            if (toCase.equalsIgnoreCase(\u201cu\u201d)) {<br \/>\n                temp = temp.toUpperCase();<br \/>\n            } else {<br \/>\n                temp = temp.toLowerCase();<br \/>\n            }<br \/>\n            StringBuffer tempBuffer = new StringBuffer(str);<br \/>\n            tempBuffer.replace(index, index + 1, temp);<br \/>\n            return tempBuffer.toString();<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Verify if [value] is a valid value.<br \/>\n     *<br \/>\n     * @param value String to be evaluated<br \/>\n     * @return [true]: If not null and not \u201c\u201d<br \/>\n     *\/<br \/>\n    private static boolean isExist(String value) {<br \/>\n        if (value != null &amp;&amp; value.length() != 0) {<br \/>\n            return true;<br \/>\n        }<br \/>\n        return false;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * java.util.Date class or its subclass in specified format<br \/>\n     * Convert to string.<br \/>\n     * @param date java.util.Date class to be converted<br \/>\n     * @param pattern specified format<br \/>\n     * @return formatted date string<br \/>\n     *\/<br \/>\n    private static String toStringDate(Date date, String pattern) {<br \/>\n        SimpleDateFormat sdFormat = new SimpleDateFormat(pattern);<br \/>\n        return sdFormat.format(date);<br \/>\n    }<\/p>\n<p>    private static java.sql.Date toSqlDate(String strDate) {<br \/>\n        Calendar cal = toCalendar(strDate);<br \/>\n        return toSqlDate(cal);<br \/>\n    }<\/p>\n<p>    private static java.sql.Date toSqlDate(Calendar cal) {<br \/>\n        long l = cal.getTime().getTime();<br \/>\n        return new java.sql.Date(l);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Converts a long time value to a string in the specified format.<br \/>\n     * @param time A long value representing milliseconds of the current time.<br \/>\n     * @param pattern specified format<br \/>\n     * @return formatted date string<br \/>\n     *\/<br \/>\n    private static String toStringDate(long time, String pattern) {<br \/>\n        return toStringDate(new Date(time), pattern);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * String \u21d2 java.sql.Date<br \/>\n     *<br \/>\n     * Convert the following date string to java.sql.Date<br \/>\n     * yyyy\/MM\/dd HH:mm:ss.SSS yyyy-MM-dd HH:mm:ss.SSS<br \/>\n     *<br \/>\n     * &#8220;20030407&#8221; &#8220;2003\/04\/07&#8221; &#8220;2003-04-07&#8221; &#8220;2003\/04\/07 15:20:16&#8221; &#8220;2003-04-07<br \/>\n     * 15:20:16&#8221;<br \/>\n     * @param strDate<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    private static Calendar toCalendar(String strDate) {<br \/>\n        strDate = format(strDate);<br \/>\n        Calendar cal = Calendar.getInstance();<\/p>\n<p>        int yyyy = Integer.parseInt(strDate.substring(0, 4));<br \/>\n        int MM = Integer.parseInt(strDate.substring(5, 7));<br \/>\n        int dd = Integer.parseInt(strDate.substring(8, 10));<br \/>\n        int HH = cal.get(Calendar.HOUR_OF_DAY);<br \/>\n        int mm = cal.get(Calendar.MINUTE);<br \/>\n        int ss = cal.get(Calendar.SECOND);<br \/>\n        int SSS = cal.get(Calendar.MILLISECOND);<\/p>\n<p>        cal.clear();<br \/>\n        cal.set(yyyy, MM \u2013 1, dd);<\/p>\n<p>        int len = strDate.length();<br \/>\n        switch (len) {<br \/>\n        case 10:<br \/>\n            break;<br \/>\n        case 16: \/\/ yyyy\/MM\/dd HH:mm<br \/>\n            HH = Integer.parseInt(strDate.substring(11, 13));<br \/>\n            mm = Integer.parseInt(strDate.substring(14, 16));<br \/>\n            cal.set(Calendar.HOUR_OF_DAY, HH);<br \/>\n            cal.set(Calendar.MINUTE, mm);<br \/>\n            break;<br \/>\n        case 19: \/\/ yyyy\/MM\/dd HH:mm:ss<br \/>\n            HH = Integer.parseInt(strDate.substring(11, 13));<br \/>\n            mm = Integer.parseInt(strDate.substring(14, 16));<br \/>\n            ss = Integer.parseInt(strDate.substring(17, 19));<br \/>\n            cal.set(Calendar.HOUR_OF_DAY, HH);<br \/>\n            cal.set(Calendar.MINUTE, mm);<br \/>\n            cal.set(Calendar.SECOND, ss);<br \/>\n            break;<br \/>\n        case 23: \/\/ yyyy\/MM\/dd HH:mm:ss.SSS<br \/>\n            HH = Integer.parseInt(strDate.substring(11, 13));<br \/>\n            mm = Integer.parseInt(strDate.substring(14, 16));<br \/>\n            ss = Integer.parseInt(strDate.substring(17, 19));<br \/>\n            SSS = Integer.parseInt(strDate.substring(20, 23));<br \/>\n            cal.set(Calendar.HOUR_OF_DAY, HH);<br \/>\n            cal.set(Calendar.MINUTE, mm);<br \/>\n            cal.set(Calendar.SECOND, ss);<br \/>\n            cal.set(Calendar.MILLISECOND, SSS);<br \/>\n            break;<br \/>\n        default:<br \/>\n            throw new IllegalStateException(<br \/>\n                    \u201cThis String string cannot be converted to a date string: \u201d<br \/>\n                    + strDate);<br \/>\n        }<br \/>\n        return cal;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Any date string as \u201cyyyy\/MM\/dd\u201d or \u201cyyyy\/MM\/dd HH:mm:ss\u201d<br \/>\n     * Attempts to convert to format.<br \/>\n     * Example: 03\/1\/3 \u21d2 2003\/01\/03<br \/>\n     * @param strDate<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    private static String format(String strDate) {<br \/>\n        strDate = strDate.trim();<br \/>\n        String yyyy = null;<br \/>\n        String MM = null;<br \/>\n        String dd = null;<br \/>\n        String HH = null;<br \/>\n        String mm = null;<br \/>\n        String ss = null;<br \/>\n        String SSS = null;<\/p>\n<p>        \/\/ If \u201c-\u201d or \u201c\/\u201d is missing<br \/>\n        if (strDate.indexOf(\u201c\/\u201d) == -1 &amp;&amp; strDate.indexOf(\u201c-\u201c) == -1) {<br \/>\n            if (strDate.length() == 8) {<br \/>\n                yyyy = strDate.substring(0, 4);<br \/>\n                MM = strDate.substring(4, 6);<br \/>\n                dd = strDate.substring(6, 8);<br \/>\n                return yyyy + \u201c\/\u201d + MM + \u201c\/\u201d + dd;<br \/>\n            } else {<br \/>\n                yyyy = strDate.substring(0, 4);<br \/>\n                MM = strDate.substring(4, 6);<br \/>\n                dd = strDate.substring(6, 8);<br \/>\n                HH = strDate.substring(9, 11);<br \/>\n                mm = strDate.substring(12, 14);<br \/>\n                ss = strDate.substring(15, 17);<br \/>\n                return yyyy + \u201c\/\u201d + MM + \u201c\/\u201d + dd + \u201d \u201d + HH + \u201c:\u201d + mm + \u201c:\u201d<br \/>\n                        +ss;<br \/>\n            }<br \/>\n        }<br \/>\n        StringTokenizer token = new StringTokenizer(strDate, \u201c_\/-:. \u201c);<br \/>\n        StringBuffer result = new StringBuffer();<br \/>\n        for (int i = 0; token.hasMoreTokens(); i++) {<br \/>\n            String temp = token.nextToken();<br \/>\n            switch (i) {<br \/>\n            case 0:\/\/ year part<br \/>\n                yyyy = fillString(strDate, temp, \u201cf\u201d, \u201c20\u201d, 4);<br \/>\n                result.append(yyyy);<br \/>\n                break;<br \/>\n            case 1:\/\/ month part<br \/>\n                MM = fillString(strDate, temp, \u201cf\u201d, \u201c0\u201d, 2);<br \/>\n                result.append(\u201c\/\u201d + MM);<br \/>\n                break;<br \/>\n            case 2:\/\/ day part<br \/>\n                dd = fillString(strDate, temp, \u201cf\u201d, \u201c0\u201d, 2);<br \/>\n                result.append(\u201c\/\u201d + dd);<br \/>\n                break;<br \/>\n            case 3:\/\/ time part<br \/>\n                HH = fillString(strDate, temp, \u201cf\u201d, \u201c0\u201d, 2);<br \/>\n                result.append(\u201d \u201d + HH);<br \/>\n                break;<br \/>\n            case 4:\/\/ minute part<br \/>\n                mm = fillString(strDate, temp, \u201cf\u201d, \u201c0\u201d, 2);<br \/>\n                result.append(\u201c:\u201d + mm);<br \/>\n                break;<br \/>\n            case 5:\/\/ second part<br \/>\n                ss = fillString(strDate, temp, \u201cf\u201d, \u201c0\u201d, 2);<br \/>\n                result.append(\u201c:\u201d + ss);<br \/>\n                break;<br \/>\n            case 6:\/\/ millisecond part<br \/>\n                SSS = fillString(strDate, temp, \u201cb\u201d, \u201c0\u201d, 3);<br \/>\n                result.append(\u201c.\u201d + SSS);<br \/>\n                break;<br \/>\n            }<br \/>\n        }<br \/>\n        return result.toString();<br \/>\n    }<\/p>\n<p>    private static String fillString(String strDate, String str,<br \/>\n            String position, String addStr, int len) {<\/p>\n<p>        if (str.length() &gt; len) {<br \/>\n            String mes = strDate + \u201cThis String string cannot be converted to a date string\u201d;<br \/>\n            throw new IllegalStateException(mes);<br \/>\n        }<br \/>\n        return fillString(str, position, addStr, len);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * Add the string [addStr] to be added to the string [str] at [position] in [len]<br \/>\n     * Insert until full.<br \/>\n     * &lt;p&gt;<br \/>\n     * Example: String ss = StringUtil.fillString(\u201caaa\u201d,\u201db\u201d,\u201d0\u2033,7); ss \u21d2 \u201caaa0000\u201d<br \/>\n     *<br \/>\n     * *fillString() inserts until len is filled, but addString() inserts len.<br \/>\n     *<br \/>\n     * @param str target string<br \/>\n     * @param position Insert before \u21d2 F\/f Insert after \u21d2 B\/b<br \/>\n     * @param addStr String to insert<br \/>\n     * @param len Number of digits to replenish<br \/>\n     * @return The string after conversion. [str] is null or empty literal, [addStr] is set to [len]<br \/>\n     * Returns inserted results until satisfied.<br \/>\n     *\/<br \/>\n    private static String fillString(String str, String position,<br \/>\n            String addStr, int len) {<br \/>\n        StringBuffer tempBuffer = null;<br \/>\n        if (!isExist(str)) {<br \/>\n            tempBuffer = new StringBuffer();<br \/>\n            for (int i = 0; i &lt; len; i++) {<br \/>\n                tempBuffer.append(addStr);<br \/>\n            }<br \/>\n            return tempBuffer.toString();<br \/>\n        } else if (str.length() != len) {<br \/>\n            tempBuffer = new StringBuffer(str);<br \/>\n            while (len &gt; tempBuffer.length()) {<br \/>\n                if (position.equalsIgnoreCase(\u201cf\u201d)) {<br \/>\n                    tempBuffer.insert(0, addStr);<br \/>\n                } else {<br \/>\n                    tempBuffer.append(addStr);<br \/>\n                }<br \/>\n            }<br \/>\n            return tempBuffer.toString();<br \/>\n        }<br \/>\n        return str;<br \/>\n    }<\/p>\n<p>}<br \/>\n<\/textarea><\/p>","protected":false},"excerpt":{"rendered":"<p>Java reflection made easy Introducing a utility class that allows you to easily use the Java reflection API [\u2026]<\/p>","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":""},"categories":[19],"tags":[],"_links":{"self":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/917"}],"collection":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/comments?post=917"}],"version-history":[{"count":6,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/917\/revisions"}],"predecessor-version":[{"id":1896,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/posts\/917\/revisions\/1896"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/media?parent=917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/categories?post=917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/en\/wp-json\/wp\/v2\/tags?post=917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}