AGSparqlDescribe.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGSparqlDescribe {
    
@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("sparql", AGPaths.TRIPLE_STORES);
                
        
        ts.registerNamespace("foaf", "http://xmlns.com/foaf/0.1/");
        
        BlankNode a = (BlankNode)ts.createBNode("_:a");
        BlankNode b = (BlankNode)ts.createBNode("_:b");
        
        
        ts.addStatement(a,"!rdf:type","!foaf:Person");
        ts.addStatement(a,"!foaf:name",ts.createLiteral("Alice"));
        ts.addStatement(a,"!foaf:mbox","<mailto:alice@example.com>");
        ts.addStatement(a,"!foaf:mbox","<mailto:alice@work.example>");
        ts.addStatement(b,"!rdf:type","!foaf:Person");
        ts.addStatement(b,"!foaf:name",ts.createLiteral("Bob"));
        ts.addStatement(b,"!foaf:homepage","<http://work.example.org/alice/>");
        
        
        String query = 
        "PREFIX foaf:   <http://xmlns.com/foaf/0.1/> " +
        "DESCRIBE ?x " +
        "WHERE    { ?x foaf:mbox <mailto:alice@example.com> } ";
        
        
        SPARQLQuery sq = new SPARQLQuery();
        Cursor cc = sq.describe(ts,query);
        AGUtils.showTriples(cc,ts);
        
        
        ts.closeTripleStore();
        ags.disable();
    }
}
Up | 
Next