Patches made to SimpleGenerator.java

"Shannon Kendrick" <[email protected]> Mon, 31 Mar 2003 13:23:52 -0500
Newsgroups gmane.comp.java.enhydra.zeus
Message-ID <003a01c2f7b2$b26a1050$c357f309@sklaptop>
I've made some bug fixes to the SimpleGenerator code to correct some
compiler warnings and to escape some XML reserved characters. I'm not sure
what the most desirable way to contribute bug fixes back to the Zeus
project, but I've included a patch file here that was generated using the
Eclipse IDE.

Shannon Kendrick

Index: SimpleGenerator.java
===================================================================
RCS file:
/u/cvs/Projects/EnhydraOrg/toolsTech/Zeus/src/java/org/enhydra/zeus/generato
r/SimpleGenerator.java,v
retrieving revision 1.56
diff -u -r1.56 SimpleGenerator.java
--- SimpleGenerator.java 21 Nov 2002 15:30:07 -0000 1.56
+++ SimpleGenerator.java 31 Mar 2003 18:31:49 -0000
@@ -527,7 +527,7 @@
          * If any of the properties do not have a Java package then we
          *   must import them, unless they are primitive types.
          */
-        boolean firstCollection = true;
+        //boolean firstCollection = true;
         List properties = container.getProperties();
         for (Iterator i = properties.iterator(); i.hasNext(); ) {
             Property property = (Property)i.next();
@@ -538,10 +538,12 @@
             }

             if (property.isCollection()) {
+             /*
                 if (firstCollection) {
                     implementationImports.add("java.util.Iterator");
                     firstCollection = false;
                 }
+                */
                 String collectionClass = property.getJavaCollectionClass();
                 if (!implementationImports.contains(collectionClass)) {
                     implementationImports.add(collectionClass);
@@ -2026,9 +2028,9 @@
                     writer.write("            writer.write(\"<");
                     writer.write(property.getXMLName());
                     writer.write(">\");\n");
-                    writer.write("            writer.write(this.");
+                    writer.write("
writer.write(escapeTextValue(this.");
                     writer.write(property.getJavaVariableName());
-                    writer.write(");\n");
+                    writer.write("));\n");
                     writer.write("            writer.write(\"</");
                     writer.write(property.getXMLName());
                     writer.write(">\\n\");\n");
@@ -2125,6 +2127,14 @@
         writer.write("                    .append(returnValue.");
         writer.write("substring(i+1))\n");
         writer.write("                    .toString();\n");
+        writer.write("            } else if (ch == '&') {\n");
+        writer.write("                returnValue = new StringBuffer()\n");
+        writer.write("                    .append(returnValue.substring(");
+        writer.write("0, i))\n");
+        writer.write("                    .append(\"&amp;\")\n");
+        writer.write("                    .append(returnValue.");
+        writer.write("substring(i+1))\n");
+        writer.write("                    .toString();\n");
         writer.write("            }\n");
         writer.write("        }\n");
         writer.write("        return returnValue;\n");
@@ -2150,6 +2160,14 @@
         writer.write("                    .append(returnValue.substring(");
         writer.write("0, i))\n");
         writer.write("                    .append(\"&gt;\")\n");
+        writer.write("                    .append(returnValue.");
+        writer.write("substring(i+1))\n");
+        writer.write("                    .toString();\n");
+        writer.write("            } else if (ch == '&') {\n");
+        writer.write("                returnValue = new StringBuffer()\n");
+        writer.write("                    .append(returnValue.substring(");
+        writer.write("0, i))\n");
+        writer.write("                    .append(\"&amp;\")\n");
         writer.write("                    .append(returnValue.");
         writer.write("substring(i+1))\n");
         writer.write("                    .toString();\n");