Author: mar...@jb...
Date: 2006-05-30 13:55:59 -0400 (Tue, 30 May 2006)
New Revision: 4487
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/SpreadsheetCompiler.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Condition.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Consequence.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLElement.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLJavaEmitter.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLOutput.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Duration.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Functions.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Global.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Import.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Package.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/SnippetBuilder.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/DecisionTableParseException.java
labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DecisionTableParser.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/SheetListener.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/Cheese.java
labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/Person.java
labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/SpreadsheetCompilerUnitTest.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/model/DurationTest.java
labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/FunctionsRenderTest.java
labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/PackageRenderTest.java
labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/RuleRenderTest.java
labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/model/SnippetBuilderTest.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
Log:
JBRULES-266 Customize how drools checks if an object is already asserted in its working memory
JBRULES-233 LogicalAssertions
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 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/InputType.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,11 +16,6 @@
* limitations under the License.
*/
-
-
-
-
-
import org.drools.decisiontable.parser.DecisionTableParser;
import org.drools.decisiontable.parser.SheetListener;
import org.drools.decisiontable.parser.csv.CsvLineParser;
@@ -32,15 +28,14 @@
*
* @author Michael Neale
*/
-public abstract class InputType
-{
- public static final InputType XLS = new XlsInput( );
- public static final InputType CSV = new CsvInput( );
+public abstract class InputType {
+ public static final InputType XLS = new XlsInput();
+ public static final InputType CSV = new CsvInput();
protected InputType() {
-
+
}
-
+
/**
* @param listener
* @return The appropriate Parser.
@@ -49,27 +44,19 @@
}
-class XlsInput
- extends
- InputType
-{
+class XlsInput extends InputType {
- public DecisionTableParser createParser(SheetListener listener)
- {
+ public DecisionTableParser createParser(final SheetListener listener) {
return new ExcelParser( listener );
}
}
-class CsvInput
- extends
- InputType
-{
+class CsvInput extends InputType {
- public DecisionTableParser createParser(SheetListener listener)
- {
+ public DecisionTableParser createParser(final SheetListener listener) {
return new CsvParser( listener,
- new CsvLineParser( ) );
+ new CsvLineParser() );
}
}
\ No newline at end of file
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 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/SpreadsheetCompiler.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,10 +16,6 @@
* limitations under the License.
*/
-
-
-
-
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
@@ -45,12 +42,12 @@
* for the decision tables, ignores others.
* @return DRL xml, ready for use in drools.
*/
- public String compile(InputStream xlsStream,
- InputType type) {
- RuleSheetListener listener = getRuleSheetListener( xlsStream,
+ public String compile(final InputStream xlsStream,
+ final InputType type) {
+ final RuleSheetListener listener = getRuleSheetListener( xlsStream,
type );
- Package rulePackage = listener.getRuleSet();
- DRLOutput out = new DRLOutput();
+ final Package rulePackage = listener.getRuleSet();
+ final DRLOutput out = new DRLOutput();
rulePackage.renderDRL( out );
return out.getDRL();
}
@@ -65,12 +62,12 @@
* Uses the first worksheet for the decision tables.
* @return DRL.
*/
- public String compile(String classPathResource,
- InputType inputType) {
- InputStream stream = this.getClass().getResourceAsStream( classPathResource );
+ public String compile(final String classPathResource,
+ final InputType inputType) {
+ final InputStream stream = this.getClass().getResourceAsStream( classPathResource );
try {
- String drl = compile( stream,
- inputType );
+ final String drl = compile( stream,
+ inputType );
return drl;
} finally {
closeStream( stream );
@@ -87,40 +84,40 @@
* The name of the worksheet that the decision tables live on.
* @return DRL, ready to go.
*/
- public String compile(InputStream stream,
- String worksheetName) {
- RuleSheetListener listener = getRuleSheetListener( stream,
+ public String compile(final InputStream stream,
+ final String worksheetName) {
+ final RuleSheetListener listener = getRuleSheetListener( stream,
worksheetName );
- Package rulePackage = listener.getRuleSet();
- DRLOutput out = new DRLOutput();
+ final Package rulePackage = listener.getRuleSet();
+ final DRLOutput out = new DRLOutput();
rulePackage.renderDRL( out );
return out.getDRL();
}
- private RuleSheetListener getRuleSheetListener(InputStream stream,
- InputType type) {
- RuleSheetListener listener = new RuleSheetListener();
+ private RuleSheetListener getRuleSheetListener(final InputStream stream,
+ final InputType type) {
+ final RuleSheetListener listener = new RuleSheetListener();
- DecisionTableParser parser = type.createParser( listener );
+ final DecisionTableParser parser = type.createParser( listener );
parser.parseFile( stream );
return listener;
}
- private RuleSheetListener getRuleSheetListener(InputStream stream,
- String worksheetName) {
- RuleSheetListener listener = new RuleSheetListener();
- Map listeners = new HashMap();
+ private RuleSheetListener getRuleSheetListener(final InputStream stream,
+ final String worksheetName) {
+ final RuleSheetListener listener = new RuleSheetListener();
+ final Map listeners = new HashMap();
listeners.put( worksheetName,
listener );
- ExcelParser parser = new ExcelParser( listeners );
+ final ExcelParser parser = new ExcelParser( listeners );
parser.parseFile( stream );
return listener;
}
- private void closeStream(InputStream stream) {
+ private void closeStream(final InputStream stream) {
try {
stream.close();
- } catch ( Exception e ) {
+ } catch ( final Exception e ) {
System.err.print( "WARNING: Wasn't able to " + "correctly close stream for decision table. " + e.getMessage() );
}
}
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Condition.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Condition.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Condition.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,32 +16,30 @@
* 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:mic...@gm..."> Michael Neale </a>
*/
-public class Condition extends DRLElement implements DRLJavaEmitter {
+public class Condition extends DRLElement
+ implements
+ DRLJavaEmitter {
- public String _snippet;
+ public String _snippet;
- /**
- * @param snippet
- * The snippet to set.
- */
- public void setSnippet(String snippet) {
- _snippet = snippet;
- }
+ /**
+ * @param snippet
+ * The snippet to set.
+ */
+ public void setSnippet(final String snippet) {
+ this._snippet = snippet;
+ }
- public String getSnippet() {
- return _snippet;
- }
+ public String getSnippet() {
+ return this._snippet;
+ }
- public void renderDRL(DRLOutput out) {
- out.writeLine("\t\t" + this._snippet);
- }
+ public void renderDRL(final DRLOutput out) {
+ out.writeLine( "\t\t" + this._snippet );
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Consequence.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Consequence.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Consequence.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,34 +16,32 @@
* 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:mic...@gm..."> Michael Neale </a>
*/
-public class Consequence extends DRLElement implements DRLJavaEmitter {
+public class Consequence extends DRLElement
+ implements
+ DRLJavaEmitter {
- private String _snippet;
+ private String _snippet;
- /**
- * @param _snippet
- * The _snippet to set.
- */
- public void setSnippet(String snippet) {
- _snippet = snippet;
- }
+ /**
+ * @param _snippet
+ * The _snippet to set.
+ */
+ public void setSnippet(final String snippet) {
+ this._snippet = snippet;
+ }
- public String getSnippet() {
- return _snippet;
- }
+ public String getSnippet() {
+ return this._snippet;
+ }
- public void renderDRL(DRLOutput out) {
- out.writeLine("\t\t" + _snippet);
- }
+ public void renderDRL(final DRLOutput out) {
+ out.writeLine( "\t\t" + this._snippet );
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLElement.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLElement.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLElement.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -20,25 +21,20 @@
*
* The LayerSupertype for this model/parse tree.
*/
-public abstract class DRLElement
-{
+public abstract class DRLElement {
private String _comment;
- public void setComment(String comment)
- {
- _comment = comment;
+ public void setComment(final String comment) {
+ this._comment = comment;
}
- String getComment()
- {
- return _comment;
+ String getComment() {
+ return this._comment;
}
-
+
boolean isCommented() {
- return (_comment != null && !("".equals(_comment)));
+ return (this._comment != null && !("".equals( this._comment )));
}
-
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLJavaEmitter.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLJavaEmitter.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLJavaEmitter.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,10 +16,6 @@
* limitations under the License.
*/
-
-
-
-
/**
* @author <a href="mailto:mic...@gm..."> Michael Neale </a>
*
@@ -28,7 +25,7 @@
*/
public interface DRLJavaEmitter {
- /** Each node can add its contribution to the output */
- void renderDRL(DRLOutput out);
+ /** Each node can add its contribution to the output */
+ void renderDRL(DRLOutput out);
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLOutput.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLOutput.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/DRLOutput.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,11 +16,8 @@
* limitations under the License.
*/
-
-
import java.io.StringWriter;
-
/**
* This contains the DRL output that each piece of the parser spreadsheet will contribute to
*
@@ -27,26 +25,26 @@
*
*/
public class DRLOutput {
-
- private StringWriter writer;
-
- public void writeLine(String line) {
- StringBuffer buf = writer.getBuffer();
- buf.append( line);
- buf.append('\n');
- }
-
- public DRLOutput() {
- this.writer = new StringWriter();
- }
-
- /** Return the rendered DRL so far */
- public String getDRL() {
- return writer.toString();
- }
- public String toString() {
- return getDRL();
- }
-
+ 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
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Duration.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Duration.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Duration.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -16,19 +17,13 @@
*/
-
-
-
-import java.util.StringTokenizer;
-
/**
* @author <a href="mailto:ric...@bl..."> Ricardo Rojas </a>
*
*/
public class Duration extends DRLElement
implements
- DRLJavaEmitter
-{
+ DRLJavaEmitter {
public String _snippet;
@@ -36,19 +31,19 @@
* @param snippet
* The snippet to set.
*/
- public void setSnippet(String snippet)
- {
- _snippet = snippet;
+ public void setSnippet(final String snippet) {
+ this._snippet = snippet;
}
- public String getSnippet()
- {
- return _snippet;
+ public String getSnippet() {
+ return this._snippet;
}
- public void renderDRL(DRLOutput out) {
- if (isCommented()) out.writeLine("#" + getComment());
- out.writeLine("\tduration " + _snippet);
-
- }
+ public void renderDRL(final DRLOutput out) {
+ if ( isCommented() ) {
+ out.writeLine( "#" + getComment() );
+ }
+ out.writeLine( "\tduration " + this._snippet );
+
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Functions.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Functions.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Functions.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -22,18 +22,20 @@
*
* @author Michael Neale
*/
-public class Functions implements DRLJavaEmitter {
+public class Functions
+ implements
+ DRLJavaEmitter {
- private String functionsListing;
+ private String functionsListing;
- public void setFunctionsListing(String functionsListing) {
- this.functionsListing = functionsListing;
- }
+ public void setFunctionsListing(final String functionsListing) {
+ this.functionsListing = functionsListing;
+ }
- public void renderDRL(DRLOutput out) {
- if (functionsListing != null) {
- out.writeLine(functionsListing);
- }
- }
+ public void renderDRL(final DRLOutput out) {
+ if ( this.functionsListing != null ) {
+ out.writeLine( this.functionsListing );
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Global.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Global.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Global.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,10 +16,6 @@
* limitations under the License.
*/
-
-
-
-
/**
* @author <a href="mailto:ric...@bl..."> Ricardo Rojas </a>
*
@@ -27,48 +24,42 @@
*/
public class Global extends DRLElement
implements
- DRLJavaEmitter
-{
+ DRLJavaEmitter {
- private String identifier;
+ private String identifier;
private String className;
/**
* @return Returns the className.
*/
- public String getClassName()
- {
- return className;
+ public String getClassName() {
+ return this.className;
}
/**
* @return Returns the varName.
*/
- public String getIdentifier()
- {
- return identifier;
+ public String getIdentifier() {
+ return this.identifier;
}
-
+
/**
* @param className
* The className to set.
*/
- public void setClassName(String clazz)
- {
- className = clazz;
+ public void setClassName(final String clazz) {
+ this.className = clazz;
}
/**
* @param varName
* The varName to set.
*/
- public void setIdentifier(String namez)
- {
- identifier = namez;
+ public void setIdentifier(final String namez) {
+ this.identifier = namez;
}
-
- public void renderDRL(DRLOutput out) {
- out.writeLine("global " + this.className + " " + this.identifier + ";");
- }
+ public void renderDRL(final DRLOutput out) {
+ out.writeLine( "global " + this.className + " " + this.identifier + ";" );
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Import.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Import.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Import.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,13 +16,6 @@
* limitations under the License.
*/
-
-
-
-
-
-
-
/**
* @author <a href="mailto:mic...@gm..."> Michael Neale </a>
*
@@ -30,29 +24,26 @@
*/
public class Import extends DRLElement
implements
- DRLJavaEmitter
-{
+ DRLJavaEmitter {
private String className;
/**
* @return Returns the className.
*/
- public String getClassName()
- {
- return className;
+ public String getClassName() {
+ return this.className;
}
/**
* @param className
* The className to set.
*/
- public void setClassName(String clazz)
- {
- className = clazz;
+ public void setClassName(final String clazz) {
+ this.className = clazz;
}
- public void renderDRL(DRLOutput out) {
- out.writeLine("import " + className + ";");
- }
+ public void renderDRL(final DRLOutput out) {
+ out.writeLine( "import " + this.className + ";" );
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Package.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Package.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Package.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,10 +16,6 @@
* limitations under the License.
*/
-
-
-
-
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -30,76 +27,80 @@
* been parsed from the spreadsheet. Also is the launching point for dumping out
* the DRL.
*/
-public class Package implements DRLJavaEmitter {
+public class Package
+ implements
+ DRLJavaEmitter {
- private String _name;
+ private String _name;
- private List _imports;
+ private List _imports;
- private List _variables; // List of the application data Variable Objects
+ private List _variables; // List of the application data Variable Objects
- private List _rules;
+ private List _rules;
- private Functions _functions;
+ private Functions _functions;
- public Package(String name) {
- _name = name;
- _imports = new LinkedList();
- _variables = new LinkedList();
- _rules = new LinkedList();
- _functions = new Functions();
- }
+ public Package(final String name) {
+ this._name = name;
+ this._imports = new LinkedList();
+ this._variables = new LinkedList();
+ this._rules = new LinkedList();
+ this._functions = new Functions();
+ }
- public void addImport(Import imp) {
- _imports.add(imp);
- }
+ public void addImport(final Import imp) {
+ this._imports.add( imp );
+ }
- public void addVariable(Global varz) {
- _variables.add(varz);
- }
+ public void addVariable(final Global varz) {
+ this._variables.add( varz );
+ }
- public void addRule(Rule rule) {
- _rules.add(rule);
- }
+ public void addRule(final Rule rule) {
+ this._rules.add( rule );
+ }
- public void addFunctions(String listing) {
- _functions.setFunctionsListing(listing);
- }
+ public void addFunctions(final String listing) {
+ this._functions.setFunctionsListing( listing );
+ }
+ public String getName() {
+ return this._name;
+ }
+ public List getImports() {
+ return this._imports;
+ }
- public String getName() {
- return _name;
- }
+ public List getVariables() {
+ return this._variables;
+ }
- public List getImports() {
- return _imports;
- }
+ public List getRules() {
+ return this._rules;
+ }
- public List getVariables() {
- return _variables;
- }
+ 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 );
- public List getRules() {
- return _rules;
- }
+ }
- public void renderDRL(DRLOutput out) {
- out.writeLine( "package " + _name.replace( ' ', '_' ) + ";" );
- out.writeLine("#generated from Decision Table");
- renderDRL(_imports, out);
- renderDRL(_variables, out);
- _functions.renderDRL(out);
- renderDRL(_rules, out);
-
+ private void renderDRL(final List list,
+ final DRLOutput out) {
+ for ( final Iterator it = list.iterator(); it.hasNext(); ) {
+ final DRLJavaEmitter emitter = (DRLJavaEmitter) it.next();
+ emitter.renderDRL( out );
+ }
+ }
- }
-
- private void renderDRL(List list, DRLOutput out) {
- for (Iterator it = list.iterator(); it.hasNext();) {
- DRLJavaEmitter emitter = (DRLJavaEmitter) it.next();
- emitter.renderDRL(out);
- }
- }
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/Rule.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,10 +16,6 @@
* limitations under the License.
*/
-
-
-
-
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import java.util.LinkedList;
@@ -29,213 +26,232 @@
*
* Represents a rule.
*/
-public class Rule extends DRLElement implements DRLJavaEmitter {
+public class Rule extends DRLElement
+ implements
+ DRLJavaEmitter {
- private static final int MAX_ROWS = 65535;
+ private static final int MAX_ROWS = 65535;
- private Integer _salience; // Integer as it may be null
+ private Integer _salience; // Integer as it may be null
- private String _name;
+ private String _name;
- private Duration _duration; // RIK: New variable to the Rule class (Defines
- // a Duration tag for the rule)
+ private Duration _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 _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 _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 _activationGroup; // RIK: New variable to the Rule class (Set the
+ // activation-group parameter of the rule tag)
- private List _lhs;
+ private List _lhs;
- private List _rhs;
+ private List _rhs;
- private int _spreadsheetRow;
+ 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(String name, Integer salience, int spreadsheetRow) {
- _name = name;
- _salience = salience;
- _description = "";
+ /**
+ * 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 = "";
- _lhs = new LinkedList();
- _rhs = new LinkedList();
- _spreadsheetRow = spreadsheetRow;
- }
+ this._lhs = new LinkedList();
+ this._rhs = new LinkedList();
+ this._spreadsheetRow = spreadsheetRow;
+ }
- public void addCondition(Condition con) {
- _lhs.add(con);
- }
+ public void addCondition(final Condition con) {
+ this._lhs.add( con );
+ }
- public void addConsequence(Consequence con) {
- _rhs.add(con);
- }
+ public void addConsequence(final Consequence con) {
+ this._rhs.add( con );
+ }
- public void renderDRL(DRLOutput out) {
- if (isCommented()) out.writeLine("#" + getComment());
- out.writeLine("rule " + "\"" + _name + "\"");
- if (_description != null) out.writeLine("\t" + _description);
- if (_salience != null) out.writeLine("\tsalience " + _salience);
- if (_activationGroup != null) out.writeLine("\tactivation-group" + _activationGroup);
- if (_noLoop != null) out.writeLine("\tno-loop" + _noLoop);
- if (_duration != null) out.writeLine("\tduration" + _duration);
-
- out.writeLine("\twhen");
- renderDRL(_lhs, out);
- out.writeLine("\tthen");
- renderDRL(_rhs, out);
-
- out.writeLine("end\n");
- }
+ 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._noLoop != null ) {
+ out.writeLine( "\tno-loop" + this._noLoop );
+ }
+ if ( this._duration != null ) {
+ out.writeLine( "\tduration" + this._duration );
+ }
-
- private void renderDRL(List list, DRLOutput out) {
- for (Iterator iter = list.iterator(); iter.hasNext();) {
- DRLJavaEmitter item = (DRLJavaEmitter) iter.next();
- item.renderDRL(out);
- }
- }
+ out.writeLine( "\twhen" );
+ renderDRL( this._lhs,
+ out );
+ out.writeLine( "\tthen" );
+ renderDRL( this._rhs,
+ out );
- public static int calcSalience(int rowNumber) {
- if (rowNumber > MAX_ROWS) {
- throw new IllegalArgumentException(
- "That row number is above the max: " + MAX_ROWS);
- }
- return MAX_ROWS - rowNumber;
- }
+ out.writeLine( "end\n" );
+ }
- /**
- * @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(int i) {
+ private void renderDRL(final List list,
+ final DRLOutput out) {
+ for ( final Iterator iter = list.iterator(); iter.hasNext(); ) {
+ final DRLJavaEmitter item = (DRLJavaEmitter) iter.next();
+ item.renderDRL( out );
+ }
+ }
- String result;
- int div = i / 26;
- int mod = i % 26;
+ 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;
+ }
- if (div == 0) {
- byte[] c = new byte[1];
- c[0] = (byte) (mod + 65);
- result = byteToString(c);
- } else {
- byte[] firstChar = new byte[1];
- firstChar[0] = (byte) ((div - 1) + 65);
+ /**
+ * @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) {
- byte[] secondChar = new byte[1];
- secondChar[0] = (byte) (mod + 65);
- String first = byteToString(firstChar);
- String second = byteToString(secondChar);
- result = first + second;
- }
- return result;
+ 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);
- private static String byteToString(byte[] secondChar) {
- try {
- return new String(secondChar, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Unable to convert char to string.", e);
- }
- }
+ 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;
- public List getConditions() {
- return _lhs;
- }
+ }
- public List getConsequences() {
- return _rhs;
- }
+ 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 void setSalience(Integer value) // Set the salience of the rule
- {
- _salience = value;
- }
+ public List getConditions() {
+ return this._lhs;
+ }
- public Integer getSalience() {
- return _salience;
- }
+ public List getConsequences() {
+ return this._rhs;
+ }
- public void setName(String value) // Set the name of the rule
- {
- _name = value;
- }
+ public void setSalience(final Integer value) // Set the salience of the rule
+ {
+ this._salience = value;
+ }
- public String getName() {
- return _name;
- }
+ public Integer getSalience() {
+ return this._salience;
+ }
- public void setDescription(String value) // Set the description of the
- // rule
- {
- _description = value;
- }
+ public void setName(final String value) // Set the name of the rule
+ {
+ this._name = value;
+ }
- public void appendDescription(String value) // Set the description of the
- // rule
- {
- _description += value;
- }
+ public String getName() {
+ return this._name;
+ }
- public String getDescription() {
- return _description;
- }
+ public void setDescription(final String value) // Set the description of the
+ // rule
+ {
+ this._description = value;
+ }
- public void setDuration(Duration value) // Set the duration of the rule
- {
- _duration = value;
- }
+ public void appendDescription(final String value) // Set the description of the
+ // rule
+ {
+ this._description += value;
+ }
- public String getDuration() {
- return _duration.getSnippet();
- }
+ public String getDescription() {
+ return this._description;
+ }
- public void setActivationrGroup(String value) // Set the duration of the rule
- {
- _activationGroup = value;
- }
+ public void setDuration(final Duration value) // Set the duration of the rule
+ {
+ this._duration = value;
+ }
- public String getActivationGroup() {
- return _activationGroup;
- }
+ public String getDuration() {
+ return this._duration.getSnippet();
+ }
- public void setNoLoop(String value) // Set the no-loop attribute of the rule
- {
- _noLoop = value;
- }
+ public void setActivationrGroup(final String value) // Set the duration of the rule
+ {
+ this._activationGroup = value;
+ }
- public boolean getNoLoop() {
- String value = "false";
- if (_noLoop.compareTo("true") != 0)
- value = _noLoop;
- Boolean b = new Boolean(value);
- return b.booleanValue();
- }
-
- /**
- * @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;
- }
+ public String getActivationGroup() {
+ return this._activationGroup;
+ }
+ public void setNoLoop(final String value) // Set the no-loop attribute of the rule
+ {
+ this._noLoop = value;
+ }
+ public boolean getNoLoop() {
+ String value = "false";
+ if ( this._noLoop.compareTo( "true" ) != 0 ) {
+ value = this._noLoop;
+ }
+ final Boolean b = new Boolean( value );
+ return b.booleanValue();
+ }
+
+ /**
+ * @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
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/SnippetBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/SnippetBuilder.java 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/model/SnippetBuilder.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.model;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,10 +16,6 @@
* limitations under the License.
*/
-
-
-
-
/**
* @author <a href="mailto:mic...@gm..."> Michael Neale </a>
*
@@ -32,14 +29,12 @@
* 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
-{
+public class SnippetBuilder {
- private static final String PARAM_PREFIX = "$";
+ private static final String PARAM_PREFIX = "$";
- private static final String PARAM = PARAM_PREFIX + "param";
+ private static final String PARAM = SnippetBuilder.PARAM_PREFIX + "param";
-
private String _template;
/**
@@ -47,9 +42,8 @@
* The snippet including the "place holder" for a parameter. If
* no "place holder" is present,
*/
- public SnippetBuilder(String snippetTemplate)
- {
- _template = snippetTemplate;
+ public SnippetBuilder(final String snippetTemplate) {
+ this._template = snippetTemplate;
}
/**
@@ -58,36 +52,29 @@
* place holder exists, will just return the snippet.
* @return The final snippet.
*/
- public String build(String cellValue)
- {
- if ( _template == null )
- {
+ public String build(final String cellValue) {
+ if ( this._template == null ) {
throw new RuntimeException( "Script template is null - check for missing script definition." );
}
-
- if ( _template.indexOf( PARAM_PREFIX + "1" ) > 0 )
- {
+
+ if ( this._template.indexOf( SnippetBuilder.PARAM_PREFIX + "1" ) > 0 ) {
return buildMulti( cellValue );
- }
- else
- {
+ } else {
return buildSingle( cellValue );
}
}
+ private String buildMulti(final String cellValue) {
+ final String[] cellVals = cellValue.split( "," );
+ 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 );
- private String buildMulti(String cellValue)
- {
- String[] cellVals = cellValue.split( "," );
- String result = _template;
-
- for ( int paramNumber = 0; paramNumber < cellVals.length; paramNumber++ )
- {
- String replace = PARAM_PREFIX + (paramNumber + 1);
- result = replace(result, replace, cellVals[paramNumber].trim( ), 256 );
-
-
}
return result;
}
@@ -96,10 +83,12 @@
* @param cellValue
* @return
*/
- private String buildSingle(String cellValue)
- {
+ private String buildSingle(final String cellValue) {
- return replace(_template, PARAM, cellValue, 256);
+ return replace( this._template,
+ SnippetBuilder.PARAM,
+ cellValue,
+ 256 );
}
@@ -107,32 +96,28 @@
* Simple replacer.
* jakarta commons provided the inspiration for this.
*/
- private String replace(String text,
- String repl,
- String with,
- int max)
- {
- if ( text == null || repl == null || repl.equals( "" ) || with == null || max == 0 )
- {
+ 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;
}
- StringBuffer buf = new StringBuffer( text.length( ) );
+ final StringBuffer buf = new StringBuffer( text.length() );
int start = 0, end = 0;
while ( (end = text.indexOf( repl,
- start )) != -1 )
- {
+ start )) != -1 ) {
buf.append( text.substring( start,
end ) ).append( with );
- start = end + repl.length( );
+ start = end + repl.length();
- if ( --max == 0 )
- {
+ if ( --max == 0 ) {
break;
}
}
buf.append( text.substring( start ) );
- return buf.toString( );
+ return buf.toString();
}
}
\ No newline at end of file
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 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.parser;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,11 +16,6 @@
* limitations under the License.
*/
-
-
-
-
-
import java.util.Map;
import org.drools.decisiontable.model.SnippetBuilder;
@@ -32,47 +28,44 @@
* There are five types of columns relevant to a rule table.
* @author <a href="mailto:Mic...@gm..."> Michael Neale</a>
*/
-public class ActionType
-{
+public class ActionType {
- public static final int CONDITION = 0;
+ public static final int CONDITION = 0;
- public static final int ACTION = 1;
+ public static final int ACTION = 1;
// 08 - 16 - 2005 RIK: Define 3 new ActionType types
// PRIORITY is used to set the salience parameter of a rule tag
- public static final int PRIORITY = 2;
+ public static final int PRIORITY = 2;
// DURATION is used to set a duration tag inside a rule tag
- public static final int DURATION = 3;
+ public static final int DURATION = 3;
// NAME is used to set the name parameter of a rule tag
- public static final int NAME = 4;
+ public static final int NAME = 4;
// 10 - 05 - 2005 RIK: Add 2 new AtcionType types
// DESCRIPTION is used to set the description parameter of a rule tag
- public static final int DESCRIPTION = 5;
+ public static final int DESCRIPTION = 5;
// NOLOOP is used to set the no-loop parameter of a rule tag
- public static final int NOLOOP = 6;
+ public static final int NOLOOP = 6;
// XOR-GROUP is used to set the activation-group parameter of a rule tag
- public static final int ACTIVATIONGROUP = 7;
+ public static final int ACTIVATIONGROUP = 7;
int type;
String value;
- ActionType(int actionType,
- String cellValue)
- {
- type = actionType;
- value = cellValue;
+ ActionType(final int actionType,
+ final String cellValue) {
+ this.type = actionType;
+ this.value = cellValue;
}
- String getSnippet(String cellValue)
- {
- SnippetBuilder builder = new SnippetBuilder( value );
+ String getSnippet(final String cellValue) {
+ final SnippetBuilder builder = new SnippetBuilder( this.value );
return builder.build( cellValue );
}
@@ -80,94 +73,80 @@
* Create a new action type that matches this cell, and add it to the map,
* keyed on that column.
*/
- public static void addNewActionType(Map actionTypeMap,
- String value,
- int column,
- int row)
- {
- if ( value.toUpperCase( ).startsWith( "C" ) )
- {
+ public static void addNewActionType(final Map actionTypeMap,
+ final String value,
+ final int column,
+ final int row) {
+ if ( value.toUpperCase().startsWith( "C" ) ) {
actionTypeMap.put( new Integer( column ),
new ActionType( ActionType.CONDITION,
null ) );
- }
- else if ( value.toUpperCase( ).startsWith( "A" ) )
- {
+ } else if ( value.toUpperCase().startsWith( "A" ) ) {
actionTypeMap.put( new Integer( column ),
new ActionType( ActionType.ACTION,
null ) );
- }
- else if ( value.toUpperCase( ).startsWith( "P" ) ) // if the title cell
- // value starts with
- // "P" then put a
- // ActionType.PRIORITY
- // to the _actions
- // list
+ } else if ( value.toUpperCase().startsWith( "P" ) ) // if the title cell
+ // value starts with
+ // "P" then put a
+ // ActionType.PRIORITY
+ // to the _actions
+ // list
{
actionTypeMap.put( new Integer( column ),
new ActionType( ActionType.PRIORITY,
null ) );
- }
- else if ( value.toUpperCase( ).startsWith( "D" ) ) // if the title cell
- // value starts with
- // "D" then put a
- // ActionType.DURATION
- // to the _actions
- // list
+ } else if ( value.toUpperCase().startsWith( "D" ) ) // if the title cell
+ // value starts with
+ // "D" then put a
+ // ActionType.DURATION
+ // to the _actions
+ // list
{
actionTypeMap.put( new Integer( column ),
new ActionType( ActionType.DURATION,
null ) );
- }
- else if ( value.toUpperCase( ).startsWith( "N" ) ) // if the title cell
- // value starts with
- // "N" then put a
- // ActionType.NAME
- // to the _actions
- // list
+ } else if ( value.toUpperCase().startsWith( "N" ) ) // if the title cell
+ // value starts with
+ // "N" then put a
+ // ActionType.NAME
+ // to the _actions
+ // list
{
actionTypeMap.put( new Integer( column ),
new ActionType( ActionType.NAME,
null ) );
- }
- else if ( value.toUpperCase( ).startsWith( "I" ) ) // if the title cell
- // value starts with
- // "I" then put a
- // ActionType.DESCRIPTION
- // to the _actions
- // list
- {
- actionTypeMap.put( new Integer( column ),
- new ActionType( ActionType.DESCRIPTION,
- null ) );
- }
- else if ( value.toUpperCase( ).startsWith( "U" ) ) // if the title cell
- // value starts with
- // "U" then put a
- // ActionType.NOLOOP
- // to the _actions
- // list
+ } else if ( value.toUpperCase().startsWith( "I" ) ) // if the title cell
+ // value starts with
+ // "I" then put a
+ // ActionType.DESCRIPTION
+ // to the _actions
+ // list
{
- actionTypeMap.put( new Integer( column ),
- new ActionType( ActionType.NOLOOP,
- null ) );
- }
- else if ( value.toUpperCase( ).startsWith( "X" ) ) // if the title cell
- // value starts with
- // "X" then put a
- // ActionType.XORGROUP
- // to the _actions
- // list
- {
- actionTypeMap.put( new Integer( column ),
- new ActionType( ActionType.ACTIVATIONGROUP,
- null ) );
- }
- else
+ actionTypeMap.put( new Integer( column ),
+ new ActionType( ActionType.DESCRIPTION,
+ null ) );
+ } else if ( value.toUpperCase().startsWith( "U" ) ) // if the title cell
+ // value starts with
+ // "U" then put a
+ // ActionType.NOLOOP
+ // to the _actions
+ // list
{
- throw new DecisionTableParseException( "Invalid column header (ACTION type), " +
- "should be CONDITION or ACTION (etc..) row number:" + (row + 1) + " cell number:" +
- (column + 1) + " - does not contain a leading C or A identifer." );
+ actionTypeMap.put( new Integer( column ),
+ new ActionType( ActionType.NOLOOP,
+ null ) );
+ } else if ( value.toUpperCase().startsWith( "X" ) ) // if the title cell
+ // value starts with
+ // "X" then put a
+ // ActionType.XORGROUP
+ // to the _actions
+ // list
+ {
+ actionTypeMap.put( new Integer( column ),
+ new ActionType( ActionType.ACTIVATIONGROUP,
+ null ) );
+ } else {
+ throw new DecisionTableParseException( "Invalid column header (ACTION type), " + "should be CONDITION or ACTION (etc..) row number:" + (row + 1) + " cell number:" + (column + 1) + " - does not contain a leading C or A identifer." );
}
}
Modified: 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 2006-05-30 17:11:53 UTC (rev 4486)
+++ labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DecisionTableParseException.java 2006-05-30 17:55:59 UTC (rev 4487)
@@ -1,4 +1,5 @@
package org.drools.decisiontable.parser;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,22 +16,17 @@
* limitations under the License.
*/
+public class DecisionTableParseException extends RuntimeException {
-
-
-
-
-public class DecisionTableParseException extends RuntimeException
-{
-
-
private static final long serialVersionUID = 2655710832124783733L;
- public DecisionTableParseException(String message) {
- super(message);
+ public DecisionTableParseException(final String message) {
+ super( message );
}
-
- public DecisionTableParseException(String message, Throwable cause) {
- super(message, cause);
+
+ public DecisionTableParseException(final String message,
+ final Throwable cause) {
+ super( message,
+ cause );
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-decisiontables/src/main/java/org/drools/decisiontabl...
[truncated message content] |