1
2
3
4
5
6
7
8
9
10
11
12
13
14 package eu.fbk.rdfpro.internal;
15
16 import org.openrdf.model.Value;
17 import org.openrdf.model.ValueFactory;
18 import org.openrdf.model.vocabulary.RDF;
19 import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
20 import org.openrdf.query.algebra.evaluation.function.Function;
21
22 import eu.fbk.rdfpro.vocab.RR;
23
24 public class FunctionStarSelectGraph implements Function {
25
26 @Override
27 public String getURI() {
28 return RR.STAR_SELECT_GRAPH.stringValue();
29 }
30
31 @Override
32 public Value evaluate(final ValueFactory valueFactory, final Value... args)
33 throws ValueExprEvaluationException {
34
35 final Value global = args[0];
36
37 Value result = null;
38 for (int i = 1; i < args.length; ++i) {
39 final Value graph = args[i];
40 if (!graph.equals(global)) {
41 if (result == null) {
42 result = graph;
43 } else {
44 return RDF.NIL;
45 }
46 }
47 }
48
49 return result != null ? result : global;
50 }
51
52 }