AGSailContexts.java

package com.franz.agsail.examples;

import com.franz.ag.*;
import com.knowledgereefsystems.agsail.*;

import info.aduna.iteration.CloseableIteration;

import java.io.File;

import org.openrdf.model.Resource;
import org.openrdf.sail.*;

public class AGSailContexts {

    /**
     * Demonstrates basics of obtaining contexts.
     * 
     * @param args unused
     * @throws AllegroGraphException
     */
    public static void main(String[] args) throws SailException {
        
        // Specify the SAIL, including AllegroGraph server and store parameters
        Sail sail = new AllegroSail("localhost", 4567, false, "store", new File(AGPaths.TRIPLE_STORES), 0, 0, false, false);
        
        // Connect and open the store (create it if necessary)  
        sail.initialize();
        SailConnection sc = sail.getConnection();
       
        // Show all Context ID's in the store -- does the default context have no ID?
        CloseableIteration<? extends Resource, SailException> iter2 = sc.getContextIDs();
        try {
            while (iter2.hasNext()) {
                System.out.println(iter2.next());
            }
        } catch (SailException e) {
            iter2.close();
        }
        
        // Close the connection and shutdown the Sail
        sc.close();
        sail.shutDown();        
    }
    
}

Up | Next