com.github.anno4j.io.StatementSailHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of anno4j-core Show documentation
Show all versions of anno4j-core Show documentation
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/)
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