[jboss-svn-commits] JBL Code SVN: r20568 - in labs/jbossrules/trunk: drools-decisiontables and 31 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jun 18 00:56:58 EDT 2008


Author: stevearoonie
Date: 2008-06-18 00:56:57 -0400 (Wed, 18 Jun 2008)
New Revision: 20568

Added:
   labs/jbossrules/trunk/drools-templates/
   labs/jbossrules/trunk/drools-templates/.classpath
   labs/jbossrules/trunk/drools-templates/.project
   labs/jbossrules/trunk/drools-templates/pom.xml
   labs/jbossrules/trunk/drools-templates/src/
   labs/jbossrules/trunk/drools-templates/src/main/
   labs/jbossrules/trunk/drools-templates/src/main/java/
   labs/jbossrules/trunk/drools-templates/src/main/java/org/
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/DataProvider.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/DataProviderCompiler.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Condition.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Consequence.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLElement.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLJavaEmitter.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLOutput.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Functions.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Global.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Import.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Package.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Rule.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/SnippetBuilder.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/AbstractColumn.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ArrayCell.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ArrayColumn.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Cell.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Column.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ColumnFactory.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DataListener.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DecisionTableParseException.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultGenerator.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateColumn.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateContainer.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateRuleBase.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Generator.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/LongCell.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/LongColumn.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Row.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/RuleTemplate.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/StringCell.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/StringColumn.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateColumn.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateContainer.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateDataListener.java
   labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateRuleBase.java
   labs/jbossrules/trunk/drools-templates/src/main/resources/
   labs/jbossrules/trunk/drools-templates/src/main/resources/org/
   labs/jbossrules/trunk/drools-templates/src/main/resources/org/drools/
   labs/jbossrules/trunk/drools-templates/src/main/resources/org/drools/template/
   labs/jbossrules/trunk/drools-templates/src/main/resources/org/drools/template/package.html
   labs/jbossrules/trunk/drools-templates/src/test/
   labs/jbossrules/trunk/drools-templates/src/test/java/
   labs/jbossrules/trunk/drools-templates/src/test/java/org/
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/DataProviderCompilerIntegrationTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/FunctionsRenderTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/PackageRenderTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/RuleRenderTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/SnippetBuilderTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/ColumnFactoryTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultGeneratorTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateContainerTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateRuleBaseTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/ExternalSheetListenerTest.java
   labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/RuleTemplateTest.java
   labs/jbossrules/trunk/drools-templates/src/test/resources/
   labs/jbossrules/trunk/drools-templates/src/test/resources/templates/
   labs/jbossrules/trunk/drools-templates/src/test/resources/templates/rule_template_1.drl
   labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_complex.drl
   labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_conditions.drl
   labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid1.drl
   labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid2.drl
   labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid3.drl
   labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid4.drl
   labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_simple.drl
Removed:
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/DataProvider.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/DataProviderCompiler.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/AbstractColumn.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ArrayCell.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ArrayColumn.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Cell.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Column.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ColumnFactory.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DecisionTableParseException.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultGenerator.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateColumn.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateContainer.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateRuleBase.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ExternalSheetListener.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Generator.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LongCell.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LongColumn.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Row.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleTemplate.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/SheetListener.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/StringCell.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/StringColumn.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateColumn.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateContainer.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateRuleBase.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/DataProviderCompilerIntegrationTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultGeneratorTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultTemplateContainerTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultTemplateRuleBaseTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ExternalSheetListenerTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleTemplateTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/rule_template_1.drl
   labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_complex.drl
   labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_conditions.drl
   labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid1.drl
   labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid2.drl
   labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid3.drl
   labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid4.drl
   labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_simple.drl
Modified:
   labs/jbossrules/trunk/drools-decisiontables/.classpath
   labs/jbossrules/trunk/drools-decisiontables/.project
   labs/jbossrules/trunk/drools-decisiontables/pom.xml
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/ExternalSpreadsheetCompiler.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/InputType.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/SpreadsheetCompiler.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LhsBuilder.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RhsBuilder.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleMatrixSheetListener.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetListener.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvParser.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/ExcelParser.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/NullSheetListener.java
   labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/PropertiesSheetListener.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/ExternalSpreadsheetCompilerIntegrationTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/SpreadsheetIntegrationTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ActionTypeTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ColumnFactoryTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/PropertiesSheetListenerTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleSheetParserUtilTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleWorksheetParseLargeTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleWorksheetParseTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RulesheetUtil.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/csv/CsvLineParserTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/csv/CsvParserTest.java
   labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/xls/ExcelParserTest.java
   labs/jbossrules/trunk/pom.xml
Log:
split drools-templates from drools-decisiontables

Modified: labs/jbossrules/trunk/drools-decisiontables/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/.classpath	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/.classpath	2008-06-18 04:56:57 UTC (rev 20568)
@@ -5,12 +5,13 @@
   <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="src" path="/drools-core"/>
+  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
+  <classpathentry kind="src" path="/drools-compiler"/>
   <classpathentry kind="var" path="M2_REPO/jexcelapi/jxl/2.4.2/jxl-2.4.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
-  <classpathentry kind="src" path="/drools-compiler"/>
-  <classpathentry kind="src" path="/drools-core"/>
   <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/2.0-SNAPSHOT/mvel-2.0-SNAPSHOT.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
   <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
+  <classpathentry kind="src" path="/drools-templates"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-decisiontables/.project
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/.project	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/.project	2008-06-18 04:56:57 UTC (rev 20568)
@@ -2,8 +2,9 @@
   <name>drools-decisiontables</name>
   <comment>A rule production system</comment>
   <projects>
+    <project>drools-core</project>
     <project>drools-compiler</project>
-    <project>drools-core</project>
+    <project>drools-templates</project>
   </projects>
   <buildSpec>
     <buildCommand>

Modified: labs/jbossrules/trunk/drools-decisiontables/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/pom.xml	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/pom.xml	2008-06-18 04:56:57 UTC (rev 20568)
@@ -22,6 +22,10 @@
       <groupId>org.drools</groupId>
       <artifactId>drools-compiler</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-templates</artifactId>
