All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.anno4j.io.StatementSailHandler Maven / Gradle / Ivy

Go to download

Read and write API for W3C Web Annotation Data Model (http://www.w3.org/TR/annotation-model/) and W3C Open Annotation Data Model (http://www.openannotation.org/spec/core/)

There is a newer version: 2.4
Show newest version
package com.github.anno4j.io;

import com.github.anno4j.io.ObjectParser;
import org.openrdf.model.Statement;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.sail.SailRepositoryConnection;
import org.openrdf.rio.helpers.RDFHandlerBase;

/**
 * Extension of an RDFHandlerBase in order to add statements, read by the {@link ObjectParser}, to the supported SailRepository.
 */
public class StatementSailHandler extends RDFHandlerBase {

    private RepositoryConnection connection;

    /**
     * Constructor which also takes the connection to the necessary Repository.
     *
     * @param connection    The connection of the corresponding Repository.
     */
    public StatementSailHandler(RepositoryConnection connection) {
        this.connection = connection;
    }

    @Override
    public void handleStatement(Statement statement) {
        try {
            this.connection.add(statement);
        } catch (RepositoryException e) {
            e.printStackTrace();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy