org.drools.decisiontable.parser
Class DefaultRuleSheetListener

java.lang.Object
  extended by org.drools.decisiontable.parser.DefaultRuleSheetListener
All Implemented Interfaces:
RuleSheetListener, DataListener
Direct Known Subclasses:
RuleMatrixSheetListener

public class DefaultRuleSheetListener
extends Object
implements RuleSheetListener

An object of this class is prepared to receive calls passing it the contents of a spreadsheet containing one or more decision tables. Each of these tables is then expanded into a set of similar rules, varying to a degree with respect to the patterns and actions. A "rule set" starts with some overall definitions such as imports, globals, functions and queries. A table is identifed by a cell beginning with the text "RuleTable". The first row after the table identifier defines the column type: either a pattern of the condition or an action for the consequence, or an attribute. The second row contains optional pattern type declarations. If cells in this row are merged, then all snippets below the merged stretch become part of the same pattern, as separate constraints. The third row identifies the java code block associated with the condition or consequence. This code block should include one or more parameter markers for the insertion of values defined in cells of that column. The third row is available for comments on the purpose of the column. All subsequent rows identify rules with the set, providing values to be inserted where there are markers in the code snippets defined in the third row, or for the attribute identified by the column header. href="mailto:michael.neale@gmail.com"> Michael Neale


Field Summary
static String FUNCTIONS_TAG
           
static String IMPORT_TAG
           
static String QUERIES_TAG
           
static String RULE_TABLE_TAG
           
static String RULESET_TAG
           
static String SEQUENTIAL_FLAG
           
static String VARIABLES_TAG
           
 
Fields inherited from interface org.drools.template.parser.DataListener
NON_MERGED
 
Constructor Summary
DefaultRuleSheetListener()
          Constructor.
DefaultRuleSheetListener(boolean showPackage)
          Constructor.
 
Method Summary
protected  void addRule(Rule newRule)
          Add a new rule to the current list of rules
 void finishSheet()
          Come to the end of the sheet.
protected  Rule getCurrentRule()
           
 PropertiesSheetListener.CaseInsensitiveMap getProperties()
          Return the rule sheet properties
 Package getRuleSet()
          Build the final ruleset as parsed.
 void newCell(int row, int column, String value, int mergedColStart)
          Enter a new cell.
 void newRow(int rowNumber, int columns)
          Enter a new row.
protected  void postInitRuleTable(int row, int column, String value)
          Called after rule table initialisation.
protected  void preInitRuleTable(int row, int column, String value)
          Called before rule table initialisation.
 void startSheet(String name)
          Start a new sheet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUERIES_TAG

public static final String QUERIES_TAG
See Also:
Constant Field Values

FUNCTIONS_TAG

public static final String FUNCTIONS_TAG
See Also:
Constant Field Values

IMPORT_TAG

public static final String IMPORT_TAG
See Also:
Constant Field Values

SEQUENTIAL_FLAG

public static final String SEQUENTIAL_FLAG
See Also:
Constant Field Values

VARIABLES_TAG

public static final String VARIABLES_TAG
See Also:
Constant Field Values

RULE_TABLE_TAG

public static final String RULE_TABLE_TAG
See Also:
Constant Field Values

RULESET_TAG

public static final String RULESET_TAG
See Also:
Constant Field Values
Constructor Detail

DefaultRuleSheetListener

public DefaultRuleSheetListener()
Constructor.


DefaultRuleSheetListener

public DefaultRuleSheetListener(boolean showPackage)
Constructor.

Parameters:
showPackage - if true, the rule set name is passed to the resulting package
Method Detail

getProperties

public PropertiesSheetListener.CaseInsensitiveMap getProperties()
Description copied from interface: RuleSheetListener
Return the rule sheet properties

Specified by:
getProperties in interface RuleSheetListener

getRuleSet

public Package getRuleSet()
Description copied from interface: RuleSheetListener
Build the final ruleset as parsed.

Specified by:
getRuleSet in interface RuleSheetListener

addRule

protected void addRule(Rule newRule)
Add a new rule to the current list of rules

Parameters:
rule -

startSheet

public void startSheet(String name)
Description copied from interface: DataListener
Start a new sheet

Specified by:
startSheet in interface DataListener
Parameters:
name - the sheet name

finishSheet

public void finishSheet()
Description copied from interface: DataListener
Come to the end of the sheet.

Specified by:
finishSheet in interface DataListener

newRow

public void newRow(int rowNumber,
                   int columns)
Description copied from interface: DataListener
Enter a new row.

Specified by:
newRow in interface DataListener

newCell

public void newCell(int row,
                    int column,
                    String value,
                    int mergedColStart)
Description copied from interface: DataListener
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.

Specified by:
newCell in interface DataListener
Parameters:
row - the row number
column - the column alpha character label
value - the string value of the cell

preInitRuleTable

protected void preInitRuleTable(int row,
                                int column,
                                String value)
Called before rule table initialisation. Subclasses may override this method to do additional processing.


getCurrentRule

protected Rule getCurrentRule()

postInitRuleTable

protected void postInitRuleTable(int row,
                                 int column,
                                 String value)
Called after rule table initialisation. Subclasses may override this method to do additional processing.



Copyright © 2001-2013 JBoss Inc.. All Rights Reserved.