+    </dependency>
 
     <!-- External dependencies -->
     <dependency>

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/DataProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/DataProvider.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/DataProvider.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,9 +0,0 @@
-package org.drools.decisiontable;
-
-public interface DataProvider {
-
-    boolean hasNext();
-
-    String[] next();
-
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/DataProviderCompiler.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/DataProviderCompiler.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/DataProviderCompiler.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,127 +0,0 @@
-package org.drools.decisiontable;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.drools.decisiontable.parser.DefaultTemplateContainer;
-import org.drools.decisiontable.parser.ExternalSheetListener;
-import org.drools.decisiontable.parser.SheetListener;
-import org.drools.decisiontable.parser.TemplateContainer;
-
-public class DataProviderCompiler {
-
-    /**
-     * Generates DRL from the input stream containing the spreadsheet.
-     * 
-     * @param xlsStream
-     *            The stream to the spreadsheet. Uses the first worksheet found
-     *            for the decision tables, ignores others.
-     * @param type
-     *            The type of the file - InputType.CSV or InputType.XLS
-     * @param listener
-     * @return DRL xml, ready for use in drools.
-     * @throws IOException
-     */
-    public String compile(final DataProvider dataProvider,
-                          final String template) {
-        final InputStream templateStream = this.getClass().getResourceAsStream( template );
-        return compile( dataProvider,
-                        templateStream );
-    }
-
-    public String compile(final DataProvider dataProvider,
-                          final InputStream templateStream) {
-        TemplateContainer tc = new DefaultTemplateContainer( templateStream );
-        closeStream( templateStream );
-        return compile( dataProvider,
-                        new ExternalSheetListener( tc ) );
-    }
-
-    public String compile(final DataProvider dataProvider,
-                          final ExternalSheetListener listener) {
-        List listeners = new ArrayList();
-        listeners.add( listener );
-        processData( dataProvider,
-                     listeners );
-        return listener.renderDRL();
-    }
-
-    private void processData(final DataProvider dataProvider,
-                             List listeners) {
-        for ( int i = 0; dataProvider.hasNext(); i++ ) {
-            String[] row = dataProvider.next();
-            newRow( listeners,
-                    i,
-                    row.length );
-            for ( int cellNum = 0; cellNum < row.length; cellNum++ ) {
-                String cell = row[cellNum];
-
-                newCell( listeners,
-                         i,
-                         cellNum,
-                         cell,
-                         SheetListener.NON_MERGED );
-            }
-        }
-        finishData( listeners );
-    }
-
-    private void finishData(List listeners) {
-        for ( Iterator it = listeners.iterator(); it.hasNext(); ) {
-            SheetListener listener = (SheetListener) it.next();
-            listener.finishSheet();
-        }
-    }
-
-    private void newRow(List listeners,
-                        int row,
-                        int cols) {
-        for ( Iterator it = listeners.iterator(); it.hasNext(); ) {
-            SheetListener listener = (SheetListener) it.next();
-            listener.newRow( row,
-                             cols );
-        }
-    }
-
-    public void newCell(List listeners,
-                        int row,
-                        int column,
-                        String value,
-                        int mergedColStart) {
-        for ( Iterator it = listeners.iterator(); it.hasNext(); ) {
-            SheetListener listener = (SheetListener) it.next();
-            listener.newCell( row,
-                              column,
-                              value,
-                              mergedColStart );
-        }
-    }
-
-    private void closeStream(final InputStream stream) {
-        try {
-            stream.close();
-        } catch ( final Exception e ) {
-            System.err.print( "WARNING: Wasn't able to correctly close stream for rule template. " + e.getMessage() );
-        }
-    }
-
-}

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/ExternalSpreadsheetCompiler.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/ExternalSpreadsheetCompiler.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/ExternalSpreadsheetCompiler.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -23,10 +24,11 @@
 import java.util.Map;
 
 import org.drools.decisiontable.parser.DecisionTableParser;
-import org.drools.decisiontable.parser.ExternalSheetListener;
-import org.drools.decisiontable.parser.DefaultTemplateContainer;
-import org.drools.decisiontable.parser.TemplateContainer;
 import org.drools.decisiontable.parser.xls.ExcelParser;
+import org.drools.template.parser.DataListener;
+import org.drools.template.parser.DefaultTemplateContainer;
+import org.drools.template.parser.TemplateContainer;
+import org.drools.template.parser.TemplateDataListener;
 
 public class ExternalSpreadsheetCompiler {
 
@@ -60,7 +62,7 @@
 			int startCol) {
 		TemplateContainer tc = new DefaultTemplateContainer(templateStream);
 		closeStream(templateStream);
-		return compile(xlsStream, type, new ExternalSheetListener(startRow,
+		return compile(xlsStream, type, new TemplateDataListener(startRow,
 				startCol, tc));
 	}
 
@@ -69,28 +71,28 @@
 			int startRow, int startCol) {
 		TemplateContainer tc = new DefaultTemplateContainer(templateStream);
 		closeStream(templateStream);
-		return compile(xlsStream, worksheetName, new ExternalSheetListener(
+		return compile(xlsStream, worksheetName, new TemplateDataListener(
 				startRow, startCol, tc));
 	}
 
-	public void compile(final String xls, InputType type, final List listeners) {
+	public void compile(final String xls, InputType type, final List<DataListener> listeners) {
 		final InputStream xlsStream = this.getClass().getResourceAsStream(xls);
 		compile(xlsStream, type, listeners);
 	}
 
-	public void compile(final String xls, final Map listeners) {
+	public void compile(final String xls, final Map<String, List<DataListener>> listeners) {
 		final InputStream xlsStream = this.getClass().getResourceAsStream(xls);
 		compile(xlsStream, listeners);
 	}
 
 	public void compile(final InputStream xlsStream, InputType type,
-			final List listeners) {
+			final List<DataListener> listeners) {
 		final DecisionTableParser parser = type.createParser(listeners);
 		parser.parseFile(xlsStream);
 		closeStream(xlsStream);
 	}
 
-	public void compile(final InputStream xlsStream, final Map listeners) {
+	public void compile(final InputStream xlsStream, final Map<String, List<DataListener>> listeners) {
 		final DecisionTableParser parser = new ExcelParser(listeners);
 		parser.parseFile(xlsStream);
 		closeStream(xlsStream);
@@ -109,17 +111,17 @@
 	 * @throws IOException
 	 */
 	public String compile(final InputStream xlsStream, final InputType type,
-			final ExternalSheetListener listener) {
-		List listeners = new ArrayList();
+			final TemplateDataListener listener) {
+		ArrayList<DataListener> listeners = new ArrayList<DataListener>();
 		listeners.add(listener);
 		compile(xlsStream, type, listeners);
 		return listener.renderDRL();
 	}
 
 	public String compile(final InputStream xlsStream,
-			final String worksheetName, final ExternalSheetListener listener) {
-		Map listeners = new HashMap();
-		List l = new ArrayList();
+			final String worksheetName, final TemplateDataListener listener) {
+		Map<String, List<DataListener>> listeners = new HashMap<String, List<DataListener>>();
+		List<DataListener> l = new ArrayList<DataListener>();
 		l.add(listener);
 		listeners.put(worksheetName, l);
 		compile(xlsStream, listeners);

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/InputType.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/InputType.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/InputType.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -19,10 +19,10 @@
 import java.util.List;
 
 import org.drools.decisiontable.parser.DecisionTableParser;
-import org.drools.decisiontable.parser.SheetListener;
 import org.drools.decisiontable.parser.csv.CsvLineParser;
 import org.drools.decisiontable.parser.csv.CsvParser;
 import org.drools.decisiontable.parser.xls.ExcelParser;
+import org.drools.template.parser.DataListener;
 
 /**
  * Provides valid input types for decision tables.
@@ -42,17 +42,17 @@
      * @param listener
      * @return The appropriate Parser. 
      */
-    public abstract DecisionTableParser createParser(SheetListener listener);
-    public abstract DecisionTableParser createParser(List listeners);
+    public abstract DecisionTableParser createParser(DataListener listener);
+    public abstract DecisionTableParser createParser(List<DataListener> listeners);
 
 }
 
 class XlsInput extends InputType {
 
-    public DecisionTableParser createParser(final SheetListener listener) {
+    public DecisionTableParser createParser(final DataListener listener) {
         return new ExcelParser( listener );
     }
-    public DecisionTableParser createParser(final List listeners) {
+    public DecisionTableParser createParser(final List<DataListener> listeners) {
     	return new ExcelParser( listeners );
     }
 
@@ -60,12 +60,12 @@
 
 class CsvInput extends InputType {
 
-    public DecisionTableParser createParser(final SheetListener listener) {
+    public DecisionTableParser createParser(final DataListener listener) {
         return new CsvParser( listener,
                               new CsvLineParser() );
     }
 
-    public DecisionTableParser createParser(final List listeners) {
+    public DecisionTableParser createParser(final List<DataListener> listeners) {
     	return new CsvParser( listeners,
     			new CsvLineParser() );
     }

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/SpreadsheetCompiler.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/SpreadsheetCompiler.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/SpreadsheetCompiler.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -22,12 +22,13 @@
 import java.util.List;
 import java.util.Map;
 
-import org.drools.decisiontable.model.DRLOutput;
-import org.drools.decisiontable.model.Package;
 import org.drools.decisiontable.parser.DecisionTableParser;
 import org.drools.decisiontable.parser.DefaultRuleSheetListener;
 import org.drools.decisiontable.parser.RuleSheetListener;
 import org.drools.decisiontable.parser.xls.ExcelParser;
+import org.drools.template.model.DRLOutput;
+import org.drools.template.model.Package;
+import org.drools.template.parser.DataListener;
 
 /**
  * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
@@ -138,8 +139,8 @@
     private RuleSheetListener getRuleSheetListener(final InputStream stream,
                                                    final String worksheetName) {
         final RuleSheetListener listener = new DefaultRuleSheetListener();
-        final Map sheetListeners = new HashMap();
-        final List listeners = new ArrayList();
+        final Map<String, List<DataListener>> sheetListeners = new HashMap<String, List<DataListener>>();
+        final List<DataListener> listeners = new ArrayList<DataListener>();
         listeners.add(listener);
         sheetListeners.put( worksheetName,
                        listeners );

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/AbstractColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/AbstractColumn.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/AbstractColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,51 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import org.drools.util.StringUtils;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * Base column of in a decision table
- */
-public abstract class AbstractColumn implements Column {
-	private String name;
-
-	public AbstractColumn(String n) {
-		this.name = n;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public String getCondition(String condition, int index) {
-		StringBuffer conditionString = new StringBuffer(getCellType());
-		conditionString.append("(row == r, column == $param");
-		if (index != -1) {
-			conditionString.append(", index == ").append(index);
-		}
-		if (!StringUtils.isEmpty(condition)) {
-			conditionString.append(", value ").append(condition);
-		}
-		conditionString.append(")");
-		return conditionString.toString();
-	}
-	
-	
-}

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -18,6 +18,8 @@
 
 import java.util.Map;
 
+import org.drools.template.parser.DecisionTableParseException;
+
 /**
  * Simple holder class identifying a condition or action column etc.
  * This is stored in a map in the main listener class, to track what type of values
@@ -88,7 +90,7 @@
      * Create a new action type that matches this cell, and add it to the map,
      * keyed on that column.
      */
-    public static void addNewActionType(final Map actionTypeMap,
+    public static void addNewActionType(final Map<Integer, ActionType> actionTypeMap,
                                         final String value,
                                         final int column,
                                         final int row) {

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ArrayCell.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ArrayCell.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ArrayCell.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,88 +0,0 @@
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * Cell containing an array of values
- */
-package org.drools.decisiontable.parser;
-
-import java.util.Map;
-
-import org.drools.StatefulSession;
-import org.drools.util.StringUtils;
-
-public class ArrayCell implements Cell {
-	Row row;
-
-	String value;
-
-	ArrayColumn column;
-
-	private String[] values;
-	
-	public ArrayCell(final Row r, final ArrayColumn c) {
-		row = r;
-		column = c;
-	}
-
-	public void addValue(Map vars) {
-		for (int i = 0; i < values.length; i++) {
-			vars.put(column.getName() + i, values[i]);
-		}		
-	}
-
-	public Column getColumn() {
-		return column;
-	}
-
-	public Row getRow() {
-		return row;
-	}
-	
-	public String getValue() {
-		return value;
-	}
-
-	public void insert(StatefulSession session) {
-		session.insert(this);
-		for (int i = 0; i < values.length; i++) {
-			Cell cell = column.getType().createCell(row);
-			cell.setValue(values[i]);
-			cell.setIndex(i);
-			cell.insert(session);
-		}				
-	}
-
-	public void setIndex(int i) {
-		throw new RuntimeException("You cannot call setIndex on an ArrayCell");
-	}
-
-	public int getIndex() {
-		return -1;
-	}
-
-	public void setValue(String v) {
-		value = v;
-		values = StringUtils.splitPreserveAllTokens(value, ",");
-	}
-
-	public boolean isEmpty() {
-		return StringUtils.isEmpty(value);
-	}
-
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ArrayColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ArrayColumn.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ArrayColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,63 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.util.StringUtils;
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * A column in a decision table that represents an array (comma-delimited)
- * of values.
- */
-public class ArrayColumn extends AbstractColumn {
-
-	private Column type;
-
-	public ArrayColumn(String n, Column typeColumn) {
-		super(n);
-		this.type = typeColumn;
-	}
-
-	public Cell createCell(Row row) {
-		return new ArrayCell(row, this);
-	}
-
-	public String getCellType() {
-		return type.getCellType();
-	}
-	
-	public Column getType() {
-		return type;
-	}
-
-	public String getCondition(String condition, int index) {
-		if (index == -1) {
-			StringBuffer conditionString = new StringBuffer("ArrayCell(row == r, column == $param");
-			if (!StringUtils.isEmpty(condition)) {
-				conditionString.append(", value ").append(condition);
-			}
-			conditionString.append(")");
-			return conditionString.toString();
-		}
-		else
-		{
-			return type.getCondition(condition, index);
-		}
-		
-	}
-
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Cell.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Cell.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Cell.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,44 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import java.util.Map;
-
-import org.drools.StatefulSession;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * A cell in a decision table
- */
-public interface Cell {
-	public Row getRow();
-
-	public Column getColumn();
-	
-	public void setValue(String value);
-
-	public void addValue(Map vars);
-	
-	public void insert(StatefulSession session);
-
-	public void setIndex(int i);
-	
-	public int getIndex();
-
-	public boolean isEmpty();
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Column.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Column.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Column.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,33 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * A column in a decision table
- */
-public interface Column {
-	String getName();
-
-	Cell createCell(Row row);
-
-	String getCellType();
-
-	String getCondition(String condition, int index);
-
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ColumnFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ColumnFactory.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ColumnFactory.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,77 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * Factory to produce a column of the correct type based on its declaration.
- * [] indicates a column that represents an array (comma-delimited) of values.
- */
-public class ColumnFactory {
-    private final static Pattern PATTERN = Pattern.compile( "([a-zA-Z0-9_]*)(\\[\\])?(:\\s*([a-zA-Z]*)(\\[\\])?)?" );
-
-    public Column getColumn(String value) {
-        Matcher m = PATTERN.matcher( value );
-        if ( !m.matches() ) throw new IllegalArgumentException( "value " + value + " is not a valid column definition" );
-        String name = m.group( 1 );
-        String type = m.group( 4 );
-        type = type == null ? "String" : type;
-        boolean array = (m.group( 2 ) != null) || (m.group( 5 ) != null);
-        if ( array ) {
-            return new ArrayColumn( name,
-                                    createColumn( name,
-                                                  type ) );
-        }
-        return createColumn( name,
-                             type );
-    }
-
-    private Column createColumn(String name,
-                                String type) {
-        try {
-            Class klass = Class.forName( this.getClass().getPackage().getName() + "." + type + "Column" );
-            Constructor constructor = klass.getConstructor( new Class[]{String.class} );
-            return (Column) constructor.newInstance( new Object[]{name} );
-        } catch ( SecurityException e ) {
-            e.printStackTrace();
-            throw new RuntimeException( e );
-        } catch ( NoSuchMethodException e ) {
-            e.printStackTrace();
-            throw new RuntimeException( e );
-        } catch ( ClassNotFoundException e ) {
-            e.printStackTrace();
-            throw new RuntimeException( e );
-        } catch ( IllegalArgumentException e ) {
-            e.printStackTrace();
-            throw new RuntimeException( e );
-        } catch ( InstantiationException e ) {
-            e.printStackTrace();
-            throw new RuntimeException( e );
-        } catch ( IllegalAccessException e ) {
-            e.printStackTrace();
-            throw new RuntimeException( e );
-        } catch ( InvocationTargetException e ) {
-            e.printStackTrace();
-            throw new RuntimeException( e );
-        }
-    }
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DecisionTableParseException.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DecisionTableParseException.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DecisionTableParseException.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,32 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class DecisionTableParseException extends RuntimeException {
-
-    private static final long serialVersionUID = 400L;
-
-    public DecisionTableParseException(final String message) {
-        super( message );
-    }
-
-    public DecisionTableParseException(final String message,
-                                       final Throwable cause) {
-        super( message,
-               cause );
-    }
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultGenerator.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultGenerator.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultGenerator.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,98 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import org.mvel.templates.*;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * Generate the rules for a decision table row from a rule template.
- */
-public class DefaultGenerator implements Generator {
-
-	private Map ruleTemplates;
-
-	private TemplateRegistry registry = new SimpleTemplateRegistry();
-
-	private List rules = new ArrayList();
-
-	public DefaultGenerator(final Map t) {
-		ruleTemplates = t;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.drools.decisiontable.parser.Generator#generate(java.lang.String,
-	 *      org.drools.decisiontable.parser.Row)
-	 */
-	public void generate(String templateName, Row row) {
-		try {
-			CompiledTemplate template = getTemplate(templateName);
-            Map vars = new HashMap();
-			vars.put("row", row);
-
-			for (Iterator it = row.getCells().iterator(); it.hasNext();) {
-				Cell cell = (Cell) it.next();
-				cell.addValue(vars);
-			}
-
-            String drl = String.valueOf(TemplateRuntime.execute(template, vars, registry));
-
-			rules.add(drl);
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		}
-	}
-
-	private CompiledTemplate getTemplate(String templateName) throws IOException {
-        CompiledTemplate contents;
-		if (!registry.contains(templateName)) {
-			RuleTemplate template = (RuleTemplate) ruleTemplates
-					.get(templateName);
-			contents = TemplateCompiler.compileTemplate(template.getContents());
-            registry.addNamedTemplate( templateName, contents);
-		}
-        else {
-            contents = registry.getNamedTemplate(templateName);
-        }
-        return contents;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.drools.decisiontable.parser.Generator#getDrl()
-	 */
-	public String getDrl() {
-		StringBuffer sb = new StringBuffer();
-		for (Iterator it = rules.iterator(); it.hasNext();) {
-			String rule = (String) it.next();
-			sb.append(rule).append("\n");
-		}
-		return sb.toString();
-	}
-
-}

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -24,13 +24,14 @@
 import java.util.Map;
 import java.util.Properties;
 
-import org.drools.decisiontable.model.Condition;
-import org.drools.decisiontable.model.Consequence;
-import org.drools.decisiontable.model.Global;
-import org.drools.decisiontable.model.Import;
-import org.drools.decisiontable.model.Package;
-import org.drools.decisiontable.model.Rule;
 import org.drools.decisiontable.parser.xls.PropertiesSheetListener;
+import org.drools.template.model.Condition;
+import org.drools.template.model.Consequence;
+import org.drools.template.model.Global;
+import org.drools.template.model.Import;
+import org.drools.template.model.Package;
+import org.drools.template.model.Rule;
+import org.drools.template.parser.DecisionTableParseException;
 
 /**
  * @author <a href="mailto:shaun.addison at gmail.com"> Shaun Addison </a><a
@@ -83,12 +84,12 @@
     private boolean                       _currentSequentialFlag = false;                        // indicates that we are in sequential mode
 
     //accumulated output
-    private Map                           _actions;
-    private final HashMap                 _cellComments          = new HashMap();
-    private final List                    _ruleList              = new LinkedList();
+    private Map<Integer, ActionType>       _actions;
+    private final HashMap<Integer, String> _cellComments          = new HashMap<Integer, String>();
+    private final List<Rule>               _ruleList              = new LinkedList<Rule>();
 
     //need to keep an ordered list of this to make conditions appear in the right order
-    private List                          sourceBuilders         = new ArrayList();
+    private List<SourceBuilder>            sourceBuilders         = new ArrayList<SourceBuilder>();
 
     private final PropertiesSheetListener _propertiesListner     = new PropertiesSheetListener();
 
@@ -130,24 +131,24 @@
 
     private Package buildRuleSet() {
         final String defaultPackageName = this.defaultPackage != null ? this.defaultPackage.getName() : "rule_table";
-        final String rulesetName = getProperties().getProperty( DefaultRuleSheetListener.RULESET_TAG,
+        final String rulesetName = getProperties().getProperty( RULESET_TAG,
                                                                 defaultPackageName );
         final Package ruleset = new Package( rulesetName );
-        for ( final Iterator it = this._ruleList.iterator(); it.hasNext(); ) {
-            ruleset.addRule( (Rule) it.next() );
+        for ( Rule rule : this._ruleList ) {
+            ruleset.addRule( rule );
         }
-        final List importList = RuleSheetParserUtil.getImportList( getProperties().getProperty( DefaultRuleSheetListener.IMPORT_TAG ) );
-        for ( final Iterator it = importList.iterator(); it.hasNext(); ) {
-            ruleset.addImport( (Import) it.next() );
+        final List<Import> importList = RuleSheetParserUtil.getImportList( getProperties().getProperty( IMPORT_TAG ) );
+        for ( Import import1 : importList ) {
+            ruleset.addImport( import1 );
         }
-        final List variableList = RuleSheetParserUtil.getVariableList( getProperties().getProperty( DefaultRuleSheetListener.VARIABLES_TAG ) ); // Set the list of variables to
+        final List<Global> variableList = RuleSheetParserUtil.getVariableList( getProperties().getProperty( VARIABLES_TAG ) ); // Set the list of variables to
         // be added to the
         // application-data tags
-        for ( final Iterator it = variableList.iterator(); it.hasNext(); ) {
-            ruleset.addVariable( (Global) it.next() );
+        for ( Global global : variableList ) {
+            ruleset.addVariable( global );
         }
 
-        final String functions = getProperties().getProperty( DefaultRuleSheetListener.FUNCTIONS_TAG );
+        final String functions = getProperties().getProperty( FUNCTIONS_TAG );
         ruleset.addFunctions( functions );
         return ruleset;
     }
@@ -189,8 +190,8 @@
      * As when there are merged/spanned cells, they may be left out.
      */
     private void flushRule() {
-        for ( Iterator iter = sourceBuilders.iterator(); iter.hasNext(); ) {
-            SourceBuilder src = (SourceBuilder) iter.next();
+        for ( Iterator<SourceBuilder> iter = sourceBuilders.iterator(); iter.hasNext(); ) {
+            SourceBuilder src = iter.next();
             if ( src.hasValues() ) {
                 if ( src instanceof LhsBuilder ) {
                     Condition con = new Condition();
@@ -244,11 +245,11 @@
                           column,
                           value );
         this._isInRuleTable = true;
-        this._actions = new HashMap();
-        this.sourceBuilders = new ArrayList();
+        this._actions = new HashMap<Integer, ActionType>();
+        this.sourceBuilders = new ArrayList<SourceBuilder>();
         this._ruleStartColumn = column;
         this._ruleStartRow = row;
-        this._ruleRow = row + DefaultRuleSheetListener.LABEL_ROW + 1;
+        this._ruleRow = row + LABEL_ROW + 1;
 
         // setup stuff for the rules to come.. (the order of these steps are
         // important !)
@@ -287,7 +288,7 @@
     }
 
     private boolean getSequentialFlag() {
-        final String seqFlag = getProperties().getProperty( DefaultRuleSheetListener.SEQUENTIAL_FLAG );
+        final String seqFlag = getProperties().getProperty( SEQUENTIAL_FLAG );
         return RuleSheetParserUtil.isStringMeaningTrue( seqFlag );
     }
 
@@ -302,7 +303,7 @@
     private void processNonRuleCell(final int row,
                                     final int column,
                                     final String value) {
-        if ( value.startsWith( DefaultRuleSheetListener.RULE_TABLE_TAG ) ) {
+        if ( value.startsWith( RULE_TABLE_TAG ) ) {
             initRuleTable( row,
                            column,
                            value );
@@ -310,7 +311,7 @@
             this._propertiesListner.newCell( row,
                                              column,
                                              value,
-                                             SheetListener.NON_MERGED );
+                                             RuleSheetListener.NON_MERGED );
         }
     }
 
@@ -318,7 +319,7 @@
                                  final int column,
                                  final String value,
                                  final int mergedColStart) {
-        if ( value.startsWith( DefaultRuleSheetListener.RULE_TABLE_TAG ) ) {
+        if ( value.startsWith( RULE_TABLE_TAG ) ) {
             finishRuleTable();
             initRuleTable( row,
                            column,
@@ -384,7 +385,7 @@
         }
         ActionType action = getActionForColumn( row,
                                                 column );
-        if ( mergedColStart == SheetListener.NON_MERGED ) {
+        if ( mergedColStart == RuleSheetListener.NON_MERGED ) {
             if ( action.type == ActionType.CONDITION ) {
                 SourceBuilder src = new LhsBuilder( value );
                 action.setSourceBuilder( src );
@@ -455,7 +456,7 @@
 
     private ActionType getActionForColumn(final int row,
                                           final int column) {
-        final ActionType actionType = (ActionType) this._actions.get( new Integer( column ) );
+        final ActionType actionType = this._actions.get( new Integer( column ) );
 
         if ( actionType == null ) {
             throw new DecisionTableParseException( "Code description - row number:" + (row + 1) + " cell number:" + (column + 1) + " - does not have an 'ACTION' or 'CONDITION' column header." );
@@ -582,8 +583,4 @@
         return value == null || "".equals( value.trim() );
     }
 
-    private String cellComment(final int column) {
-        return "From column: " + Rule.convertColNumToColName( column );
-    }
-
 }
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateColumn.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,105 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.drools.decisiontable.model.Condition;
-import org.drools.decisiontable.model.Rule;
-import org.drools.decisiontable.model.SnippetBuilder;
-import org.drools.util.StringUtils;
-
-/**
- * 
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * The default column condition for a rule template to be generated. If the
- * conditon starts with "!" then the template will only be generated if the
- * column condition does not exist. If there is no condition string then the
- * template will be generated only if the column contains a value. The condition
- * can be any valid rule condition.
- */
-class DefaultTemplateColumn implements TemplateColumn {
-	private static final Pattern COLUMN_PATTERN = Pattern
-			.compile("^(!?)([a-zA-Z0-9_]*)(\\[([0-9]+)\\])?\\s*(.*)");
-
-	private boolean notCondition;
-
-	private String columnName;
-
-	private String condition;
-
-	private TemplateContainer templateContainer;
-
-	private int index = -1;
-
-	DefaultTemplateColumn(TemplateContainer tc, String columnString) {
-		templateContainer = tc;
-		Matcher matcher = COLUMN_PATTERN.matcher(columnString);
-		if (!matcher.matches())
-			throw new IllegalArgumentException("column " + columnString
-					+ " is not valid");
-		notCondition = !StringUtils.isEmpty(matcher.group(1));
-		columnName = matcher.group(2);
-		String indexString = matcher.group(4);
-		condition = matcher.group(5);
-		if (!StringUtils.isEmpty(indexString)) {
-			index = Integer.parseInt(indexString);
-		}
-	}
-
-	private void createCellCondition(final Rule rule) {
-		StringBuffer conditionString = new StringBuffer();
-		Column column = templateContainer.getColumn(columnName);
-		column.getCondition(condition, index);
-		
-		if (notCondition) {
-			conditionString.append("not ");
-		}
-		conditionString.append("exists ");
-		conditionString.append(column.getCondition(condition, index));
-		SnippetBuilder snip = new SnippetBuilder(conditionString.toString());
-		Condition condition = new Condition();
-		condition.setSnippet(snip.build(columnName));
-		rule.addCondition(condition);
-	}
-
-	private void createColumnCondition(final Rule rule, final String value) {
-		SnippetBuilder colSnip = new SnippetBuilder(
-				"$param : Column(name == \"$param\")");
-		Condition colCondition = new Condition();
-		colCondition.setSnippet(colSnip.build(value));
-		rule.addCondition(colCondition);
-	}
-
-	public void addCondition(Rule rule) {
-		createColumnCondition(rule, columnName);
-		createCellCondition(rule);
-	}
-
-	public String getName() {
-		return columnName;
-	}
-
-	public boolean isNotCondition() {
-		return notCondition;
-	}
-
-	public String getCondition() {
-		return condition;
-	}
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateContainer.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateContainer.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateContainer.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,176 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * Container for a set of templates (residing in one file). This class will
- * parse the template file.
- * 
- */
-public class DefaultTemplateContainer implements TemplateContainer {
-	private String header;
-
-	private Map columnMap = new HashMap();
-
-	private List columns = new ArrayList();
-
-	private Map templates = new HashMap();
-
-	public DefaultTemplateContainer(final String template) {
-		this(DefaultTemplateContainer.class.getResourceAsStream(template));
-	}
-
-	public DefaultTemplateContainer(final InputStream templateStream) {
-		parseTemplate(templateStream);
-		validateTemplate();
-	}
-
-	private void validateTemplate() {
-		if (columns.size() == 0) {
-			throw new DecisionTableParseException("Missing header columns");
-		}
-		if (templates.size() == 0) {
-			throw new DecisionTableParseException("Missing templates");
-		}
-
-	}
-
-	private void parseTemplate(final InputStream templateStream) {
-		try {
-			final ColumnFactory cf = new ColumnFactory();
-			final BufferedReader templateReader = new BufferedReader(
-					new InputStreamReader(templateStream));
-			String line = null;
-			StringBuffer header = new StringBuffer();
-			boolean inTemplate = false;
-			boolean inHeader = false;
-			boolean inContents = false;
-			RuleTemplate template = null;
-			StringBuffer contents = new StringBuffer();
-			while ((line = templateReader.readLine()) != null) {
-				if (line.trim().length() > 0) {
-					if (line.startsWith("template header")) {
-						inHeader = true;
-					} else if (line.startsWith("template")) {
-						inTemplate = true;
-						String quotedName = line.substring(8).trim();
-						quotedName = quotedName.substring(1, quotedName
-								.length() - 1);
-						template = new RuleTemplate(quotedName, this);
-						addTemplate(template);
-
-					} else if (line.startsWith("package")) {
-						if (inHeader == false) {
-							throw new DecisionTableParseException(
-									"Missing header");
-						}
-						inHeader = false;
-						header.append(line).append("\n");
-					} else if (inHeader) {
-						addColumn(cf.getColumn(line.trim()));
-					} else if (!inTemplate && !inHeader) {
-						header.append(line).append("\n");
-					} else if (!inContents && line.startsWith("rule")) {
-						inContents = true;
-						contents.append(line).append("\n");
-					} else if (line.equals("end template")) {
-						template.setContents(contents.toString());
-						contents.setLength(0);
-						inTemplate = false;
-						inContents = false;
-					} else if (inContents) {
-						contents.append(line).append("\n");
-					} else if (inTemplate) {
-						template.addColumn(line.trim());
-					}
-				}
-
-			}
-			if (inTemplate) {
-				throw new DecisionTableParseException("Missing end template");
-			}
-			this.header = header.toString();
-
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		} finally {
-			if (templateStream != null)
-				closeStream(templateStream);
-		}
-	}
-
-	private void addTemplate(RuleTemplate template) {
-		templates.put(template.getName(), template);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.drools.decisiontable.parser.TemplateContainer#getTemplates()
-	 */
-	public Map getTemplates() {
-		return templates;
-	}
-
-	private void addColumn(Column c) {
-		columns.add(c);
-		columnMap.put(c.getName(), c);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.drools.decisiontable.parser.TemplateContainer#getColumns()
-	 */
-	public Column[] getColumns() {
-		return (Column[]) columns.toArray(new Column[columns.size()]);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.drools.decisiontable.parser.TemplateContainer#getHeader()
-	 */
-	public String getHeader() {
-		return header;
-	}
-
-	private void closeStream(final InputStream stream) {
-		try {
-			stream.close();
-		} catch (final Exception e) {
-			System.err.print("WARNING: Wasn't able to "
-					+ "correctly close stream for decision table. "
-					+ e.getMessage());
-		}
-	}
-
-	public Column getColumn(final String name) {
-		return (Column) columnMap.get(name);
-	}
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateRuleBase.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultTemplateRuleBase.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,160 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
-import org.drools.compiler.PackageBuilder;
-import org.drools.decisiontable.model.Condition;
-import org.drools.decisiontable.model.Consequence;
-import org.drools.decisiontable.model.DRLOutput;
-import org.drools.decisiontable.model.Global;
-import org.drools.decisiontable.model.Import;
-import org.drools.decisiontable.model.Rule;
-import org.drools.rule.Package;
-
-/**
- * 
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * Create a rule base for the set of rule templates in the 
- * TemplateContainer. These rules are used internally by the
- * engine to generate the actual decision table rules based on
- * which columns have been filled in.
- * 
- * Basically, if a rule template requires columns A and B then 
- * the template rule base will generate a rule with columns A and B
- * as the LHS and a RHS which triggers the rule to be generated.
- * ie.
- * rule "template1"
- *   when
- *     r : Row()
- *     column1 : Column(name == "column1")
- *     Cell(row == r, column == column1)
- *     column2 : Column(name == "column2")
- *     Cell(row == r, column == column2, value == "xyz")
- *   then
- *     generator.generate( "template1", r);
- *   end
- * 
- */
-public class DefaultTemplateRuleBase implements TemplateRuleBase {
-	private RuleBase ruleBase;
-
-	public DefaultTemplateRuleBase(final TemplateContainer tc) {
-		ruleBase = readRule(getDTRules(tc.getTemplates()));
-	}
-	
-	/* (non-Javadoc)
-	 * @see org.drools.decisiontable.parser.TemplateRuleBase#newWorkingMemory()
-	 */
-	public StatefulSession newStatefulSession() {
-		return ruleBase.newStatefulSession();
-	}
-	/**
-	 * 
-	 * @param templates
-	 * @return
-	 */
-	private String getDTRules(Map templates) {
-		org.drools.decisiontable.model.Package p = new org.drools.decisiontable.model.Package(
-				"org.drools.decisiontable.parser");
-		addImports(p);
-		addGlobals(p);
-		int i = 1;
-		for (Iterator it = templates.values().iterator(); it.hasNext();) {
-			RuleTemplate template = (RuleTemplate) it.next();
-
-			createTemplateRule(p, i++, template);
-		}
-		DRLOutput out = new DRLOutput();
-		p.renderDRL(out);
-		return out.getDRL();
-
-	}
-
-	private void createTemplateRule(org.drools.decisiontable.model.Package p, int index, RuleTemplate template) {
-		Rule rule = new Rule(template.getName(), null, index);
-		Condition condition = new Condition();
-		condition.setSnippet("r : Row()");
-		rule.addCondition(condition);
-		createColumnConditions(template, rule);
-		rule.addConsequence(createConsequence(template));
-		p.addRule(rule);
-	}
-
-	private void createColumnConditions(RuleTemplate template, Rule rule) {
-		List templateColumns = template.getColumns();
-		for (Iterator it = templateColumns.iterator(); it.hasNext();) {
-			TemplateColumn column = (TemplateColumn) it.next();
-			column.addCondition(rule);
-		}
-	}
-
-
-	private void addGlobals(org.drools.decisiontable.model.Package p) {
-		Global global = new Global();
-		global.setClassName(DefaultGenerator.class.getName());
-		global.setIdentifier("generator");
-		p.addVariable(global);
-	}
-
-	private void addImports(org.drools.decisiontable.model.Package p) {
-		Import drlImport1 = new Import();
-		drlImport1.setClassName(Map.class.getName());
-		Import drlImport2 = new Import();
-		drlImport2.setClassName(HashMap.class.getName());
-		p.addImport(drlImport1);
-		p.addImport(drlImport2);
-	}
-
-	private Consequence createConsequence(RuleTemplate template) {
-		StringBuffer action = new StringBuffer();
-		action.append("generator.generate( \"");
-		action.append(template.getName()).append("\", r);");
-		final Consequence consequence = new Consequence();
-		consequence.setSnippet(action.toString());
-		return consequence;
-	}
-
-	private RuleBase readRule(String drl) {
-		try {
-//			System.out.println(drl);
-			// read in the source
-			Reader source = new StringReader(drl);
-			PackageBuilder builder = new PackageBuilder();
-			builder.addPackageFromDrl(source);
-			Package pkg = builder.getPackage();
-
-			// add the package to a rulebase (deploy the rule package).
-			RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-			ruleBase.addPackage(pkg);
-			return ruleBase;
-
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		}
-	}
-
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ExternalSheetListener.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ExternalSheetListener.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ExternalSheetListener.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,137 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.StatefulSession;
-import org.drools.audit.WorkingMemoryFileLogger;
-import org.drools.decisiontable.model.DRLOutput;
-
-/**
- * SheetListener for creating rules from a template
- * 
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- */
-public class ExternalSheetListener implements SheetListener {
-
-	private int startRow = -1;
-
-	private boolean tableFinished = false;
-
-	private Row currentRow;
-
-	private Column[] columns;
-
-	private StatefulSession session;
-
-	private TemplateContainer templateContainer;
-
-	private int startCol;
-
-	private Generator generator;
-
-//	private WorkingMemoryFileLogger logger;
-
-	public ExternalSheetListener(final TemplateContainer tc) {
-		this(1, 1, tc);
-	}
-
-	public ExternalSheetListener(final int startRow, final int startCol,
-	                             final String template) {
-	    this(startRow, startCol, new DefaultTemplateContainer(template));
-	}
-	
-	public ExternalSheetListener(final int startRow, final int startCol,
-			final TemplateContainer tc) {
-		this(startRow, startCol, tc, new DefaultTemplateRuleBase(tc));
-	}
-
-	public ExternalSheetListener(final int startRow, final int startCol,
-			final TemplateContainer tc, final TemplateRuleBase rb) {
-		this(startRow, startCol, tc, rb,
-				new DefaultGenerator(tc.getTemplates()));
-	}
-
-	public ExternalSheetListener(final int startRow, final int startCol,
-			final TemplateContainer tc, final TemplateRuleBase ruleBase,
-			final Generator generator) {
-		this.startRow = startRow - 1;
-		this.startCol = startCol - 1;
-		columns = tc.getColumns();
-		this.templateContainer = tc;
-		session = ruleBase.newStatefulSession();
-//		logger = new WorkingMemoryFileLogger(session);
-//		logger.setFileName("log/event");
-		this.generator = generator;
-		session.setGlobal("generator", generator);
-		assertColumns();
-	}
-
-	private void assertColumns() {
-		for (int i = 0; i < columns.length; i++) {
-			session.insert(columns[i]);			
-		}
-	}
-
-	public void finishSheet() {
-		if (currentRow != null) {
-			session.insert(currentRow);
-		}
-		session.fireAllRules();
-//		logger.writeToDisk();
-		session.dispose();
-	}
-
-	public void newCell(int row, int column, String value, int mergedColStart) {
-		if (currentRow != null && column >= startCol && value != null
-				&& value.trim().length() > 0) {
-
-			int columnIndex = column - startCol;
-			// System.out.println("asserting cell " + row + ", " + column + ": "
-			// + value);
-			Cell cell = currentRow.getCell(columnIndex);
-			cell.setValue(value);
-			cell.insert(session);
-		}
-	}
-
-	public void newRow(int rowNumber, int columnCount) {
-		if (!tableFinished && rowNumber >= startRow) {
-			if (currentRow != null && currentRow.isEmpty()) {
-				currentRow = null;
-				tableFinished = true;
-			} else {
-				if (currentRow != null)
-					session.insert(currentRow);
-				currentRow = new Row(rowNumber, columns);
-			}
-		}
-	}
-
-	public void startSheet(String name) {
-
-	}
-
-	public String renderDRL() {
-		DRLOutput out = new DRLOutput();
-		out.writeLine(templateContainer.getHeader());
-
-		out.writeLine(generator.getDrl());
-		// System.err.println(out.getDRL());
-		return out.getDRL();
-	}
-
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Generator.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Generator.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Generator.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,28 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * <a href="stevearoonie at gmail.com">Steven Williams</a>
- * Generate the rules for a decision table
- */
-public interface Generator {
-
-	void generate(String templateName, Row row);
-
-	String getDrl();
-
-}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LhsBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LhsBuilder.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LhsBuilder.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -8,7 +8,7 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.drools.decisiontable.model.SnippetBuilder;
+import org.drools.template.model.SnippetBuilder;
 
 /**
  * This utility will build up a list of constraints for a column.
@@ -20,13 +20,13 @@
 public class LhsBuilder implements SourceBuilder {
 
     private String column;
-    private Map    constraints;
-    private List    values;
+    private Map<Integer, String> constraints;
+    private List<String> values;
     private boolean hasValues;
-    private static Set operators;
+    private static Set<String> operators;
 
     static {
-        operators = new HashSet();
+        operators = new HashSet<String>();
         operators.add( "==" );
         operators.add( "=" );
         operators.add( "!=" );
@@ -44,8 +44,8 @@
      */
     public LhsBuilder(String colDefinition) {
         this.column = colDefinition == null ? "" : colDefinition;
-        this.constraints = new HashMap();
-        this.values = new ArrayList();
+        this.constraints = new HashMap<Integer, String>();
+        this.values = new ArrayList<String>();
     }
 
     public void addTemplate(int column, String content) {
@@ -88,8 +88,8 @@
     public String getResult() {
         StringBuffer buf = new StringBuffer();
         if ( !isMultipleConstraints() ) {
-            for ( Iterator iter = values.iterator(); iter.hasNext(); ) {
-                String content = (String) iter.next();
+            for ( Iterator<String> iter = values.iterator(); iter.hasNext(); ) {
+                String content = iter.next();
                 buf.append( content );
                 if (iter.hasNext()) {
                     buf.append( '\n' );
@@ -99,7 +99,7 @@
         } else {
             buf.append( this.column );
             buf.append( '(' );
-            for ( Iterator iter = values.iterator(); iter.hasNext(); ) {
+            for ( Iterator<String> iter = values.iterator(); iter.hasNext(); ) {
                 buf.append( iter.next());
                 if (iter.hasNext()) {
                     buf.append( ", " );
@@ -140,8 +140,7 @@
         if (content.indexOf( "$param" ) != -1 || content.indexOf( "$1" ) != -1 ) {
             return FieldType.NORMAL_FIELD;
         }
-        for ( Iterator iter = operators.iterator(); iter.hasNext(); ) {
-            String op = (String) iter.next();
+        for ( String op : operators ) {
             if (content.endsWith( op )) {
                 return FieldType.OPERATOR_FIELD;
             }            

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LongCell.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LongCell.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LongCell.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,79 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import java.util.Map;
-
-import org.drools.StatefulSession;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * A cell in a decision table containing a long value
- */
-public class LongCell implements Cell {
-	Row row;
-
-	Long value;
-
-	Column column;
-
-	private int index;
-
-	public LongCell() {
-		
-	}
-	LongCell(Row r, Column c) {
-		row = r;
-		column = c;
-	}
-
-	public String toString() {
-		return "Cell[" + column + ": " + value + "]";
-	}
-
-	public Row getRow() {
-		return row;
-	}
-
-	public Column getColumn() {
-		return column;
-	}
-
-	public Long getValue() {
-		return value;
-	}
-
-	public void addValue(Map vars) {
-		vars.put(column.getName(), value);
-	}
-	public void insert(StatefulSession session) {
-		session.insert(this);
-	}
-	public void setIndex(int i) {
-		index = i;
-	}
-	public int getIndex() {
-		return index;
-	}
-	public void setValue(String v) {
-		value = new Long(v);
-	}
-	public boolean isEmpty() {
-		return value == null;
-	}
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LongColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LongColumn.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/LongColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,43 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.util.Map;
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * A column of type Long in a decision table
- */
-public class LongColumn extends AbstractColumn {
-
-	public LongColumn(String n) {
-		super(n);
-	}
-
-	public void addValue(Map vars, Object value) {
-		vars.put(getName(), value);
-	}
-
-	public Cell createCell(Row row) {
-		return new LongCell(row, this);
-	}
-
-	public String getCellType() {
-		return "LongCell";
-	}
-
-}

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RhsBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RhsBuilder.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RhsBuilder.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -6,7 +6,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.drools.decisiontable.model.SnippetBuilder;
+import org.drools.template.model.SnippetBuilder;
 
 /**
  * Builds up a consequence entry.
@@ -15,9 +15,9 @@
  */
 public class RhsBuilder implements SourceBuilder {
 
-    private Map     templates;
+    private Map<Integer, String> templates;
     private String  variable;
-    private List    values;
+    private List<String> values;
     private boolean hasValues;
 
     /**
@@ -27,8 +27,8 @@
      */
     public RhsBuilder(String boundVariable) {
         this.variable = boundVariable == null ? "" : boundVariable.trim();
-        this.templates = new HashMap();
-        this.values = new ArrayList();
+        this.templates = new HashMap<Integer, String>();
+        this.values = new ArrayList<String>();
     }
 
     public void addTemplate(int col,
@@ -63,7 +63,7 @@
     
     public String getResult() {
         StringBuffer buf = new StringBuffer();
-        for ( Iterator iter = this.values.iterator(); iter.hasNext(); ) {            
+        for ( Iterator<String> iter = this.values.iterator(); iter.hasNext(); ) {            
             buf.append( iter.next() );
             if (iter.hasNext()) {
                 buf.append( '\n' );

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Row.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Row.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/Row.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,70 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- *  
- * Represents a row in a decision table.
- */
-public class Row {
-    int  rowNum;
-    List cells = new ArrayList();
-
-    public Row() {
-    	
-    }
-    
-    Row(int r, Column[] columns) {
-        rowNum = r;
-        for (int i = 0; i < columns.length; i++) {
-			cells.add(columns[i].createCell(this));
-		}
-    }
-    
-    public int getRowNumber() {
-        return rowNum;
-    }
-
-    Cell getCell(int columnIndex)
-    {
-    	return (Cell) cells.get(columnIndex);
-    }
-    
-    boolean isEmpty() {
-    	for (Iterator it = cells.iterator(); it.hasNext();) {
-			Cell cell = (Cell) it.next();
-			if (!cell.isEmpty())
-			{
-				return false;
-			}
-		}
-    	return true;
-    }
-    
-    public List getCells() {
-    	return cells;
-    }
-
-    public String toString() {
-        return "Row " + rowNum + cells + "\n";
-    }
-
-
-}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleMatrixSheetListener.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleMatrixSheetListener.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleMatrixSheetListener.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -19,11 +19,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.drools.decisiontable.model.Condition;
-import org.drools.decisiontable.model.Consequence;
-import org.drools.decisiontable.model.Rule;
-import org.drools.decisiontable.model.SnippetBuilder;
 import org.drools.decisiontable.parser.DefaultRuleSheetListener;
+import org.drools.template.model.Condition;
+import org.drools.template.model.Consequence;
+import org.drools.template.model.Rule;
+import org.drools.template.model.SnippetBuilder;
 import org.drools.util.StringUtils;
 
 /**
@@ -77,7 +77,7 @@
     private String             _action;
     private String             _horizontalCondition;
     private String             _verticalCondition;
-    private List               _horizontalConditions   = new ArrayList();
+    private List<Condition>    _horizontalConditions   = new ArrayList<Condition>();
     private Condition          _currentVerticalCondition;
     private boolean            isInRuleTable;
     private Rule               firstRule;

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetListener.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetListener.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetListener.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -18,7 +18,8 @@
 
 import java.util.Properties;
 
-import org.drools.decisiontable.model.Package;
+import org.drools.template.model.Package;
+import org.drools.template.parser.DataListener;
 /**
  * @author <a href="mailto:stevearoonie at gmail.com"> Steven Williams</a>
  * 
@@ -26,7 +27,7 @@
  */
 public interface RuleSheetListener
     extends
-    SheetListener {
+    DataListener {
 
     /**
      * Return the rule sheet properties

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -20,8 +20,9 @@
 import java.util.List;
 import java.util.StringTokenizer;
 
-import org.drools.decisiontable.model.Global;
-import org.drools.decisiontable.model.Import;
+import org.drools.template.model.Global;
+import org.drools.template.model.Import;
+import org.drools.template.parser.DecisionTableParseException;
 
 /**
  * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
@@ -53,8 +54,8 @@
      *            The cell text for all the classes to import.
      * @return A list of Import classes, which can be added to the ruleset.
      */
-    public static List getImportList(final String importCell) {
-        final List importList = new LinkedList();
+    public static List<Import> getImportList(final String importCell) {
+        final List<Import> importList = new LinkedList<Import>();
         if ( importCell == null ) {
             return importList;
         }
@@ -75,8 +76,8 @@
      *            The cell text for all the application data variables to set.
      * @return A list of Variable classes, which can be added to the ruleset.
      */
-    public static List getVariableList(final String variableCell) {
-        final List variableList = new LinkedList();
+    public static List<Global> getVariableList(final String variableCell) {
+        final List<Global> variableList = new LinkedList<Global>();
         if ( variableCell == null ) {
             return variableList;
         }

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleTemplate.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleTemplate.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleTemplate.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,125 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.drools.util.StringUtils;
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * A rule template made up of a name, the decision table columns required, the
- * decision table columns that must be empty and the contents of the rule.
- */
-public class RuleTemplate {
-	private String name;
-
-	private String contents;
-
-	private List columns;
-
-	private TemplateContainer templateContainer;
-
-	public RuleTemplate(final String n, final TemplateContainer tc) {
-		name = n;
-		columns = new ArrayList();
-		templateContainer = tc;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public List getColumns() {
-		return columns;
-	}
-
-	public String getContents() {
-		return contents;
-	}
-
-	public void addColumn(String columnString) {
-		TemplateColumn column = new DefaultTemplateColumn(templateContainer, columnString);
-		this.columns.add(column);
-	}
-
-	public void setContents(String contents) {
-		this.contents = replaceOptionals(contents);
-	}
-
-	/**
-	 * @see java.lang.Object#toString()
-	 */
-	public String toString() {
-		return "RuleTemplate[name," + this.name + "contents," + this.columns
-				+ "columns";
-	}
-
-	/*
-	 * Replace the optional columns in the rule contents with an if statement.
-	 * if (column is empty) do not show the line.
-	 */
-	private String replaceOptionals(String contents) {
-		try {
-			final Pattern pattern = Pattern.compile("@\\{(.[^}]*)\\}");
-			final Collection columns = getColumnNames();
-			columns.add("row.rowNumber");
-			final BufferedReader reader = new BufferedReader(new StringReader(
-					contents));
-			String line = null;
-			final StringBuffer newLine = new StringBuffer();
-			while ((line = reader.readLine()) != null) {
-				final Matcher matcher = pattern.matcher(line);
-				int optCols = 0;
-				while (matcher.find()) {
-					final String c = matcher.group(1);
-					if (!columns.contains(c)) {
-						newLine.append("@if{").append(matcher.group(1)).append(
-								" != null}");
-						optCols++;
-					}
-				}
-				newLine.append(line);
-				newLine.append(StringUtils.repeat("@end{}", optCols));
-				newLine.append("\n");
-			}
-//			System.out.println("newLine: " + newLine);
-			return newLine.toString();
-
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-	}
-
-	private Collection getColumnNames() {
-		Collection columnNames = new ArrayList();
-		for (Iterator it = getColumns().iterator(); it.hasNext();) {
-			TemplateColumn column = (TemplateColumn) it.next();
-			columnNames.add(column.getName());
-		}
-		return columnNames;
-	}
-
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/SheetListener.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/SheetListener.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/SheetListener.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,74 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:shaun.addison at gmail.com"> Shaun Addison </a>
- * 
- * Callback interface for scanning an spreadsheet.
- */
-public interface SheetListener {
-	
-    public static final int NON_MERGED = -1;
-
-    /**
-     * Start a new sheet
-     * 
-     * @param name
-     *            the sheet name
-     */
-    public void startSheet(String name);
-
-    /**
-     * Come to the end of the sheet.
-     */
-    public void finishSheet();
-
-    /**
-     * Enter a new row.
-     * 
-     * 
-     * @param rowNumber
-     *            
-     * @param columns
-     *            
-     */
-    public void newRow(int rowNumber,
-                       int columns);
-
-    /**
-     * Enter a new cell.
-     * Do NOT call this event for trailling cells at the end of the line. 
-     * It will just confuse the parser. If all the trailing cells are empty, just 
-     * stop raising events.
-     * 
-     * 
-     * @param row
-     *            the row number
-     * @param column
-     *            the column alpha character label
-     * @param value
-     *            the string value of the cell
-     * @param mergedCol
-     *            the "source" column if it is merged. -1 otherwise.           
-     */
-    public void newCell(int row,
-                        int column,
-                        String value,
-                        int mergedColStart);
-
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/StringCell.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/StringCell.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/StringCell.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,80 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import java.util.Map;
-
-import org.drools.StatefulSession;
-import org.drools.util.StringUtils;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * A cell in a decision table containing a String value
- */
-public class StringCell implements Cell {
-	Row row;
-
-	String value;
-
-	Column column;
-
-	private int index;
-
-	public StringCell() {
-		
-	}
-	StringCell(Row r, Column c) {
-		row = r;
-		column = c;
-	}
-
-	public String toString() {
-		return "Cell[" + column + ": " + value + "]";
-	}
-
-	public Row getRow() {
-		return row;
-	}
-
-	public Column getColumn() {
-		return column;
-	}
-
-	public Object getValue() {
-		return value;
-	}
-
-	public void addValue(Map vars) {
-		vars.put(column.getName(), value);
-	}
-	public int getIndex() {
-		return index;
-	}
-	public void insert(StatefulSession session) {
-		session.insert(this);
-	}
-	public void setIndex(int i) {
-		index = i;
-	}
-	public void setValue(String v) {
-		value = v;
-	}
-	public boolean isEmpty() {
-		return StringUtils.isEmpty(value);
-	}
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/StringColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/StringColumn.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/StringColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,43 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.util.Map;
-
-/**
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * A column of type String in a decision table
- */
-public class StringColumn extends AbstractColumn {
-
-	public StringColumn(String n) {
-		super(n);
-	}
-
-	public void addValue(Map vars, Object value) {
-		vars.put(getName(), value);
-	}
-
-	public Cell createCell(Row row) {
-		return new StringCell(row, this);
-	}
-
-	public String getCellType() {
-		return "StringCell";
-	}
-
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateColumn.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,32 +0,0 @@
-package org.drools.decisiontable.parser;
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import org.drools.decisiontable.model.Rule;
-/**
- * 
- * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
- * 
- * A column condition for a rule template to be generated.
- */
-interface TemplateColumn {
-	void addCondition(final Rule rule);
-
-	String getName();
-
-	boolean isNotCondition();
-
-	String getCondition();
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateContainer.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateContainer.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateContainer.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,30 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.util.Map;
-
-public interface TemplateContainer {
-
-	Map getTemplates();
-
-	Column[] getColumns();
-	
-	Column getColumn(String name);
-
-	String getHeader();
-
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateRuleBase.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/TemplateRuleBase.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,24 +0,0 @@
-package org.drools.decisiontable.parser;
-
-/*
- * Copyright 2005 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import org.drools.StatefulSession;
-
-public interface TemplateRuleBase {
-
-    StatefulSession newStatefulSession();
-
-}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvLineParser.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -35,7 +35,7 @@
      * Use the current lineParser implementation to return a CSV line as a List
      * of cells. (Strings).
      */
-    public List parse(final CharSequence line) {
+    public List<String> parse(final CharSequence line) {
         return this.lineParser.parse( line.toString() );
     }
 
@@ -44,7 +44,7 @@
      * handlers in the future.
      */
     static interface ICsvParser {
-        public List parse(String line);
+        public List<String> parse(String line);
     }
 
     /**
@@ -87,7 +87,7 @@
         }
 
         /** The fields in the current String */
-        protected List list = new ArrayList();
+        protected List<String> list = new ArrayList<String>();
 
         /** the separator char for this parser */
         protected char fieldSep;
@@ -98,7 +98,7 @@
          * @return java.util.Iterator containing each field from the original as
          *         a String, in order.
          */
-        public List parse(final String line) {
+        public List<String> parse(final String line) {
             final StringBuffer sb = new StringBuffer();
             this.list.clear(); // recycle to initial state
             int i = 0;

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvParser.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvParser.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/csv/CsvParser.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -21,12 +21,11 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
-import org.drools.decisiontable.parser.DecisionTableParseException;
 import org.drools.decisiontable.parser.DecisionTableParser;
-import org.drools.decisiontable.parser.SheetListener;
+import org.drools.template.parser.DataListener;
+import org.drools.template.parser.DecisionTableParseException;
 
 /**
  * Csv implementation. This implementation removes empty "cells" at the end of
@@ -44,18 +43,18 @@
  */
 public class CsvParser implements DecisionTableParser {
 
-	private List _listeners;
+	private List<DataListener> _listeners;
 
 	private CsvLineParser _lineParser;
 
-	public CsvParser(final SheetListener listener,
+	public CsvParser(final DataListener listener,
 			final CsvLineParser lineParser) {
-		_listeners = new ArrayList();
+		_listeners = new ArrayList<DataListener>();
 		_listeners.add(listener);
 		this._lineParser = lineParser;
 	}
 
-	public CsvParser(final List listeners, final CsvLineParser lineParser) {
+	public CsvParser(final List<DataListener> listeners, final CsvLineParser lineParser) {
 		this._listeners = listeners;
 		this._lineParser = lineParser;
 	}
@@ -74,30 +73,26 @@
 	}
 
 	private void startSheet() {
-		for (Iterator it = _listeners.iterator(); it.hasNext();) {
-			SheetListener listener = (SheetListener) it.next();
+	    for ( DataListener listener : _listeners ) {
 			listener.startSheet("csv");
 		}
 	}
 
 	private void finishSheet() {
-		for (Iterator it = _listeners.iterator(); it.hasNext();) {
-			SheetListener listener = (SheetListener) it.next();
+        for ( DataListener listener : _listeners ) {
 			listener.finishSheet();
 		}
 	}
 
 	private void newRow(final int row, final int numCells) {
-		for (Iterator it = _listeners.iterator(); it.hasNext();) {
-			SheetListener listener = (SheetListener) it.next();
+        for ( DataListener listener : _listeners ) {
 			listener.newRow(row, numCells);
 		}
 	}
 
 	private void newCell(final int row, final int column, final String value,
 			final int mergedColStart) {
-		for (Iterator it = _listeners.iterator(); it.hasNext();) {
-			SheetListener listener = (SheetListener) it.next();
+        for ( DataListener listener : _listeners ) {
 			listener.newCell(row, column, value, mergedColStart);
 		}
 	}
@@ -108,12 +103,12 @@
 		int row = 0;
 		while (line != null) {
 
-			final List cells = this._lineParser.parse(line);
+			final List<String> cells = this._lineParser.parse(line);
 			// remove the trailing empty "cells" which some tools smatter around
 			// trimCells(cells);
 			newRow(row, cells.size());
 
-			int startMergeCol = SheetListener.NON_MERGED;
+			int startMergeCol = DataListener.NON_MERGED;
 			for (int col = 0; col < cells.size(); col++) {
 				String cell = (String) cells.get(col);
 
@@ -130,32 +125,19 @@
 	}
 
 	String calcCellText(int startMergeCol, String cell) {
-		if (startMergeCol != SheetListener.NON_MERGED) {
+		if (startMergeCol != DataListener.NON_MERGED) {
 			cell = cell.substring(0, cell.length() - 3);
 		}
 		return cell;
 	}
 
 	int calcStartMerge(int startMergeCol, int col, String cell) {
-		if (cell.endsWith("...") && startMergeCol == SheetListener.NON_MERGED) {
+		if (cell.endsWith("...") && startMergeCol == DataListener.NON_MERGED) {
 			startMergeCol = col;
 		} else if (!cell.endsWith("...")) {
-			startMergeCol = SheetListener.NON_MERGED;
+			startMergeCol = DataListener.NON_MERGED;
 		}
 		return startMergeCol;
 	}
 
-	/** remove the trailing empty cells */
-	private void trimCells(final List cells) {
-		for (int i = cells.size() - 1; i > 0; i--) {
-			final String cell = (String) cells.get(i);
-			if (!cell.trim().equals("")) {
-				return;
-			} else {
-				cells.remove(i);
-			}
-		}
-
-	}
-
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/ExcelParser.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/ExcelParser.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/ExcelParser.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -20,10 +20,8 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import jxl.Cell;
 import jxl.Range;
@@ -31,9 +29,9 @@
 import jxl.Workbook;
 import jxl.read.biff.BiffException;
 
-import org.drools.decisiontable.parser.DecisionTableParseException;
 import org.drools.decisiontable.parser.DecisionTableParser;
-import org.drools.decisiontable.parser.SheetListener;
+import org.drools.template.parser.DataListener;
+import org.drools.template.parser.DecisionTableParseException;
 
 /**
  * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
@@ -44,7 +42,7 @@
     DecisionTableParser {
 
     public static final String DEFAULT_RULESHEET_NAME = "Decision Tables";
-    private Map                _listners              = new HashMap();
+    private Map<String, List<DataListener>> _listners = new HashMap<String, List<DataListener>>();
     private boolean            _useFirstSheet;
 
     /**
@@ -53,18 +51,18 @@
      * @param sheetListners
      *            map of String to SheetListener
      */
-    public ExcelParser(final Map sheetListners) {
+    public ExcelParser(final Map<String, List<DataListener>> sheetListners) {
         this._listners = sheetListners;
     }
 
-    public ExcelParser(final List sheetListners) {
+    public ExcelParser(final List<DataListener> sheetListners) {
         this._listners.put( ExcelParser.DEFAULT_RULESHEET_NAME,
                             sheetListners );
         this._useFirstSheet = true;
     }
 
-    public ExcelParser(final SheetListener listener) {
-        List listeners = new ArrayList();
+    public ExcelParser(final DataListener listener) {
+        List<DataListener> listeners = new ArrayList<DataListener>();
         listeners.add( listener );
         this._listners.put( ExcelParser.DEFAULT_RULESHEET_NAME,
                             listeners );
@@ -78,14 +76,12 @@
             if ( _useFirstSheet ) {
                 Sheet sheet = workbook.getSheet( 0 );
                 processSheet( sheet,
-                              (List) _listners.get( DEFAULT_RULESHEET_NAME ) );
+                              _listners.get( DEFAULT_RULESHEET_NAME ) );
             } else {
-                Set sheetNames = _listners.keySet();
-                for ( Iterator iter = sheetNames.iterator(); iter.hasNext(); ) {
-                    String sheetName = (String) iter.next();
+                for ( String sheetName : _listners.keySet() ) {
                     Sheet sheet = workbook.getSheet( sheetName );
                     processSheet( sheet,
-                                  (List) _listners.get( sheetName ) );
+                                  _listners.get( sheetName ) );
 
                 }
             }
@@ -101,7 +97,7 @@
     }
 
     private void processSheet(Sheet sheet,
-                              List listeners) {
+                              List<? extends DataListener> listeners) {
         int maxRows = sheet.getRows();
 
         Range[] mergedRanges = sheet.getMergedCells();
@@ -129,7 +125,7 @@
                              i,
                              cellNum,
                              cell.getContents(),
-                             SheetListener.NON_MERGED );
+                             DataListener.NON_MERGED );
                 }
             }
         }
@@ -157,30 +153,27 @@
         return stringVal;
     }
 
-    private void finishSheet(List listeners) {
-        for ( Iterator it = listeners.iterator(); it.hasNext(); ) {
-            SheetListener listener = (SheetListener) it.next();
+    private void finishSheet(List<? extends DataListener> listeners) {
+        for ( DataListener listener : listeners ) {
             listener.finishSheet();
         }
     }
 
-    private void newRow(List listeners,
+    private void newRow(List<? extends DataListener> listeners,
                         int row,
                         int cols) {
-        for ( Iterator it = listeners.iterator(); it.hasNext(); ) {
-            SheetListener listener = (SheetListener) it.next();
+        for ( DataListener listener : listeners ) {
             listener.newRow( row,
                              cols );
         }
     }
 
-    public void newCell(List listeners,
+    public void newCell(List<? extends DataListener> listeners,
                         int row,
                         int column,
                         String value,
                         int mergedColStart) {
-        for ( Iterator it = listeners.iterator(); it.hasNext(); ) {
-            SheetListener listener = (SheetListener) it.next();
+        for ( DataListener listener : listeners ) {
             listener.newCell( row,
                               column,
                               value,

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/NullSheetListener.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/NullSheetListener.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/NullSheetListener.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-import org.drools.decisiontable.parser.SheetListener;
+import org.drools.template.parser.DataListener;
 
 /**
  * @author <a href="mailto:shaun.addison at gmail.com"> Shaun Addison </a>
@@ -25,7 +25,7 @@
  */
 public class NullSheetListener
     implements
-    SheetListener {
+    DataListener {
 
     public void startSheet(final String name) {
     }

Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/PropertiesSheetListener.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/PropertiesSheetListener.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/xls/PropertiesSheetListener.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -17,11 +17,10 @@
  */
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
-import org.drools.decisiontable.parser.SheetListener;
+import org.drools.template.parser.DataListener;
 
 /**
  * Reads an Excel sheet as key-value properties.
@@ -38,11 +37,11 @@
  */
 public class PropertiesSheetListener
     implements
-    SheetListener {
+    DataListener {
 
     private static final String EMPTY_STRING   = "";
 
-    private final Map                 _rowProperties = new HashMap();
+    private final Map<Integer, String[]> _rowProperties = new HashMap<Integer, String[]>();
 
     private final Properties  _properties = new CaseInsensitiveMap();
 
@@ -74,8 +73,7 @@
      * @see my.hssf.util.SheetListener#finishSheet()
      */
     public void finishSheet() {
-        for ( final Iterator iter = this._rowProperties.keySet().iterator(); iter.hasNext(); ) {
-            final String[] keyValue = (String[]) this._rowProperties.get( iter.next() );
+        for ( String[] keyValue : _rowProperties.values() ) {
             this._properties.put( keyValue[0],
                                      keyValue[1] );
         }
@@ -124,6 +122,7 @@
         return value == null || value.trim().equals( "" );
     }
 
+    @SuppressWarnings("serial")
     public static class CaseInsensitiveMap extends Properties {
 
 
@@ -142,9 +141,7 @@
     	}
 
     	private String get(String key) {
-
-    		for (Iterator iterator = this.keySet().iterator(); iterator.hasNext();) {
-    			String k = (String) iterator.next();
+    	    for ( String k : this.stringPropertyNames() ) {
     			if (key.equalsIgnoreCase(k)) {
     				return super.getProperty(k);
     			}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/DataProviderCompilerIntegrationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/DataProviderCompilerIntegrationTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/DataProviderCompilerIntegrationTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,57 +0,0 @@
-package org.drools.decisiontable;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class DataProviderCompilerIntegrationTest extends TestCase {
-
-    private class TestDataProvider implements DataProvider {
-
-        private Iterator iterator;
-
-        TestDataProvider(List rows) {
-            this.iterator = rows.iterator();
-        }
-        public boolean hasNext() {
-            return iterator.hasNext();
-        }
-
-        public String[] next() {
-            return (String[]) iterator.next();
-        }
-        
-    }
-
-    public void testCompiler() throws Exception {
-        ArrayList rows = new ArrayList();
-        rows.add( createRow("1","STANDARD","FLAT",null,"SBLC","ISS","Commission",null,"USD",null,"750") ); 
-        rows.add( createRow("15","STANDARD","FLAT",null,"SBLC","ISS","Commission",null,"YEN",null,"1600") ); 
-        rows.add( createRow("12","STANDARD","FLAT",null,"SBLC","ISS","Postage",null,"YEN",null,"40") ); 
-        rows.add( createRow("62","STANDARD","FLAT",null,"SBLC","ISS","Telex",null,"YEN","< 30000","45") ); 
-        TestDataProvider tdp = new TestDataProvider(rows);
-        final DataProviderCompiler converter = new DataProviderCompiler();
-        final String drl = converter.compile(tdp, "/templates/rule_template_1.drl");
-        System.out.println(drl);
-        
-    }
-    
-    private String[] createRow(String cell1, String cell2, String cell3, String cell4, String cell5, String cell6, String cell7, String cell8, String cell9, String cell10, String cell11) {
-        String[] row = new String[11];
-        row[0] = cell1;
-        row[1] = cell2;
-        row[2] = cell3;
-        row[3] = cell4;
-        row[4] = cell5;
-        row[5] = cell6;
-        row[6] = cell7;
-        row[7] = cell8;
-        row[8] = cell9;
-        row[9] = cell10;
-        row[10] = cell11;
-        return row;
-    }
-    
-}

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/ExternalSpreadsheetCompilerIntegrationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/ExternalSpreadsheetCompilerIntegrationTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/ExternalSpreadsheetCompilerIntegrationTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -29,8 +29,9 @@
 import org.drools.WorkingMemory;
 import org.drools.compiler.DroolsError;
 import org.drools.compiler.PackageBuilder;
-import org.drools.decisiontable.parser.ExternalSheetListener;
 import org.drools.rule.Package;
+import org.drools.template.parser.DataListener;
+import org.drools.template.parser.TemplateDataListener;
 /**
  * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a> Some basic unit tests for converter utility.
  *         Note that some of this may still use the drools 2.x syntax, as it is not compiled, only tested that it
@@ -64,7 +65,7 @@
         wm.insert( new Person( "michael",
                                      "stilton",
                                      42 ) );
-        final List list = new ArrayList();
+        final List<String> list = new ArrayList<String>();
         wm.setGlobal( "list",
                       list );
         wm.fireAllRules();
@@ -77,10 +78,10 @@
     public void testPricing() throws Exception 
     {
         final ExternalSpreadsheetCompiler converter = new ExternalSpreadsheetCompiler();
-        final List listeners = new ArrayList();
-        ExternalSheetListener l1 = new ExternalSheetListener(10, 3, "/templates/test_pricing1.drl");
+        final List<DataListener> listeners = new ArrayList<DataListener>();
+        TemplateDataListener l1 = new TemplateDataListener(10, 3, "/templates/test_pricing1.drl");
 		listeners.add(l1);
-        ExternalSheetListener l2 = new ExternalSheetListener(30, 3, "/templates/test_pricing2.drl");
+        TemplateDataListener l2 = new TemplateDataListener(30, 3, "/templates/test_pricing2.drl");
 		listeners.add(l2);
 		converter.compile("/data/ExamplePolicyPricing.xls", InputType.XLS, listeners);
         //COMPILE

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/SpreadsheetIntegrationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/SpreadsheetIntegrationTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/SpreadsheetIntegrationTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -61,7 +61,7 @@
         wm.insert( new Person( "michael",
                                      "stilton",
                                      42 ) );
-        final List list = new ArrayList();
+        final List<String> list = new ArrayList<String>();
         wm.setGlobal( "list",
                       list );
         wm.fireAllRules();

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ActionTypeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ActionTypeTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ActionTypeTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -10,34 +10,34 @@
 public class ActionTypeTest extends TestCase {
 
     public void testChooseActionType() {
-        Map actionTypeMap = new HashMap();
+        Map<Integer, ActionType> actionTypeMap = new HashMap<Integer, ActionType>();
         ActionType.addNewActionType( actionTypeMap, "C", 0, 1 );
         
         ActionType type = (ActionType) actionTypeMap.get( new Integer(0) );
         assertEquals(ActionType.CONDITION, type.type);
         
         
-        actionTypeMap = new HashMap();
+        actionTypeMap = new HashMap<Integer, ActionType>();
         ActionType.addNewActionType( actionTypeMap, "A", 0, 1 );
         type = (ActionType) actionTypeMap.get( new Integer(0) );
         assertEquals(ActionType.ACTION, type.type);
         
-        actionTypeMap = new HashMap();
+        actionTypeMap = new HashMap<Integer, ActionType>();
         ActionType.addNewActionType( actionTypeMap, "X", 0, 1 );
         type = (ActionType) actionTypeMap.get( new Integer(0) );
         assertEquals(ActionType.ACTIVATIONGROUP, type.type);
         
-        actionTypeMap = new HashMap();
+        actionTypeMap = new HashMap<Integer, ActionType>();
         ActionType.addNewActionType( actionTypeMap, "ACTIVATION-GROUP", 0, 1 );
         type = (ActionType) actionTypeMap.get( new Integer(0) );
         assertEquals(ActionType.ACTIVATIONGROUP, type.type);
         
-        actionTypeMap = new HashMap();
+        actionTypeMap = new HashMap<Integer, ActionType>();
         ActionType.addNewActionType( actionTypeMap, "NO-LOOP", 0, 1 );
         type = (ActionType) actionTypeMap.get( new Integer(0) );
         assertEquals(ActionType.NOLOOP, type.type);
         
-        actionTypeMap = new HashMap();
+        actionTypeMap = new HashMap<Integer, ActionType>();
         ActionType.addNewActionType( actionTypeMap, "RULEFLOW-GROUP", 0, 1 );
         type = (ActionType) actionTypeMap.get( new Integer(0) );
         assertEquals(ActionType.RULEFLOWGROUP, type.type);

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ColumnFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ColumnFactoryTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ColumnFactoryTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,5 +1,11 @@
 package org.drools.decisiontable.parser;
 
+import org.drools.template.parser.ArrayColumn;
+import org.drools.template.parser.Column;
+import org.drools.template.parser.ColumnFactory;
+import org.drools.template.parser.LongColumn;
+import org.drools.template.parser.StringColumn;
+
 import junit.framework.TestCase;
 
 public class ColumnFactoryTest extends TestCase {

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultGeneratorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultGeneratorTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultGeneratorTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,76 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-public class DefaultGeneratorTest extends TestCase {
-	private DefaultGenerator g;
-
-    protected void setUp() throws Exception {
-        Map t = new HashMap();
-        TemplateContainer tc = new TemplateContainer() {
-
-			public Column getColumn(String name) {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			public Column[] getColumns() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			public String getHeader() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			public Map getTemplates() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-        	
-        };
-        RuleTemplate rt1 = new RuleTemplate("rt1", tc);
-        rt1.setContents("Test template 1");
-        RuleTemplate rt2 = new RuleTemplate("rt2", tc);
-        rt2.setContents("Test template 2");
-        RuleTemplate rt3 = new RuleTemplate("rt3", tc);
-        rt3.addColumn("col1");
-        rt3.addColumn("col2");
-        rt3.setContents("@{row.rowNumber} @{col1} @{col2}");
-        t.put("rt1", rt1);
-        t.put("rt2", rt2);
-        t.put("rt3", rt3);
-        g = new DefaultGenerator(t);
-    }
-    
-	public void testSelectTemplate() {
-		g.generate("rt2", new Row());
-		String drl = g.getDrl();
-		assertEquals("Test template 2\n\n", drl);
-	}
-	
-	public void testGenerate() {
-		g.generate("rt2", new Row());
-		g.generate("rt1", new Row());
-		String drl = g.getDrl();
-		assertEquals("Test template 2\n\nTest template 1\n\n", drl);
-	}
-	
-	public void testAddColumns() {
-		Column[] columns = {new StringColumn("col1"), new StringColumn("col2")};
-		Row r = new Row(1, columns);
-		r.getCell(0).setValue("value1");
-		r.getCell(1).setValue("value2");
-//		Row r = new Row(1);
-//		r.addCell(new StringCell(r, new StringColumn("col1"), "value1"));
-//		r.addCell(new StringCell(r, new StringColumn("col2"), "value2"));
-		g.generate("rt3", r);
-		String drl = g.getDrl();
-		assertEquals("1 value1 value2\n\n", drl);
-	}
-
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultTemplateContainerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultTemplateContainerTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultTemplateContainerTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,156 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-public class DefaultTemplateContainerTest extends TestCase {
-	public void testParseTemplate() {
-		InputStream is = DefaultTemplateContainerTest.class
-				.getResourceAsStream("/templates/test_template_simple.drl");
-		DefaultTemplateContainer t = new DefaultTemplateContainer(is);
-		assertEquals("package This_is_a_ruleset;\n", t.getHeader());
-		assertEquals(1, t.getColumns().length);
-		assertEquals("name", t.getColumns()[0].getName());
-		Map templates = t.getTemplates();
-		assertEquals(1, templates.size());
-		RuleTemplate template = (RuleTemplate) templates.get("template1");
-		assertNotNull(template);
-		List columns = template.getColumns();
-		assertEquals(1, columns.size());
-		TemplateColumn column = (TemplateColumn) columns.get(0);
-		assertEquals("name", column.getName());
-		String contents = template.getContents();
-		assertTrue(contents
-				.startsWith("rule \"How cool is @{name} @{row.rowNumber}\""));
-		assertTrue(contents.endsWith("then\nend\n"));
-	}
-
-	public void testParseTemplateConditions() {
-		InputStream is = DefaultTemplateContainerTest.class
-				.getResourceAsStream("/templates/test_template_conditions.drl");
-		DefaultTemplateContainer t = new DefaultTemplateContainer(is);
-		assertEquals("package This_is_a_ruleset;\n", t.getHeader());
-		assertEquals(1, t.getColumns().length);
-		assertEquals("name", t.getColumns()[0].getName());
-		Map templates = t.getTemplates();
-		assertEquals(1, templates.size());
-		RuleTemplate template = (RuleTemplate) templates.get("template1");
-		assertNotNull(template);
-		List columns = template.getColumns();
-		assertEquals(1, columns.size());
-		TemplateColumn templateColumn = (TemplateColumn) columns.get(0);
-		assertEquals("name", templateColumn.getName());
-		assertEquals("== \"name1\"", templateColumn.getCondition());
-		String contents = template.getContents();
-		assertTrue(contents
-				.startsWith("rule \"How cool is @{name} @{row.rowNumber}\""));
-		assertTrue(contents.endsWith("then\nend\n"));
-	}
-
-	public void testParseTemplateNoHeader() {
-		try {
-			InputStream is = DefaultTemplateContainerTest.class
-					.getResourceAsStream("/templates/test_template_invalid1.drl");
-			new DefaultTemplateContainer(is);
-			fail("DecisionTableParseException expected");
-		} catch (DecisionTableParseException expected) {
-			assertEquals("Missing header", expected.getMessage());
-		}
-	}
-
-	public void testParseTemplateNoHeaderColumns() {
-		try {
-			InputStream is = DefaultTemplateContainerTest.class
-					.getResourceAsStream("/templates/test_template_invalid2.drl");
-			new DefaultTemplateContainer(is);
-			fail("DecisionTableParseException expected");
-		} catch (DecisionTableParseException expected) {
-			assertEquals("Missing header columns", expected.getMessage());
-		}
-	}
-
-	public void testParseTemplateNoTemplates() {
-		try {
-			InputStream is = DefaultTemplateContainerTest.class
-					.getResourceAsStream("/templates/test_template_invalid3.drl");
-			new DefaultTemplateContainer(is);
-			fail("DecisionTableParseException expected");
-		} catch (DecisionTableParseException expected) {
-			assertEquals("Missing templates", expected.getMessage());
-		}
-	}
-
-	public void testParseTemplateNoEndTemplate() {
-		try {
-			InputStream is = DefaultTemplateContainerTest.class
-					.getResourceAsStream("/templates/test_template_invalid4.drl");
-			new DefaultTemplateContainer(is);
-			fail("DecisionTableParseException expected");
-		} catch (DecisionTableParseException expected) {
-			assertEquals("Missing end template", expected.getMessage());
-		}
-	}
-
-	public void testNullInputStream() {
-		try {
-			new DefaultTemplateContainer((InputStream) null);
-			fail("NullPointerException expected");
-		} catch (NullPointerException expected) {
-		}
-	}
-
-	public void testInvalidTemplatePath() {
-		try {
-			new DefaultTemplateContainer("invalid path");
-			fail("NullPointerException expected");
-		} catch (NullPointerException expected) {
-		}
-	}
-
-	public void testParseComplexTemplate() {
-		InputStream is = DefaultTemplateContainerTest.class
-				.getResourceAsStream("/templates/test_template_complex.drl");
-		DefaultTemplateContainer t = new DefaultTemplateContainer(is);
-		assertEquals("package This_is_a_ruleset;\n", t.getHeader());
-		Column[] columnList = t.getColumns();
-		assertEquals(5, columnList.length);
-		assertEquals("first_name", columnList[0].getName());
-		assertEquals("last_name", columnList[1].getName());
-		assertEquals("age", columnList[2].getName());
-		assertEquals("city", columnList[3].getName());
-		assertEquals("phone", columnList[4].getName());
-		assertEquals(columnList[1], t.getColumn("last_name"));
-		Map templates = t.getTemplates();
-		assertEquals(2, templates.size());
-
-		RuleTemplate template = (RuleTemplate) templates.get("template1");
-		assertNotNull(template);
-		List columns = template.getColumns();
-		assertEquals(1, columns.size());
-		TemplateColumn column = (TemplateColumn) columns.get(0);
-		assertEquals("first_name", column.getName());
-		
-		String contents = template.getContents();
-		assertTrue(contents
-				.startsWith("rule \"How cool is @{first_name} @{row.rowNumber}\""));
-		assertTrue(contents.endsWith("then\nend\n"));
-
-		template = (RuleTemplate) templates.get("template2");
-		assertNotNull(template);
-		columns = template.getColumns();
-		assertEquals(2, columns.size());
-		column = (TemplateColumn) columns.get(0);
-		assertEquals("first_name", column.getName());
-		TemplateColumn column2 = (TemplateColumn) columns.get(1);
-		assertEquals("last_name", column2.getName());
-		contents = template.getContents();
-		assertTrue(contents
-				.startsWith("rule \"How uncool is @{first_name} @{row.rowNumber}\""));
-		assertTrue(contents.endsWith("then\nend\n"));
-		
-
-	}
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultTemplateRuleBaseTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultTemplateRuleBaseTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/DefaultTemplateRuleBaseTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,97 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.drools.rule.GroupElement;
-import org.drools.rule.LiteralConstraint;
-import org.drools.rule.Package;
-import org.drools.rule.Rule;
-import org.drools.rule.VariableConstraint;
-
-public class DefaultTemplateRuleBaseTest extends TestCase {
-
-	public void testSimpleTemplate() throws Exception
-	{
-		TemplateContainer tc = new TemplateContainer() {
-			private Column[] columns = new Column[] {
-					new LongColumn("column1"),
-					new LongColumn("column2"),
-					new StringColumn("column3")
-			};
-			
-			public Column[] getColumns() {
-				return columns;
-			}
-
-			public String getHeader() {
-				return null;
-			}
-
-			public Map getTemplates() {
-				Map templates = new HashMap();
-				RuleTemplate ruleTemplate = new RuleTemplate("template1", this);
-				ruleTemplate.addColumn("column1 == 10");
-				ruleTemplate.addColumn("column2 < 5 || > 20");
-				ruleTemplate.addColumn("column3 == \"xyz\"");
-				templates.put("template1", ruleTemplate);
-				return templates;
-			}
-
-			public Column getColumn(String name) {
-				return columns[Integer.parseInt(name.substring(6)) - 1];
-			}
-			
-		};
-		DefaultTemplateRuleBase ruleBase = new DefaultTemplateRuleBase(tc);
-		Package[] packages = ruleBase.newStatefulSession().getRuleBase().getPackages();
-		assertEquals(1, packages.length);
-		Map globals = packages[0].getGlobals();
-		assertEquals(DefaultGenerator.class, globals.get("generator"));
-		Rule[] rules = packages[0].getRules();
-		assertEquals(1, rules.length);
-		assertEquals("template1", rules[0].getName());
-		GroupElement lhs = rules[0].getLhs();
-		//when
-		//  r : Row()
-		//  column1 : Column(name == "column1")
-		//  exists LongCell(row == r, column == column1, value == 10)
-		//  column2 : Column(name == "column2")
-		//  exists LongCell(row == r, column == column2, value < 5 | > 20)
-		//  column3 : Column(name == "column3")
-		//  exists StringCell(row == r, column == column3, value == "xyz")
-		assertEquals(7, lhs.getChildren().size());
-		org.drools.rule.Pattern pattern = (org.drools.rule.Pattern) lhs.getChildren().get(1);
-		assertEquals(1, pattern.getConstraints().size());
-		LiteralConstraint constraint = (LiteralConstraint) pattern.getConstraints().get(0);
-		assertEquals("column1", constraint.getField().getValue());
-		GroupElement exists = (GroupElement) lhs.getChildren().get(2);
-		pattern = (org.drools.rule.Pattern) exists.getChildren().get(0);
-		assertEquals(3, pattern.getConstraints().size());
-		VariableConstraint vconstraint = (VariableConstraint) pattern.getConstraints().get(1);
-		assertEquals(Column.class, vconstraint.getFieldExtractor().getExtractToClass());
-		assertEquals("column1", vconstraint.getRequiredDeclarations()[0].getIdentifier());
-		pattern = (org.drools.rule.Pattern) lhs.getChildren().get(3);
-		assertEquals(1, pattern.getConstraints().size());
-		constraint = (LiteralConstraint) pattern.getConstraints().get(0);
-		assertEquals("column2", constraint.getField().getValue());
-		exists = (GroupElement) lhs.getChildren().get(4);
-		pattern = (org.drools.rule.Pattern) exists.getChildren().get(0);
-		assertEquals(3, pattern.getConstraints().size());
-		vconstraint = (VariableConstraint) pattern.getConstraints().get(1);
-		assertEquals(Column.class, vconstraint.getFieldExtractor().getExtractToClass());
-		assertEquals("column2", vconstraint.getRequiredDeclarations()[0].getIdentifier());
-		pattern = (org.drools.rule.Pattern) lhs.getChildren().get(5);
-		assertEquals(1, pattern.getConstraints().size());
-		constraint = (LiteralConstraint) pattern.getConstraints().get(0);
-		assertEquals("column3", constraint.getField().getValue());
-		exists = (GroupElement) lhs.getChildren().get(6);
-		pattern = (org.drools.rule.Pattern) exists.getChildren().get(0);
-		assertEquals(3, pattern.getConstraints().size());
-		vconstraint = (VariableConstraint) pattern.getConstraints().get(1);
-		assertEquals(Column.class, vconstraint.getFieldExtractor().getExtractToClass());
-		assertEquals("column3", vconstraint.getRequiredDeclarations()[0].getIdentifier());
-	}
-}

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ExternalSheetListenerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ExternalSheetListenerTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/ExternalSheetListenerTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,503 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import junit.framework.TestCase;
-import org.drools.Agenda;
-import org.drools.FactException;
-import org.drools.FactHandle;
-import org.drools.ObjectFilter;
-import org.drools.QueryResults;
-import org.drools.RuleBase;
-import org.drools.StatefulSession;
-import org.drools.WorkingMemoryEntryPoint;
-import org.drools.concurrent.Future;
-import org.drools.event.AgendaEventListener;
-import org.drools.event.RuleBaseEventListener;
-import org.drools.event.RuleFlowEventListener;
-import org.drools.event.WorkingMemoryEventListener;
-import org.drools.process.instance.ProcessInstance;
-import org.drools.process.instance.WorkItemManager;
-import org.drools.process.instance.timer.TimerManager;
-import org.drools.rule.Rule;
-import org.drools.spi.Activation;
-import org.drools.spi.AgendaFilter;
-import org.drools.spi.AgendaGroup;
-import org.drools.spi.AsyncExceptionHandler;
-import org.drools.spi.GlobalResolver;
-import org.drools.time.SessionClock;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-public class ExternalSheetListenerTest extends TestCase {
-
-	private ExternalSheetListener esl;
-
-	private Map assertedRows = new HashMap();
-
-	private List currentRow = new ArrayList();
-
-	protected void setUp() throws Exception {
-		esl = new ExternalSheetListener(2, 2, new TestTemplateContainer(),
-				new TestTemplateRuleBase(), new TestGenerator());
-
-	}
-
-	public void testRenderDrl() {
-		String drl = esl.renderDRL();
-		assertEquals("Test Template Header\nTest Generated DRL\n", drl);
-	}
-
-	public void testRowHandling() {
-		esl.newRow(0, 3);
-		esl.newCell(0, 0, "row0col0", 0);
-		esl.newCell(0, 1, "row0col1", 0);
-		esl.newCell(0, 2, "row0col2", 0);
-		esl.newRow(1, 3);
-		esl.newCell(1, 0, "row1col0", 0);
-		esl.newCell(1, 1, "row1col1", 0);
-		esl.newCell(1, 2, "row1col2", 0);
-		esl.newRow(2, 3);
-		esl.newCell(2, 0, "row2col0", 0);
-		esl.newCell(2, 1, "row2col1", 0);
-		esl.newCell(2, 2, "row2col2", 0);
-		esl.finishSheet();
-		assertEquals(2, assertedRows.size());
-		for (Iterator it = assertedRows.entrySet().iterator(); it.hasNext();) {
-			Map.Entry entry = (Map.Entry) it.next();
-			Row row = (Row)entry.getKey();
-			List cells = (List) entry.getValue();
-			// first column is not part of the decision table
-			int i = 1;
-			for (Iterator it2 = cells.iterator(); it2.hasNext(); i++) {
-				StringCell cell = (StringCell) it2.next();
-				assertEquals("row" + row.getRowNumber() + "col" + i, cell.getValue());
-				assertEquals("Pattern " + i, cell.getColumn().getName());
-			}
-		}
-	}
-
-	public void testRowHandlingBlankRows() {
-		esl.newRow(0, 3);
-		esl.newCell(0, 0, "row0col0", 0);
-		esl.newCell(0, 1, "row0col1", 0);
-		esl.newCell(0, 2, "row0col2", 0);
-		esl.newRow(1, 3);
-		esl.newCell(1, 0, "row1col0", 0);
-		esl.newCell(1, 1, "row1col1", 0);
-		esl.newCell(1, 2, "row1col2", 0);
-		esl.newRow(2, 3);
-		esl.newCell(2, 0, "row2col0", 0);
-		esl.newCell(2, 1, "row2col1", 0);
-		esl.newCell(2, 2, "row2col2", 0);
-		esl.newRow(3, 3);
-		esl.newCell(3, 0, "", 0);
-		esl.newCell(3, 1, "", 0);
-		esl.newCell(3, 2, "", 0);
-		esl.newRow(4, 3);
-		esl.newCell(4, 0, "", 0);
-		esl.newCell(4, 1, "", 0);
-		esl.newCell(4, 2, "", 0);
-
-		esl.finishSheet();
-		assertEquals(2, assertedRows.size());
-	}
-
-	private class TestTemplateRuleBase implements TemplateRuleBase {
-
-		public StatefulSession newStatefulSession() {
-			return new StatefulSession() {
-                private static final long serialVersionUID = 1L;
-
-                public void addEventListener(WorkingMemoryEventListener arg0) {
-
-				}
-
-				public void addEventListener(AgendaEventListener arg0) {
-
-				}
-
-				public void addEventListener(RuleFlowEventListener arg0) {
-
-				}
-
-				public FactHandle insert(Object fact)
-						throws FactException {
-					if (fact instanceof Row) {
-						assertedRows.put(fact, currentRow);
-						currentRow = new ArrayList();
-					} else if (fact instanceof Cell) {
-						currentRow.add(fact);
-					}
-					return null;
-				}
-
-				public FactHandle insert(Object arg0, boolean arg1)
-						throws FactException {
-					return null;
-				}
-
-				public void clearAgenda() {
-
-				}
-
-				public void clearAgendaGroup(String arg0) {
-
-				}
-
-				public void dispose() {
-
-				}
-
-				public void fireAllRules() throws FactException {
-
-				}
-
-				public void fireAllRules(AgendaFilter arg0)
-						throws FactException {
-
-				}
-
-				public Agenda getAgenda() {
-					return null;
-				}
-
-				public List getAgendaEventListeners() {
-					return null;
-				}
-
-				public FactHandle getFactHandle(Object arg0) {
-					return null;
-				}
-
-				public List getFactHandles() {
-					return null;
-				}
-
-				public AgendaGroup getFocus() {
-					return null;
-				}
-
-				public Object getGlobal(String arg0) {
-					return null;
-				}
-
-				public Object getObject(FactHandle arg0) {
-					return null;
-				}
-
-				public QueryResults getQueryResults(String arg0) {
-					return null;
-				}
-
-				public RuleBase getRuleBase() {
-					return null;
-				}
-
-				public List getWorkingMemoryEventListeners() {
-					return null;
-				}
-
-				public void update(FactHandle arg0, Object arg1)
-						throws FactException {
-
-				}
-
-				public void removeEventListener(WorkingMemoryEventListener arg0) {
-
-				}
-
-				public void removeEventListener(AgendaEventListener arg0) {
-
-				}
-
-				public void removeEventListener(RuleFlowEventListener arg0) {
-
-				}
-
-				public void retract(FactHandle arg0) throws FactException {
-
-				}
-
-				public void setAsyncExceptionHandler(AsyncExceptionHandler arg0) {
-
-				}
-
-				public void setFocus(String arg0) {
-
-				}
-
-				public void setFocus(AgendaGroup arg0) {
-
-				}
-
-				public void setGlobal(String arg0, Object arg1) {
-
-				}
-
-				public void setGlobalResolver(GlobalResolver globalResolver) {
-
-				}
-
-				public ProcessInstance startProcess(String processId) {
-					return null;
-				}
-
-                public Iterator iterateFactHandles() {
-                    return null;
-                }
-
-                public Iterator iterateFactHandles(ObjectFilter filter) {
-                    return null;
-                }
-
-                public Iterator iterateObjects() {
-                    return null;
-                }
-
-                public Iterator iterateObjects(ObjectFilter filter) {
-                    return null;
-                }
-
-                public Future asyncInsert(Object object) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public Future asyncInsert(Object[] list) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public Future asyncInsert(Collection collection) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public Future asyncFireAllRules() {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public Future asyncFireAllRules(AgendaFilter agendaFilter) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public Future asyncUpdate(FactHandle factHandle,
-                                                Object object) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public Future asyncRetract(FactHandle factHandle) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public QueryResults getQueryResults(String query,
-                                                    Object[] arguments) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public void modifyInsert(FactHandle factHandle,
-                                         Object object,
-                                         Rule rule,
-                                         Activation activation) {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public void modifyRetract(FactHandle factHandle,
-                                          Rule rule,
-                                          Activation activation) {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public void modifyInsert(FactHandle factHandle,
-                                         Object object) {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public void modifyRetract(FactHandle factHandle) {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public void halt() {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public void fireAllRules(int fireLimit) throws FactException {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public void fireAllRules(AgendaFilter agendaFilter,
-                                         int fireLimit) throws FactException {
-                    // TODO Auto-generated method stub
-
-                }
-
-				public Future asyncInsert(List list) {
-					// TODO Auto-generated method stub
-					return null;
-				}
-
-                public GlobalResolver getGlobalResolver() {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public List getRuleFlowEventListeners() {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public void clearActivationGroup(String group) {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public void clearRuleFlowGroup(String group) {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public void addEventListener(RuleBaseEventListener listener) {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public List getRuleBaseEventListeners() {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public void removeEventListener(RuleBaseEventListener listener) {
-                    // TODO Auto-generated method stub
-
-                }
-
-                public List getRuleBaseUpdateListeners() {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public ProcessInstance getProcessInstance(long id) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public WorkItemManager getWorkItemManager() {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public Collection getProcessInstances() {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public ProcessInstance startProcess(String processId,
-                        Map<String, Object> parameters) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-				public FactHandle insert(Object object, long duration)
-						throws FactException {
-					// TODO Auto-generated method stub
-					return null;
-				}
-
-				public FactHandle insert(Object object, long duration,
-						boolean dynamic) throws FactException {
-					// TODO Auto-generated method stub
-					return null;
-				}
-
-                public FactHandle getFactHandleByIdentity(Object object) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String id) {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-
-                public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-                }
-
-                public void writeExternal(ObjectOutput out) throws IOException {
-                }
-
-				public TimerManager getTimerManager() {
-					// TODO Auto-generated method stub
-					return null;
-				}
-
-                public SessionClock getSessionClock() {
-                    // TODO Auto-generated method stub
-                    return null;
-                }
-			};
-		}
-	}
-
-	private class TestGenerator implements Generator {
-
-		public void generate(String templateName, Row row) {
-		}
-
-		public String getDrl() {
-			return "Test Generated DRL";
-		}
-
-	}
-
-	private class TestTemplateContainer implements TemplateContainer {
-
-		public void addColumn(Column c) {
-		}
-
-		public void addTemplate(RuleTemplate template) {
-		}
-
-		public Column[] getColumns() {
-			return new Column[] { new StringColumn("Pattern 1"),
-					new StringColumn("Pattern 2"), new StringColumn("Pattern 3") };
-		}
-
-		public String getHeader() {
-			return "Test Template Header";
-		}
-
-		public Map getTemplates() {
-			return null;
-		}
-
-		public void setHeader(String head) {
-		}
-
-		public void setTemplates(Map templates) {
-
-		}
-
-		public Column getColumn(String name) {
-			return null;
-		}
-	}
-
-}

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/PropertiesSheetListenerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/PropertiesSheetListenerTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/PropertiesSheetListenerTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -21,6 +21,7 @@
 import junit.framework.TestCase;
 
 import org.drools.decisiontable.parser.xls.PropertiesSheetListener;
+import org.drools.template.parser.DataListener;
 
 public class PropertiesSheetListenerTest extends TestCase {
 
@@ -33,23 +34,23 @@
 
         listener.newCell( 0,
                           0,
-                          "", SheetListener.NON_MERGED );
+                          "", DataListener.NON_MERGED );
 
         listener.newCell( 0,
                           1,
-                          "key1", SheetListener.NON_MERGED );
+                          "key1", DataListener.NON_MERGED );
         listener.newCell( 0,
                           2,
-                          "value1", SheetListener.NON_MERGED );
+                          "value1", DataListener.NON_MERGED );
 
         listener.newRow( 1,
                          4 );
         listener.newCell( 1,
                           1,
-                          "key2", SheetListener.NON_MERGED );
+                          "key2", DataListener.NON_MERGED );
         listener.newCell( 1,
                           3,
-                          "value2", SheetListener.NON_MERGED );
+                          "value2", DataListener.NON_MERGED );
 
         final Properties props = listener.getProperties();
 
@@ -57,7 +58,7 @@
                          4 );
         listener.newCell( 1,
                           1,
-                          "key3", SheetListener.NON_MERGED );
+                          "key3", DataListener.NON_MERGED );
 
         assertEquals( "value1",
                       props.getProperty( "Key1" ) );

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleSheetParserUtilTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleSheetParserUtilTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleSheetParserUtilTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -20,8 +20,9 @@
 
 import junit.framework.TestCase;
 
-import org.drools.decisiontable.model.Global;
-import org.drools.decisiontable.model.Import;
+import org.drools.template.model.Global;
+import org.drools.template.model.Import;
+import org.drools.template.parser.DecisionTableParseException;
 
 /**
  * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale</a>
@@ -63,7 +64,7 @@
 
     public void testListImports() {
         String cellVal = null;
-        List list = RuleSheetParserUtil.getImportList( cellVal );
+        List<Import> list = RuleSheetParserUtil.getImportList( cellVal );
         assertNotNull( list );
         assertEquals( 0,
                       list.size() );
@@ -76,22 +77,22 @@
         assertEquals( 3,
                       list.size() );
         assertEquals( "com.something.Yeah",
-                      ((Import) list.get( 0 )).getClassName() );
+                      (list.get( 0 )).getClassName() );
         assertEquals( "com.something.No",
-                      ((Import) list.get( 1 )).getClassName() );
+                      (list.get( 1 )).getClassName() );
         assertEquals( "com.something.yeah.*",
-                      ((Import) list.get( 2 )).getClassName() );
+                      (list.get( 2 )).getClassName() );
     }
 
     public void testListVariables() {
-        final List varList = RuleSheetParserUtil.getVariableList( "Var1 var1, Var2 var2,Var3 var3" );
+        final List<Global> varList = RuleSheetParserUtil.getVariableList( "Var1 var1, Var2 var2,Var3 var3" );
         assertNotNull( varList );
         assertEquals( 3,
                       varList.size() );
-        Global var = (Global) varList.get( 0 );
+        Global var = varList.get( 0 );
         assertEquals( "Var1",
                       var.getClassName() );
-        var = (Global) varList.get( 2 );
+        var = varList.get( 2 );
         assertEquals( "Var3",
                       var.getClassName() );
         assertEquals( "var3",

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleTemplateTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleTemplateTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleTemplateTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,70 +0,0 @@
-package org.drools.decisiontable.parser;
-
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.drools.util.StringUtils;
-
-public class RuleTemplateTest extends TestCase {
-	public void testSetContents() {
-		RuleTemplate rt = new RuleTemplate("rt1", getTemplateContainer());
-		rt.setContents("Test template");
-		assertEquals("Test template\n", rt.getContents());
-	}
-	
-	private TemplateContainer getTemplateContainer() {
-		return new TemplateContainer() {
-
-			public Column getColumn(String name) {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			public Column[] getColumns() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			public String getHeader() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			public Map getTemplates() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-			
-		};
-	}
-
-	public void testAddColumn() {
-		RuleTemplate rt = new RuleTemplate("rt1", getTemplateContainer());
-		rt.addColumn("StandardColumn");
-		rt.addColumn("!NotColumn");
-		rt.addColumn("ColumnCondition == \"test\"");
-		rt.addColumn("!NotColumnCondition == \"test2\"");
-		rt.addColumn("ArrayColumnCondition[0] == \"test2\"");
-		List columns = rt.getColumns();
-		assertEquals(5, columns.size());
-		TemplateColumn column1 = (TemplateColumn) columns.get(0);
-		assertEquals("StandardColumn", column1.getName());
-		assertFalse(column1.isNotCondition());
-		assertTrue(StringUtils.isEmpty(column1.getCondition()));
-		TemplateColumn column2 = (TemplateColumn) columns.get(1);
-		assertEquals("NotColumn", column2.getName());
-		assertTrue(column2.isNotCondition());
-		assertTrue(StringUtils.isEmpty(column2.getCondition()));
-		TemplateColumn column3 = (TemplateColumn) columns.get(2);
-		assertEquals("ColumnCondition", column3.getName());
-		assertFalse(column3.isNotCondition());
-		assertEquals("== \"test\"", column3.getCondition());
-		TemplateColumn column4 = (TemplateColumn) columns.get(3);
-		assertEquals("NotColumnCondition", column4.getName());
-		assertTrue(column4.isNotCondition());
-		assertEquals("== \"test2\"", column4.getCondition());
-		
-	}
-}

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleWorksheetParseLargeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleWorksheetParseLargeTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleWorksheetParseLargeTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -26,10 +26,10 @@
  */
 public class RuleWorksheetParseLargeTest extends TestCase {
 
-    private long startTimer;
+//    private long startTimer;
+//
+//    private long endTimer;
 
-    private long endTimer;
-
     /**
      * Tests parsing a large spreadsheet into an in memory ruleset. This doesn't
      * really do anything much at present. Takes a shed-load of memory to dump
@@ -63,16 +63,16 @@
          */
     }
 
-    private void startTimer() {
-        this.startTimer = System.currentTimeMillis();
-    }
+//    private void startTimer() {
+//        this.startTimer = System.currentTimeMillis();
+//    }
+//
+//    private void stopTimer() {
+//        this.endTimer = System.currentTimeMillis();
+//    }
+//
+//    private long getTime() {
+//        return this.endTimer - this.startTimer;
+//    }
 
-    private void stopTimer() {
-        this.endTimer = System.currentTimeMillis();
-    }
-
-    private long getTime() {
-        return this.endTimer - this.startTimer;
-    }
-
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleWorksheetParseTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleWorksheetParseTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RuleWorksheetParseTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -22,11 +22,11 @@
 
 import junit.framework.TestCase;
 
-import org.drools.decisiontable.model.Condition;
-import org.drools.decisiontable.model.Consequence;
-import org.drools.decisiontable.model.Import;
-import org.drools.decisiontable.model.Package;
-import org.drools.decisiontable.model.Rule;
+import org.drools.template.model.Condition;
+import org.drools.template.model.Consequence;
+import org.drools.template.model.Import;
+import org.drools.template.model.Package;
+import org.drools.template.model.Rule;
 
 /**
  * @author Shaun Addison, Michael Neale

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RulesheetUtil.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RulesheetUtil.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/RulesheetUtil.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -24,6 +24,7 @@
 import java.util.Map;
 
 import org.drools.decisiontable.parser.xls.ExcelParser;
+import org.drools.template.parser.DataListener;
 
 /**
  * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale</a>
@@ -35,8 +36,8 @@
      * Utility method showing how to get a rule sheet listener from a stream.
      */
     public static RuleSheetListener getRuleSheetListener(final InputStream stream) throws IOException {
-        final Map sheetListeners = new HashMap();
-        final List listeners = new ArrayList(); 
+        final Map<String, List<DataListener>> sheetListeners = new HashMap<String, List<DataListener>>();
+        final List<DataListener> listeners = new ArrayList<DataListener>(); 
         final RuleSheetListener listener = new DefaultRuleSheetListener();
         listeners.add(listener);
         sheetListeners.put( ExcelParser.DEFAULT_RULESHEET_NAME,

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/csv/CsvLineParserTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/csv/CsvLineParserTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/csv/CsvLineParserTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -25,7 +25,7 @@
     public void testSimpleLineParse() {
         final CsvLineParser parser = new CsvLineParser();
         final String s = "a,b,c";
-        final List list = parser.parse( s );
+        final List<String> list = parser.parse( s );
         assertEquals( 3,
                       list.size() );
 
@@ -40,7 +40,7 @@
     public void testLineParse() {
         final CsvLineParser parser = new CsvLineParser();
         final String s = "a,\"b\",c";
-        final List list = parser.parse( s );
+        final List<String> list = parser.parse( s );
         assertEquals( 3,
                       list.size() );
 
@@ -55,7 +55,7 @@
     public void testDoubleQuotes() {
         final CsvLineParser parser = new CsvLineParser();
         final String s = "a,\"\"\"b\"\"\",c";
-        final List list = parser.parse( s );
+        final List<String> list = parser.parse( s );
         assertEquals( 3,
                       list.size() );
 

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/csv/CsvParserTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/csv/CsvParserTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/csv/CsvParserTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -21,7 +21,7 @@
 
 import junit.framework.TestCase;
 
-import org.drools.decisiontable.parser.SheetListener;
+import org.drools.template.parser.DataListener;
 
 public class CsvParserTest extends TestCase {
 
@@ -29,7 +29,7 @@
         final MockSheetListener listener = new MockSheetListener();
         final CsvLineParser lineParser = new CsvLineParser();
         final CsvParser parser = new CsvParser( listener,
-                                          lineParser );
+                                                lineParser );
 
         parser.parseFile( getClass().getResourceAsStream( "/data/TestCsv.csv" ) );
         assertEquals( "A",
@@ -52,37 +52,54 @@
                                         3 ) );
 
     }
-    
+
     /**
      * Test the handling of merged cells.
      */
     public void testCellMergeHandling() {
-        CsvParser parser = new CsvParser((SheetListener)null, null);
-        assertEquals(SheetListener.NON_MERGED, parser.calcStartMerge( SheetListener.NON_MERGED, 1, "foo" ));
-        assertEquals(42, parser.calcStartMerge( SheetListener.NON_MERGED, 42, "..." ));
-        
-        assertEquals(42, parser.calcStartMerge( 42, 43, "..." ));
-        
-        assertEquals(SheetListener.NON_MERGED, parser.calcStartMerge( 42, 44, "VanHalen" ));
-        
-        
-        assertEquals("VanHalen", parser.calcCellText( SheetListener.NON_MERGED, "VanHalen" ));
-        assertEquals("VanHalen", parser.calcCellText( 42, "VanHalen..." ));
-        assertEquals("", parser.calcCellText( 42, "..." ));
-        
-        
+        CsvParser parser = new CsvParser( (DataListener) null,
+                                          null );
+        assertEquals( DataListener.NON_MERGED,
+                      parser.calcStartMerge( DataListener.NON_MERGED,
+                                             1,
+                                             "foo" ) );
+        assertEquals( 42,
+                      parser.calcStartMerge( DataListener.NON_MERGED,
+                                             42,
+                                             "..." ) );
+
+        assertEquals( 42,
+                      parser.calcStartMerge( 42,
+                                             43,
+                                             "..." ) );
+
+        assertEquals( DataListener.NON_MERGED,
+                      parser.calcStartMerge( 42,
+                                             44,
+                                             "VanHalen" ) );
+
+        assertEquals( "VanHalen",
+                      parser.calcCellText( DataListener.NON_MERGED,
+                                           "VanHalen" ) );
+        assertEquals( "VanHalen",
+                      parser.calcCellText( 42,
+                                           "VanHalen..." ) );
+        assertEquals( "",
+                      parser.calcCellText( 42,
+                                           "..." ) );
+
     }
 
     static class MockSheetListener
         implements
-        SheetListener {
+        DataListener {
 
-        Map data = new HashMap();
+        Map<String, String> data = new HashMap<String, String>();
 
         public String getCell(final int row,
                               final int col) {
-            return (String) this.data.get( cellKey( row,
-                                               col ) );
+            return this.data.get( cellKey( row,
+                                           col ) );
         }
 
         public void startSheet(final String name) {
@@ -102,14 +119,13 @@
                             final int mergeCellStart) {
 
             this.data.put( cellKey( row,
-                               column ),
-                      value );
+                                    column ),
+                           value );
         }
 
         String cellKey(final int row,
                        final int column) {
             return "R" + row + "C" + column;
         }
-
     }
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/xls/ExcelParserTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/xls/ExcelParserTest.java	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/parser/xls/ExcelParserTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -16,8 +16,11 @@
  * limitations under the License.
  */
 
+import java.util.List;
 import java.util.Map;
 
+import org.drools.template.parser.DataListener;
+
 import junit.framework.TestCase;
 import jxl.Cell;
 //import jxl.CellFeatures;
@@ -54,7 +57,7 @@
      * @throws Exception
      */
     public void testCellMerge() throws Exception {
-    	ExcelParser parser = new ExcelParser((Map) null);
+    	ExcelParser parser = new ExcelParser((Map<String, List<DataListener>>) null);
     	
     	Range[] ranges = new Range[1];
     	

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/rule_template_1.drl
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/rule_template_1.drl	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/rule_template_1.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,36 +0,0 @@
-template header
-FEE_SCHEDULE_ID
-FEE_SCHEDULE_TYPE
-FEE_MODE_TYPE
-ENTITY_BRANCH
-PRODUCT_TYPE
-ACTIVITY_TYPE
-FEE_TYPE
-OWNING_PARTY
-CCY
-LC_AMOUNT
-dummy
-AMOUNT
-
-
-package org.drools.decisiontable;
-#generated from Decision Table
-
-global FeeResult result;
-
-template "Fee Schedule"
-rule "Fee Schedule_@{row.rowNumber}"
-	agenda-group "@{FEE_SCHEDULE_TYPE}"
-	when
-		FeeEvent(productType == "@{PRODUCT_TYPE}",
-			activityType == "@{ACTIVITY_TYPE}",
-			feeType == "@{FEE_TYPE}",
-			txParty == "@{OWNING_PARTY}",
-			entityBranch == "@{ENTITY_BRANCH}",
-			amount @{LC_AMOUNT},
-			ccy == "@{CCY}"
-			)
-	then
-		result.setSchedule(new FeeSchedule("@{FEE_SCHEDULE_ID}", "@{FEE_SCHEDULE_TYPE}", @{AMOUNT}));	
-end
-end template

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_complex.drl
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_complex.drl	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_complex.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,27 +0,0 @@
-template header
-first_name
-last_name
-age
-city
-phone
-
-package This_is_a_ruleset;
-
-template "template1"
-first_name
-rule "How cool is @{first_name} @{row.rowNumber}"
-	when
-		user.getName().equals("@{first_name}")
-	then
-end
-end template
-
-template "template2"
-first_name
-last_name
-rule "How uncool is @{first_name} @{row.rowNumber}"
-	when
-		user.getFirstName().equals("@{first_name}")
-	then
-end
-end template

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_conditions.drl
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_conditions.drl	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_conditions.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,14 +0,0 @@
-template header
-name
-
-package This_is_a_ruleset;
-
-template "template1"
-name == "name1"
-rule "How cool is @{name} @{row.rowNumber}"
-	when
-		user.getName().equals("@{name}")
-	then
-end
-end template
-

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid1.drl
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid1.drl	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid1.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,11 +0,0 @@
-package This_is_a_ruleset;
-
-template "template1"
-name
-rule "How cool is @{name} @{row.rowNumber}"
-	when
-		user.getName().equals("@{name}")
-	then
-end
-end template
-

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid2.drl
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid2.drl	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid2.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,13 +0,0 @@
-template header
-
-package This_is_a_ruleset;
-
-template "template1"
-name
-rule "How cool is @{name} @{row.rowNumber}"
-	when
-		user.getName().equals("@{name}")
-	then
-end
-end template
-

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid3.drl
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid3.drl	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid3.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,13 +0,0 @@
-template header
-name
-
-package This_is_a_ruleset;
-
-name
-rule "How cool is @{name} @{row.rowNumber}"
-	when
-		user.getName().equals("@{name}")
-	then
-end
-end template
-

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid4.drl
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid4.drl	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_invalid4.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,14 +0,0 @@
-template header
-name
-
-package This_is_a_ruleset;
-
-template "template1"
-name
-rule "How cool is @{name} @{row.rowNumber}"
-	when
-		user.getName().equals("@{name}"
-	then
-end
-
-

Deleted: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_simple.drl
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_simple.drl	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template_simple.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -1,14 +0,0 @@
-template header
-name
-
-package This_is_a_ruleset;
-
-template "template1"
-name
-rule "How cool is @{name} @{row.rowNumber}"
-	when
-		user.getName().equals("@{name}")
-	then
-end
-end template
-


Property changes on: labs/jbossrules/trunk/drools-templates
___________________________________________________________________
Name: svn:ignore
   + .settings
target


Added: labs/jbossrules/trunk/drools-templates/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-templates/.classpath	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/.classpath	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,15 @@
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
+  <classpathentry kind="src" path="/drools-core"/>
+  <classpathentry kind="src" path="/drools-compiler"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/2.0-SNAPSHOT/mvel-2.0-SNAPSHOT.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
+</classpath>
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/.project
===================================================================
--- labs/jbossrules/trunk/drools-templates/.project	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/.project	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,16 @@
+<projectDescription>
+  <name>drools-templates</name>
+  <comment>A rule production system</comment>
+  <projects>
+    <project>drools-core</project>
+    <project>drools-compiler</project>
+  </projects>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-templates/pom.xml	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/pom.xml	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>drools</artifactId>
+    <groupId>org.drools</groupId>
+  <version>5.0.0.SNAPSHOT</version>
+  </parent>
+
+  <artifactId>drools-templates</artifactId>
+  <packaging>jar</packaging>
+  <name>Drools :: Templates</name>
+
+  <repositories>
+    <repository>
+      <id>basedir</id>
+      <url>file://${basedir}/../m2_repo</url>
+    </repository>
+  </repositories>  
+  
+  <dependencies>
+    <!-- Internal dependencies -->
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-compiler</artifactId>
+    </dependency>
+  </dependencies>
+
+</project>

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/DataProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/DataProvider.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/DataProvider.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,9 @@
+package org.drools.template;
+
+public interface DataProvider {
+
+    boolean hasNext();
+
+    String[] next();
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/DataProviderCompiler.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/DataProviderCompiler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/DataProviderCompiler.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,123 @@
+package org.drools.template;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.template.parser.DataListener;
+import org.drools.template.parser.DefaultTemplateContainer;
+import org.drools.template.parser.TemplateContainer;
+import org.drools.template.parser.TemplateDataListener;
+
+public class DataProviderCompiler {
+
+    /**
+     * Generates DRL from the input stream containing the spreadsheet.
+     * 
+     * @param xlsStream
+     *            The stream to the spreadsheet. Uses the first worksheet found
+     *            for the decision tables, ignores others.
+     * @param type
+     *            The type of the file - InputType.CSV or InputType.XLS
+     * @param listener
+     * @return DRL xml, ready for use in drools.
+     * @throws IOException
+     */
+    public String compile(final DataProvider dataProvider,
+                          final String template) {
+        final InputStream templateStream = this.getClass().getResourceAsStream( template );
+        return compile( dataProvider,
+                        templateStream );
+    }
+
+    public String compile(final DataProvider dataProvider,
+                          final InputStream templateStream) {
+        TemplateContainer tc = new DefaultTemplateContainer( templateStream );
+        closeStream( templateStream );
+        return compile( dataProvider,
+                        new TemplateDataListener( tc ) );
+    }
+
+    public String compile(final DataProvider dataProvider,
+                          final TemplateDataListener listener) {
+        List<DataListener> listeners = new ArrayList<DataListener>();
+        listeners.add( listener );
+        processData( dataProvider,
+                     listeners );
+        return listener.renderDRL();
+    }
+
+    private void processData(final DataProvider dataProvider,
+                             List<DataListener> listeners) {
+        for ( int i = 0; dataProvider.hasNext(); i++ ) {
+            String[] row = dataProvider.next();
+            newRow( listeners,
+                    i,
+                    row.length );
+            for ( int cellNum = 0; cellNum < row.length; cellNum++ ) {
+                String cell = row[cellNum];
+
+                newCell( listeners,
+                         i,
+                         cellNum,
+                         cell,
+                         DataListener.NON_MERGED );
+            }
+        }
+        finishData( listeners );
+    }
+
+    private void finishData(List<DataListener> listeners) {
+        for ( DataListener listener : listeners ) {
+            listener.finishSheet();
+        }
+    }
+
+    private void newRow(List<DataListener> listeners,
+                        int row,
+                        int cols) {
+        for ( DataListener listener : listeners ) {
+            listener.newRow( row,
+                             cols );
+        }
+    }
+
+    public void newCell(List<DataListener> listeners,
+                        int row,
+                        int column,
+                        String value,
+                        int mergedColStart) {
+        for ( DataListener listener : listeners ) {
+            listener.newCell( row,
+                              column,
+                              value,
+                              mergedColStart );
+        }
+    }
+
+    private void closeStream(final InputStream stream) {
+        try {
+            stream.close();
+        } catch ( final Exception e ) {
+            System.err.print( "WARNING: Wasn't able to correctly close stream for rule template. " + e.getMessage() );
+        }
+    }
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Condition.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Condition.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Condition.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,45 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This class represents a single LHS item (which will be the same as a line in 
+ * traditional DRL). 
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
+ */
+public class Condition extends DRLElement
+    implements
+    DRLJavaEmitter {
+
+    public String _snippet;
+
+    /**
+     * @param snippet
+     *            The snippet to set.
+     */
+    public void setSnippet(final String snippet) {
+        this._snippet = snippet;
+    }
+
+    public String getSnippet() {
+        return this._snippet;
+    }
+
+    public void renderDRL(final DRLOutput out) {
+        out.writeLine( "\t\t" + this._snippet );
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Consequence.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Consequence.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Consequence.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,47 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This represents a RHS fragement. A rule may have many of these, or just one.
+ * They are all mushed together.
+ * 
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
+ */
+public class Consequence extends DRLElement
+    implements
+    DRLJavaEmitter {
+
+    private String _snippet;
+
+    /**
+     * @param _snippet
+     *            The _snippet to set.
+     */
+    public void setSnippet(final String snippet) {
+        this._snippet = snippet;
+    }
+
+    public String getSnippet() {
+        return this._snippet;
+    }
+
+    public void renderDRL(final DRLOutput out) {
+        out.writeLine( "\t\t" + this._snippet );
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLElement.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLElement.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLElement.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,40 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
+ * 
+ * The LayerSupertype for this model/parse tree.
+ */
+public abstract class DRLElement {
+
+    private String _comment;
+
+    public void setComment(final String comment) {
+        this._comment = comment;
+    }
+
+    String getComment() {
+        return this._comment;
+    }
+
+    boolean isCommented() {
+        return (this._comment != null && !("".equals( this._comment )));
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLJavaEmitter.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLJavaEmitter.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLJavaEmitter.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,31 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
+ * 
+ * Classes that implement this interface should generate DRL fragments according
+ * to the drools java semantic module.
+ * 
+ */
+public interface DRLJavaEmitter {
+
+    /** Each node can add its contribution to the output */
+    void renderDRL(DRLOutput out);
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLOutput.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLOutput.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/DRLOutput.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,50 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.StringWriter;
+
+/**
+ * This contains the DRL output that each piece of the parser spreadsheet will contribute to
+ * 
+ * @author Michael Neale
+ *
+ */
+public class DRLOutput {
+
+    private StringWriter writer;
+
+    public void writeLine(final String line) {
+        final StringBuffer buf = this.writer.getBuffer();
+        buf.append( line );
+        buf.append( '\n' );
+    }
+
+    public DRLOutput() {
+        this.writer = new StringWriter();
+    }
+
+    /** Return the rendered DRL so far */
+    public String getDRL() {
+        return this.writer.toString();
+    }
+
+    public String toString() {
+        return getDRL();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Functions.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Functions.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Functions.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,41 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Wrapper for functions. Functions must be written in the appropriate style, no 
+ * formatting is contributed here.
+ * 
+ * @author Michael Neale
+ */
+public class Functions
+    implements
+    DRLJavaEmitter {
+
+    private String functionsListing;
+
+    public void setFunctionsListing(final String functionsListing) {
+        this.functionsListing = functionsListing;
+    }
+
+    public void renderDRL(final DRLOutput out) {
+        if ( this.functionsListing != null ) {
+            out.writeLine( this.functionsListing );
+        }
+    }
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Global.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Global.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Global.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,65 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:ricardo.rojas at bluesoft.cl"> Ricardo Rojas </a>
+ * 
+ * Represents an application-data tag (nominally at the rule-set level). The idea of this can
+ * be extended to other ruleset level settings.
+ */
+public class Global extends DRLElement
+    implements
+    DRLJavaEmitter {
+
+    private String identifier;
+    private String className;
+
+    /**
+     * @return Returns the className.
+     */
+    public String getClassName() {
+        return this.className;
+    }
+
+    /**
+     * @return Returns the varName.
+     */
+    public String getIdentifier() {
+        return this.identifier;
+    }
+
+    /**
+     * @param className
+     *            The className to set.
+     */
+    public void setClassName(final String clazz) {
+        this.className = clazz;
+    }
+
+    /**
+     * @param varName
+     *            The varName to set.
+     */
+    public void setIdentifier(final String namez) {
+        this.identifier = namez;
+    }
+
+    public void renderDRL(final DRLOutput out) {
+        out.writeLine( "global " + this.className + " " + this.identifier + ";" );
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Import.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Import.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Import.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,49 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
+ * 
+ * Represents an import (nominally at the rule-set level). The idea of this can
+ * be extended to other ruleset level settings.
+ */
+public class Import extends DRLElement
+    implements
+    DRLJavaEmitter {
+
+    private String className;
+
+    /**
+     * @return Returns the className.
+     */
+    public String getClassName() {
+        return this.className;
+    }
+
+    /**
+     * @param className
+     *            The className to set.
+     */
+    public void setClassName(final String clazz) {
+        this.className = clazz;
+    }
+
+    public void renderDRL(final DRLOutput out) {
+        out.writeLine( "import " + this.className + ";" );
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Package.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Package.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Package.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,104 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
+ * 
+ * This is the top of the parse tree. Represents a package of rules once it has
+ * been parsed from the spreadsheet. Also is the launching point for dumping out
+ * the DRL.
+ */
+public class Package
+    implements
+    DRLJavaEmitter {
+
+    private String       _name;
+
+    private List<Import> _imports;
+
+    private List<Global> _variables; // List of the application data Variable Objects
+
+    private List<Rule>   _rules;
+
+    private Functions _functions;
+
+    public Package(final String name) {
+        this._name = name;
+        this._imports = new LinkedList<Import>();
+        this._variables = new LinkedList<Global>();
+        this._rules = new LinkedList<Rule>();
+        this._functions = new Functions();
+    }
+
+    public void addImport(final Import imp) {
+        this._imports.add( imp );
+    }
+
+    public void addVariable(final Global varz) {
+        this._variables.add( varz );
+    }
+
+    public void addRule(final Rule rule) {
+        this._rules.add( rule );
+    }
+
+    public void addFunctions(final String listing) {
+        this._functions.setFunctionsListing( listing );
+    }
+
+    public String getName() {
+        return this._name;
+    }
+
+    public List<Import> getImports() {
+        return this._imports;
+    }
+
+    public List<Global> getVariables() {
+        return this._variables;
+    }
+
+    public List<Rule> getRules() {
+        return this._rules;
+    }
+
+    public void renderDRL(final DRLOutput out) {
+        out.writeLine( "package " + this._name.replace( ' ',
+                                                   '_' ) + ";" );
+        out.writeLine( "#generated from Decision Table" );
+        renderDRL( this._imports,
+                   out );
+        renderDRL( this._variables,
+                   out );
+        this._functions.renderDRL( out );
+        renderDRL( this._rules,
+                   out );
+
+    }
+
+    private void renderDRL(final List<? extends DRLJavaEmitter> list,
+                           final DRLOutput out) {
+        for ( DRLJavaEmitter emitter : list ) {
+            emitter.renderDRL( out );
+        }
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Rule.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Rule.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/Rule.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,275 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.UnsupportedEncodingException;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
+ *
+ * Represents a rule.
+ */
+public class Rule extends DRLElement
+    implements
+    DRLJavaEmitter {
+
+    private static final int MAX_ROWS = 65535;
+
+    private Integer           _salience;       // Integer as it may be null
+
+    private String            _name;
+
+    private String            _duration;       // RIK: New variable to the Rule class (Defines
+    // a Duration tag for the rule)
+
+    private String            _description;    // RIK: New variable to the Rule class (Set
+    // the description parameter of the rule
+    // tag)
+
+    private String            _noLoop;         // RIK: New variable to the Rule class (Set the
+    // no-loop parameter of the rule tag)
+
+    private String            _activationGroup; // RIK: New variable to the Rule class (Set the
+    // activation-group parameter of the rule tag)
+
+    private String            _ruleFlowGroup;
+
+    private String            _agendaGroup;    // SJW: New variable to the Rule class (Set the
+    // agenda-group parameter of the rule tag
+
+    private List<Condition>   _lhs;
+
+    private List<Consequence> _rhs;
+
+    private int               _spreadsheetRow;
+
+    /**
+     * Create a new rule. Note that the rule name should be post-fixed with the row number,
+     * as one way of providing tracability for errors back to the originating spreadsheet.
+     * @param name The name of the rule. This may be used to calculate DRL row error
+     * to Spreadsheet row error (just need to keep track of output lines, and map spreadsheetRow to a start
+     * and end range in the rendered output).
+     * @param salience
+     * @param spreadsheetRow The phyical row number from the spreadsheet.
+     */
+    public Rule(final String name,
+                final Integer salience,
+                final int spreadsheetRow) {
+        this._name = name;
+        this._salience = salience;
+        this._description = "";
+
+        this._lhs = new LinkedList<Condition>();
+        this._rhs = new LinkedList<Consequence>();
+        this._spreadsheetRow = spreadsheetRow;
+    }
+
+    public void addCondition(final Condition con) {
+        this._lhs.add( con );
+    }
+
+    public void addConsequence(final Consequence con) {
+        this._rhs.add( con );
+    }
+
+    public void renderDRL(final DRLOutput out) {
+        if ( isCommented() ) {
+            out.writeLine( "#" + getComment() );
+        }
+        out.writeLine( "rule " + "\"" + this._name + "\"" );
+        if ( this._description != null ) {
+            out.writeLine( "\t" + this._description );
+        }
+        if ( this._salience != null ) {
+            out.writeLine( "\tsalience " + this._salience );
+        }
+        if ( this._activationGroup != null ) {
+            out.writeLine( "\tactivation-group \"" + this._activationGroup + "\"" );
+        }
+        if ( this._agendaGroup != null ) {
+            out.writeLine( "\tagenda-group " + this._agendaGroup );
+        }
+        if ( this._noLoop != null ) {
+            out.writeLine( "\tno-loop " + this._noLoop );
+        }
+        if ( this._duration != null ) {
+            out.writeLine( "\tduration " + this._duration );
+        }
+
+        if ( this._ruleFlowGroup != null ) {
+            out.writeLine( "\truleflow-group \"" + this._ruleFlowGroup + "\"" );
+        }
+
+        out.writeLine( "\twhen" );
+        renderDRL( this._lhs,
+                   out );
+        out.writeLine( "\tthen" );
+        renderDRL( this._rhs,
+                   out );
+
+        out.writeLine( "end\n" );
+    }
+
+    private void renderDRL(final List<? extends DRLJavaEmitter> list,
+                           final DRLOutput out) {
+        for ( DRLJavaEmitter item : list ) {
+            item.renderDRL( out );
+        }
+    }
+
+    public static int calcSalience(final int rowNumber) {
+        if ( rowNumber > Rule.MAX_ROWS ) {
+            throw new IllegalArgumentException( "That row number is above the max: " + Rule.MAX_ROWS );
+        }
+        return Rule.MAX_ROWS - rowNumber;
+    }
+
+    /**
+     * @param col -
+     *            the column number. Start with zero.
+     * @return The spreadsheet name for this col number, such as "AA" or "AB" or
+     *         "A" and such and such.
+     */
+    public static String convertColNumToColName(final int i) {
+
+        String result;
+        final int div = i / 26;
+        final int mod = i % 26;
+
+        if ( div == 0 ) {
+            final byte[] c = new byte[1];
+            c[0] = (byte) (mod + 65);
+            result = byteToString( c );
+        } else {
+            final byte[] firstChar = new byte[1];
+            firstChar[0] = (byte) ((div - 1) + 65);
+
+            final byte[] secondChar = new byte[1];
+            secondChar[0] = (byte) (mod + 65);
+            final String first = byteToString( firstChar );
+            final String second = byteToString( secondChar );
+            result = first + second;
+        }
+        return result;
+
+    }
+
+    private static String byteToString(final byte[] secondChar) {
+        try {
+            return new String( secondChar,
+                               "UTF-8" );
+        } catch ( final UnsupportedEncodingException e ) {
+            throw new RuntimeException( "Unable to convert char to string.",
+                                        e );
+        }
+    }
+
+    public List<Condition> getConditions() {
+        return this._lhs;
+    }
+
+    public List<Consequence> getConsequences() {
+        return this._rhs;
+    }
+
+    public void setSalience(final Integer value) // Set the salience of the rule
+    {
+        this._salience = value;
+    }
+
+    public Integer getSalience() {
+        return this._salience;
+    }
+
+    public void setName(final String value) // Set the name of the rule
+    {
+        this._name = value;
+    }
+
+    public String getName() {
+        return this._name;
+    }
+
+    public void setDescription(final String value) // Set the description of the
+    // rule
+    {
+        this._description = value;
+    }
+
+    public void appendDescription(final String value) // Set the description of the
+    // rule
+    {
+        this._description += value;
+    }
+
+    public String getDescription() {
+        return this._description;
+    }
+
+    public void setDuration(final String value) // Set the duration of the rule
+    {
+        this._duration = value;
+    }
+
+    public String getDuration() {
+        return this._duration;
+    }
+
+    public void setActivationGroup(final String value) // Set the duration of the rule
+    {
+        this._activationGroup = value;
+    }
+
+    public void setRuleFlowGroup(final String value) {
+        this._ruleFlowGroup = value;
+    }
+
+    public String getRuleFlowGroup() {
+        return this._ruleFlowGroup;
+    }
+
+    public String getActivationGroup() {
+        return this._activationGroup;
+    }
+
+    public String getAgendaGroup() {
+        return _agendaGroup;
+    }
+
+    public void setAgendaGroup(String group) // Set the agenda-group of the rule
+    {
+        _agendaGroup = group;
+    }
+
+    public void setNoLoop(final String value) // Set the no-loop attribute of the rule
+    {
+        this._noLoop = value;
+    }
+
+    /**
+     * @return The row in the spreadsheet this represents.
+     * This can be handy when mapping a line error from Parser back to the rule row.
+     * Will need to have a map of ranges of line numbers that each rule covers.
+     * Then can find out the rule that cause it, and this will give the row number to report.
+     */
+    public int getSpreadsheetRowNumber() {
+        return this._spreadsheetRow;
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/SnippetBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/SnippetBuilder.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/model/SnippetBuilder.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,143 @@
+package org.drools.template.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale </a>
+ * 
+ * This utility class exists to convert rule script snippets to actual code. The
+ * snippets contain place holders for values to be substituted into. See the
+ * test case for how it really works !
+ * 
+ * Snippet template example: "something.getBlah($param)" $param is the "place
+ * holder". This will get replaced with the "cellValue" that is passed in.
+ * 
+ * 12-Oct-2005 change: moved from regex to using simple character based interpolation.
+ * Regex was overkill and couldn't not quite get it right.
+ */
+public class SnippetBuilder {
+
+    private static final String PARAM_PREFIX = "$";
+
+    private static final String PARAM        = SnippetBuilder.PARAM_PREFIX + "param";
+
+    private final String        _template;
+    
+    private final boolean       single;
+    
+    private final Pattern       delimiter;
+
+    /**
+     * @param snippetTemplate
+     *            The snippet including the "place holder" for a parameter. If
+     *            no "place holder" is present,
+     */
+    public SnippetBuilder(final String snippetTemplate) {
+        if ( snippetTemplate == null ) {
+            throw new RuntimeException( "Script template is null - check for missing script definition." );
+        }
+        this._template = snippetTemplate;
+        this.single = this._template.indexOf( SnippetBuilder.PARAM_PREFIX + "1" ) < 0;
+        this.delimiter = Pattern.compile( "(.*?[^\\\\])(,|\\z)" );
+    }
+
+    /**
+     * @param cellValue
+     *            The value from the cell to populate the snippet with. If no
+     *            place holder exists, will just return the snippet.
+     * @return The final snippet.
+     */
+    public String build(final String cellValue) {
+        if ( single ) {
+            return buildSingle( cellValue );
+        } else {
+            return buildMulti( cellValue );
+        }
+    }
+
+    private String buildMulti(final String cellValue) {
+        final String[] cellVals = split( cellValue );
+        String result = this._template;
+
+        for ( int paramNumber = 0; paramNumber < cellVals.length; paramNumber++ ) {
+            final String replace = SnippetBuilder.PARAM_PREFIX + (paramNumber + 1);
+            result = replace( result,
+                              replace,
+                              cellVals[paramNumber].trim(),
+                              256 );
+
+        }
+        return result;
+    }
+    
+    private String[] split( String input ) {
+        Matcher m = delimiter.matcher( input );
+        List<String> result = new ArrayList<String>();
+        while( m.find() ) {
+            result.add( m.group( 1 ).replaceAll( "\\\\,", "," ) );
+        }
+        return result.toArray( new String[result.size()] );
+        
+    }
+
+    /**
+     * @param cellValue
+     * @return
+     */
+    private String buildSingle(final String cellValue) {
+
+        return replace( this._template,
+                        SnippetBuilder.PARAM,
+                        cellValue,
+                        256 );
+
+    }
+
+    /**
+     * Simple replacer. 
+     * jakarta commons provided the inspiration for this.
+     */
+    private String replace(final String text,
+                           final String repl,
+                           final String with,
+                           int max) {
+        if ( text == null || repl == null || repl.equals( "" ) || with == null || max == 0 ) {
+            return text;
+        }
+
+        final StringBuffer buf = new StringBuffer( text.length() );
+        int start = 0, end = 0;
+        while ( (end = text.indexOf( repl,
+                                     start )) != -1 ) {
+            buf.append( text.substring( start,
+                                        end ) ).append( with );
+            start = end + repl.length();
+
+            if ( --max == 0 ) {
+                break;
+            }
+        }
+        buf.append( text.substring( start ) );
+        return buf.toString();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/AbstractColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/AbstractColumn.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/AbstractColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,51 @@
+package org.drools.template.parser;
+
+import org.drools.util.StringUtils;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * Base column of in a decision table
+ */
+public abstract class AbstractColumn implements Column {
+	private String name;
+
+	public AbstractColumn(String n) {
+		this.name = n;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public String getCondition(String condition, int index) {
+		StringBuffer conditionString = new StringBuffer(getCellType());
+		conditionString.append("(row == r, column == $param");
+		if (index != -1) {
+			conditionString.append(", index == ").append(index);
+		}
+		if (!StringUtils.isEmpty(condition)) {
+			conditionString.append(", value ").append(condition);
+		}
+		conditionString.append(")");
+		return conditionString.toString();
+	}
+	
+	
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ArrayCell.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ArrayCell.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ArrayCell.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * Cell containing an array of values
+ */
+package org.drools.template.parser;
+
+import java.util.Map;
+
+import org.drools.StatefulSession;
+import org.drools.util.StringUtils;
+
+public class ArrayCell implements Cell {
+	Row row;
+
+	String value;
+
+	ArrayColumn column;
+
+	private String[] values;
+	
+	public ArrayCell(final Row r, final ArrayColumn c) {
+		row = r;
+		column = c;
+	}
+
+	public void addValue(Map<String, Object> vars) {
+		for (int i = 0; i < values.length; i++) {
+			vars.put(column.getName() + i, values[i]);
+		}		
+	}
+
+	public Column getColumn() {
+		return column;
+	}
+
+	public Row getRow() {
+		return row;
+	}
+	
+	public String getValue() {
+		return value;
+	}
+
+	public void insert(StatefulSession session) {
+		session.insert(this);
+		for (int i = 0; i < values.length; i++) {
+			Cell cell = column.getType().createCell(row);
+			cell.setValue(values[i]);
+			cell.setIndex(i);
+			cell.insert(session);
+		}				
+	}
+
+	public void setIndex(int i) {
+		throw new RuntimeException("You cannot call setIndex on an ArrayCell");
+	}
+
+	public int getIndex() {
+		return -1;
+	}
+
+	public void setValue(String v) {
+		value = v;
+		values = StringUtils.splitPreserveAllTokens(value, ",");
+	}
+
+	public boolean isEmpty() {
+		return StringUtils.isEmpty(value);
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ArrayColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ArrayColumn.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ArrayColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,63 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.util.StringUtils;
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * A column in a decision table that represents an array (comma-delimited)
+ * of values.
+ */
+public class ArrayColumn extends AbstractColumn {
+
+	private Column type;
+
+	public ArrayColumn(String n, Column typeColumn) {
+		super(n);
+		this.type = typeColumn;
+	}
+
+	public Cell createCell(Row row) {
+		return new ArrayCell(row, this);
+	}
+
+	public String getCellType() {
+		return type.getCellType();
+	}
+	
+	public Column getType() {
+		return type;
+	}
+
+	public String getCondition(String condition, int index) {
+		if (index == -1) {
+			StringBuffer conditionString = new StringBuffer("ArrayCell(row == r, column == $param");
+			if (!StringUtils.isEmpty(condition)) {
+				conditionString.append(", value ").append(condition);
+			}
+			conditionString.append(")");
+			return conditionString.toString();
+		}
+		else
+		{
+			return type.getCondition(condition, index);
+		}
+		
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Cell.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Cell.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Cell.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,44 @@
+package org.drools.template.parser;
+
+import java.util.Map;
+
+import org.drools.StatefulSession;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * A cell in a decision table
+ */
+public interface Cell {
+	public Row getRow();
+
+	public Column getColumn();
+	
+	public void setValue(String value);
+
+	public void addValue(Map<String, Object> vars);
+	
+	public void insert(StatefulSession session);
+
+	public void setIndex(int i);
+	
+	public int getIndex();
+
+	public boolean isEmpty();
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Column.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Column.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Column.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,33 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * A column in a decision table
+ */
+public interface Column {
+	String getName();
+
+	Cell createCell(Row row);
+
+	String getCellType();
+
+	String getCondition(String condition, int index);
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ColumnFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ColumnFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/ColumnFactory.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,78 @@
+package org.drools.template.parser;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * Factory to produce a column of the correct type based on its declaration.
+ * [] indicates a column that represents an array (comma-delimited) of values.
+ */
+public class ColumnFactory {
+    private final static Pattern PATTERN = Pattern.compile( "([a-zA-Z0-9_]*)(\\[\\])?(:\\s*([a-zA-Z]*)(\\[\\])?)?" );
+
+    public Column getColumn(String value) {
+        Matcher m = PATTERN.matcher( value );
+        if ( !m.matches() ) throw new IllegalArgumentException( "value " + value + " is not a valid column definition" );
+        String name = m.group( 1 );
+        String type = m.group( 4 );
+        type = type == null ? "String" : type;
+        boolean array = (m.group( 2 ) != null) || (m.group( 5 ) != null);
+        if ( array ) {
+            return new ArrayColumn( name,
+                                    createColumn( name,
+                                                  type ) );
+        }
+        return createColumn( name,
+                             type );
+    }
+
+    @SuppressWarnings("unchecked")
+    private Column createColumn(String name,
+                                String type) {
+        try {
+            Class<Column> klass = (Class<Column>) Class.forName( this.getClass().getPackage().getName() + "." + type + "Column" );
+            Constructor<Column> constructor = klass.getConstructor( new Class[]{String.class} );
+            return constructor.newInstance( new Object[]{name} );
+        } catch ( SecurityException e ) {
+            e.printStackTrace();
+            throw new RuntimeException( e );
+        } catch ( NoSuchMethodException e ) {
+            e.printStackTrace();
+            throw new RuntimeException( e );
+        } catch ( ClassNotFoundException e ) {
+            e.printStackTrace();
+            throw new RuntimeException( e );
+        } catch ( IllegalArgumentException e ) {
+            e.printStackTrace();
+            throw new RuntimeException( e );
+        } catch ( InstantiationException e ) {
+            e.printStackTrace();
+            throw new RuntimeException( e );
+        } catch ( IllegalAccessException e ) {
+            e.printStackTrace();
+            throw new RuntimeException( e );
+        } catch ( InvocationTargetException e ) {
+            e.printStackTrace();
+            throw new RuntimeException( e );
+        }
+    }
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DataListener.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DataListener.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DataListener.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,74 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:shaun.addison at gmail.com"> Shaun Addison </a>
+ * 
+ * Callback interface for scanning an spreadsheet.
+ */
+public interface DataListener {
+	
+    public static final int NON_MERGED = -1;
+
+    /**
+     * Start a new sheet
+     * 
+     * @param name
+     *            the sheet name
+     */
+    public void startSheet(String name);
+
+    /**
+     * Come to the end of the sheet.
+     */
+    public void finishSheet();
+
+    /**
+     * Enter a new row.
+     * 
+     * 
+     * @param rowNumber
+     *            
+     * @param columns
+     *            
+     */
+    public void newRow(int rowNumber,
+                       int columns);
+
+    /**
+     * Enter a new cell.
+     * Do NOT call this event for trailling cells at the end of the line. 
+     * It will just confuse the parser. If all the trailing cells are empty, just 
+     * stop raising events.
+     * 
+     * 
+     * @param row
+     *            the row number
+     * @param column
+     *            the column alpha character label
+     * @param value
+     *            the string value of the cell
+     * @param mergedCol
+     *            the "source" column if it is merged. -1 otherwise.           
+     */
+    public void newCell(int row,
+                        int column,
+                        String value,
+                        int mergedColStart);
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DecisionTableParseException.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DecisionTableParseException.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DecisionTableParseException.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,32 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class DecisionTableParseException extends RuntimeException {
+
+    private static final long serialVersionUID = 400L;
+
+    public DecisionTableParseException(final String message) {
+        super( message );
+    }
+
+    public DecisionTableParseException(final String message,
+                                       final Throwable cause) {
+        super( message,
+               cause );
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultGenerator.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultGenerator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultGenerator.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,103 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.mvel.templates.CompiledTemplate;
+import org.mvel.templates.SimpleTemplateRegistry;
+import org.mvel.templates.TemplateCompiler;
+import org.mvel.templates.TemplateRegistry;
+import org.mvel.templates.TemplateRuntime;
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * Generate the rules for a decision table row from a rule template.
+ */
+public class DefaultGenerator
+    implements
+    Generator {
+
+    private Map<String, RuleTemplate> ruleTemplates;
+
+    private TemplateRegistry          registry = new SimpleTemplateRegistry();
+
+    private List<String>              rules    = new ArrayList<String>();
+
+    public DefaultGenerator(final Map<String, RuleTemplate> t) {
+        ruleTemplates = t;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.drools.decisiontable.parser.Generator#generate(java.lang.String,
+     *      org.drools.decisiontable.parser.Row)
+     */
+    public void generate(String templateName,
+                         Row row) {
+        try {
+            CompiledTemplate template = getTemplate( templateName );
+            Map<String, Object> vars = new HashMap<String, Object>();
+            vars.put( "row",
+                      row );
+
+            for ( Cell cell : row.getCells() ) {
+                cell.addValue( vars );
+            }
+
+            String drl = String.valueOf( TemplateRuntime.execute( template,
+                                                                  vars,
+                                                                  registry ) );
+
+            rules.add( drl );
+        } catch ( Exception e ) {
+            throw new RuntimeException( e );
+        }
+    }
+
+    private CompiledTemplate getTemplate(String templateName) throws IOException {
+        CompiledTemplate contents;
+        if ( !registry.contains( templateName ) ) {
+            RuleTemplate template = ruleTemplates.get( templateName );
+            contents = TemplateCompiler.compileTemplate( template.getContents() );
+            registry.addNamedTemplate( templateName,
+                                       contents );
+        } else {
+            contents = registry.getNamedTemplate( templateName );
+        }
+        return contents;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.drools.decisiontable.parser.Generator#getDrl()
+     */
+    public String getDrl() {
+        StringBuffer sb = new StringBuffer();
+        for ( String rule : rules ) {
+            sb.append( rule ).append( "\n" );
+        }
+        return sb.toString();
+    }
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateColumn.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,105 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.drools.template.model.Condition;
+import org.drools.template.model.Rule;
+import org.drools.template.model.SnippetBuilder;
+import org.drools.util.StringUtils;
+
+/**
+ * 
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * The default column condition for a rule template to be generated. If the
+ * conditon starts with "!" then the template will only be generated if the
+ * column condition does not exist. If there is no condition string then the
+ * template will be generated only if the column contains a value. The condition
+ * can be any valid rule condition.
+ */
+class DefaultTemplateColumn implements TemplateColumn {
+	private static final Pattern COLUMN_PATTERN = Pattern
+			.compile("^(!?)([a-zA-Z0-9_]*)(\\[([0-9]+)\\])?\\s*(.*)");
+
+	private boolean notCondition;
+
+	private String columnName;
+
+	private String condition;
+
+	private TemplateContainer templateContainer;
+
+	private int index = -1;
+
+	DefaultTemplateColumn(TemplateContainer tc, String columnString) {
+		templateContainer = tc;
+		Matcher matcher = COLUMN_PATTERN.matcher(columnString);
+		if (!matcher.matches())
+			throw new IllegalArgumentException("column " + columnString
+					+ " is not valid");
+		notCondition = !StringUtils.isEmpty(matcher.group(1));
+		columnName = matcher.group(2);
+		String indexString = matcher.group(4);
+		condition = matcher.group(5);
+		if (!StringUtils.isEmpty(indexString)) {
+			index = Integer.parseInt(indexString);
+		}
+	}
+
+	private void createCellCondition(final Rule rule) {
+		StringBuffer conditionString = new StringBuffer();
+		Column column = templateContainer.getColumn(columnName);
+		column.getCondition(condition, index);
+		
+		if (notCondition) {
+			conditionString.append("not ");
+		}
+		conditionString.append("exists ");
+		conditionString.append(column.getCondition(condition, index));
+		SnippetBuilder snip = new SnippetBuilder(conditionString.toString());
+		Condition condition = new Condition();
+		condition.setSnippet(snip.build(columnName));
+		rule.addCondition(condition);
+	}
+
+	private void createColumnCondition(final Rule rule, final String value) {
+		SnippetBuilder colSnip = new SnippetBuilder(
+				"$param : Column(name == \"$param\")");
+		Condition colCondition = new Condition();
+		colCondition.setSnippet(colSnip.build(value));
+		rule.addCondition(colCondition);
+	}
+
+	public void addCondition(Rule rule) {
+		createColumnCondition(rule, columnName);
+		createCellCondition(rule);
+	}
+
+	public String getName() {
+		return columnName;
+	}
+
+	public boolean isNotCondition() {
+		return notCondition;
+	}
+
+	public String getCondition() {
+		return condition;
+	}
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateContainer.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateContainer.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateContainer.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,176 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * Container for a set of templates (residing in one file). This class will
+ * parse the template file.
+ * 
+ */
+public class DefaultTemplateContainer implements TemplateContainer {
+	private String header;
+
+	private Map<String, Column> columnMap = new HashMap<String, Column>();
+
+	private List<Column> columns = new ArrayList<Column>();
+
+	private Map<String, RuleTemplate> templates = new HashMap<String, RuleTemplate>();
+
+	public DefaultTemplateContainer(final String template) {
+		this(DefaultTemplateContainer.class.getResourceAsStream(template));
+	}
+
+	public DefaultTemplateContainer(final InputStream templateStream) {
+		parseTemplate(templateStream);
+		validateTemplate();
+	}
+
+	private void validateTemplate() {
+		if (columns.size() == 0) {
+			throw new DecisionTableParseException("Missing header columns");
+		}
+		if (templates.size() == 0) {
+			throw new DecisionTableParseException("Missing templates");
+		}
+
+	}
+
+	private void parseTemplate(final InputStream templateStream) {
+		try {
+			final ColumnFactory cf = new ColumnFactory();
+			final BufferedReader templateReader = new BufferedReader(
+					new InputStreamReader(templateStream));
+			String line = null;
+			StringBuffer header = new StringBuffer();
+			boolean inTemplate = false;
+			boolean inHeader = false;
+			boolean inContents = false;
+			RuleTemplate template = null;
+			StringBuffer contents = new StringBuffer();
+			while ((line = templateReader.readLine()) != null) {
+				if (line.trim().length() > 0) {
+					if (line.startsWith("template header")) {
+						inHeader = true;
+					} else if (line.startsWith("template")) {
+						inTemplate = true;
+						String quotedName = line.substring(8).trim();
+						quotedName = quotedName.substring(1, quotedName
+								.length() - 1);
+						template = new RuleTemplate(quotedName, this);
+						addTemplate(template);
+
+					} else if (line.startsWith("package")) {
+						if (inHeader == false) {
+							throw new DecisionTableParseException(
+									"Missing header");
+						}
+						inHeader = false;
+						header.append(line).append("\n");
+					} else if (inHeader) {
+						addColumn(cf.getColumn(line.trim()));
+					} else if (!inTemplate && !inHeader) {
+						header.append(line).append("\n");
+					} else if (!inContents && line.startsWith("rule")) {
+						inContents = true;
+						contents.append(line).append("\n");
+					} else if (line.equals("end template")) {
+						template.setContents(contents.toString());
+						contents.setLength(0);
+						inTemplate = false;
+						inContents = false;
+					} else if (inContents) {
+						contents.append(line).append("\n");
+					} else if (inTemplate) {
+						template.addColumn(line.trim());
+					}
+				}
+
+			}
+			if (inTemplate) {
+				throw new DecisionTableParseException("Missing end template");
+			}
+			this.header = header.toString();
+
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		} finally {
+			if (templateStream != null)
+				closeStream(templateStream);
+		}
+	}
+
+	private void addTemplate(RuleTemplate template) {
+		templates.put(template.getName(), template);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.drools.decisiontable.parser.TemplateContainer#getTemplates()
+	 */
+	public Map<String, RuleTemplate> getTemplates() {
+		return templates;
+	}
+
+	private void addColumn(Column c) {
+		columns.add(c);
+		columnMap.put(c.getName(), c);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.drools.decisiontable.parser.TemplateContainer#getColumns()
+	 */
+	public Column[] getColumns() {
+		return (Column[]) columns.toArray(new Column[columns.size()]);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.drools.decisiontable.parser.TemplateContainer#getHeader()
+	 */
+	public String getHeader() {
+		return header;
+	}
+
+	private void closeStream(final InputStream stream) {
+		try {
+			stream.close();
+		} catch (final Exception e) {
+			System.err.print("WARNING: Wasn't able to "
+					+ "correctly close stream for decision table. "
+					+ e.getMessage());
+		}
+	}
+
+	public Column getColumn(final String name) {
+		return (Column) columnMap.get(name);
+	}
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateRuleBase.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/DefaultTemplateRuleBase.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,154 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.StatefulSession;
+import org.drools.compiler.PackageBuilder;
+import org.drools.rule.Package;
+import org.drools.template.model.Condition;
+import org.drools.template.model.Consequence;
+import org.drools.template.model.DRLOutput;
+import org.drools.template.model.Global;
+import org.drools.template.model.Import;
+import org.drools.template.model.Rule;
+
+/**
+ * 
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * Create a rule base for the set of rule templates in the 
+ * TemplateContainer. These rules are used internally by the
+ * engine to generate the actual decision table rules based on
+ * which columns have been filled in.
+ * 
+ * Basically, if a rule template requires columns A and B then 
+ * the template rule base will generate a rule with columns A and B
+ * as the LHS and a RHS which triggers the rule to be generated.
+ * ie.
+ * rule "template1"
+ *   when
+ *     r : Row()
+ *     column1 : Column(name == "column1")
+ *     Cell(row == r, column == column1)
+ *     column2 : Column(name == "column2")
+ *     Cell(row == r, column == column2, value == "xyz")
+ *   then
+ *     generator.generate( "template1", r);
+ *   end
+ * 
+ */
+public class DefaultTemplateRuleBase implements TemplateRuleBase {
+	private RuleBase ruleBase;
+
+	public DefaultTemplateRuleBase(final TemplateContainer tc) {
+		ruleBase = readRule(getDTRules(tc.getTemplates()));
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.drools.decisiontable.parser.TemplateRuleBase#newWorkingMemory()
+	 */
+	public StatefulSession newStatefulSession() {
+		return ruleBase.newStatefulSession();
+	}
+	/**
+	 * 
+	 * @param templates
+	 * @return
+	 */
+	private String getDTRules(Map<String, RuleTemplate> templates) {
+		org.drools.template.model.Package p = new org.drools.template.model.Package(
+				DefaultTemplateRuleBase.class.getPackage().getName());
+		addImports(p);
+		addGlobals(p);
+		int i = 1;
+		for ( RuleTemplate template : templates.values() ) {
+			createTemplateRule(p, i++, template);
+		}
+		DRLOutput out = new DRLOutput();
+		p.renderDRL(out);
+		return out.getDRL();
+
+	}
+
+	private void createTemplateRule(org.drools.template.model.Package p, int index, RuleTemplate template) {
+		Rule rule = new Rule(template.getName(), null, index);
+		Condition condition = new Condition();
+		condition.setSnippet("r : Row()");
+		rule.addCondition(condition);
+		createColumnConditions(template, rule);
+		rule.addConsequence(createConsequence(template));
+		p.addRule(rule);
+	}
+
+	private void createColumnConditions(RuleTemplate template, Rule rule) {
+		for ( TemplateColumn column : template.getColumns() ) {
+			column.addCondition(rule);
+		}
+	}
+
+
+	private void addGlobals(org.drools.template.model.Package p) {
+		Global global = new Global();
+		global.setClassName(DefaultGenerator.class.getName());
+		global.setIdentifier("generator");
+		p.addVariable(global);
+	}
+
+	private void addImports(org.drools.template.model.Package p) {
+		Import drlImport1 = new Import();
+		drlImport1.setClassName(Map.class.getName());
+		Import drlImport2 = new Import();
+		drlImport2.setClassName(HashMap.class.getName());
+		p.addImport(drlImport1);
+		p.addImport(drlImport2);
+	}
+
+	private Consequence createConsequence(RuleTemplate template) {
+		StringBuffer action = new StringBuffer();
+		action.append("generator.generate( \"");
+		action.append(template.getName()).append("\", r);");
+		final Consequence consequence = new Consequence();
+		consequence.setSnippet(action.toString());
+		return consequence;
+	}
+
+	private RuleBase readRule(String drl) {
+		try {
+//			System.out.println(drl);
+			// read in the source
+			Reader source = new StringReader(drl);
+			PackageBuilder builder = new PackageBuilder();
+			builder.addPackageFromDrl(source);
+			Package pkg = builder.getPackage();
+
+			// add the package to a rulebase (deploy the rule package).
+			RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+			ruleBase.addPackage(pkg);
+			return ruleBase;
+
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Generator.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Generator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Generator.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,28 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * <a href="stevearoonie at gmail.com">Steven Williams</a>
+ * Generate the rules for a decision table
+ */
+public interface Generator {
+
+	void generate(String templateName, Row row);
+
+	String getDrl();
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/LongCell.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/LongCell.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/LongCell.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,79 @@
+package org.drools.template.parser;
+
+import java.util.Map;
+
+import org.drools.StatefulSession;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * A cell in a decision table containing a long value
+ */
+public class LongCell implements Cell {
+	Row row;
+
+	Long value;
+
+	Column column;
+
+	private int index;
+
+	public LongCell() {
+		
+	}
+	LongCell(Row r, Column c) {
+		row = r;
+		column = c;
+	}
+
+	public String toString() {
+		return "Cell[" + column + ": " + value + "]";
+	}
+
+	public Row getRow() {
+		return row;
+	}
+
+	public Column getColumn() {
+		return column;
+	}
+
+	public Long getValue() {
+		return value;
+	}
+
+	public void addValue(Map<String, Object> vars) {
+		vars.put(column.getName(), value);
+	}
+	public void insert(StatefulSession session) {
+		session.insert(this);
+	}
+	public void setIndex(int i) {
+		index = i;
+	}
+	public int getIndex() {
+		return index;
+	}
+	public void setValue(String v) {
+		value = new Long(v);
+	}
+	public boolean isEmpty() {
+		return value == null;
+	}
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/LongColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/LongColumn.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/LongColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,42 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * A column of type Long in a decision table
+ */
+public class LongColumn extends AbstractColumn {
+
+	public LongColumn(String n) {
+		super(n);
+	}
+//
+//	public void addValue(Map vars, Object value) {
+//		vars.put(getName(), value);
+//	}
+
+	public Cell createCell(Row row) {
+		return new LongCell(row, this);
+	}
+
+	public String getCellType() {
+		return "LongCell";
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Row.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Row.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/Row.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,68 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.ArrayList;
+import java.util.List;
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ *  
+ * Represents a row in a decision table.
+ */
+public class Row {
+    int  rowNum;
+    List<Cell> cells = new ArrayList<Cell>();
+
+    public Row() {
+    	
+    }
+    
+    Row(int r, Column[] columns) {
+        rowNum = r;
+        for (int i = 0; i < columns.length; i++) {
+			cells.add(columns[i].createCell(this));
+		}
+    }
+    
+    public int getRowNumber() {
+        return rowNum;
+    }
+
+    Cell getCell(int columnIndex)
+    {
+    	return cells.get(columnIndex);
+    }
+    
+    boolean isEmpty() {
+        for ( Cell cell : cells ) {
+			if (!cell.isEmpty())
+			{
+				return false;
+			}
+		}
+    	return true;
+    }
+    
+    public List<Cell> getCells() {
+    	return cells;
+    }
+
+    public String toString() {
+        return "Row " + rowNum + cells + "\n";
+    }
+
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/RuleTemplate.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/RuleTemplate.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/RuleTemplate.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,123 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.drools.util.StringUtils;
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * A rule template made up of a name, the decision table columns required, the
+ * decision table columns that must be empty and the contents of the rule.
+ */
+public class RuleTemplate {
+	private String name;
+
+	private String contents;
+
+	private List<TemplateColumn> columns;
+
+	private TemplateContainer templateContainer;
+
+	public RuleTemplate(final String n, final TemplateContainer tc) {
+		name = n;
+		columns = new ArrayList<TemplateColumn>();
+		templateContainer = tc;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public List<TemplateColumn> getColumns() {
+		return columns;
+	}
+
+	public String getContents() {
+		return contents;
+	}
+
+	public void addColumn(String columnString) {
+		TemplateColumn column = new DefaultTemplateColumn(templateContainer, columnString);
+		this.columns.add(column);
+	}
+
+	public void setContents(String contents) {
+		this.contents = replaceOptionals(contents);
+	}
+
+	/**
+	 * @see java.lang.Object#toString()
+	 */
+	public String toString() {
+		return "RuleTemplate[name," + this.name + "contents," + this.columns
+				+ "columns";
+	}
+
+	/*
+	 * Replace the optional columns in the rule contents with an if statement.
+	 * if (column is empty) do not show the line.
+	 */
+	private String replaceOptionals(String contents) {
+		try {
+			final Pattern pattern = Pattern.compile("@\\{(.[^}]*)\\}");
+			final Collection<String> columns = getColumnNames();
+			columns.add("row.rowNumber");
+			final BufferedReader reader = new BufferedReader(new StringReader(
+					contents));
+			String line = null;
+			final StringBuffer newLine = new StringBuffer();
+			while ((line = reader.readLine()) != null) {
+				final Matcher matcher = pattern.matcher(line);
+				int optCols = 0;
+				while (matcher.find()) {
+					final String c = matcher.group(1);
+					if (!columns.contains(c)) {
+						newLine.append("@if{").append(matcher.group(1)).append(
+								" != null}");
+						optCols++;
+					}
+				}
+				newLine.append(line);
+				newLine.append(StringUtils.repeat("@end{}", optCols));
+				newLine.append("\n");
+			}
+//			System.out.println("newLine: " + newLine);
+			return newLine.toString();
+
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	private Collection<String> getColumnNames() {
+		Collection<String> columnNames = new ArrayList<String>();
+		for ( TemplateColumn column : getColumns() ) {
+			columnNames.add(column.getName());
+		}
+		return columnNames;
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/StringCell.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/StringCell.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/StringCell.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,80 @@
+package org.drools.template.parser;
+
+import java.util.Map;
+
+import org.drools.StatefulSession;
+import org.drools.util.StringUtils;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * A cell in a decision table containing a String value
+ */
+public class StringCell implements Cell {
+	Row row;
+
+	String value;
+
+	Column column;
+
+	private int index;
+
+	public StringCell() {
+		
+	}
+	StringCell(Row r, Column c) {
+		row = r;
+		column = c;
+	}
+
+	public String toString() {
+		return "Cell[" + column + ": " + value + "]";
+	}
+
+	public Row getRow() {
+		return row;
+	}
+
+	public Column getColumn() {
+		return column;
+	}
+
+	public Object getValue() {
+		return value;
+	}
+
+	public void addValue(Map<String, Object> vars) {
+		vars.put(column.getName(), value);
+	}
+	public int getIndex() {
+		return index;
+	}
+	public void insert(StatefulSession session) {
+		session.insert(this);
+	}
+	public void setIndex(int i) {
+		index = i;
+	}
+	public void setValue(String v) {
+		value = v;
+	}
+	public boolean isEmpty() {
+		return StringUtils.isEmpty(value);
+	}
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/StringColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/StringColumn.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/StringColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,42 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * A column of type String in a decision table
+ */
+public class StringColumn extends AbstractColumn {
+
+	public StringColumn(String n) {
+		super(n);
+	}
+//
+//	public void addValue(Map vars, Object value) {
+//		vars.put(getName(), value);
+//	}
+
+	public Cell createCell(Row row) {
+		return new StringCell(row, this);
+	}
+
+	public String getCellType() {
+		return "StringCell";
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateColumn.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateColumn.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,32 @@
+package org.drools.template.parser;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.drools.template.model.Rule;
+/**
+ * 
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ * 
+ * A column condition for a rule template to be generated.
+ */
+interface TemplateColumn {
+	void addCondition(final Rule rule);
+
+	String getName();
+
+	boolean isNotCondition();
+
+	String getCondition();
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateContainer.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateContainer.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateContainer.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,30 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.Map;
+
+public interface TemplateContainer {
+
+	Map<String, RuleTemplate> getTemplates();
+
+	Column[] getColumns();
+	
+	Column getColumn(String name);
+
+	String getHeader();
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateDataListener.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateDataListener.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateDataListener.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,136 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.StatefulSession;
+import org.drools.template.model.DRLOutput;
+
+/**
+ * SheetListener for creating rules from a template
+ * 
+ * @author <a href="mailto:stevearoonie at gmail.com">Steven Williams</a>
+ */
+public class TemplateDataListener implements DataListener {
+
+	private int startRow = -1;
+
+	private boolean tableFinished = false;
+
+	private Row currentRow;
+
+	private Column[] columns;
+
+	private StatefulSession session;
+
+	private TemplateContainer templateContainer;
+
+	private int startCol;
+
+	private Generator generator;
+
+//	private WorkingMemoryFileLogger logger;
+
+	public TemplateDataListener(final TemplateContainer tc) {
+		this(1, 1, tc);
+	}
+
+	public TemplateDataListener(final int startRow, final int startCol,
+	                             final String template) {
+	    this(startRow, startCol, new DefaultTemplateContainer(template));
+	}
+	
+	public TemplateDataListener(final int startRow, final int startCol,
+			final TemplateContainer tc) {
+		this(startRow, startCol, tc, new DefaultTemplateRuleBase(tc));
+	}
+
+	public TemplateDataListener(final int startRow, final int startCol,
+			final TemplateContainer tc, final TemplateRuleBase rb) {
+		this(startRow, startCol, tc, rb,
+				new DefaultGenerator(tc.getTemplates()));
+	}
+
+	public TemplateDataListener(final int startRow, final int startCol,
+			final TemplateContainer tc, final TemplateRuleBase ruleBase,
+			final Generator generator) {
+		this.startRow = startRow - 1;
+		this.startCol = startCol - 1;
+		columns = tc.getColumns();
+		this.templateContainer = tc;
+		session = ruleBase.newStatefulSession();
+//		logger = new WorkingMemoryFileLogger(session);
+//		logger.setFileName("log/event");
+		this.generator = generator;
+		session.setGlobal("generator", generator);
+		assertColumns();
+	}
+
+	private void assertColumns() {
+		for (int i = 0; i < columns.length; i++) {
+			session.insert(columns[i]);			
+		}
+	}
+
+	public void finishSheet() {
+		if (currentRow != null) {
+			session.insert(currentRow);
+		}
+		session.fireAllRules();
+//		logger.writeToDisk();
+		session.dispose();
+	}
+
+	public void newCell(int row, int column, String value, int mergedColStart) {
+		if (currentRow != null && column >= startCol && value != null
+				&& value.trim().length() > 0) {
+
+			int columnIndex = column - startCol;
+			// System.out.println("asserting cell " + row + ", " + column + ": "
+			// + value);
+			Cell cell = currentRow.getCell(columnIndex);
+			cell.setValue(value);
+			cell.insert(session);
+		}
+	}
+
+	public void newRow(int rowNumber, int columnCount) {
+		if (!tableFinished && rowNumber >= startRow) {
+			if (currentRow != null && currentRow.isEmpty()) {
+				currentRow = null;
+				tableFinished = true;
+			} else {
+				if (currentRow != null)
+					session.insert(currentRow);
+				currentRow = new Row(rowNumber, columns);
+			}
+		}
+	}
+
+	public void startSheet(String name) {
+
+	}
+
+	public String renderDRL() {
+		DRLOutput out = new DRLOutput();
+		out.writeLine(templateContainer.getHeader());
+
+		out.writeLine(generator.getDrl());
+		// System.err.println(out.getDRL());
+		return out.getDRL();
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateRuleBase.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/java/org/drools/template/parser/TemplateRuleBase.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,24 @@
+package org.drools.template.parser;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.drools.StatefulSession;
+
+public interface TemplateRuleBase {
+
+    StatefulSession newStatefulSession();
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/main/resources/org/drools/template/package.html
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/main/resources/org/drools/template/package.html	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/main/resources/org/drools/template/package.html	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,3 @@
+<body>
+	This is a utility for generating rules from templates. Use DataProviderCompiler.
+</body>
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/DataProviderCompilerIntegrationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/DataProviderCompilerIntegrationTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/DataProviderCompilerIntegrationTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,114 @@
+package org.drools.template;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.template.DataProvider;
+import org.drools.template.DataProviderCompiler;
+
+import junit.framework.TestCase;
+
+public class DataProviderCompilerIntegrationTest extends TestCase {
+
+    private class TestDataProvider
+        implements
+        DataProvider {
+
+        private Iterator<String[]> iterator;
+
+        TestDataProvider(List<String[]> rows) {
+            this.iterator = rows.iterator();
+        }
+
+        public boolean hasNext() {
+            return iterator.hasNext();
+        }
+
+        public String[] next() {
+            return iterator.next();
+        }
+
+    }
+
+    public void testCompiler() throws Exception {
+        ArrayList<String[]> rows = new ArrayList<String[]>();
+        rows.add( createRow( "1",
+                             "STANDARD",
+                             "FLAT",
+                             null,
+                             "SBLC",
+                             "ISS",
+                             "Commission",
+                             null,
+                             "USD",
+                             null,
+                             "750" ) );
+        rows.add( createRow( "15",
+                             "STANDARD",
+                             "FLAT",
+                             null,
+                             "SBLC",
+                             "ISS",
+                             "Commission",
+                             null,
+                             "YEN",
+                             null,
+                             "1600" ) );
+        rows.add( createRow( "12",
+                             "STANDARD",
+                             "FLAT",
+                             null,
+                             "SBLC",
+                             "ISS",
+                             "Postage",
+                             null,
+                             "YEN",
+                             null,
+                             "40" ) );
+        rows.add( createRow( "62",
+                             "STANDARD",
+                             "FLAT",
+                             null,
+                             "SBLC",
+                             "ISS",
+                             "Telex",
+                             null,
+                             "YEN",
+                             "< 30000",
+                             "45" ) );
+        TestDataProvider tdp = new TestDataProvider( rows );
+        final DataProviderCompiler converter = new DataProviderCompiler();
+        final String drl = converter.compile( tdp,
+                                              "/templates/rule_template_1.drl" );
+        System.out.println( drl );
+
+    }
+
+    private String[] createRow(String cell1,
+                               String cell2,
+                               String cell3,
+                               String cell4,
+                               String cell5,
+                               String cell6,
+                               String cell7,
+                               String cell8,
+                               String cell9,
+                               String cell10,
+                               String cell11) {
+        String[] row = new String[11];
+        row[0] = cell1;
+        row[1] = cell2;
+        row[2] = cell3;
+        row[3] = cell4;
+        row[4] = cell5;
+        row[5] = cell6;
+        row[6] = cell7;
+        row[7] = cell8;
+        row[8] = cell9;
+        row[9] = cell10;
+        row[10] = cell11;
+        return row;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/FunctionsRenderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/FunctionsRenderTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/FunctionsRenderTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,43 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.template.model.DRLOutput;
+import org.drools.template.model.Functions;
+
+import junit.framework.TestCase;
+
+public class FunctionsRenderTest extends TestCase {
+
+    public void testFunctionRender() {
+        final Functions func = new Functions();
+
+        DRLOutput out = new DRLOutput();
+        func.renderDRL( out );
+
+        assertEquals( "",
+                      out.toString() );
+
+        func.setFunctionsListing( "function myFunction() {}" );
+        out = new DRLOutput();
+        func.renderDRL( out );
+        final String s = out.toString();
+        assertEquals( "function myFunction() {}\n",
+                      s );
+    }
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/PackageRenderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/PackageRenderTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/PackageRenderTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,84 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.template.model.Condition;
+import org.drools.template.model.Consequence;
+import org.drools.template.model.DRLOutput;
+import org.drools.template.model.Import;
+import org.drools.template.model.Package;
+import org.drools.template.model.Rule;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale</a>
+ * 
+ * Test rendering and running a whole sample ruleset, from the model classes
+ * down.
+ */
+public class PackageRenderTest extends TestCase {
+
+    public Rule buildRule() {
+        final Rule rule = new Rule( "myrule",
+                              new Integer( 42 ),
+                              1 );
+        rule.setComment( "rule comments" );
+
+        final Condition cond = new Condition();
+        cond.setComment( "cond comment" );
+        cond.setSnippet( "cond snippet" );
+        rule.addCondition( cond );
+
+        final Consequence cons = new Consequence();
+        cons.setComment( "cons comment" );
+        cons.setSnippet( "cons snippet" );
+        rule.addConsequence( cons );
+
+        return rule;
+    }
+
+    public void testRulesetRender() {
+        final Package ruleSet = new Package( "my ruleset" );
+        ruleSet.addFunctions( "my functions" );
+        ruleSet.addRule( buildRule() );
+
+        final Rule rule = buildRule();
+        rule.setName( "other rule" );
+        ruleSet.addRule( rule );
+
+        final Import imp = new Import();
+        imp.setClassName( "clazz name" );
+        imp.setComment( "import comment" );
+        ruleSet.addImport( imp );
+
+        final DRLOutput out = new DRLOutput();
+        ruleSet.renderDRL( out );
+
+        final String drl = out.getDRL();
+        assertNotNull( drl );
+        System.out.println( drl );
+        assertTrue( drl.indexOf( "rule \"myrule\"" ) > -1 );
+        assertTrue( drl.indexOf( "salience 42" ) > -1 );
+        assertTrue( drl.indexOf( "#rule comments" ) > -1 );
+        assertTrue( drl.indexOf( "my functions" ) > -1 );
+        assertTrue( drl.indexOf( "package my_ruleset;" ) > -1 );
+        assertTrue( drl.indexOf( "rule \"other rule\"" ) > drl.indexOf( "rule \"myrule\"" ) );
+
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/RuleRenderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/RuleRenderTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/RuleRenderTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,155 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.template.model.Condition;
+import org.drools.template.model.Consequence;
+import org.drools.template.model.DRLOutput;
+import org.drools.template.model.Rule;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale</a>
+ *
+ * Tests how the rule parse tree renders itself to a rule XML fragment.
+ */
+public class RuleRenderTest extends TestCase {
+
+    public void testRuleRender() {
+        final Rule rule = new Rule( "myrule",
+                              new Integer( 42 ),
+                              1 );
+        rule.setComment( "rule comments" );
+
+        final Condition cond = new Condition();
+        cond.setComment( "cond comment" );
+        cond.setSnippet( "cond snippet" );
+        rule.addCondition( cond );
+
+        final Consequence cons = new Consequence();
+        cons.setComment( "cons comment" );
+        cons.setSnippet( "cons snippet;" );
+        rule.addConsequence( cons );
+        rule.addConsequence( cons );
+
+        final DRLOutput out = new DRLOutput();
+        rule.renderDRL( out );
+        final String drl = out.getDRL();
+        assertNotNull( drl );
+
+        assertTrue( drl.indexOf( "cond snippet" ) != -1 );
+        assertTrue( drl.indexOf( "cons snippet" ) != -1 );
+        assertTrue( drl.indexOf( "salience 42" ) != -1 );
+        assertTrue( drl.indexOf( "salience 42" ) < drl.indexOf( "when" ) );
+        assertTrue( drl.indexOf( "cond snippet" ) < drl.indexOf( "then" ) );
+        assertTrue( drl.indexOf( "cons snippet;" ) > drl.indexOf( "then" ) );
+        assertTrue( drl.indexOf( "rule" ) != -1 );
+        assertTrue( drl.indexOf( "end" ) > drl.indexOf( "rule " ) );
+        assertTrue( drl.indexOf( "#rule comments" ) > -1 );
+
+    }
+
+    public void testAttributes() throws Exception {
+        Rule rule = new Rule("la", new Integer(42), 2);
+
+        rule.setActivationGroup( "foo" );
+        rule.setNoLoop( "true" );
+        rule.setRuleFlowGroup( "ruleflowgroup" );
+        rule.setDuration("42");
+        DRLOutput out = new DRLOutput();
+        rule.renderDRL( out );
+
+        String result = out.toString();
+
+        assertTrue(result.indexOf( "ruleflow-group \"ruleflowgroup\"" ) > -1 );
+        assertTrue(result.indexOf( "no-loop true" ) > -1);
+        assertTrue(result.indexOf( "activation-group \"foo\"" ) > -1);
+        assertTrue(result.indexOf( "duration 42" ) > -1);
+
+    }
+
+    public void testSalienceCalculator() {
+        final int rowNumber = 2;
+        final int salience = Rule.calcSalience( rowNumber );
+        assertEquals( 65533,
+                      salience );
+    }
+
+    public void testColNumToColName() {
+        String colName = Rule.convertColNumToColName( 1 );
+        assertEquals( "B",
+                      colName );
+
+        colName = Rule.convertColNumToColName( 10 );
+        assertEquals( "K",
+                      colName );
+
+        colName = Rule.convertColNumToColName( 42 );
+        assertEquals( "AQ",
+                      colName );
+
+        colName = Rule.convertColNumToColName( 27 );
+        assertEquals( "AB",
+                      colName );
+
+        colName = Rule.convertColNumToColName( 53 );
+        assertEquals( "BB",
+                      colName );
+
+    }
+
+    public void testNotEscapeChars() {
+        //bit of a legacy from the olde XML dayes of yesteryeare
+        final Condition cond = new Condition();
+        cond.setSnippet( "a < b" );
+        final DRLOutput out = new DRLOutput();
+        cond.renderDRL( out );
+
+        assertTrue( out.toString().indexOf( "a < b" ) != -1 );
+
+    }
+
+    /**
+     * This checks that if the rule has "nil" salience, then
+     * no salience value should be put in the rule definition.
+     * This allows default salience to work as advertised.
+     *
+     */
+    public void testNilSalience() {
+        Rule rule = new Rule( "MyRule",
+                              null,
+                              1 );
+
+        DRLOutput out = new DRLOutput();
+        rule.renderDRL( out );
+        String xml = out.toString();
+        int idx = xml.indexOf( "salience" );
+        assertEquals( -1,
+                      idx );
+
+        rule = new Rule( "MyRule",
+                         new Integer( 42 ),
+                         1 );
+        out = new DRLOutput();
+        rule.renderDRL( out );
+        xml = out.toString();
+        idx = xml.indexOf( "salience" );
+        assertTrue( idx > -1 );
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/SnippetBuilderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/SnippetBuilderTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/model/SnippetBuilderTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,98 @@
+package org.drools.template.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.template.model.SnippetBuilder;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:michael.neale at gmail.com"> Michael Neale</a>
+ * 
+ */
+public class SnippetBuilderTest extends TestCase {
+
+    public void testBuildSnippet() {
+        final String snippet = "something.param.getAnother().equals($param);";
+        final SnippetBuilder snip = new SnippetBuilder( snippet );
+        final String cellValue = "$42";
+        final String result = snip.build( cellValue );
+        assertNotNull( result );
+
+        assertEquals( "something.param.getAnother().equals($42);",
+                      result );
+    }
+
+    public void testBuildSnippetNoPlaceHolder() {
+        final String snippet = "something.getAnother().equals(blah);";
+        final SnippetBuilder snip = new SnippetBuilder( snippet );
+        final String cellValue = "this is ignored...";
+        final String result = snip.build( cellValue );
+
+        assertEquals( snippet,
+                      result );
+    }
+
+    public void testSingleParamMultipleTimes() {
+        final String snippet = "something.param.getAnother($param).equals($param);";
+        final SnippetBuilder snip = new SnippetBuilder( snippet );
+        final String cellValue = "42";
+        final String result = snip.build( cellValue );
+        assertNotNull( result );
+
+        assertEquals( "something.param.getAnother(42).equals(42);",
+                      result );
+
+    }
+
+    public void testMultiPlaceHolder() {
+        final String snippet = "something.getAnother($1,$2).equals($2, '$2');";
+        final SnippetBuilder snip = new SnippetBuilder( snippet );
+        final String result = snip.build( "x, y" );
+        assertEquals( "something.getAnother(x,y).equals(y, 'y');",
+                      result );
+
+    }
+
+    public void testMultiPlaceHolderSingle() {
+        final String snippet = "something.getAnother($1).equals($1);";
+        final SnippetBuilder snip = new SnippetBuilder( snippet );
+        final String result = snip.build( "x" );
+        assertEquals( "something.getAnother(x).equals(x);",
+                      result );
+
+    }
+    
+    public void testStartWithParam() {
+        final String snippet = "$1 goo $2";
+        final SnippetBuilder snip = new SnippetBuilder( snippet );
+        final String result = snip.build( "x, y" );
+        assertEquals( "x goo y",
+                      result );
+        
+    }
+
+    public void testMultiPlaceHolderEscapedComma() {
+        final String snippet = "rulesOutputRouting.set( $1, $2, $3, $4, $5 );";
+        final SnippetBuilder snip = new SnippetBuilder( snippet );
+        final String result = snip.build( "\"80\",\"Department Manager\",toa.getPersonExpense().getEntityCode(\"Part Of\"\\,\"Office\"),10004,30" );
+        assertEquals( "rulesOutputRouting.set( \"80\", \"Department Manager\", toa.getPersonExpense().getEntityCode(\"Part Of\",\"Office\"), 10004, 30 );",
+                      result );
+
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/ColumnFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/ColumnFactoryTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/ColumnFactoryTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,62 @@
+package org.drools.template.parser;
+
+import org.drools.template.parser.ArrayColumn;
+import org.drools.template.parser.Column;
+import org.drools.template.parser.ColumnFactory;
+import org.drools.template.parser.LongColumn;
+import org.drools.template.parser.StringColumn;
+
+import junit.framework.TestCase;
+
+public class ColumnFactoryTest extends TestCase {
+
+	public void testGetColumn() {
+		ColumnFactory f = new ColumnFactory();
+		Column column = f.getColumn("column");
+		assertTrue(column instanceof StringColumn);
+		assertEquals("column", column.getName());
+	}
+
+	public void testGetStringArrayColumn() {
+		ColumnFactory f = new ColumnFactory();
+		Column column = f.getColumn("column: String[]");
+		assertTrue(column instanceof ArrayColumn);
+		assertEquals("column", column.getName());
+		assertEquals("StringCell", ((ArrayColumn)column).getCellType());
+	}
+	
+	public void testGetLongArrayColumn() {
+		ColumnFactory f = new ColumnFactory();
+		Column column = f.getColumn("column: Long[]");
+		assertTrue(column instanceof ArrayColumn);
+		assertEquals("column", column.getName());
+		assertEquals("LongCell", ((ArrayColumn)column).getCellType());
+	}
+	
+	public void testGetArrayColumnSimple() {
+		ColumnFactory f = new ColumnFactory();
+		Column column = f.getColumn("column[]");
+		assertTrue(column instanceof ArrayColumn);
+		assertEquals("column", column.getName());
+		assertEquals("StringCell", ((ArrayColumn)column).getCellType());
+		
+	}
+
+	public void testGetLongColumn() {
+		ColumnFactory f = new ColumnFactory();
+		Column column = f.getColumn("column: Long");
+		assertTrue(column instanceof LongColumn);
+		assertEquals("column", column.getName());
+	}
+
+	public void testInvalidGetColumn() {
+		try {
+			ColumnFactory f = new ColumnFactory();
+			f.getColumn("column$");
+			fail("IllegalArgumentException expected");
+		} catch (IllegalArgumentException expected) {
+
+		}
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultGeneratorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultGeneratorTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultGeneratorTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,79 @@
+package org.drools.template.parser;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.template.parser.Column;
+import org.drools.template.parser.DefaultGenerator;
+import org.drools.template.parser.Row;
+import org.drools.template.parser.RuleTemplate;
+import org.drools.template.parser.StringColumn;
+import org.drools.template.parser.TemplateContainer;
+
+import junit.framework.TestCase;
+
+public class DefaultGeneratorTest extends TestCase {
+	private DefaultGenerator g;
+
+    protected void setUp() throws Exception {
+        Map<String, RuleTemplate> t = new HashMap<String, RuleTemplate>();
+        TemplateContainer tc = new TemplateContainer() {
+
+			public Column getColumn(String name) {
+				return null;
+			}
+
+			public Column[] getColumns() {
+				return null;
+			}
+
+			public String getHeader() {
+				return null;
+			}
+
+			public Map<String, RuleTemplate> getTemplates() {
+				return null;
+			}
+        	
+        };
+        RuleTemplate rt1 = new RuleTemplate("rt1", tc);
+        rt1.setContents("Test template 1");
+        RuleTemplate rt2 = new RuleTemplate("rt2", tc);
+        rt2.setContents("Test template 2");
+        RuleTemplate rt3 = new RuleTemplate("rt3", tc);
+        rt3.addColumn("col1");
+        rt3.addColumn("col2");
+        rt3.setContents("@{row.rowNumber} @{col1} @{col2}");
+        t.put("rt1", rt1);
+        t.put("rt2", rt2);
+        t.put("rt3", rt3);
+        g = new DefaultGenerator(t);
+    }
+    
+	public void testSelectTemplate() {
+		g.generate("rt2", new Row());
+		String drl = g.getDrl();
+		assertEquals("Test template 2\n\n", drl);
+	}
+	
+	public void testGenerate() {
+		g.generate("rt2", new Row());
+		g.generate("rt1", new Row());
+		String drl = g.getDrl();
+		assertEquals("Test template 2\n\nTest template 1\n\n", drl);
+	}
+	
+	public void testAddColumns() {
+		Column[] columns = {new StringColumn("col1"), new StringColumn("col2")};
+		Row r = new Row(1, columns);
+		r.getCell(0).setValue("value1");
+		r.getCell(1).setValue("value2");
+//		Row r = new Row(1);
+//		r.addCell(new StringCell(r, new StringColumn("col1"), "value1"));
+//		r.addCell(new StringCell(r, new StringColumn("col2"), "value2"));
+		g.generate("rt3", r);
+		String drl = g.getDrl();
+		assertEquals("1 value1 value2\n\n", drl);
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateContainerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateContainerTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateContainerTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,162 @@
+package org.drools.template.parser;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.template.parser.Column;
+import org.drools.template.parser.DecisionTableParseException;
+import org.drools.template.parser.DefaultTemplateContainer;
+import org.drools.template.parser.RuleTemplate;
+import org.drools.template.parser.TemplateColumn;
+
+import junit.framework.TestCase;
+
+public class DefaultTemplateContainerTest extends TestCase {
+	public void testParseTemplate() {
+		InputStream is = DefaultTemplateContainerTest.class
+				.getResourceAsStream("/templates/test_template_simple.drl");
+		DefaultTemplateContainer t = new DefaultTemplateContainer(is);
+		assertEquals("package This_is_a_ruleset;\n", t.getHeader());
+		assertEquals(1, t.getColumns().length);
+		assertEquals("name", t.getColumns()[0].getName());
+		Map<String, RuleTemplate> templates = t.getTemplates();
+		assertEquals(1, templates.size());
+		RuleTemplate template = templates.get("template1");
+		assertNotNull(template);
+		List<TemplateColumn> columns = template.getColumns();
+		assertEquals(1, columns.size());
+		TemplateColumn column = (TemplateColumn) columns.get(0);
+		assertEquals("name", column.getName());
+		String contents = template.getContents();
+		assertTrue(contents
+				.startsWith("rule \"How cool is @{name} @{row.rowNumber}\""));
+		assertTrue(contents.endsWith("then\nend\n"));
+	}
+
+	public void testParseTemplateConditions() {
+		InputStream is = DefaultTemplateContainerTest.class
+				.getResourceAsStream("/templates/test_template_conditions.drl");
+		DefaultTemplateContainer t = new DefaultTemplateContainer(is);
+		assertEquals("package This_is_a_ruleset;\n", t.getHeader());
+		assertEquals(1, t.getColumns().length);
+		assertEquals("name", t.getColumns()[0].getName());
+		Map<String, RuleTemplate> templates = t.getTemplates();
+		assertEquals(1, templates.size());
+		RuleTemplate template = (RuleTemplate) templates.get("template1");
+		assertNotNull(template);
+		List<TemplateColumn> columns = template.getColumns();
+		assertEquals(1, columns.size());
+		TemplateColumn templateColumn = (TemplateColumn) columns.get(0);
+		assertEquals("name", templateColumn.getName());
+		assertEquals("== \"name1\"", templateColumn.getCondition());
+		String contents = template.getContents();
+		assertTrue(contents
+				.startsWith("rule \"How cool is @{name} @{row.rowNumber}\""));
+		assertTrue(contents.endsWith("then\nend\n"));
+	}
+
+	public void testParseTemplateNoHeader() {
+		try {
+			InputStream is = DefaultTemplateContainerTest.class
+					.getResourceAsStream("/templates/test_template_invalid1.drl");
+			new DefaultTemplateContainer(is);
+			fail("DecisionTableParseException expected");
+		} catch (DecisionTableParseException expected) {
+			assertEquals("Missing header", expected.getMessage());
+		}
+	}
+
+	public void testParseTemplateNoHeaderColumns() {
+		try {
+			InputStream is = DefaultTemplateContainerTest.class
+					.getResourceAsStream("/templates/test_template_invalid2.drl");
+			new DefaultTemplateContainer(is);
+			fail("DecisionTableParseException expected");
+		} catch (DecisionTableParseException expected) {
+			assertEquals("Missing header columns", expected.getMessage());
+		}
+	}
+
+	public void testParseTemplateNoTemplates() {
+		try {
+			InputStream is = DefaultTemplateContainerTest.class
+					.getResourceAsStream("/templates/test_template_invalid3.drl");
+			new DefaultTemplateContainer(is);
+			fail("DecisionTableParseException expected");
+		} catch (DecisionTableParseException expected) {
+			assertEquals("Missing templates", expected.getMessage());
+		}
+	}
+
+	public void testParseTemplateNoEndTemplate() {
+		try {
+			InputStream is = DefaultTemplateContainerTest.class
+					.getResourceAsStream("/templates/test_template_invalid4.drl");
+			new DefaultTemplateContainer(is);
+			fail("DecisionTableParseException expected");
+		} catch (DecisionTableParseException expected) {
+			assertEquals("Missing end template", expected.getMessage());
+		}
+	}
+
+	public void testNullInputStream() {
+		try {
+			new DefaultTemplateContainer((InputStream) null);
+			fail("NullPointerException expected");
+		} catch (NullPointerException expected) {
+		}
+	}
+
+	public void testInvalidTemplatePath() {
+		try {
+			new DefaultTemplateContainer("invalid path");
+			fail("NullPointerException expected");
+		} catch (NullPointerException expected) {
+		}
+	}
+
+	public void testParseComplexTemplate() {
+		InputStream is = DefaultTemplateContainerTest.class
+				.getResourceAsStream("/templates/test_template_complex.drl");
+		DefaultTemplateContainer t = new DefaultTemplateContainer(is);
+		assertEquals("package This_is_a_ruleset;\n", t.getHeader());
+		Column[] columnList = t.getColumns();
+		assertEquals(5, columnList.length);
+		assertEquals("first_name", columnList[0].getName());
+		assertEquals("last_name", columnList[1].getName());
+		assertEquals("age", columnList[2].getName());
+		assertEquals("city", columnList[3].getName());
+		assertEquals("phone", columnList[4].getName());
+		assertEquals(columnList[1], t.getColumn("last_name"));
+		Map<String, RuleTemplate> templates = t.getTemplates();
+		assertEquals(2, templates.size());
+
+		RuleTemplate template = (RuleTemplate) templates.get("template1");
+		assertNotNull(template);
+		List<TemplateColumn> columns = template.getColumns();
+		assertEquals(1, columns.size());
+		TemplateColumn column = (TemplateColumn) columns.get(0);
+		assertEquals("first_name", column.getName());
+		
+		String contents = template.getContents();
+		assertTrue(contents
+				.startsWith("rule \"How cool is @{first_name} @{row.rowNumber}\""));
+		assertTrue(contents.endsWith("then\nend\n"));
+
+		template = (RuleTemplate) templates.get("template2");
+		assertNotNull(template);
+		columns = template.getColumns();
+		assertEquals(2, columns.size());
+		column = (TemplateColumn) columns.get(0);
+		assertEquals("first_name", column.getName());
+		TemplateColumn column2 = (TemplateColumn) columns.get(1);
+		assertEquals("last_name", column2.getName());
+		contents = template.getContents();
+		assertTrue(contents
+				.startsWith("rule \"How uncool is @{first_name} @{row.rowNumber}\""));
+		assertTrue(contents.endsWith("then\nend\n"));
+		
+
+	}
+}

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateRuleBaseTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateRuleBaseTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/DefaultTemplateRuleBaseTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,105 @@
+package org.drools.template.parser;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.drools.rule.GroupElement;
+import org.drools.rule.LiteralConstraint;
+import org.drools.rule.Package;
+import org.drools.rule.Rule;
+import org.drools.rule.VariableConstraint;
+import org.drools.template.parser.Column;
+import org.drools.template.parser.DefaultGenerator;
+import org.drools.template.parser.DefaultTemplateRuleBase;
+import org.drools.template.parser.LongColumn;
+import org.drools.template.parser.RuleTemplate;
+import org.drools.template.parser.StringColumn;
+import org.drools.template.parser.TemplateContainer;
+
+public class DefaultTemplateRuleBaseTest extends TestCase {
+
+	@SuppressWarnings("unchecked")
+    public void testSimpleTemplate() throws Exception
+	{
+		TemplateContainer tc = new TemplateContainer() {
+			private Column[] columns = new Column[] {
+					new LongColumn("column1"),
+					new LongColumn("column2"),
+					new StringColumn("column3")
+			};
+			
+			public Column[] getColumns() {
+				return columns;
+			}
+
+			public String getHeader() {
+				return null;
+			}
+
+			public Map<String, RuleTemplate> getTemplates() {
+				Map<String, RuleTemplate> templates = new HashMap<String, RuleTemplate>();
+				RuleTemplate ruleTemplate = new RuleTemplate("template1", this);
+				ruleTemplate.addColumn("column1 == 10");
+				ruleTemplate.addColumn("column2 < 5 || > 20");
+				ruleTemplate.addColumn("column3 == \"xyz\"");
+				templates.put("template1", ruleTemplate);
+				return templates;
+			}
+
+			public Column getColumn(String name) {
+				return columns[Integer.parseInt(name.substring(6)) - 1];
+			}
+			
+		};
+		DefaultTemplateRuleBase ruleBase = new DefaultTemplateRuleBase(tc);
+		Package[] packages = ruleBase.newStatefulSession().getRuleBase().getPackages();
+		assertEquals(1, packages.length);
+		Map<String, Class> globals = packages[0].getGlobals();
+		assertEquals(DefaultGenerator.class, globals.get("generator"));
+		Rule[] rules = packages[0].getRules();
+		assertEquals(1, rules.length);
+		assertEquals("template1", rules[0].getName());
+		GroupElement lhs = rules[0].getLhs();
+		//when
+		//  r : Row()
+		//  column1 : Column(name == "column1")
+		//  exists LongCell(row == r, column == column1, value == 10)
+		//  column2 : Column(name == "column2")
+		//  exists LongCell(row == r, column == column2, value < 5 | > 20)
+		//  column3 : Column(name == "column3")
+		//  exists StringCell(row == r, column == column3, value == "xyz")
+		assertEquals(7, lhs.getChildren().size());
+		org.drools.rule.Pattern pattern = (org.drools.rule.Pattern) lhs.getChildren().get(1);
+		assertEquals(1, pattern.getConstraints().size());
+		LiteralConstraint constraint = (LiteralConstraint) pattern.getConstraints().get(0);
+		assertEquals("column1", constraint.getField().getValue());
+		GroupElement exists = (GroupElement) lhs.getChildren().get(2);
+		pattern = (org.drools.rule.Pattern) exists.getChildren().get(0);
+		assertEquals(3, pattern.getConstraints().size());
+		VariableConstraint vconstraint = (VariableConstraint) pattern.getConstraints().get(1);
+		assertEquals(Column.class, vconstraint.getFieldExtractor().getExtractToClass());
+		assertEquals("column1", vconstraint.getRequiredDeclarations()[0].getIdentifier());
+		pattern = (org.drools.rule.Pattern) lhs.getChildren().get(3);
+		assertEquals(1, pattern.getConstraints().size());
+		constraint = (LiteralConstraint) pattern.getConstraints().get(0);
+		assertEquals("column2", constraint.getField().getValue());
+		exists = (GroupElement) lhs.getChildren().get(4);
+		pattern = (org.drools.rule.Pattern) exists.getChildren().get(0);
+		assertEquals(3, pattern.getConstraints().size());
+		vconstraint = (VariableConstraint) pattern.getConstraints().get(1);
+		assertEquals(Column.class, vconstraint.getFieldExtractor().getExtractToClass());
+		assertEquals("column2", vconstraint.getRequiredDeclarations()[0].getIdentifier());
+		pattern = (org.drools.rule.Pattern) lhs.getChildren().get(5);
+		assertEquals(1, pattern.getConstraints().size());
+		constraint = (LiteralConstraint) pattern.getConstraints().get(0);
+		assertEquals("column3", constraint.getField().getValue());
+		exists = (GroupElement) lhs.getChildren().get(6);
+		pattern = (org.drools.rule.Pattern) exists.getChildren().get(0);
+		assertEquals(3, pattern.getConstraints().size());
+		vconstraint = (VariableConstraint) pattern.getConstraints().get(1);
+		assertEquals(Column.class, vconstraint.getFieldExtractor().getExtractToClass());
+		assertEquals("column3", vconstraint.getRequiredDeclarations()[0].getIdentifier());
+	}
+}

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/ExternalSheetListenerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/ExternalSheetListenerTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/ExternalSheetListenerTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,460 @@
+package org.drools.template.parser;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.drools.Agenda;
+import org.drools.FactException;
+import org.drools.FactHandle;
+import org.drools.ObjectFilter;
+import org.drools.QueryResults;
+import org.drools.RuleBase;
+import org.drools.StatefulSession;
+import org.drools.WorkingMemoryEntryPoint;
+import org.drools.concurrent.Future;
+import org.drools.event.AgendaEventListener;
+import org.drools.event.RuleBaseEventListener;
+import org.drools.event.RuleFlowEventListener;
+import org.drools.event.WorkingMemoryEventListener;
+import org.drools.process.instance.ProcessInstance;
+import org.drools.process.instance.WorkItemManager;
+import org.drools.process.instance.timer.TimerManager;
+import org.drools.spi.AgendaFilter;
+import org.drools.spi.AgendaGroup;
+import org.drools.spi.AsyncExceptionHandler;
+import org.drools.spi.GlobalResolver;
+import org.drools.time.SessionClock;
+
+public class ExternalSheetListenerTest extends TestCase {
+
+	private TemplateDataListener esl;
+
+	private Map<Row, List<StringCell>> assertedRows = new HashMap<Row, List<StringCell>>();
+
+	private List<StringCell> currentRow = new ArrayList<StringCell>();
+
+	protected void setUp() throws Exception {
+		esl = new TemplateDataListener(2, 2, new TestTemplateContainer(),
+				new TestTemplateRuleBase(), new TestGenerator());
+
+	}
+
+	public void testRenderDrl() {
+		String drl = esl.renderDRL();
+		assertEquals("Test Template Header\nTest Generated DRL\n", drl);
+	}
+
+	public void testRowHandling() {
+		esl.newRow(0, 3);
+		esl.newCell(0, 0, "row0col0", 0);
+		esl.newCell(0, 1, "row0col1", 0);
+		esl.newCell(0, 2, "row0col2", 0);
+		esl.newRow(1, 3);
+		esl.newCell(1, 0, "row1col0", 0);
+		esl.newCell(1, 1, "row1col1", 0);
+		esl.newCell(1, 2, "row1col2", 0);
+		esl.newRow(2, 3);
+		esl.newCell(2, 0, "row2col0", 0);
+		esl.newCell(2, 1, "row2col1", 0);
+		esl.newCell(2, 2, "row2col2", 0);
+		esl.finishSheet();
+		assertEquals(2, assertedRows.size());
+		for ( Map.Entry<Row, List<StringCell>> entry : assertedRows.entrySet() ) {
+			Row row = entry.getKey();
+			List<StringCell> cells = entry.getValue();
+			// first column is not part of the decision table
+			int i = 1;
+			for ( StringCell cell : cells ) {
+				assertEquals("row" + row.getRowNumber() + "col" + i, cell.getValue());
+				assertEquals("Pattern " + i, cell.getColumn().getName());
+				i++;
+			}
+		}
+	}
+
+	public void testRowHandlingBlankRows() {
+		esl.newRow(0, 3);
+		esl.newCell(0, 0, "row0col0", 0);
+		esl.newCell(0, 1, "row0col1", 0);
+		esl.newCell(0, 2, "row0col2", 0);
+		esl.newRow(1, 3);
+		esl.newCell(1, 0, "row1col0", 0);
+		esl.newCell(1, 1, "row1col1", 0);
+		esl.newCell(1, 2, "row1col2", 0);
+		esl.newRow(2, 3);
+		esl.newCell(2, 0, "row2col0", 0);
+		esl.newCell(2, 1, "row2col1", 0);
+		esl.newCell(2, 2, "row2col2", 0);
+		esl.newRow(3, 3);
+		esl.newCell(3, 0, "", 0);
+		esl.newCell(3, 1, "", 0);
+		esl.newCell(3, 2, "", 0);
+		esl.newRow(4, 3);
+		esl.newCell(4, 0, "", 0);
+		esl.newCell(4, 1, "", 0);
+		esl.newCell(4, 2, "", 0);
+
+		esl.finishSheet();
+		assertEquals(2, assertedRows.size());
+	}
+
+	private class TestTemplateRuleBase implements TemplateRuleBase {
+
+		public StatefulSession newStatefulSession() {
+			return new StatefulSession() {
+                private static final long serialVersionUID = 1L;
+
+                public void addEventListener(WorkingMemoryEventListener arg0) {
+
+				}
+
+				public void addEventListener(AgendaEventListener arg0) {
+
+				}
+
+				public void addEventListener(RuleFlowEventListener arg0) {
+
+				}
+
+				public FactHandle insert(Object fact)
+						throws FactException {
+					if (fact instanceof Row) {
+						assertedRows.put((Row) fact, currentRow);
+						currentRow = new ArrayList<StringCell>();
+					} else if (fact instanceof StringCell) {
+						currentRow.add((StringCell) fact);
+					}
+					return null;
+				}
+
+				public FactHandle insert(Object arg0, boolean arg1)
+						throws FactException {
+					return null;
+				}
+
+				public void clearAgenda() {
+
+				}
+
+				public void clearAgendaGroup(String arg0) {
+
+				}
+
+				public void dispose() {
+
+				}
+
+				public void fireAllRules() throws FactException {
+
+				}
+
+				public void fireAllRules(AgendaFilter arg0)
+						throws FactException {
+
+				}
+
+				public Agenda getAgenda() {
+					return null;
+				}
+
+				@SuppressWarnings("unchecked")
+                public List getAgendaEventListeners() {
+					return null;
+				}
+
+				public FactHandle getFactHandle(Object arg0) {
+					return null;
+				}
+
+				public AgendaGroup getFocus() {
+					return null;
+				}
+
+				public Object getGlobal(String arg0) {
+					return null;
+				}
+
+				public Object getObject(FactHandle arg0) {
+					return null;
+				}
+
+				public QueryResults getQueryResults(String arg0) {
+					return null;
+				}
+
+				public RuleBase getRuleBase() {
+					return null;
+				}
+
+				@SuppressWarnings("unchecked")
+                public List getWorkingMemoryEventListeners() {
+					return null;
+				}
+
+				public void update(FactHandle arg0, Object arg1)
+						throws FactException {
+
+				}
+
+				public void removeEventListener(WorkingMemoryEventListener arg0) {
+
+				}
+
+				public void removeEventListener(AgendaEventListener arg0) {
+
+				}
+
+				public void removeEventListener(RuleFlowEventListener arg0) {
+
+				}
+
+				public void retract(FactHandle arg0) throws FactException {
+
+				}
+
+				public void setAsyncExceptionHandler(AsyncExceptionHandler arg0) {
+
+				}
+
+				public void setFocus(String arg0) {
+
+				}
+
+				public void setFocus(AgendaGroup arg0) {
+
+				}
+
+				public void setGlobal(String arg0, Object arg1) {
+
+				}
+
+				public void setGlobalResolver(GlobalResolver globalResolver) {
+
+				}
+
+				public ProcessInstance startProcess(String processId) {
+					return null;
+				}
+
+                @SuppressWarnings("unchecked")
+                public Iterator iterateFactHandles() {
+                    return null;
+                }
+
+                @SuppressWarnings("unchecked")
+                public Iterator iterateFactHandles(ObjectFilter filter) {
+                    return null;
+                }
+
+                @SuppressWarnings("unchecked")
+                public Iterator iterateObjects() {
+                    return null;
+                }
+
+                @SuppressWarnings("unchecked")
+                public Iterator iterateObjects(ObjectFilter filter) {
+                    return null;
+                }
+
+                public Future asyncInsert(Object object) {
+                    return null;
+                }
+
+                public Future asyncInsert(Object[] list) {
+                    return null;
+                }
+
+                @SuppressWarnings("unchecked")
+                public Future asyncInsert(Collection collection) {
+                    return null;
+                }
+
+                public Future asyncFireAllRules() {
+                    return null;
+                }
+
+                public Future asyncFireAllRules(AgendaFilter agendaFilter) {
+                    return null;
+                }
+
+                public Future asyncUpdate(FactHandle factHandle,
+                                                Object object) {
+
+                    return null;
+                }
+
+                public Future asyncRetract(FactHandle factHandle) {
+                    
+                    return null;
+                }
+
+                public QueryResults getQueryResults(String query,
+                                                    Object[] arguments) {
+                    
+                    return null;
+                }
+
+                public void modifyInsert(FactHandle factHandle,
+                                         Object object) {
+                    
+
+                }
+
+                public void modifyRetract(FactHandle factHandle) {
+                    
+
+                }
+
+                public void halt() {
+                    
+
+                }
+
+                public void fireAllRules(int fireLimit) throws FactException {
+                    
+
+                }
+
+                public void fireAllRules(AgendaFilter agendaFilter,
+                                         int fireLimit) throws FactException {
+                    
+
+                }
+
+				public GlobalResolver getGlobalResolver() {
+                    
+                    return null;
+                }
+
+                @SuppressWarnings("unchecked")
+                public List getRuleFlowEventListeners() {
+                    
+                    return null;
+                }
+
+                public void clearActivationGroup(String group) {
+                    
+
+                }
+
+                public void clearRuleFlowGroup(String group) {
+                    
+
+                }
+
+                public void addEventListener(RuleBaseEventListener listener) {
+                    
+
+                }
+
+                @SuppressWarnings("unchecked")
+                public List getRuleBaseEventListeners() {
+                    
+                    return null;
+                }
+
+                public void removeEventListener(RuleBaseEventListener listener) {
+                    
+
+                }
+
+                @SuppressWarnings("unchecked")
+                public List getRuleBaseUpdateListeners() {
+                    
+                    return null;
+                }
+
+                public ProcessInstance getProcessInstance(long id) {
+                    
+                    return null;
+                }
+
+                public WorkItemManager getWorkItemManager() {
+                    
+                    return null;
+                }
+
+                @SuppressWarnings("unchecked")
+                public Collection getProcessInstances() {
+                    
+                    return null;
+                }
+
+                public ProcessInstance startProcess(String processId,
+                        Map<String, Object> parameters) {
+                    
+                    return null;
+                }
+
+                public FactHandle getFactHandleByIdentity(Object object) {
+                    
+                    return null;
+                }
+
+                public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String id) {
+                    
+                    return null;
+                }
+				public TimerManager getTimerManager() {
+					
+					return null;
+				}
+
+                public SessionClock getSessionClock() {
+                    return null;
+                }
+			};
+		}
+	}
+
+	private class TestGenerator implements Generator {
+
+		public void generate(String templateName, Row row) {
+		}
+
+		public String getDrl() {
+			return "Test Generated DRL";
+		}
+
+	}
+
+	private class TestTemplateContainer implements TemplateContainer {
+
+		public void addColumn(Column c) {
+		}
+
+		public void addTemplate(RuleTemplate template) {
+		}
+
+		public Column[] getColumns() {
+			return new Column[] { new StringColumn("Pattern 1"),
+					new StringColumn("Pattern 2"), new StringColumn("Pattern 3") };
+		}
+
+		public String getHeader() {
+			return "Test Template Header";
+		}
+
+		public Map<String, RuleTemplate> getTemplates() {
+			return null;
+		}
+
+		public void setHeader(String head) {
+		}
+
+		public void setTemplates(Map<String, RuleTemplate> templates) {
+
+		}
+
+		public Column getColumn(String name) {
+			return null;
+		}
+	}
+
+}

Added: labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/RuleTemplateTest.java
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/RuleTemplateTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/java/org/drools/template/parser/RuleTemplateTest.java	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,70 @@
+package org.drools.template.parser;
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.drools.template.parser.Column;
+import org.drools.template.parser.RuleTemplate;
+import org.drools.template.parser.TemplateColumn;
+import org.drools.template.parser.TemplateContainer;
+import org.drools.util.StringUtils;
+
+public class RuleTemplateTest extends TestCase {
+	public void testSetContents() {
+		RuleTemplate rt = new RuleTemplate("rt1", getTemplateContainer());
+		rt.setContents("Test template");
+		assertEquals("Test template\n", rt.getContents());
+	}
+	
+	private TemplateContainer getTemplateContainer() {
+		return new TemplateContainer() {
+
+			public Column getColumn(String name) {
+				return null;
+			}
+
+			public Column[] getColumns() {
+				return null;
+			}
+
+			public String getHeader() {
+				return null;
+			}
+
+			public Map<String, RuleTemplate> getTemplates() {
+				return null;
+			}
+			
+		};
+	}
+
+	public void testAddColumn() {
+		RuleTemplate rt = new RuleTemplate("rt1", getTemplateContainer());
+		rt.addColumn("StandardColumn");
+		rt.addColumn("!NotColumn");
+		rt.addColumn("ColumnCondition == \"test\"");
+		rt.addColumn("!NotColumnCondition == \"test2\"");
+		rt.addColumn("ArrayColumnCondition[0] == \"test2\"");
+		List<TemplateColumn> columns = rt.getColumns();
+		assertEquals(5, columns.size());
+		TemplateColumn column1 = (TemplateColumn) columns.get(0);
+		assertEquals("StandardColumn", column1.getName());
+		assertFalse(column1.isNotCondition());
+		assertTrue(StringUtils.isEmpty(column1.getCondition()));
+		TemplateColumn column2 = (TemplateColumn) columns.get(1);
+		assertEquals("NotColumn", column2.getName());
+		assertTrue(column2.isNotCondition());
+		assertTrue(StringUtils.isEmpty(column2.getCondition()));
+		TemplateColumn column3 = (TemplateColumn) columns.get(2);
+		assertEquals("ColumnCondition", column3.getName());
+		assertFalse(column3.isNotCondition());
+		assertEquals("== \"test\"", column3.getCondition());
+		TemplateColumn column4 = (TemplateColumn) columns.get(3);
+		assertEquals("NotColumnCondition", column4.getName());
+		assertTrue(column4.isNotCondition());
+		assertEquals("== \"test2\"", column4.getCondition());
+		
+	}
+}

Added: labs/jbossrules/trunk/drools-templates/src/test/resources/templates/rule_template_1.drl
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/resources/templates/rule_template_1.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/resources/templates/rule_template_1.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,36 @@
+template header
+FEE_SCHEDULE_ID
+FEE_SCHEDULE_TYPE
+FEE_MODE_TYPE
+ENTITY_BRANCH
+PRODUCT_TYPE
+ACTIVITY_TYPE
+FEE_TYPE
+OWNING_PARTY
+CCY
+LC_AMOUNT
+dummy
+AMOUNT
+
+
+package org.drools.decisiontable;
+#generated from Decision Table
+
+global FeeResult result;
+
+template "Fee Schedule"
+rule "Fee Schedule_@{row.rowNumber}"
+	agenda-group "@{FEE_SCHEDULE_TYPE}"
+	when
+		FeeEvent(productType == "@{PRODUCT_TYPE}",
+			activityType == "@{ACTIVITY_TYPE}",
+			feeType == "@{FEE_TYPE}",
+			txParty == "@{OWNING_PARTY}",
+			entityBranch == "@{ENTITY_BRANCH}",
+			amount @{LC_AMOUNT},
+			ccy == "@{CCY}"
+			)
+	then
+		result.setSchedule(new FeeSchedule("@{FEE_SCHEDULE_ID}", "@{FEE_SCHEDULE_TYPE}", @{AMOUNT}));	
+end
+end template

Added: labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_complex.drl
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_complex.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_complex.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,27 @@
+template header
+first_name
+last_name
+age
+city
+phone
+
+package This_is_a_ruleset;
+
+template "template1"
+first_name
+rule "How cool is @{first_name} @{row.rowNumber}"
+	when
+		user.getName().equals("@{first_name}")
+	then
+end
+end template
+
+template "template2"
+first_name
+last_name
+rule "How uncool is @{first_name} @{row.rowNumber}"
+	when
+		user.getFirstName().equals("@{first_name}")
+	then
+end
+end template

Added: labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_conditions.drl
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_conditions.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_conditions.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,14 @@
+template header
+name
+
+package This_is_a_ruleset;
+
+template "template1"
+name == "name1"
+rule "How cool is @{name} @{row.rowNumber}"
+	when
+		user.getName().equals("@{name}")
+	then
+end
+end template
+

Added: labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid1.drl
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid1.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid1.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,11 @@
+package This_is_a_ruleset;
+
+template "template1"
+name
+rule "How cool is @{name} @{row.rowNumber}"
+	when
+		user.getName().equals("@{name}")
+	then
+end
+end template
+

Added: labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid2.drl
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid2.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid2.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,13 @@
+template header
+
+package This_is_a_ruleset;
+
+template "template1"
+name
+rule "How cool is @{name} @{row.rowNumber}"
+	when
+		user.getName().equals("@{name}")
+	then
+end
+end template
+

Added: labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid3.drl
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid3.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid3.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,13 @@
+template header
+name
+
+package This_is_a_ruleset;
+
+name
+rule "How cool is @{name} @{row.rowNumber}"
+	when
+		user.getName().equals("@{name}")
+	then
+end
+end template
+

Added: labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid4.drl
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid4.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_invalid4.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,14 @@
+template header
+name
+
+package This_is_a_ruleset;
+
+template "template1"
+name
+rule "How cool is @{name} @{row.rowNumber}"
+	when
+		user.getName().equals("@{name}"
+	then
+end
+
+

Added: labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_simple.drl
===================================================================
--- labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_simple.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-templates/src/test/resources/templates/test_template_simple.drl	2008-06-18 04:56:57 UTC (rev 20568)
@@ -0,0 +1,14 @@
+template header
+name
+
+package This_is_a_ruleset;
+
+template "template1"
+name
+rule "How cool is @{name} @{row.rowNumber}"
+	when
+		user.getName().equals("@{name}")
+	then
+end
+end template
+

Modified: labs/jbossrules/trunk/pom.xml
===================================================================
--- labs/jbossrules/trunk/pom.xml	2008-06-18 00:00:06 UTC (rev 20567)
+++ labs/jbossrules/trunk/pom.xml	2008-06-18 04:56:57 UTC (rev 20568)
@@ -651,6 +651,7 @@
         <module>drools-core</module>
         <module>drools-compiler</module>
         <module>drools-jsr94</module>
+        <module>drools-templates</module>
         <module>drools-decisiontables</module>
         <!-- TODO enable these or create a profile in which they are enabled (to avoid making the build slow) -->
         <!--module>drools-server</module-->
@@ -718,6 +719,18 @@
             </dependency>
             <dependency>
                 <groupId>org.drools</groupId>
+                <artifactId>drools-templates</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.drools</groupId>
+                <artifactId>drools-templates</artifactId>
+                <type>test-jar</type>
+                <version>${project.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.drools</groupId>
                 <artifactId>drools-decisiontables</artifactId>
                 <version>${project.version}</version>
             </dependency>




More information about the jboss-svn-commits mailing list