AGGetStatements.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGGetStatements {
@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("getstatements", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex","http://example.org/");
ts.addStatement("!ex:a","!ex:p", "!ex:b");
ts.addStatement("!ex:p","!rdfs:domain", "!ex:D");
ts.addStatement("!ex:p","!rdfs:range", "!ex:R");
Cursor cc = ts.getStatements(false,"!ex:a",null,null);
System.out.println("Retrieving triples with subject ex:a");
AGUtils.showTriples(cc);
cc = ts.getStatements(false,null,"!rdfs:domain",null);
System.out.println("Retrieving triples with predicate rdfs:domain");
AGUtils.showTriples(cc);
cc = ts.getStatements(false,null,null,"!ex:b");
System.out.println("Retrieving triples with object ex:b");
AGUtils.showTriples(cc);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next