use of com.inova8.pathql.pathPattern.PathPatternParser.QueryOptionContext in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternVisitor method visitQueryOptions.
/**
* Visit query options.
*
* @param ctx the ctx
* @return the query options path element
*/
@Override
public QueryOptionsPathElement visitQueryOptions(QueryOptionsContext ctx) {
// queryOptions : ( queryOption )+;
// queryOption: KEY '=' literal ('^^' type )?;
// KEY : '&' [a-zA-Z]+ ;
CustomQueryOptions customQueryOptions = new CustomQueryOptions();
for (QueryOptionContext queryOption : ctx.queryOption()) {
String key = queryOption.KEY().getText().substring(1);
LiteralValueElement literal = (LiteralValueElement) visit(queryOption.literal());
if (queryOption.type() != null) {
IriRefValueElement type = (IriRefValueElement) visit(queryOption.type());
Literal typeLiteral = Values.literal(Values.getValueFactory(), literal.getLiteral().getLabel(), type.getIri());
customQueryOptions.add(key, typeLiteral);
} else {
customQueryOptions.add(key, literal.getLiteral());
}
}
QueryOptionsPathElement queryOptionsPathElement = new QueryOptionsPathElement(this.repositoryContext);
queryOptionsPathElement.setCustomQueryOptions(customQueryOptions);
return queryOptionsPathElement;
}
Aggregations