例: ビジネス・ルール言語のルート構造の再定義
新しいルート・ノードの実装例として、Business Query Language (BQL) のルート・ノードを追加できます。 ルート・ノード・トランスレーターも用意する必要があります。
非推奨フィーチャー:
カスタム・ビジネス・ルール言語のサポートは V8.8.1 では非推奨です。このフィーチャーは、製品の今後のリリースでは削除されます。移行の詳細は、非推奨フィーチャー を参照してください。
抽象構文の新しいルート・ノードを用意する、つまり、完全に新しいルール言語を作成する場合には、固有のルート・ノード・トランスレーターを用意する必要があります。
ルート・ノード・トランスレーターは、IlrRuleStatement インスタンスを作成したり、サブノードで context.processNode を呼び出して構造を完成させたりします。
例えば、Business Query Language (BQL) のルート・ノード (T-class-rule) は、以下のように実装します。
public static class ClassRuleNodeTranslator implements IlrNodeTranslator
{
public IlrStatement process(IlrSyntaxTree.Node node,
IlrTranslationContext context) {
// BQL generates one rule
IlrRuleStatement rule = new IlrRuleStatement(node);
IlrIntermediateForm iform = context.getIntermediateForm();
iform.setRuleStatement(rule);
// Binding is implicit in BQL
IlrConcept ruleQueryConcept =
context.getVocabulary().getConcept("bql.RuleQuery");
rule.addConditionStatement(new IlrSimpleBindingStatement(node,
"ruleQuery", ruleQueryConcept));
// Process class condition
IlrSyntaxTree.Node classCondNode = node.getSubNode("class-condition");
// Process the condition part
context.setCurrentRulePart(IlrTranslationContext.CONDITIONS_PART);
IlrConditionStatement condStmt =
(IlrConditionStatement) context.processNode(classCondNode);
if (condStmt != null)
rule.addConditionStatement(condStmt);
// Process the action part
context.setCurrentRulePart(IlrTranslationContext.ACTIONS_PART);
IlrSyntaxTree.Node actionsNode = node.getSubNode("actions");
if (actionsNode != null)
{
IlrActionStatement actionStmt =
(IlrActionStatement) context.processNode(actionsNode);
if (actionStmt != null)
rule.addActionStatement(actionStmt);
}
return rule;
}
}