/**
* Gets the rules test.
* @author: Yan Tang, VUB, 2009
* @return the rules test
*/
public static void getRulesTest() {
String[][] content = new String[][] { { "CONDITION", "", "", "", "" },
{ "C1", "Y", "N", "Y", "N" }, { "C2", "Y", "Y", "N", "N" },
{ "ACTION", "", "", "", "" }, { "A1", "/", "*", "/", "/" },
{ "A2", "*", "*", "/", "/" } };
DecisionTable table = new DecisionTable();
Vector<DecisionRule> rules = table.getRules(content);
for (int i = 0; i < rules.size(); i++)
rules.get(i).printToConsole();
}
// step1: create the jaxb context
JAXBContext jaxbContext = JAXBContext.newInstance("sdt.xml");
// step2: create the marshaller
Marshaller marshaller = jaxbContext.createMarshaller();
// set xml file output format: line breaks and indentation will appear
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true));... read more
A relevant condition stub is a condition stub that cannot be removed safely. If you remove it, your decision table will not be complete.
When we say a condition stub is irrelevant, it means that the decision rules won't change if we remove this condition stub from the decision table.
Vector<decisionrule> rules = makeExample();</decisionrule>
IrrelevantConditionStubRemover remover = new IrrelevantConditionStubRemover(
rules);
rules = remover.removeIrrelevantConditionStubs(new String[] { "C1" });
System.err.println("-----------result-----------" + rules.size());
for (int i = 0; i < rules.size(); i++)
System.err.println(rules.get(i).getInfo());
A relevant condition stub is a condition stub that cannot be removed safely. If you remove it, your decision table will not be complete.
When we say a condition stub is irrelevant, it means that the decision rules won't change if we remove this condition stub from the decision table.
/**
*@author: Yan Tang, VUB, 2009
*/
Vector<DecisionRule> rules = makeExample();... [read more](/p/sdtapi/blog/2012/10/get-relevant-condition-stubs/)
/**
* Checks if is range or value test_ float.
* @author: Yan Tang, VUB, 2009
*/
public static void isRangeOrValueTest_Float() {
ValueRange range = new ValueRange("<=100");
boolean isRangeOrValue = range.isFloatRangeOrValue();
System.out.println(range.getInput() + " isRangeOrValue = "
+ isRangeOrValue);
System.err.print(range.getInfo());... [read more](/p/sdtapi/blog/2012/10/how-to-use-valuerange/)
/**
* Removes the empty spaces begin and end test.
* @author: Yan Tang, VUB, 2009
*/
public static void removeEmptySpacesBeginAndEndTest() {
String s = "1234";
StringManager manager = new StringManager(s);
manager.removeEmptySpacesBeginAndEnd();
System.out.println(manager.getString());
s = " 1234 ";
manager.setString(s);
manager.removeEmptySpacesBeginAndEnd();
System.out.println(manager.getString());... [read more](/p/sdtapi/blog/2012/10/how-to-use-stringmanager/)
/**
* Reverse test.
* @author: Yan Tang, VUB, 2009
*/
public static void reverseTest() {
StringArrayVector vector = new StringArrayVector();
Vector<String[]> v = new Vector<String[]>();
v.add(new String[] { "1", "2", "3" });
v.add(new String[] { "3", "4", "5" });
vector.printToconsole(v);
v = vector.reverse(v);
vector.printToconsole(v);
}
/**
* Contains test.
* @author: Yan Tang, VUB, 2009
*/
public static void containsTest() {
StringArray array = new StringArray(new String[] { "0", "1", "2", " ",
"", "4", "*" });
String containingComponent = " ";
boolean contains = array.contains(containingComponent, 1, 5);
System.out
.println("contains=" + contains + "\ninfo=" + array.getInfo());... [read more](/p/sdtapi/blog/2012/10/how-to-use-stringarray/)
/**
* Gets the all columns test.
* @author: Yan Tang, VUB, 2009
* @return the all columns test
*/
public static void getAllColumnsTest() {
openSDTfile file = new openSDTfile();
String filePathName = "C:\\SDT\\DT in XML files\\Nokeos_ERM_exampleRearrange00.xml";
SDT sdt = file.openSDTXMLFile(filePathName);
SemanticDecisionTable table = new SemanticDecisionTable(sdt);
Vector<String[]> columns = table.getAllColumns();
for (int i = 0; i < columns.size(); i++) {
String[] array = columns.get(i);
StringArray sa = new StringArray(array);
sa.printArrayToConsole();
}
System.out.println(table.getProcessInfo());... [read more](/p/sdtapi/blog/2012/10/how-to-use-semanticdecisiontable/)
/**
* Gets the column test.
* @author: Yan Tang, VUB, 2009
* @return the column test
*/
public static void getColumnTest() {
String[][] matrix = new String[][] { { "C1", "1", "2", "1", "2" },
{ "C2", "1", "1", "2", "2" }, { "A1", "*", "", "", "" } };
SDTMatrix m = new SDTMatrix(matrix);... [read more](/p/sdtapi/blog/2012/10/how-to-use-sdtmatrix/)
/**
* Make example.
* @author: Yan Tang, VUB, 2009
* @return the vector
*/
private static Vector<DecisionRule> makeExample() {
// Originally first c1 then c2, start building a decision table
Vector<DecisionRule> rules = new Vector<DecisionRule>();
// column 1
DecisionRule rule = new DecisionRule();
rule.addCondition(new ConditionPair("C1", "Y"));
rule.addCondition(new ConditionPair("C2", "N"));
rule.addAction(new ActionPair("A1", "*"));
rule.addAction(new ActionPair("A2", "/"));
rules.add(rule);... [read more](/p/sdtapi/blog/2012/10/how-to-use-rowfiller/)
/**
* Make example.
*
* @return the vector
*/
private static Vector<DecisionRule> makeExample() {
// Originally first c1 then c2, start building a decision table
Vector<DecisionRule> rules = new Vector<DecisionRule>();
// column 1
DecisionRule rule = new DecisionRule();
rule.addCondition(new ConditionPair("C1", "Y"));
rule.addCondition(new ConditionPair("C2", "N"));
rule.addAction(new ActionPair("A1", "*"));
rule.addAction(new ActionPair("A2", "/"));
rules.add(rule);... [read more](/p/sdtapi/blog/2012/10/how-to-use-rowshifter/)
/**
* Make example.
* @author: Yan Tang, VUB, 2009
* @return the vector
*/
private static Vector<DecisionRule> makeExample() {
// Originally first c1 then c2, start building a decision table
Vector<DecisionRule> rules = new Vector<DecisionRule>();
// column 1
DecisionRule rule = new DecisionRule();
rule.addCondition(new ConditionPair("C1", "Y"));
rule.addCondition(new ConditionPair("C2", "N"));
rule.addAction(new ActionPair("A1", "*"));
rule.addAction(new ActionPair("A2", "/"));
rules.add(rule);... [read more](/p/sdtapi/blog/2012/10/how-to-use-emptytablegetter/)
/**
* Gets the nbr of empty entries test.
* @author: Yan Tang, VUB, 2009
* @return the nbr of empty entries test
*/
public static void getNbrOfEmptyEntriesTest() {
DecisonRulePropagator p = new DecisonRulePropagator("J", "N");
String[] column = new String[] { "", "J", "J", "", "*", "" };
int start = 1;
int end = 2;
String emptyToken = "";
Integer[] ids = p.getNbrOfEmptyEntries(column, start, end, emptyToken);
System.out.println(p.getInfo());... [read more](/p/sdtapi/blog/2012/10/how-to-use-decisionrulepropagator/)
/**
*@author: Yan Tang, VUB, 2009
*/
public static void getTableLayoutTest() {
DecisionTable dt = new DecisionTable();
Vector<String> conEntries = new Vector<String>();
conEntries.add("Yes");
conEntries.add("No");
conEntries.add(" ");
DTCondition con1 = new DTCondition("c1", conEntries);
DTCondition con2 = (new DTCondition("c2", conEntries));
dt.addCondition(con1);
dt.addCondition(con2);
dt.addActionStub("a1");
dt.addActionStub("a2");... [read more](/p/sdtapi/blog/2012/10/how-to-use-decisiontable/)
This method can be used to check whether or not a decision rule column exists in a decision table
/*
* Make example.
* @author Yan Tang, 2009
* @return the vector
/
private static Vector<DecisionRule> makeExample() {
// Originally first c1 then c2, start building a decision table
Vector<DecisionRule> rules = new Vector<DecisionRule>();
// column 1
DecisionRule rule = new DecisionRule();
rule.addCondition(new ConditionPair("C1", "Y"));
rule.addCondition(new ConditionPair("C2", "N"));
rule.addAction(new ActionPair("A1", "*"));
rule.addAction(new ActionPair("A2", "/"));
rules.add(rule);... [read more](/p/sdtapi/blog/2012/10/how-to-use-decisionrulevector/)
In the examples, you will find how to check whether or not 1) a condition, e.g., C1-Y, exists in a decision rule (a column in a decision table); 2)an action, e.g., A1-, exists in a decision rule; 3) two conditions are same, e.g, C-Y and C-Y are same ; 4) two actions are same, e.g. A-/, A- are not same.
/
* Condition pair exists test.
@author: Yan Tang, 2009
/
public static void conditionPairExistsTest() {
DecisionRule rule = new DecisionRule();
rule.addCondition(new ConditionPair("C1", "Y"));
rule.addCondition(new ConditionPair("C2", "N"));... read more