public static String parseTLD(Class cls) {
StringBuilder sb = new StringBuilder();
Method methods[] = cls.getMethods();
for (Method m : methods) {
if ("Object".equals(m.getDeclaringClass().getSimpleName())
|| (m.getModifiers() != (Modifier.PUBLIC | Modifier.STATIC))) {
continue;
}
String s = "<function>\r\n";
s += "\t<name>" + m.getName();
Class[] cs = m.getParameterTypes();
String n = "", p = "";
for (Class c : cs) {
String sn = c.getSimpleName();
if (sn.indexOf("[]") != -1) {
n += sn.toLowerCase().substring(0, 1) + "x";
} else {
n += sn.toLowerCase().substring(0, 1);
}
p += c.getCanonicalName() + ",";
}
if (p.length() > 1) {
n = "_" + n;
p = p.substring(0, p.length() - 1);
}
s += n + "</name>\r\n";
s += "\t<function-class>" + m.getDeclaringClass().getName() + "</function-class>\r\n";
s += "\t<function-signature>" + m.getReturnType().getCanonicalName() + " " + m.getName() + "(" + p + ")"
+ "</function-signature>\r\n";
s += "</function>";
sb.append(s);
}
return sb.toString();
}
posted on 2011-10-14 15:01
SIMONE 阅读(555)
评论(0) 编辑 收藏 所属分类:
JAVA 、
JSP