use of org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public ValueConstant visit(ASTLiteral litNode, Object data) throws VisitorException {
IRI datatype = null;
// Get datatype URI from child URI node, if present
ASTValueExpr dtNode = litNode.getDatatypeNode();
if (dtNode instanceof ASTURI) {
datatype = valueFactory.createIRI(((ASTURI) dtNode).getValue());
} else if (dtNode != null) {
throw new IllegalArgumentException("Unexpected datatype type: " + dtNode.getClass());
}
Literal literal;
if (datatype != null) {
literal = valueFactory.createLiteral(litNode.getLabel(), datatype);
} else if (litNode.hasLang()) {
literal = valueFactory.createLiteral(litNode.getLabel(), litNode.getLang());
} else {
literal = valueFactory.createLiteral(litNode.getLabel());
}
return new ValueConstant(literal);
}
use of org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public ValueExpr visit(ASTInList node, Object data) throws VisitorException {
ValueExpr leftArg = (ValueExpr) node.getValueExpr().jjtAccept(this, null);
ValueExpr result = null;
for (ASTValueExpr argExpr : node.getArgList().getElements()) {
ValueExpr rightArg = (ValueExpr) argExpr.jjtAccept(this, null);
if (result == null) {
// First argument
result = new SameTerm(leftArg, rightArg);
} else {
SameTerm sameTerm = new SameTerm(leftArg.clone(), rightArg);
result = new Or(result, sameTerm);
}
}
assert result != null;
return result;
}
use of org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public FunctionCall visit(ASTFunctionCall node, Object data) throws VisitorException {
ValueConstant vc = (ValueConstant) node.getURI().jjtAccept(this, null);
assert vc.getValue() instanceof IRI;
FunctionCall functionCall = new FunctionCall(vc.getValue().toString());
for (ASTValueExpr argExpr : node.getArgList().getElements()) {
functionCall.addArg((ValueExpr) argExpr.jjtAccept(this, null));
}
return functionCall;
}
Aggregations