AGSailGetStatements.java
package com.franz.agsail.examples;
import com.knowledgereefsystems.agsail.*;
import info.aduna.iteration.CloseableIteration;
import java.io.File;
import org.openrdf.model.Statement;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.openrdf.sail.*;
public class AGSailGetStatements {
@param
@throws
public static void main(String[] args) throws SailException {
Sail sail = new AllegroSail("localhost", 4567, false, "store", new File(AGPaths.TRIPLE_STORES), 0, 0, false, false);
sail.initialize();
SailConnection sc = sail.getConnection();
ValueFactory f = sail.getValueFactory();
String ex = "http://example.org/";
String rdf = sc.getNamespace("rdf");
String rdfs = sc.getNamespace("rdfs");
URI a = f.createURI(ex, "a");
URI classA = f.createURI(ex, "A");
URI classB = f.createURI(ex, "B");
URI rdf_type = f.createURI(rdf, "type");
URI rdfs_subClassOf = f.createURI(rdfs, "subClassOf");
sc.addStatement(a, rdf_type, classA);
sc.addStatement(classA,rdfs_subClassOf,classB);
System.out.println("Statements <ex:a, rdf:type, null> - no inference");
CloseableIteration<? extends Statement, SailException> iter1 = sc.getStatements(a, rdf_type, null, false);
try {
while (iter1.hasNext()) {
System.out.println(iter1.next());
}
} catch (SailException e) {
iter1.close();
}
System.out.println("Statements <ex:a, rdf:type, null> - with inference");
CloseableIteration<? extends Statement, SailException> iter2 = sc.getStatements(a, rdf_type, null, true);
try {
while (iter2.hasNext()) {
System.out.println(iter2.next());
}
} catch (SailException e) {
iter2.close();
}
sc.close();
sail.shutDown();
}
}
Up |
Next