OSDN Git Service

save
authoriga <tosiki.iga@nifty.ne.jp>
Tue, 1 Apr 2014 12:22:34 +0000 (21:22 +0900)
committeriga <tosiki.iga@nifty.ne.jp>
Tue, 1 Apr 2014 12:22:34 +0000 (21:22 +0900)
jcfa/src/jp/igapyon/jcfa/JavaClassFileAnalyzer.java
jcfa/src/jp/igapyon/jcfa/util/JcfaWriteUtil.java
jcfa/src/jp/igapyon/jcfa/vo/JcfaMethod.java
jcfa/testJavaClass/output/test/TestJavaClass001.jcfa

index a11794f..1ae2884 100644 (file)
@@ -18,6 +18,7 @@ import org.apache.bcel.classfile.ConstantValue;
 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
@@ -156,6 +157,11 @@ public class JavaClassFileAnalyzer {
                        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
index d24d4a0..0917c22 100644 (file)
@@ -84,6 +84,13 @@ public class JcfaWriteUtil {
                result.append(";");
        }
 
+       /**
+        * Write method.
+        * 
+        * @param jcfaClass
+        * @param jcfaMethod
+        * @param result
+        */
        public static void writeToBuffer(final JcfaClass jcfaClass,
                        final JcfaMethod jcfaMethod, final StringBuffer result) {
 
@@ -92,12 +99,19 @@ public class JcfaWriteUtil {
                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()) {
@@ -106,8 +120,16 @@ public class JcfaWriteUtil {
                        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");
index 34cdbcf..8e6b3e0 100644 (file)
@@ -3,12 +3,32 @@ package jp.igapyon.jcfa.vo;
 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;
+       }
+
 }
index 030a2ae..c8fd808 100644 (file)
@@ -6,7 +6,9 @@ public class TestJavaClass001 {
        public TestJavaClass001() {
        }
 
-       /** Method. */
-       public void main() {
+       /**
+        * Method. java.lang.String[]
+        */
+       public V main() {
        }
 }
\ No newline at end of file