Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
RDFReactor creates domain-specific, type-safe Java classes which
act as a view over domain-free, loosely typed RDF instances.
This library needs to be shipped together with generated
classes.
package org.ontoware.rdfreactor.runtime;
import java.lang.reflect.Array;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.ontoware.aifbcommons.collection.ClosableIterator;
import org.ontoware.rdf2go.exception.ModelRuntimeException;
import org.ontoware.rdf2go.model.Model;
import org.ontoware.rdf2go.model.Statement;
import org.ontoware.rdf2go.model.impl.ModelAddRemoveMemoryImpl;
import org.ontoware.rdf2go.model.impl.TriplePatternImpl;
import org.ontoware.rdf2go.model.node.Node;
import org.ontoware.rdf2go.model.node.Resource;
import org.ontoware.rdf2go.model.node.URI;
import org.ontoware.rdf2go.model.node.Variable;
import org.ontoware.rdf2go.vocabulary.RDF;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* BridgeBase provides methods for adding, querying and deleting
* statements from the underlying RDF2Go model.
*
* TODO: be type-safe
*
*
*
*
* RDF Reactor uses the following naming:
*
* resource - instance of an RDF schema class, identified by the
* resource ID (an URI or BlankNode), allmost all statements about the resource
* use the resource ID as the object
*
* property - a property belongs to a resource, represented by the
* predicate of a statement about a resource
*
* value - value of a property of a resource, represented by the object
* of the statement with the property as predicate and the resource ID as the
* subject
*
* @author mvo
*/
public class BridgeBase {
private static Logger log = LoggerFactory.getLogger(BridgeBase.class);
// /////////////////////////
// true implementations
/**
* Check if the resource identified by resourceID, has a property
* identidified by propertyURI which has the given value among its values.
*
* @param model -
* the underlying RDF2Go model
* @param resource -
* must be an URI or a BlankNode
* @param propertyURI -
* URI of the property
* @param value -
* look for this value of the property
* @return true if value is among values for the property
* @throws Exception
*/
@Patrolled
public static boolean containsGivenValue(Model model, Resource resource,
URI propertyURI, Object value) throws ModelRuntimeException {
Node objectNode = RDFReactorRuntime.java2node(model, value);
return model.contains(resource, propertyURI, objectNode);
}
/**
* Return the first x with matching statement (resourceObject, propertyURI,
* x) from the given model. If severeal matching statements exist, only the
* first is returned.
*
* @param model -
* the underlying RDF2Go model
* @param resourceSubject -
* the URI or BlankNode of the resource
* @param propertyURI -
* the URI of the property
* @param returnType -
* return the value from the statement as the given Java Type
* @return the first x matching (resourceObject, propertyURI, x)
* @throws RDFDataException
* if more then one value was found
* @throws ModelRuntimeException
*/
@Patrolled
public static Object getValue(Model model, Resource resourceSubject,
URI propertyURI, java.lang.Class> returnType)
throws RDFDataException, ModelRuntimeException {
Node node = ResourceUtils.getSingleValue(model, resourceSubject,
propertyURI);
return RDFReactorRuntime.node2javatype(model, node, returnType);
}
/**
* Return a Set with all x matching (resourceObject, propertyURI, x) in the
* given model.
*
* @param model -
* the underlying model
* @param resource -
* URI or BlankNode of the resource
* @param propertyURI -
* URI of the property
* @param returnType -
* return the found values as the given Java Type
* @return Set