public IRuleNode visit(RuleList obj, IRuleNode arg) throws RIFException {
try {
//Wenn Liste leer
if (obj.getItems().isEmpty()) {
return new Constant(
LiteralFactory
.createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>"),
arg);
}
Conjunction conjunction = new Conjunction();
conjunction.setParent(arg);
int iteration = 0;
//Listenidentifikator erstellen
String baseName = aliasString + "list" + listCtr++ + "it";
conjunction.addExpr(new RuleVariable(baseName + iteration));
int ctr = obj.getItems().size();
for (IExpression expr : obj.getItems()) {
ctr--;
IRuleNode result = expr.accept(this, conjunction);
final String itVar = baseName + iteration++;
if (result instanceof Conjunction) {
for (IExpression item : new ArrayList<IExpression>(
((Conjunction) result).exprs))
if (item instanceof RulePredicate)
conjunction.addExpr(item);
else if (item instanceof RuleVariable)
result = item;
}
final RulePredicate item = new RulePredicate(
new RuleVariable(itVar),
new Constant(
LiteralFactory
.createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#first>"),
arg), (IExpression) result);
conjunction.addExpr(item);
final RulePredicate next = new RulePredicate(
new RuleVariable(itVar),
new Constant(
LiteralFactory
.createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>"),
arg),
ctr == 0 ? new Constant(
LiteralFactory
.createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>"),
arg)
: new RuleVariable(baseName + iteration));
conjunction.addExpr(next);