[jboss-svn-commits] JBL Code SVN: r12904 - in labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools: xml and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jun 27 21:44:02 EDT 2007


Author: fmeyer
Date: 2007-06-27 21:44:02 -0400 (Wed, 27 Jun 2007)
New Revision: 12904

Modified:
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/DrlDumper.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/XmlDumper.java
Log:
JBRULES-546 -fixing DRLDumper and XMLDumper

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/DrlDumper.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/DrlDumper.java	2007-06-28 00:07:57 UTC (rev 12903)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/DrlDumper.java	2007-06-28 01:44:02 UTC (rev 12904)
@@ -123,6 +123,7 @@
             buf.append( " from " );
             this.template = buf.toString();
             visit( descr.getSource() );
+            buf.append( this.template );
         }
         this.template = buf.toString();
     }
@@ -143,7 +144,7 @@
 
     public void visitCollectDescr(final CollectDescr descr) {
         String tmpstr = new String();
-        tmpstr += this.template + " collect (";
+        tmpstr += " collect (";
         visitPatternDescr( descr.getInputPattern() );
         tmpstr += this.template.substring( 2 );
         this.template = tmpstr + ");";
@@ -151,7 +152,7 @@
 
     public void visitAccumulateDescr(final AccumulateDescr descr) {
         String tmpstr = new String();
-        tmpstr += this.template + " accumulate (";
+        tmpstr += " accumulate (";
         visitPatternDescr( descr.getInputPattern() );
         tmpstr += this.template.substring( 2 );
 
@@ -169,7 +170,7 @@
     }
 
     public void visitFromDescr(final FromDescr descr) {
-        this.template += descr.getDataSource();
+        this.template = descr.getDataSource().toString();
     }
 
     public void visitForallDescr(final ForallDescr descr) {

Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/XmlDumper.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/XmlDumper.java	2007-06-28 00:07:57 UTC (rev 12903)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/XmlDumper.java	2007-06-28 01:44:02 UTC (rev 12904)
@@ -88,21 +88,31 @@
 
     public void visitPatternDescr(final PatternDescr descr) {
         this.patternContext = true;
-
         this.template = new String();
+        StringBuffer localString = new StringBuffer();
+        
         if ( descr.getDescrs() != Collections.EMPTY_LIST ) {
             if ( descr.getIdentifier() != null ) {
-                this.template = "<pattern identifier=\"" + descr.getIdentifier() + "\" object-type=\"" + descr.getObjectType() + "\" >" + XmlDumper.eol + processDescrList( descr.getDescrs() ) + XmlDumper.eol + "</pattern>" + XmlDumper.eol;
+                localString.append("<pattern identifier=\"" + descr.getIdentifier() + "\" object-type=\"" + descr.getObjectType() + "\" >" + XmlDumper.eol + processDescrList( descr.getDescrs() ) + XmlDumper.eol);
             } else {
-                this.template = "<pattern object-type=\"" + descr.getObjectType() + "\" >" + XmlDumper.eol + processDescrList( descr.getDescrs() ) + XmlDumper.eol + "</pattern>" + XmlDumper.eol;
+                localString.append("<pattern object-type=\"" + descr.getObjectType() + "\" >" + XmlDumper.eol + processDescrList( descr.getDescrs() ) + XmlDumper.eol);
             }
         } else {
             if ( descr.getIdentifier() != null ) {
-                this.template = "<pattern identifier=\"" + descr.getIdentifier() + "\" object-type=\"" + descr.getObjectType() + "\" > </pattern>" + XmlDumper.eol;
+                localString.append("<pattern identifier=\"" + descr.getIdentifier() + "\" object-type=\"" + descr.getObjectType() + "\" >" + XmlDumper.eol);;
             } else {
-                this.template = "<pattern object-type=\"" + descr.getObjectType() + "\" > </pattern>" + XmlDumper.eol;
+                localString.append("<pattern object-type=\"" + descr.getObjectType() + "\" >" + XmlDumper.eol);
             }
         }
+        
+        if ( descr.getSource() != null ) {
+            visit(descr.getSource());
+            localString.append( this.template );
+        }
+        localString.append("</pattern>" + XmlDumper.eol);
+        
+        this.template = localString.toString();
+        
         this.patternContext = false;
     }
 
@@ -113,23 +123,16 @@
     }
 
     public void visitCollectDescr(final CollectDescr descr) {
-        String tmpstr = new String();
-        //visitPatternDescr( descr.getOutputPattern() );
-
-        this.template = this.template.substring( 0,
-                                                 this.template.indexOf( "</pattern>" ) );
-        tmpstr += this.template + " <from> <collect> ";
-        visitPatternDescr( descr.getInputPattern() );
-        tmpstr += this.template;
-        this.template = tmpstr + " </collect> </from> ";
-        this.template += "</pattern>";
+        StringBuffer tmpstr = new StringBuffer();
+        tmpstr.append( "<from> <collect>" );
+        visit(descr.getInputPattern() );
+        tmpstr.append( this.template );
+        tmpstr.append(" </collect> </from> ");
+        this.template = tmpstr.toString();
     }
 
     public void visitAccumulateDescr(final AccumulateDescr descr) {
         String tmpstr = new String();
-        //visit( descr.getOutputPattern() );
-        this.template = this.template.substring( 0,
-                                                 this.template.indexOf( "</pattern>" ) );
         tmpstr += this.template + " <from> <accumulate> ";
         visit( descr.getInputPattern() );
         tmpstr += this.template;
@@ -138,18 +141,13 @@
         else tmpstr += "<init>" + descr.getInitCode() + "</init><action>" + descr.getActionCode() + "</action><result>" + descr.getResultCode() + "</result>";
 
         this.template = tmpstr + " </accumulate> </from> ";
-        this.template += "</pattern>";
     }
 
     public void visitFromDescr(final FromDescr descr) {
         String tmpstr = new String();
-        //visitPatternDescr( descr.getOutputPattern() );
-        this.template = this.template.substring( 0,
-                                                 this.template.indexOf( "</pattern>" ) );
         tmpstr += this.template + " <from> <expression> ";
         tmpstr += descr.getDataSource();
         this.template = tmpstr + " </expression> </from> ";
-        this.template += "</pattern>";
     }
 
     public void visitForallDescr(final ForallDescr descr) {




More information about the jboss-svn-commits mailing list