AGNamedGraphs.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGNamedGraphs {
@param
@throws
public static void main(String[] args) throws AllegroGraphException {
AllegroGraphConnection ags = new AllegroGraphConnection();
try {
ags.enable();
} catch (Exception e) {
throw new AllegroGraphException("Server connection problem", e);
}
AllegroGraph ts = ags.renew("namedgraphs", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex","http://example.org/");
ts.addStatement("!ex:a", "!ex:p", "!ex:b");
ts.addStatement("!ex:Dog","!rdf:type","!owl:Class","<http://animals.example.org>");
System.out.println("Show all triples in all graphs in the store");
Cursor cc = ts.getStatements(null, null, null, null);
AGUtils.showTriplesWithGraph(cc);
System.out.println("Show all triples in graph http://animals.example.org");
cc = ts.getStatements(null, null, null, "<http://animals.example.org>");
AGUtils.showTriplesWithGraph(cc);
System.out.println("Show all triples in the default graph");
cc = ts.getStatements(null, null, null);
AGUtils.showTriplesWithGraph(cc);
System.out.println("Another way of showing all triples in the default graph");
cc = ts.getStatements(null, null, null, "");
AGUtils.showTriplesWithGraph(cc);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next