Package org.openrdf.sail

Examples of org.openrdf.sail.Sail


    }

    // Verifies that Sesame does not unescape literal labels (not that one would
    // reasonably suspect it of doing so).
    public void testEscapeCharactersInLiterals() throws Exception {
        Sail sail = new MemoryStore();
        sail.initialize();
        ValueFactory vf = sail.getValueFactory();
        Literal l;

        l = vf.createLiteral("\"");
        assertEquals(1, l.getLabel().length());
        l = vf.createLiteral("\\\"");
        assertEquals(2, l.getLabel().length());

        l = vf.createLiteral("\"", XMLSchema.STRING);
        assertEquals(1, l.getLabel().length());
        l = vf.createLiteral("\\\"", XMLSchema.STRING);
        assertEquals(2, l.getLabel().length());

        sail.shutDown();
    }
View Full Code Here


* @author Joshua Shinavier (http://fortytwo.net)
*/
public class LinkedDataCacheTest {
    @Test
    public void testMediaTypes() throws Exception {
        Sail sail = new MemoryStore();
        sail.initialize();

        LinkedDataCache cache = LinkedDataCache.createDefault(sail);
        String header = cache.getAcceptHeader();
        assertTrue(header.contains("application/rdf+xml"));
        assertTrue(header.contains("text/plain;q=0.5"));
View Full Code Here

/**
* @author Joshua Shinavier (http://fortytwo.net)
*/
public class DefinitionsTest extends RippleTestCase {
    public void testDefinitions() throws Exception {
        Sail sail = getTestSail();
        SailConnection sc = sail.getConnection();
        QueryEngine qe = getTestQueryEngine();

        ListAST foobar = new ListAST(
                new PlainLiteralAST("foo"), new ListAST(new PlainLiteralAST("bar"), new ListAST()));
        ListAST foobar2 = new ListAST(
                new PlainLiteralAST("foo2"), new ListAST(new PlainLiteralAST("bar2"), new ListAST()));
        URI foobarUri = sail.getValueFactory().createURI(qe.getLexicon().getDefaultNamespace() + "foobar");
        Literal foo = sail.getValueFactory().createLiteral("foo");
        Literal foo2 = sail.getValueFactory().createLiteral("foo2");

        Command defCmd = new DefineListCmd("foobar", foobar);
        Command undefCmd = new UndefineListCmd("foobar");
        Command redefCmd = new RedefineListCmd("foobar", foobar2);

View Full Code Here

    // For debugging/experimentation
    public static void main(final String[] args) throws Exception {
        Ripple.initialize();

        Sail baseSail = new MemoryStore();
        baseSail.initialize();

        try {
            Repository repo = new SailRepository(baseSail);

            LinkedDataSail sail = new LinkedDataSail(baseSail);
            sail.initialize();
            try {
                SailConnection sc = sail.getConnection();
                try {
                    sc.begin();
                    sc.getStatements(new URIImpl("http://rdf.freebase.com/rdf/en.stephen_fry"), null, null, false);
                    sc.commit();
                } finally {
                    sc.close();
                }
            } finally {
                sail.shutDown();
            }

            RepositoryConnection rc = repo.getConnection();
            try {
                rc.export(new RDFHandler() {
                    public void startRDF() throws RDFHandlerException {
                    }

                    public void endRDF() throws RDFHandlerException {
                    }

                    public void handleNamespace(String s, String s1) throws RDFHandlerException {
                    }

                    public void handleStatement(Statement statement) throws RDFHandlerException {
                        System.out.println("" + statement);
                    }

                    public void handleComment(String s) throws RDFHandlerException {
                    }
                });
            } finally {
                rc.close();
            }
        } finally {
            baseSail.shutDown();
        }
    }
View Full Code Here

        return sail;
    }

    public Sail createSail(final String sailType,
                           final URIMap uriMap) throws RippleException {
        Sail sail = null;

        for (SailFactory f : loader) {
            if (f.getSailClass().getName().equals(sailType)) {
                sail = f.createSail(uriMap, this);
            }
View Full Code Here

    public Sail createSail(URIMap uriMap, SailConfiguration config) throws RippleException {
        RippleProperties props = Ripple.getConfiguration();
        File dir = props.getFile(Ripple.NATIVESTORE_DIRECTORY);
        String indexes = props.getString(Ripple.NATIVESTORE_INDEXES, null);

        Sail sail = (null == indexes)
                ? new NativeStore(dir)
                : new NativeStore(dir, indexes.trim());
        try {
            sail.initialize();
        } catch (SailException e) {
            throw new RippleException(e);
        }

        return sail;
View Full Code Here

    public Sail createSail(final URIMap uriMap,
                           final SailConfiguration config) throws RippleException {
        RippleProperties props = Ripple.getConfiguration();
        String baseSailType = props.getString(Ripple.LINKEDDATASAIL_BASE_SAIL);

        Sail base = config.createSail(baseSailType, uriMap);
        LinkedDataCache cache = LinkedDataCache.createDefault(base);
        cache.setURIMap(uriMap);
        Sail sail = new LinkedDataSail(base, cache);
        try {
            // Note: base Sail is already initialized.
            sail.initialize();
        } catch (SailException e) {
            throw new RippleException(e);
        }

        return sail;
View Full Code Here

    /**
     * Return the wrapped bigdata sail, even if it is somewhere deep in the stack
     * @return
     */
    private BigdataSail getBaseSail() {
        Sail sail = wrapped;
        while(sail instanceof SailWrapper) {
            sail = ((SailWrapper) sail).getBaseSail();
        }
        if(sail instanceof BigDataSesame27Sail) {
            return ((BigDataSesame27Sail) sail).getWrapped();
View Full Code Here

TOP

Related Classes of org.openrdf.sail.Sail

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.