MCPcopy Index your code
hub / github.com/processing/processing / populateMap

Method populateMap

core/src/processing/data/JSONObject.java:1110–1155  ·  view source on GitHub ↗
(Object bean)

Source from the content-addressed store, hash-verified

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 /**

Callers 1

JSONObjectMethod · 0.95

Calls 7

wrapMethod · 0.95
getClassLoaderMethod · 0.80
getModifiersMethod · 0.80
startsWithMethod · 0.80
getNameMethod · 0.45
equalsMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected