private void codeRow(final int row, final int column, final String value) { final ActionType actionType = getActionForColumn(row, column); if (actionType.getSourceBuilder() == null) { if (actionType.getCode() == Code.CONDITION) { actionType.setSourceBuilder(new LhsBuilder(row - 2, column, null)); this.sourceBuilders.add(actionType.getSourceBuilder()); } else if (actionType.getCode() == Code.ACTION) { actionType.setSourceBuilder(new RhsBuilder(Code.ACTION, row - 2, column, null)); this.sourceBuilders.add(actionType.getSourceBuilder()); } else if (actionType.getCode() == Code.SALIENCE) { actionType.setSourceBuilder(new LhsBuilder(row - 2, column, null)); this.sourceBuilders.add(actionType.getSourceBuilder()); } else if (actionType.getCode() == Code.METADATA) { actionType.setSourceBuilder(new RhsBuilder(Code.METADATA, row - 2, column, null)); this.sourceBuilders.add(actionType.getSourceBuilder()); } } if (value.trim().equals("") && (actionType.getCode() == Code.ACTION || actionType.getCode() == Code.CONDITION || actionType.getCode() == Code.METADATA)) { throw new DecisionTableParseException( "Code description in cell " + RuleSheetParserUtil.rc2name(row, column) + " does not contain any code specification. It should!"); } actionType.addTemplate(row, column, value); }
/** * This is for handling a row where an object declaration may appear, this is the row immediately * above the snippets. It may be blank, but there has to be a row here. * * <p>Merged cells have "special meaning" which is why this is so freaking hard. A future refactor * may be to move away from an "event" based listener. */ private void objectTypeRow( final int row, final int column, final String value, final int mergedColStart) { if (value.indexOf("$param") > -1 || value.indexOf("$1") > -1) { throw new DecisionTableParseException( "It looks like you have snippets in the row that is " + "meant for object declarations." + " Please insert an additional row before the snippets, " + "at cell " + RuleSheetParserUtil.rc2name(row, column)); } ActionType action = getActionForColumn(row, column); if (mergedColStart == RuleSheetListener.NON_MERGED) { if (action.getCode() == Code.CONDITION) { SourceBuilder src = new LhsBuilder(row - 1, column, value); action.setSourceBuilder(src); this.sourceBuilders.add(src); } else if (action.getCode() == Code.ACTION) { SourceBuilder src = new RhsBuilder(Code.ACTION, row - 1, column, value); action.setSourceBuilder(src); this.sourceBuilders.add(src); } } else { if (column == mergedColStart) { if (action.getCode() == Code.CONDITION) { action.setSourceBuilder(new LhsBuilder(row - 1, column, value)); this.sourceBuilders.add(action.getSourceBuilder()); } else if (action.getCode() == Code.ACTION) { action.setSourceBuilder(new RhsBuilder(Code.ACTION, row - 1, column, value)); this.sourceBuilders.add(action.getSourceBuilder()); } } else { ActionType startOfMergeAction = getActionForColumn(row, mergedColStart); action.setSourceBuilder(startOfMergeAction.getSourceBuilder()); } } }