(Object bean)
| 1108 | |
| 1109 | |
| 1110 | private void populateMap(Object bean) { |
| 1111 | Class klass = bean.getClass(); |
| 1112 | |
| 1113 | // If klass is a System class then set includeSuperClass to false. |
| 1114 | |
| 1115 | boolean includeSuperClass = klass.getClassLoader() != null; |
| 1116 | |
| 1117 | Method[] methods = includeSuperClass |
| 1118 | ? klass.getMethods() |
| 1119 | : klass.getDeclaredMethods(); |
| 1120 | for (int i = 0; i < methods.length; i += 1) { |
| 1121 | try { |
| 1122 | Method method = methods[i]; |
| 1123 | if (Modifier.isPublic(method.getModifiers())) { |
| 1124 | String name = method.getName(); |
| 1125 | String key = ""; |
| 1126 | if (name.startsWith("get")) { |
| 1127 | if ("getClass".equals(name) || |
| 1128 | "getDeclaringClass".equals(name)) { |
| 1129 | key = ""; |
| 1130 | } else { |
| 1131 | key = name.substring(3); |
| 1132 | } |
| 1133 | } else if (name.startsWith("is")) { |
| 1134 | key = name.substring(2); |
| 1135 | } |
| 1136 | if (key.length() > 0 && |
| 1137 | Character.isUpperCase(key.charAt(0)) && |
| 1138 | method.getParameterTypes().length == 0) { |
| 1139 | if (key.length() == 1) { |
| 1140 | key = key.toLowerCase(); |
| 1141 | } else if (!Character.isUpperCase(key.charAt(1))) { |
| 1142 | key = key.substring(0, 1).toLowerCase() + |
| 1143 | key.substring(1); |
| 1144 | } |
| 1145 | |
| 1146 | Object result = method.invoke(bean, (Object[])null); |
| 1147 | if (result != null) { |
| 1148 | this.map.put(key, wrap(result)); |
| 1149 | } |
| 1150 | } |
| 1151 | } |
| 1152 | } catch (Exception ignore) { |
| 1153 | } |
| 1154 | } |
| 1155 | } |
| 1156 | |
| 1157 | |
| 1158 | /** |
no test coverage detected