eu.fbk.rdfpro.rules.functions.StarSelectGraphFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rdfpro-rules Show documentation
Show all versions of rdfpro-rules Show documentation
Parser and writer for RDF in Turtle Quads (TQL) format. TQL is N-Quads
with the more permissive (and efficient!) Turtle encoding. TQL is used in
DBpedia exports and is supported in input by the Virtuoso triple store.
package eu.fbk.rdfpro.rules.functions;
import org.openrdf.model.Value;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.vocabulary.RDF;
import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
import org.openrdf.query.algebra.evaluation.function.Function;
import eu.fbk.rdfpro.rules.RR;
public class StarSelectGraphFunction implements Function {
@Override
public String getURI() {
return RR.STAR_SELECT_GRAPH.stringValue();
}
@Override
public Value evaluate(final ValueFactory valueFactory, final Value... args)
throws ValueExprEvaluationException {
final Value global = args[0];
Value result = null;
for (int i = 1; i < args.length; ++i) {
final Value graph = args[i];
if (!graph.equals(global)) {
if (result == null) {
result = graph;
} else {
return RDF.NIL;
}
}
}
return result != null ? result : global;
}
}