AGNamespaces.java
package com.franz.ag.examples;
import com.franz.ag.*;
import org.openrdf.model.URI;
public class AGNamespaces {
@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("namespaces", AGPaths.TRIPLE_STORES);
ts.addStatement("<http://example.org/c>",
"<http://example.org/p>",
"<http://example.org/d>");
ts.registerNamespace("ex","http://example.org/");
ts.registerNamespace("xsd", "http://www.w3.org/2001/XMLSchema#");
URI a = (URI)ts.addPart("!ex:a");
AGUtils.showURI(a);
Literal lit = (Literal)ts.addPart("!\"42\"^^xsd:integer");
ts.addStatement(a,"!ex:p", lit);
ts.addStatement("!ex:b","!ex:p", "!ex:c");
ts.addStatement("!ex:p","!rdf:type", "!owl:TransitiveProperty");
Cursor cc = ts.getStatements(false,null,"<http://example.org/p>",null);
System.out.println("Triples with predicate http://example.org/p:");
AGUtils.showTriples(cc);
cc = ts.getStatements(false,null,"!ex:p",null);
System.out.println("Triples with predicate ex:p");
AGUtils.showTriples(cc);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next