use of org.eclipse.rdf4j.query.parser.serql.ast.ASTLiteral 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);
}
Aggregations