AGRangeQueries.java
package com.franz.ag.examples;
import com.franz.ag.*;
import org.openrdf.model.Literal;
public class AGRangeQueries {
@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("rangequeries", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex","http://example.org/");
ts.addStatement("!ex:person1","!ex:age", ts.createEncodedLiteral(28,"int"));
ts.addStatement("!ex:person2","!ex:age", ts.createEncodedLiteral(30,"int"));
ts.addStatement("!ex:person3","!ex:age", ts.createEncodedLiteral(32,"int"));
ts.addStatement("!ex:person4","!ex:age", ts.createEncodedLiteral(40,"int"));
ts.addStatement("!ex:person5","!ex:age", ts.createEncodedLiteral(42,"int"));
Literal low = ts.createEncodedLiteral(30,"int");
Literal high = ts.createEncodedLiteral(40,"int");
System.out.println("Retrieving triples with range 30 <= ex:age <= 40");
Cursor cc = ts.getStatements(null, "!ex:age", low, high, null, null);
AGUtils.showTriples(cc);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next