OSDN Git Service

save
authoriga <tosiki.iga@nifty.ne.jp>
Mon, 31 Mar 2014 21:53:48 +0000 (06:53 +0900)
committeriga <tosiki.iga@nifty.ne.jp>
Mon, 31 Mar 2014 21:53:48 +0000 (06:53 +0900)
jcfa/src/jp/igapyon/jcfa/JavaClassFileAnalyzer.java
jcfa/src/jp/igapyon/jcfa/util/JcfaWriteUtil.java
jcfa/src/jp/igapyon/jcfa/vo/JcfaField.java
jcfa/testJavaClass/output/test/TestJavaClass002.jcfa

index 2740724..011fde3 100644 (file)
@@ -110,20 +110,16 @@ public class JavaClassFileAnalyzer {
                String constValue = null;\r
                final ConstantValue cv = field.getConstantValue();\r
                if (cv != null) {\r
-                       jcfaField.setConstantValue(jc.getConstantPool().getConstantString(\r
-                                       cv.getConstantValueIndex(), Constants.CONSTANT_String));\r
+                       jcfaField.setConstantValue("\""\r
+                                       + jc.getConstantPool().getConstantString(\r
+                                                       cv.getConstantValueIndex(),\r
+                                                       Constants.CONSTANT_String) + "\"");\r
 \r
                        jcfaField\r
                                        .getComment()\r
                                        .getCommentList()\r
-                                       .add("FIXME other type support is missing. Now only String.");\r
-\r
-                       jcfaField.setConstantValueType(Constants.CONSTANT_String);\r
+                                       .add("FIXME other type support is missing. <br />Now only String.");\r
                }\r
-\r
-               System.out.println("    " + access + field.getType().toString() + " "\r
-                               + field.getName()\r
-                               + (constValue == null ? "" : " = \"" + constValue + "\""));\r
        }\r
 \r
        private void analyzeMethods(final JavaClass jc, final JcfaClass jcfaClass)\r
index 5848ddf..3c236a9 100644 (file)
@@ -65,12 +65,22 @@ public class JcfaWriteUtil {
                result.append("}");
        }
 
+       /**
+        * Write field.
+        * 
+        * @param jcfaField
+        * @param result
+        */
        public static void writeToBuffer(final JcfaField jcfaField,
                        final StringBuffer result) {
                writeToBuffer(jcfaField.getComment(), result);
 
                result.append(" " + jcfaField.getAccess() + " " + jcfaField.getType()
                                + " " + jcfaField.getName());
+               if (jcfaField.getConstantValue() != null) {
+                       result.append(" = ");
+                       result.append(jcfaField.getConstantValue());
+               }
                result.append(";");
        }
 
index 6571dc2..4cda264 100644 (file)
@@ -9,8 +9,6 @@ public class JcfaField extends JcfaNode {
 
        protected String constantValue;
 
-       protected short constantValueType;
-
        public String getAccess() {
                return access;
        }
@@ -19,10 +17,6 @@ public class JcfaField extends JcfaNode {
                return constantValue;
        }
 
-       public short getConstantValueType() {
-               return constantValueType;
-       }
-
        public String getName() {
                return name;
        }
@@ -39,10 +33,6 @@ public class JcfaField extends JcfaNode {
                this.constantValue = constantValue;
        }
 
-       public void setConstantValueType(short constantValueType) {
-               this.constantValueType = constantValueType;
-       }
-
        public void setName(String name) {
                this.name = name;
        }
index 4e36029..c646f47 100644 (file)
@@ -2,8 +2,8 @@ package test;
 
 /*  TODO import func. is missing.  */
 public class TestJavaClass002 {
-       /* FIXME other type support is missing. Now only String. */
-       public static final java.lang.String TEST_001;
+       /* FIXME other type support is missing. <br />Now only String. */
+       public static final java.lang.String TEST_001 = "Hello jcfa world.";
        /*  */
        protected static java.lang.String test002;
        /*  */