本文整理汇总了Java中org.eclipse.rdf4j.RDF4JException类的典型用法代码示例。如果您正苦于以下问题:Java RDF4JException类的具体用法?Java RDF4JException怎么用?Java RDF4JException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RDF4JException类属于org.eclipse.rdf4j包,在下文中一共展示了RDF4JException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Override
/**
* Parse graph representation of config.
*
*/
public void parse(Model model, Resource implNode)
throws RepositoryConfigException {
super.parse(model, implNode);
try {
IRI iri = Models.getPropertyIRI(model, implNode, QUERY_ENDPOINT).orElse(null);
if (iri != null) {
setQueryEndpointUrl(iri.stringValue());
}
iri = Models.getPropertyIRI(model, implNode, UPDATE_ENDPOINT).orElse(null);
if (iri != null) {
setUpdateEndpointUrl(iri.stringValue());
}
} catch (RDF4JException e) {
throw new RepositoryConfigException(e.getMessage(), e);
}
}
示例2: testAddDeleteInsertWithTransaction
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Test
public void testAddDeleteInsertWithTransaction()
throws RDF4JException
{
ValueFactory vf= conn.getValueFactory();
IRI fei = vf.createIRI("http://marklogicsparql.com/id#3333");
IRI lname = vf.createIRI("http://marklogicsparql.com/addressbook#lastName");
IRI email = vf.createIRI("http://marklogicsparql.com/addressbook#email");
Literal feilname = vf.createLiteral("Ling");
Literal feiemail = vf.createLiteral("[email protected]");
conn.add(fei, lname, feilname);
conn.add(fei, email, feiemail);
conn.begin();
conn.prepareUpdate("" +
"DELETE { <http://marklogicsparql.com/id#3333> <#email> \"[email protected]\"} INSERT { <http://marklogicsparql.com/id#3333> <#email> \"[email protected]\"}" +
" where{ ?s <#email> ?o}","http://marklogicsparql.com/addressbook").execute();
conn.commit();
logger.info(
"hasStatement:{}", conn.hasStatement(vf.createStatement(fei, email, vf.createLiteral("[email protected]")), false)
);
Assert.assertTrue("The value of email should be updated", conn.hasStatement(vf.createStatement(fei, email, vf.createLiteral("[email protected]")), false));
Assert.assertFalse(conn.isEmpty());
}
示例3: testLiterals
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Test
public void testLiterals()
throws RDF4JException
{
ValueFactory vf= conn.getValueFactory();
IRI fei = vf.createIRI("http://marklogicsparql.com/id#3333");
IRI lname = vf.createIRI("http://marklogicsparql.com/addressbook#lastName");
IRI age = vf.createIRI("http://marklogicsparql.com/addressbook#age");
Literal feilname = vf.createLiteral("Ling", "zh");
//Literal shouldfail = vf.createLiteral(1, "zh");
Literal invalidIntegerLiteral = vf.createLiteral("four", XMLSchema.INTEGER);
Literal feiage = vf.createLiteral(25);
conn.add(fei, lname, feilname);
conn.add(fei, age, feiage);
//conn.add(fei, age, invalidIntegerLiteral);
logger.info("lang:{}", conn.hasStatement(vf.createStatement(fei, lname, vf.createLiteral("Ling", "zh")), false));
logger.info("size:{}", conn.size());
Assert.assertFalse("The lang tag of lname is not en", conn.hasStatement(vf.createStatement(fei, lname, vf.createLiteral("Ling", "en")), false));
Assert.assertTrue("The lang tag of lname is zh", conn.hasStatement(vf.createStatement(fei, lname, feilname), false));
Assert.assertFalse(conn.isEmpty());
}
示例4: testAddRemoveInsert
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Test
public void testAddRemoveInsert()
throws RDF4JException {
ValueFactory vf = conn.getValueFactory();
IRI tommy = vf.createIRI("http://marklogicsparql.com/id#4444");
IRI lname = vf.createIRI("http://marklogicsparql.com/addressbook#lastName");
Literal tommylname = vf.createLiteral("Ramone");
Statement stmt = vf.createStatement(tommy, lname, tommylname);
conn.add(stmt);
try {
conn.begin();
conn.remove(stmt);
Assert.assertEquals("The size of repository must be zero", 0, conn.size());
} catch (Exception e) {
e.printStackTrace();
}finally {
conn.commit();
}
}
示例5: exportEmptyStore
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Test
public final void exportEmptyStore()
throws RDF4JException
{
IRI dirgraph = conn.getValueFactory().createIRI("http://marklogic.com/dirgraph");
Assert.assertEquals(0L, conn.size());
conn.exportStatements(null, null, null, false, new RDFHandlerBase() {
@Override
public void handleStatement(Statement st1)
throws RDFHandlerException {
Assert.assertNull(st1);
}
}, dirgraph);
}
示例6: testAddDeleteAdd
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Test
public void testAddDeleteAdd()
throws RDF4JException
{
Resource context5 = conn.getValueFactory().createIRI("http://marklogic.com/test/context5");
ValueFactory f= conn.getValueFactory();
IRI alice = f.createIRI("http://example.org/people/alice");
IRI name = f.createIRI("http://example.org/ontology/name");
Literal alicesName = f.createLiteral("Alice");
Statement st = f.createStatement(alice, name, alicesName, context5);
conn.add(st);
conn.begin();
String defGraphQuery = "DELETE DATA {GRAPH <" + context5.stringValue()+ "> { <" + alice.stringValue() + "> <" + name.stringValue() + "> \"" + alicesName.stringValue() + "\"^^<http://www.w3.org/2001/XMLSchema#string>} }";
conn.prepareUpdate(QueryLanguage.SPARQL, defGraphQuery).execute();
Assert.assertTrue(conn.isEmpty());
conn.add(st);
conn.commit();
Assert.assertFalse(conn.isEmpty());
conn.remove(st);
}
示例7: next
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
public org.ontoware.rdf2go.model.Statement next() {
org.ontoware.rdf2go.model.Statement result = null;
try {
Statement nextStatement = this.cit.next();
result = new StatementWrapper(this.model, nextStatement);
if (!this.cit.hasNext()) {
close();
}
}
catch (RDF4JException e) {
throw new ModelRuntimeException(e);
}
return result;
}
示例8: findStatements
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Override
public ClosableIterator<org.ontoware.rdf2go.model.Statement> findStatements(
ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
throws ModelRuntimeException {
assertModel();
// convert parameters to RDF4J data types
org.eclipse.rdf4j.model.Resource targetSubject = (org.eclipse.rdf4j.model.Resource) ConversionUtil
.toRDF4J(subject, this.valueFactory);
org.eclipse.rdf4j.model.IRI targetPredicate = (org.eclipse.rdf4j.model.IRI) ConversionUtil.toRDF4J(
predicate, this.valueFactory);
Value targetObject = ConversionUtil.toRDF4J(object, this.valueFactory);
try {
// find the matching statements
CloseableIteration<? extends org.eclipse.rdf4j.model.Statement, ? extends RDF4JException> statements = this.connection
.getStatements(targetSubject, targetPredicate, targetObject, true,
this.rdf4jContext);
// wrap them in a StatementIterable
return new StatementIterator(statements, this);
} catch (RepositoryException e) {
throw new ModelRuntimeException(e);
}
}
示例9: queryConstruct
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Override
public ClosableIterable<Statement> queryConstruct(String queryString, String queryLanguage)
throws QueryLanguageNotSupportedException, ModelRuntimeException {
this.assertModel();
// resolve the query language String to a QueryLanguage
QueryLanguage language = ConversionUtil.toRDF4JQueryLanguage(queryLanguage);
try {
// determine query result
GraphQuery query = this.connection.prepareGraphQuery(language, queryString);
GraphQueryResult queryResult = query.evaluate();
// wrap it in a GraphIterable
return new GraphIterable(queryResult, null);
} catch(RDF4JException e) {
throw new ModelRuntimeException(e);
}
}
示例10: testLiteralsWithNonexistantLangTag
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Test
public void testLiteralsWithNonexistantLangTag()
throws RDF4JException
{
ValueFactory vf= conn.getValueFactory();
IRI fei = vf.createIRI("http://marklogicsparql.com/id#3333");
IRI lname = vf.createIRI("http://marklogicsparql.com/addressbook#lastName");
IRI age = vf.createIRI("http://marklogicsparql.com/addressbook#age");
Literal feilname = vf.createLiteral("Ling", "nonexistentlangtag");
conn.add(fei, lname, feilname);
}
示例11: testNestedConnections
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Test
public void testNestedConnections()
throws RDF4JException {
MarkLogicRepositoryConfig config = new MarkLogicRepositoryConfig();
config.setHost(host);
config.setPort(port);
config.setUser(user);
config.setPassword(password);
config.setAuth("DIGEST");
MarkLogicRepositoryFactory FACTORY = new MarkLogicRepositoryFactory();
ValueFactory vf = conn.getValueFactory();
IRI tommy = vf.createIRI("http://marklogicsparql.com/id#4444");
IRI lname = vf.createIRI("http://marklogicsparql.com/addressbook#lastName");
Literal tommylname = vf.createLiteral("Ramone");
Statement stmt = vf.createStatement(tommy, lname, tommylname);
conn.add(stmt);
conn.begin();
Repository repo2 = FACTORY.getRepository(config);
repo2.initialize();
RepositoryConnection conn2 = repo2.getConnection();
conn2.begin();
Assert.assertEquals("The size of repository must be zero", 1, conn.size());
conn2.commit();
conn2.close();
repo2.shutDown();
conn.commit();
}
示例12: close
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
public void close() {
try {
this.cit.close();
}
catch (RDF4JException e) {
throw new ModelRuntimeException(e);
}
this.closed = true;
}
示例13: readFrom
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Override
public void readFrom(InputStream in, Syntax syntax) throws IOException, ModelRuntimeException {
this.assertModel();
try {
this.connection.add(in, "", getRDFFormat(syntax));
} catch(RDF4JException e) {
throw new ModelRuntimeException(e);
}
}
示例14: sparqlAsk
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Override
public boolean sparqlAsk(String queryString) throws ModelRuntimeException {
this.assertModel();
BooleanQuery booleanQuery;
try {
booleanQuery = this.connection.prepareBooleanQuery(QueryLanguage.SPARQL, queryString);
boolean result = booleanQuery.evaluate();
return result;
} catch(RDF4JException e) {
throw new ModelRuntimeException(e);
}
}
示例15: sparqlConstruct
import org.eclipse.rdf4j.RDF4JException; //导入依赖的package包/类
@Override
public ClosableIterable<Statement> sparqlConstruct(String queryString)
throws ModelRuntimeException {
this.assertModel();
GraphQuery query;
try {
query = this.connection.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
GraphQueryResult graphQueryResult = query.evaluate();
return new StatementIterable(graphQueryResult, null);
} catch(RDF4JException e) {
throw new ModelRuntimeException(e);
}
}