import org.apache.bcel.classfile.Field;\r
import org.apache.bcel.classfile.JavaClass;\r
import org.apache.bcel.classfile.Method;\r
+import org.apache.bcel.generic.Type;\r
\r
public class JavaClassFileAnalyzer {\r
protected JcfaUnit jcfaUnit = new JcfaUnit();\r
jcfaMethod.getComment().getCommentList().add("Method.");\r
}\r
\r
+ for (Type type : method.getArgumentTypes()) {\r
+ jcfaMethod.getComment().getCommentList().add(type.toString());\r
+ }\r
+ jcfaMethod.setType(method.getReturnType().getSignature());\r
+\r
final Code code = method.getCode();\r
if (code == null) {\r
return;\r
result.append(";");
}
+ /**
+ * Write method.
+ *
+ * @param jcfaClass
+ * @param jcfaMethod
+ * @param result
+ */
public static void writeToBuffer(final JcfaClass jcfaClass,
final JcfaMethod jcfaMethod, final StringBuffer result) {
if (jcfaMethod.getName().equals("<init>")) {
result.append("public " + jcfaClass.getLocalName() + "() {");
} else {
- result.append("public void " + jcfaMethod.getName() + "() {");
+ result.append("public " + jcfaMethod.getType() + " "
+ + jcfaMethod.getName() + "() {");
}
result.append("}");
}
+ /**
+ * Write comment.
+ *
+ * @param jcfaComment
+ * @param result
+ */
public static void writeToBuffer(final JcfaComment jcfaComment,
final StringBuffer result) {
if (jcfaComment.isJavaDoc()) {
result.append("\n/* ");
}
+ if (jcfaComment.getCommentList().size() > 1) {
+ result.append("\n");
+ }
+
for (String comment : jcfaComment.getCommentList()) {
- result.append(" " + comment + " ");
+ if (jcfaComment.getCommentList().size() > 1) {
+ result.append(" * " + comment + "\n");
+ } else {
+ result.append(comment);
+ }
}
result.append(" */\n");
public class JcfaMethod extends JcfaNode {
protected String name;
+ protected String type;
+
+ protected String access;
+
+ public String getAccess() {
+ return access;
+ }
+
public String getName() {
return name;
}
+ public String getType() {
+ return type;
+ }
+
+ public void setAccess(String access) {
+ this.access = access;
+ }
+
public void setName(String name) {
this.name = name;
}
+ public void setType(String type) {
+ this.type = type;
+ }
+
}
public TestJavaClass001() {
}
- /** Method. */
- public void main() {
+ /**
+ * Method. java.lang.String[]
+ */
+ public V main() {
}
}
\ No newline at end of file