in src/main/java/com/alibaba/com/caucho/hessian/io/BeanSerializer.java [74:144]
public BeanSerializer(Class cl, ClassLoader loader) {
introspectWriteReplace(cl, loader);
ArrayList primitiveMethods = new ArrayList();
ArrayList compoundMethods = new ArrayList();
for (; cl != null; cl = cl.getSuperclass()) {
Method[] methods = cl.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
if (Modifier.isStatic(method.getModifiers()))
continue;
if (method.getParameterTypes().length != 0)
continue;
String name = method.getName();
if (!name.startsWith("get"))
continue;
Class type = method.getReturnType();
if (type.equals(void.class))
continue;
if (findSetter(methods, name, type) == null)
continue;
// XXX: could parameterize the handler to only deal with public
method.setAccessible(true);
if (type.isPrimitive()
|| type.getName().startsWith("java.lang.")
&& !type.equals(Object.class))
primitiveMethods.add(method);
else
compoundMethods.add(method);
}
}
ArrayList methodList = new ArrayList();
methodList.addAll(primitiveMethods);
methodList.addAll(compoundMethods);
Collections.sort(methodList, new MethodNameCmp());
_methods = new Method[methodList.size()];
methodList.toArray(_methods);
_names = new String[_methods.length];
for (int i = 0; i < _methods.length; i++) {
String name = _methods[i].getName();
name = name.substring(3);
int j = 0;
for (; j < name.length() && Character.isUpperCase(name.charAt(j)); j++) {
}
if (j == 1)
name = name.substring(0, j).toLowerCase() + name.substring(j);
else if (j > 1)
name = name.substring(0, j - 1).toLowerCase() + name.substring(j - 1);
_names[i] = name;
}
}