All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.fbk.rdfpro.rules.functions.StarSelectGraphFunction Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 0.4.1
Show newest version
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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy