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

com.github.tkurz.sparqlmm.function.accessor.StartAccessor Maven / Gradle / Ivy

Go to download

SPARQL-MM is a multimedia-extension for SPARQL 1.1 (www.w3.org/TR/sparql11-query/‎) implemented for Sesame (http://www.openrdf.org/).

There is a newer version: 2.0
Show newest version
package com.github.tkurz.sparqlmm.function.accessor;

import com.github.tkurz.media.ontology.type.TemporalEntity;
import com.github.tkurz.sparqlmm.Constants;
import com.github.tkurz.sparqlmm.doc.FunctionDoc;
import com.github.tkurz.sparqlmm.utils.FunctionHelper;
import org.openrdf.model.Value;
import org.openrdf.model.ValueFactory;
import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
import org.openrdf.query.algebra.evaluation.function.Function;

/**
 * ...
 * 

* Author: Thomas Kurz ([email protected]) */ @FunctionDoc(title = "Start Accessor", properties = {TemporalEntity.class}, reference = FunctionDoc.Reference.temporal, description = "returns the start of an interval, null if there is none.", type = FunctionDoc.Type.accessorFunction) public class StartAccessor implements Function { @Override public String getURI() { return Constants.NAMESPACE + "getStart"; } @Override public Value evaluate(ValueFactory valueFactory, Value... values) throws ValueExprEvaluationException { if(values.length != 1) return null; try { TemporalEntity e = FunctionHelper.toTemporalEntity(values[0]); if(e == null) return null; return valueFactory.createLiteral(e.getStart().getValue()); } catch (IllegalArgumentException e) { return null; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy