當前位置: 首頁>>代碼示例>>Java>>正文


Java RDF4JException類代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:marklogic,項目名稱:marklogic-rdf4j,代碼行數:23,代碼來源:MarkLogicRepositoryConfig.java

示例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());
}
 
開發者ID:marklogic,項目名稱:marklogic-rdf4j,代碼行數:25,代碼來源:MarkLogicRepositoryConnectionTest.java

示例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());
}
 
開發者ID:marklogic,項目名稱:marklogic-rdf4j,代碼行數:24,代碼來源:MarkLogicRepositoryConnectionTest.java

示例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();
    }

}
 
開發者ID:marklogic,項目名稱:marklogic-rdf4j,代碼行數:21,代碼來源:MarkLogicRepositoryConnectionTest.java

示例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);
}
 
開發者ID:marklogic,項目名稱:marklogic-rdf4j,代碼行數:18,代碼來源:MarkLogicRepositoryConnectionTest.java

示例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);
}
 
開發者ID:marklogic,項目名稱:marklogic-rdf4j,代碼行數:23,代碼來源:MarkLogicRepositoryConnectionTest.java

示例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;
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:18,代碼來源:StatementIterator.java

示例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);
	}
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:24,代碼來源:RepositoryModel.java

示例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);
	}
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:19,代碼來源:RepositoryModelSet.java

示例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);
}
 
開發者ID:marklogic,項目名稱:marklogic-rdf4j,代碼行數:12,代碼來源:MarkLogicRepositoryConnectionTest.java

示例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();

}
 
開發者ID:marklogic,項目名稱:marklogic-rdf4j,代碼行數:38,代碼來源:MarkLogicRepositoryConnectionTest.java

示例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;
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:10,代碼來源:StatementIterator.java

示例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);
	}
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:11,代碼來源:RepositoryModelSet.java

示例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);
	}
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:13,代碼來源:RepositoryModelSet.java

示例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);
	}
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:14,代碼來源:RepositoryModelSet.java


注:本文中的org.eclipse.rdf4j.RDF4JException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。